@btst/stack 3.0.0-rc.1 → 3.0.0-rc.3
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 +122 -46
- package/dist/api/index.cjs +133 -29
- package/dist/api/index.d.cts +14 -32
- package/dist/api/index.d.mts +14 -32
- package/dist/api/index.d.ts +14 -32
- package/dist/api/index.mjs +133 -28
- package/dist/authorization/client.cjs +154 -0
- package/dist/authorization/client.d.cts +70 -0
- package/dist/authorization/client.d.mts +70 -0
- package/dist/authorization/client.d.ts +70 -0
- package/dist/authorization/client.mjs +152 -0
- package/dist/authorization/index.cjs +371 -0
- package/dist/authorization/index.d.cts +201 -0
- package/dist/authorization/index.d.mts +201 -0
- package/dist/authorization/index.d.ts +201 -0
- package/dist/authorization/index.mjs +365 -0
- package/dist/authorization/remote.cjs +117 -0
- package/dist/authorization/remote.d.cts +79 -0
- package/dist/authorization/remote.d.mts +79 -0
- package/dist/authorization/remote.d.ts +79 -0
- package/dist/authorization/remote.mjs +111 -0
- package/dist/authorization/server.cjs +77 -0
- package/dist/authorization/server.d.cts +51 -0
- package/dist/authorization/server.d.mts +51 -0
- package/dist/authorization/server.d.ts +51 -0
- package/dist/authorization/server.mjs +73 -0
- package/dist/client/components/index.cjs +1 -0
- package/dist/client/components/index.d.cts +23 -6
- package/dist/client/components/index.d.mts +23 -6
- package/dist/client/components/index.d.ts +23 -6
- package/dist/client/components/index.mjs +1 -1
- package/dist/client/hooks/index.cjs +8 -0
- package/dist/client/hooks/index.d.cts +25 -0
- package/dist/client/hooks/index.d.mts +25 -0
- package/dist/client/hooks/index.d.ts +25 -0
- package/dist/client/hooks/index.mjs +2 -0
- package/dist/client/index.cjs +38 -7
- package/dist/client/index.d.cts +30 -100
- package/dist/client/index.d.mts +30 -100
- package/dist/client/index.d.ts +30 -100
- package/dist/client/index.mjs +38 -7
- package/dist/client/server.cjs +96 -0
- package/dist/client/server.d.cts +57 -0
- package/dist/client/server.d.mts +57 -0
- package/dist/client/server.d.ts +57 -0
- package/dist/client/server.mjs +92 -0
- package/dist/components/auto-form/index.d.cts +2 -2
- package/dist/components/auto-form/index.d.mts +2 -2
- package/dist/components/auto-form/index.d.ts +2 -2
- package/dist/components/form-builder/index.d.cts +1 -1
- package/dist/components/form-builder/index.d.mts +1 -1
- package/dist/components/form-builder/index.d.ts +1 -1
- package/dist/components/stepped-auto-form/index.d.cts +1 -1
- package/dist/components/stepped-auto-form/index.d.mts +1 -1
- package/dist/components/stepped-auto-form/index.d.ts +1 -1
- package/dist/context/index.cjs +8 -2
- package/dist/context/index.d.cts +111 -89
- package/dist/context/index.d.mts +111 -89
- package/dist/context/index.d.ts +111 -89
- package/dist/context/index.mjs +3 -1
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +8 -3
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.mjs +1 -1
- package/dist/next/index.d.cts +30 -12
- package/dist/next/index.d.mts +30 -12
- package/dist/next/index.d.ts +30 -12
- package/dist/next/server.cjs +7 -0
- package/dist/next/server.d.cts +56 -0
- package/dist/next/server.d.mts +56 -0
- package/dist/next/server.d.ts +56 -0
- package/dist/next/server.mjs +1 -0
- package/dist/packages/stack/src/authorization/json.cjs +57 -0
- package/dist/packages/stack/src/authorization/json.mjs +55 -0
- package/dist/packages/stack/src/client/components/compose.cjs +91 -9
- package/dist/packages/stack/src/client/components/compose.mjs +92 -11
- package/dist/packages/stack/src/client/runtime.cjs +295 -0
- package/dist/packages/stack/src/client/runtime.mjs +293 -0
- package/dist/packages/stack/src/context/auth.cjs +141 -73
- package/dist/packages/stack/src/context/auth.mjs +139 -73
- package/dist/packages/stack/src/context/provider.cjs +11 -5
- package/dist/packages/stack/src/context/provider.mjs +11 -5
- package/dist/packages/stack/src/context/router.cjs +9 -0
- package/dist/packages/stack/src/context/router.mjs +7 -0
- package/dist/packages/stack/src/context/site-navigation.cjs +40 -0
- package/dist/packages/stack/src/context/site-navigation.mjs +38 -0
- package/dist/packages/stack/src/next/layout.cjs +27 -0
- package/dist/packages/stack/src/next/layout.mjs +25 -0
- package/dist/packages/stack/src/next/page.cjs +8 -6
- package/dist/packages/stack/src/next/page.mjs +8 -6
- package/dist/packages/stack/src/plugin-registration.cjs +59 -0
- package/dist/packages/stack/src/plugin-registration.mjs +57 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/lifecycle-migrations.cjs +18 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/lifecycle-migrations.mjs +16 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/operations.cjs +1341 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/operations.mjs +1333 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +82 -640
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +78 -641
- package/dist/packages/stack/src/plugins/ai-chat/api/serializers.cjs +23 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/serializers.mjs +20 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-input.cjs +183 -111
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-input.mjs +187 -115
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.cjs +562 -116
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.mjs +567 -121
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.cjs +6 -6
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.mjs +6 -6
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-sidebar.cjs +45 -29
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-sidebar.mjs +46 -30
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/404-page.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/404-page.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.cjs +46 -7
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.cjs +5 -3
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.mjs +5 -3
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.mjs +48 -9
- package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/tool-call-display.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/tool-call-display.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/ai-chat-resource.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/ai-chat-resource.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/chat-hooks.cjs +179 -19
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/chat-hooks.mjs +180 -21
- package/dist/packages/stack/src/plugins/ai-chat/client/navigation.cjs +11 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/navigation.mjs +9 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/overrides.cjs +24 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/overrides.mjs +21 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/plugin.cjs +152 -82
- package/dist/packages/stack/src/plugins/ai-chat/client/plugin.mjs +152 -82
- package/dist/packages/stack/src/plugins/api/create-endpoint.cjs +27 -9
- package/dist/packages/stack/src/plugins/api/create-endpoint.mjs +27 -10
- package/dist/packages/stack/src/plugins/api/endpoint-inventory.cjs +125 -0
- package/dist/packages/stack/src/plugins/api/endpoint-inventory.mjs +123 -0
- package/dist/packages/stack/src/plugins/api/operation.cjs +208 -0
- package/dist/packages/stack/src/plugins/api/operation.mjs +198 -0
- package/dist/packages/stack/src/plugins/blog/api/lifecycle-migrations.cjs +17 -0
- package/dist/packages/stack/src/plugins/blog/api/lifecycle-migrations.mjs +15 -0
- package/dist/packages/stack/src/plugins/blog/api/mutations.cjs +10 -2
- package/dist/packages/stack/src/plugins/blog/api/mutations.mjs +10 -2
- package/dist/packages/stack/src/plugins/blog/api/operations.cjs +455 -0
- package/dist/packages/stack/src/plugins/blog/api/operations.mjs +448 -0
- package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +51 -298
- package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +55 -304
- package/dist/packages/stack/src/plugins/blog/client/components/forms/image-field.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/image-field.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/post-forms.cjs +82 -67
- package/dist/packages/stack/src/plugins/blog/client/components/forms/post-forms.mjs +84 -69
- package/dist/packages/stack/src/plugins/blog/client/components/pages/404-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/404-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.cjs +22 -4
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.mjs +23 -5
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.cjs +6 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.mjs +6 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.cjs +4 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.mjs +4 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.cjs +30 -3
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.mjs +31 -4
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.cjs +4 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.mjs +4 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/collapsible-tag-list.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/collapsible-tag-list.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/on-this-page.cjs +3 -2
- package/dist/packages/stack/src/plugins/blog/client/components/shared/on-this-page.mjs +3 -2
- package/dist/packages/stack/src/plugins/blog/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/post-card.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/post-card.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/posts-list.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/posts-list.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/search-input.cjs +2 -2
- package/dist/packages/stack/src/plugins/blog/client/components/shared/search-input.mjs +1 -1
- package/dist/packages/stack/src/plugins/blog/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/blog/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/blog/client/hooks/blog-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/hooks/blog-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +169 -163
- package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +169 -163
- package/dist/packages/stack/src/plugins/client/resource/hooks.cjs +31 -16
- package/dist/packages/stack/src/plugins/client/resource/hooks.mjs +31 -16
- package/dist/packages/stack/src/plugins/client/resource/internal.cjs +66 -52
- package/dist/packages/stack/src/plugins/client/resource/internal.mjs +66 -52
- package/dist/packages/stack/src/plugins/client/resource/use-form.cjs +20 -17
- package/dist/packages/stack/src/plugins/client/resource/use-form.mjs +20 -17
- package/dist/packages/stack/src/plugins/client/resource/use-select.cjs +39 -33
- package/dist/packages/stack/src/plugins/client/resource/use-select.mjs +39 -33
- package/dist/packages/stack/src/plugins/cms/api/lifecycle-migrations.cjs +13 -0
- package/dist/packages/stack/src/plugins/cms/api/lifecycle-migrations.mjs +11 -0
- package/dist/packages/stack/src/plugins/cms/api/operations.cjs +1763 -0
- package/dist/packages/stack/src/plugins/cms/api/operations.mjs +1756 -0
- package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +165 -752
- package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +164 -755
- package/dist/packages/stack/src/plugins/cms/client/components/forms/content-form.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/content-form.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/file-upload.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/file-upload.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/inverse-relations-panel.cjs +23 -13
- package/dist/packages/stack/src/plugins/cms/client/components/inverse-relations-panel.mjs +24 -14
- package/dist/packages/stack/src/plugins/cms/client/components/pages/404-page.cjs +5 -4
- package/dist/packages/stack/src/plugins/cms/client/components/pages/404-page.mjs +6 -5
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.cjs +40 -7
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.cjs +15 -9
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.mjs +14 -8
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.mjs +41 -8
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.cjs +7 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.internal.cjs +42 -29
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.internal.mjs +40 -27
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.mjs +7 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.cjs +4 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.internal.cjs +13 -7
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.internal.mjs +12 -6
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.mjs +4 -1
- package/dist/packages/stack/src/plugins/cms/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/cms/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/overrides.cjs +26 -0
- package/dist/packages/stack/src/plugins/cms/client/overrides.mjs +24 -0
- package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +102 -81
- package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +103 -82
- package/dist/packages/stack/src/plugins/comments/api/getters.cjs +6 -2
- package/dist/packages/stack/src/plugins/comments/api/getters.mjs +6 -3
- package/dist/packages/stack/src/plugins/comments/api/lifecycle-migrations.cjs +18 -0
- package/dist/packages/stack/src/plugins/comments/api/lifecycle-migrations.mjs +16 -0
- package/dist/packages/stack/src/plugins/comments/api/mutations.cjs +179 -68
- package/dist/packages/stack/src/plugins/comments/api/mutations.mjs +179 -68
- package/dist/packages/stack/src/plugins/comments/api/operations.cjs +453 -0
- package/dist/packages/stack/src/plugins/comments/api/operations.mjs +445 -0
- package/dist/packages/stack/src/plugins/comments/api/plugin.cjs +51 -276
- package/dist/packages/stack/src/plugins/comments/api/plugin.mjs +48 -277
- package/dist/packages/stack/src/plugins/comments/client/components/comment-count.cjs +32 -5
- package/dist/packages/stack/src/plugins/comments/client/components/comment-count.mjs +34 -7
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.cjs +161 -105
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.mjs +162 -106
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.cjs +14 -2
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.cjs +141 -71
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.mjs +142 -72
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.mjs +14 -2
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-state.cjs +12 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-state.mjs +9 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.cjs +40 -26
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.mjs +40 -26
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.cjs +9 -1
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.cjs +25 -20
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.mjs +26 -21
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.mjs +9 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.cjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.mjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/comments/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.cjs +323 -290
- package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.mjs +325 -292
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.cjs +1 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.mjs +1 -0
- package/dist/packages/stack/src/plugins/comments/client/plugin.cjs +78 -46
- package/dist/packages/stack/src/plugins/comments/client/plugin.mjs +80 -48
- package/dist/packages/stack/src/plugins/form-builder/api/getters.cjs +9 -0
- package/dist/packages/stack/src/plugins/form-builder/api/getters.mjs +9 -1
- package/dist/packages/stack/src/plugins/form-builder/api/lifecycle-migrations.cjs +15 -0
- package/dist/packages/stack/src/plugins/form-builder/api/lifecycle-migrations.mjs +13 -0
- package/dist/packages/stack/src/plugins/form-builder/api/operations.cjs +1093 -0
- package/dist/packages/stack/src/plugins/form-builder/api/operations.mjs +1082 -0
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.cjs +97 -466
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.mjs +92 -468
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.cjs +5 -0
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.mjs +5 -0
- package/dist/packages/stack/src/plugins/form-builder/client/components/forms/form-renderer.cjs +41 -11
- package/dist/packages/stack/src/plugins/form-builder/client/components/forms/form-renderer.mjs +42 -12
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/404-page.cjs +8 -5
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/404-page.mjs +9 -6
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.cjs +36 -3
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.cjs +32 -11
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.mjs +35 -14
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.mjs +37 -4
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.cjs +6 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.cjs +34 -26
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.mjs +34 -26
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.mjs +6 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.cjs +24 -7
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +72 -40
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +76 -44
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.mjs +25 -8
- package/dist/packages/stack/src/plugins/form-builder/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/form-builder/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-hooks.cjs +29 -0
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-hooks.mjs +28 -1
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +113 -86
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +114 -87
- package/dist/packages/stack/src/plugins/form-builder/schemas.cjs +9 -3
- package/dist/packages/stack/src/plugins/form-builder/schemas.mjs +9 -3
- package/dist/packages/stack/src/plugins/kanban/api/getters.cjs +47 -36
- package/dist/packages/stack/src/plugins/kanban/api/getters.mjs +47 -37
- package/dist/packages/stack/src/plugins/kanban/api/lifecycle-migrations.cjs +23 -0
- package/dist/packages/stack/src/plugins/kanban/api/lifecycle-migrations.mjs +21 -0
- package/dist/packages/stack/src/plugins/kanban/api/operations.cjs +1552 -0
- package/dist/packages/stack/src/plugins/kanban/api/operations.mjs +1543 -0
- package/dist/packages/stack/src/plugins/kanban/api/plugin.cjs +64 -631
- package/dist/packages/stack/src/plugins/kanban/api/plugin.mjs +62 -634
- package/dist/packages/stack/src/plugins/kanban/api/serializers.cjs +21 -0
- package/dist/packages/stack/src/plugins/kanban/api/serializers.mjs +21 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/board-form.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/board-form.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/column-form.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/column-form.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.cjs +72 -54
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.mjs +74 -56
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/404-page.cjs +4 -6
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/404-page.mjs +5 -7
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.cjs +22 -6
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.cjs +82 -77
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.mjs +83 -78
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.mjs +23 -7
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.internal.cjs +34 -24
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.internal.mjs +35 -25
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.internal.cjs +6 -9
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.internal.mjs +7 -10
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/column-content.cjs +72 -45
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/column-content.mjs +73 -46
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/kanban-board.cjs +4 -4
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/kanban-board.mjs +4 -4
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/permission-access-any.cjs +23 -0
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/permission-access-any.mjs +21 -0
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/task-card.cjs +54 -17
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/task-card.mjs +55 -18
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/user-avatar.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/user-avatar.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/kanban/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-hooks.cjs +38 -9
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-hooks.mjs +39 -10
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +177 -104
- package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +178 -105
- package/dist/packages/stack/src/plugins/kanban/schemas.cjs +32 -23
- package/dist/packages/stack/src/plugins/kanban/schemas.mjs +33 -21
- package/dist/packages/stack/src/plugins/media/api/lifecycle-migrations.cjs +9 -0
- package/dist/packages/stack/src/plugins/media/api/lifecycle-migrations.mjs +7 -0
- package/dist/packages/stack/src/plugins/media/api/mutations.cjs +7 -2
- package/dist/packages/stack/src/plugins/media/api/mutations.mjs +7 -2
- package/dist/packages/stack/src/plugins/media/api/operations.cjs +1299 -0
- package/dist/packages/stack/src/plugins/media/api/operations.mjs +1290 -0
- package/dist/packages/stack/src/plugins/media/api/plugin.cjs +131 -508
- package/dist/packages/stack/src/plugins/media/api/plugin.mjs +127 -510
- package/dist/packages/stack/src/plugins/media/api/query-key-defs.cjs +26 -2
- package/dist/packages/stack/src/plugins/media/api/query-key-defs.mjs +25 -3
- package/dist/packages/stack/src/plugins/media/api/serializers.cjs +4 -2
- package/dist/packages/stack/src/plugins/media/api/serializers.mjs +4 -2
- package/dist/packages/stack/src/plugins/media/asset-url.cjs +13 -0
- package/dist/packages/stack/src/plugins/media/asset-url.mjs +11 -0
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/asset-card.cjs +10 -10
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/asset-card.mjs +12 -12
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/folder-tree.cjs +47 -27
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/folder-tree.mjs +49 -29
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/index.cjs +225 -180
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/index.mjs +228 -183
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/upload-tab.cjs +1 -8
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/upload-tab.mjs +2 -9
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/url-tab.cjs +0 -6
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/url-tab.mjs +1 -7
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.cjs +4 -2
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.internal.cjs +92 -75
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.internal.mjs +93 -76
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.mjs +4 -2
- package/dist/packages/stack/src/plugins/media/client/components/upload-permission-check.cjs +52 -0
- package/dist/packages/stack/src/plugins/media/client/components/upload-permission-check.mjs +49 -0
- package/dist/packages/stack/src/plugins/media/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/media/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/media/client/hooks/media-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/media/client/hooks/media-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/media/client/hooks/use-media.cjs +214 -43
- package/dist/packages/stack/src/plugins/media/client/hooks/use-media.mjs +217 -46
- package/dist/packages/stack/src/plugins/media/client/plugin.cjs +122 -62
- package/dist/packages/stack/src/plugins/media/client/plugin.mjs +123 -63
- package/dist/packages/stack/src/plugins/media/client/upload.cjs +121 -52
- package/dist/packages/stack/src/plugins/media/client/upload.mjs +121 -53
- package/dist/packages/stack/src/plugins/media/db.cjs +8 -0
- package/dist/packages/stack/src/plugins/media/db.mjs +8 -0
- package/dist/packages/stack/src/plugins/open-api/api/generator.cjs +36 -5
- package/dist/packages/stack/src/plugins/open-api/api/generator.mjs +36 -5
- package/dist/packages/stack/src/plugins/open-api/api/plugin.cjs +22 -11
- package/dist/packages/stack/src/plugins/open-api/api/plugin.mjs +22 -11
- package/dist/packages/stack/src/plugins/route-docs/client/components/pages/docs-page.cjs +65 -34
- package/dist/packages/stack/src/plugins/route-docs/client/components/pages/docs-page.mjs +56 -25
- package/dist/packages/stack/src/plugins/route-docs/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/route-docs/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/route-docs/client/hooks.cjs +9 -8
- package/dist/packages/stack/src/plugins/route-docs/client/hooks.mjs +10 -9
- package/dist/packages/stack/src/plugins/route-docs/client/plugin.cjs +143 -75
- package/dist/packages/stack/src/plugins/route-docs/client/plugin.mjs +144 -74
- package/dist/packages/stack/src/plugins/route-docs/client/schema.cjs +26 -0
- package/dist/packages/stack/src/plugins/route-docs/client/schema.mjs +23 -0
- package/dist/packages/stack/src/plugins/route-docs/generator.cjs +7 -4
- package/dist/packages/stack/src/plugins/route-docs/generator.mjs +7 -4
- package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.cjs +41 -12
- package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.mjs +42 -13
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.cjs +37 -3
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.cjs +32 -20
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.mjs +34 -22
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.mjs +38 -4
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.cjs +8 -2
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.internal.cjs +37 -19
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.internal.mjs +38 -20
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.mjs +8 -2
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.cjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.mjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/hooks/ui-builder-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/hooks/ui-builder-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/overrides.cjs +8 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/overrides.mjs +6 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/plugin.cjs +93 -53
- package/dist/packages/stack/src/plugins/ui-builder/client/plugin.mjs +94 -54
- package/dist/packages/stack/src/plugins/utils.cjs +4 -12
- package/dist/packages/stack/src/plugins/utils.mjs +5 -12
- package/dist/packages/stack/src/react-router/layout.cjs +14 -0
- package/dist/packages/stack/src/react-router/layout.mjs +12 -0
- package/dist/packages/stack/src/react-router/page.cjs +27 -16
- package/dist/packages/stack/src/react-router/page.mjs +28 -17
- package/dist/packages/stack/src/shared/initial-identity.cjs +27 -0
- package/dist/packages/stack/src/shared/initial-identity.mjs +23 -0
- package/dist/packages/stack/src/tanstack/layout.cjs +10 -0
- package/dist/packages/stack/src/tanstack/layout.mjs +8 -0
- package/dist/packages/stack/src/tanstack/page.cjs +11 -5
- package/dist/packages/stack/src/tanstack/page.mjs +11 -5
- package/dist/plugins/ai-chat/api/index.cjs +10 -0
- package/dist/plugins/ai-chat/api/index.d.cts +31 -5
- package/dist/plugins/ai-chat/api/index.d.mts +31 -5
- package/dist/plugins/ai-chat/api/index.d.ts +31 -5
- package/dist/plugins/ai-chat/api/index.mjs +3 -1
- package/dist/plugins/ai-chat/client/components/index.d.cts +1 -1
- package/dist/plugins/ai-chat/client/components/index.d.mts +1 -1
- package/dist/plugins/ai-chat/client/components/index.d.ts +1 -1
- package/dist/plugins/ai-chat/client/hooks/index.cjs +1 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.cts +14 -8
- package/dist/plugins/ai-chat/client/hooks/index.d.mts +14 -8
- package/dist/plugins/ai-chat/client/hooks/index.d.ts +14 -8
- package/dist/plugins/ai-chat/client/hooks/index.mjs +1 -1
- package/dist/plugins/ai-chat/client/index.d.cts +21 -25
- package/dist/plugins/ai-chat/client/index.d.mts +21 -25
- package/dist/plugins/ai-chat/client/index.d.ts +21 -25
- package/dist/plugins/ai-chat/permissions.cjs +90 -0
- package/dist/plugins/ai-chat/permissions.d.cts +84 -0
- package/dist/plugins/ai-chat/permissions.d.mts +84 -0
- package/dist/plugins/ai-chat/permissions.d.ts +84 -0
- package/dist/plugins/ai-chat/permissions.mjs +88 -0
- package/dist/plugins/ai-chat/query-keys.cjs +116 -18
- package/dist/plugins/ai-chat/query-keys.d.cts +6 -2
- package/dist/plugins/ai-chat/query-keys.d.mts +6 -2
- package/dist/plugins/ai-chat/query-keys.d.ts +6 -2
- package/dist/plugins/ai-chat/query-keys.mjs +116 -19
- package/dist/plugins/api/index.cjs +4 -0
- package/dist/plugins/api/index.d.cts +13 -18
- package/dist/plugins/api/index.d.mts +13 -18
- package/dist/plugins/api/index.d.ts +13 -18
- package/dist/plugins/api/index.mjs +1 -0
- package/dist/plugins/blog/api/index.cjs +9 -2
- package/dist/plugins/blog/api/index.d.cts +118 -4
- package/dist/plugins/blog/api/index.d.mts +118 -4
- package/dist/plugins/blog/api/index.d.ts +118 -4
- package/dist/plugins/blog/api/index.mjs +4 -1
- 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 +210 -226
- package/dist/plugins/blog/client/index.d.mts +210 -226
- package/dist/plugins/blog/client/index.d.ts +210 -226
- package/dist/plugins/blog/permissions.cjs +47 -0
- package/dist/plugins/blog/permissions.d.cts +49 -0
- package/dist/plugins/blog/permissions.d.mts +49 -0
- package/dist/plugins/blog/permissions.d.ts +49 -0
- package/dist/plugins/blog/permissions.mjs +45 -0
- package/dist/plugins/blog/query-keys.d.cts +7 -3
- package/dist/plugins/blog/query-keys.d.mts +7 -3
- package/dist/plugins/blog/query-keys.d.ts +7 -3
- package/dist/plugins/client/hooks/index.d.cts +2 -2
- package/dist/plugins/client/hooks/index.d.mts +2 -2
- package/dist/plugins/client/hooks/index.d.ts +2 -2
- package/dist/plugins/client/index.cjs +3 -0
- package/dist/plugins/client/index.d.cts +30 -10
- package/dist/plugins/client/index.d.mts +30 -10
- package/dist/plugins/client/index.d.ts +30 -10
- package/dist/plugins/client/index.mjs +3 -0
- package/dist/plugins/cms/api/index.cjs +7 -0
- package/dist/plugins/cms/api/index.d.cts +173 -4
- package/dist/plugins/cms/api/index.d.mts +173 -4
- package/dist/plugins/cms/api/index.d.ts +173 -4
- package/dist/plugins/cms/api/index.mjs +2 -0
- package/dist/plugins/cms/client/hooks/index.d.cts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.mts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.ts +1 -1
- package/dist/plugins/cms/client/index.d.cts +188 -184
- package/dist/plugins/cms/client/index.d.mts +188 -184
- package/dist/plugins/cms/client/index.d.ts +188 -184
- package/dist/plugins/cms/permissions.cjs +46 -0
- package/dist/plugins/cms/permissions.d.cts +42 -0
- package/dist/plugins/cms/permissions.d.mts +42 -0
- package/dist/plugins/cms/permissions.d.ts +42 -0
- package/dist/plugins/cms/permissions.mjs +44 -0
- package/dist/plugins/cms/query-keys.d.cts +4 -4
- package/dist/plugins/cms/query-keys.d.mts +4 -4
- package/dist/plugins/cms/query-keys.d.ts +4 -4
- package/dist/plugins/comments/api/index.cjs +10 -0
- package/dist/plugins/comments/api/index.d.cts +54 -18
- package/dist/plugins/comments/api/index.d.mts +54 -18
- package/dist/plugins/comments/api/index.d.ts +54 -18
- package/dist/plugins/comments/api/index.mjs +3 -0
- package/dist/plugins/comments/client/components/index.d.cts +7 -2
- package/dist/plugins/comments/client/components/index.d.mts +7 -2
- package/dist/plugins/comments/client/components/index.d.ts +7 -2
- package/dist/plugins/comments/client/hooks/index.d.cts +12 -18
- package/dist/plugins/comments/client/hooks/index.d.mts +12 -18
- package/dist/plugins/comments/client/hooks/index.d.ts +12 -18
- package/dist/plugins/comments/client/index.d.cts +96 -114
- package/dist/plugins/comments/client/index.d.mts +96 -114
- package/dist/plugins/comments/client/index.d.ts +96 -114
- package/dist/plugins/comments/permissions.cjs +70 -0
- package/dist/plugins/comments/permissions.d.cts +76 -0
- package/dist/plugins/comments/permissions.d.mts +76 -0
- package/dist/plugins/comments/permissions.d.ts +76 -0
- package/dist/plugins/comments/permissions.mjs +68 -0
- package/dist/plugins/comments/query-keys.cjs +1 -1
- package/dist/plugins/comments/query-keys.d.cts +16 -19
- package/dist/plugins/comments/query-keys.d.mts +16 -19
- package/dist/plugins/comments/query-keys.d.ts +16 -19
- package/dist/plugins/comments/query-keys.mjs +1 -1
- package/dist/plugins/form-builder/api/index.cjs +8 -0
- package/dist/plugins/form-builder/api/index.d.cts +115 -4
- package/dist/plugins/form-builder/api/index.d.mts +115 -4
- package/dist/plugins/form-builder/api/index.d.ts +115 -4
- package/dist/plugins/form-builder/api/index.mjs +4 -1
- package/dist/plugins/form-builder/client/components/index.d.cts +6 -2
- package/dist/plugins/form-builder/client/components/index.d.mts +6 -2
- package/dist/plugins/form-builder/client/components/index.d.ts +6 -2
- package/dist/plugins/form-builder/client/hooks/index.cjs +2 -0
- package/dist/plugins/form-builder/client/hooks/index.d.cts +34 -8
- package/dist/plugins/form-builder/client/hooks/index.d.mts +34 -8
- package/dist/plugins/form-builder/client/hooks/index.d.ts +34 -8
- package/dist/plugins/form-builder/client/hooks/index.mjs +1 -1
- package/dist/plugins/form-builder/client/index.d.cts +153 -174
- package/dist/plugins/form-builder/client/index.d.mts +153 -174
- package/dist/plugins/form-builder/client/index.d.ts +153 -174
- package/dist/plugins/form-builder/permissions.cjs +95 -0
- package/dist/plugins/form-builder/permissions.d.cts +94 -0
- package/dist/plugins/form-builder/permissions.d.mts +94 -0
- package/dist/plugins/form-builder/permissions.d.ts +94 -0
- package/dist/plugins/form-builder/permissions.mjs +93 -0
- package/dist/plugins/form-builder/query-keys.cjs +11 -4
- package/dist/plugins/form-builder/query-keys.d.cts +38 -12
- package/dist/plugins/form-builder/query-keys.d.mts +38 -12
- package/dist/plugins/form-builder/query-keys.d.ts +38 -12
- package/dist/plugins/form-builder/query-keys.mjs +11 -4
- package/dist/plugins/kanban/api/index.cjs +9 -0
- package/dist/plugins/kanban/api/index.d.cts +137 -5
- package/dist/plugins/kanban/api/index.d.mts +137 -5
- package/dist/plugins/kanban/api/index.d.ts +137 -5
- package/dist/plugins/kanban/api/index.mjs +5 -2
- package/dist/plugins/kanban/client/components/index.d.cts +18 -10
- package/dist/plugins/kanban/client/components/index.d.mts +18 -10
- package/dist/plugins/kanban/client/components/index.d.ts +18 -10
- package/dist/plugins/kanban/client/hooks/index.d.cts +15 -7
- package/dist/plugins/kanban/client/hooks/index.d.mts +15 -7
- package/dist/plugins/kanban/client/hooks/index.d.ts +15 -7
- package/dist/plugins/kanban/client/index.d.cts +32 -28
- package/dist/plugins/kanban/client/index.d.mts +32 -28
- package/dist/plugins/kanban/client/index.d.ts +32 -28
- package/dist/plugins/kanban/permissions.cjs +101 -0
- package/dist/plugins/kanban/permissions.d.cts +109 -0
- package/dist/plugins/kanban/permissions.d.mts +109 -0
- package/dist/plugins/kanban/permissions.d.ts +109 -0
- package/dist/plugins/kanban/permissions.mjs +99 -0
- package/dist/plugins/kanban/query-keys.cjs +14 -15
- package/dist/plugins/kanban/query-keys.d.cts +63 -42
- package/dist/plugins/kanban/query-keys.d.mts +63 -42
- package/dist/plugins/kanban/query-keys.d.ts +63 -42
- package/dist/plugins/kanban/query-keys.mjs +14 -15
- package/dist/plugins/media/api/adapters/local.d.cts +1 -1
- package/dist/plugins/media/api/adapters/local.d.mts +1 -1
- package/dist/plugins/media/api/adapters/local.d.ts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.cts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.mts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.ts +1 -1
- package/dist/plugins/media/api/adapters/vercel-blob.cjs +46 -0
- package/dist/plugins/media/api/adapters/vercel-blob.d.cts +6 -9
- package/dist/plugins/media/api/adapters/vercel-blob.d.mts +6 -9
- package/dist/plugins/media/api/adapters/vercel-blob.d.ts +6 -9
- package/dist/plugins/media/api/adapters/vercel-blob.mjs +46 -0
- package/dist/plugins/media/api/index.cjs +10 -0
- package/dist/plugins/media/api/index.d.cts +93 -6
- package/dist/plugins/media/api/index.d.mts +93 -6
- package/dist/plugins/media/api/index.d.ts +93 -6
- package/dist/plugins/media/api/index.mjs +2 -0
- package/dist/plugins/media/client/components/index.d.cts +1 -1
- package/dist/plugins/media/client/components/index.d.mts +1 -1
- package/dist/plugins/media/client/components/index.d.ts +1 -1
- package/dist/plugins/media/client/hooks/index.d.cts +20 -10
- package/dist/plugins/media/client/hooks/index.d.mts +20 -10
- package/dist/plugins/media/client/hooks/index.d.ts +20 -10
- package/dist/plugins/media/client/index.cjs +1 -0
- package/dist/plugins/media/client/index.d.cts +112 -100
- package/dist/plugins/media/client/index.d.mts +112 -100
- package/dist/plugins/media/client/index.d.ts +112 -100
- package/dist/plugins/media/client/index.mjs +1 -1
- package/dist/plugins/media/permissions.cjs +63 -0
- package/dist/plugins/media/permissions.d.cts +64 -0
- package/dist/plugins/media/permissions.d.mts +64 -0
- package/dist/plugins/media/permissions.d.ts +64 -0
- package/dist/plugins/media/permissions.mjs +61 -0
- package/dist/plugins/media/query-keys.cjs +29 -17
- package/dist/plugins/media/query-keys.d.cts +24 -31
- package/dist/plugins/media/query-keys.d.mts +24 -31
- package/dist/plugins/media/query-keys.d.ts +24 -31
- package/dist/plugins/media/query-keys.mjs +30 -18
- package/dist/plugins/open-api/api/index.d.cts +9 -4
- package/dist/plugins/open-api/api/index.d.mts +9 -4
- package/dist/plugins/open-api/api/index.d.ts +9 -4
- package/dist/plugins/route-docs/client/index.cjs +2 -2
- package/dist/plugins/route-docs/client/index.d.cts +54 -53
- package/dist/plugins/route-docs/client/index.d.mts +54 -53
- package/dist/plugins/route-docs/client/index.d.ts +54 -53
- package/dist/plugins/route-docs/client/index.mjs +2 -1
- package/dist/plugins/ui-builder/client/components/index.d.cts +8 -5
- package/dist/plugins/ui-builder/client/components/index.d.mts +8 -5
- package/dist/plugins/ui-builder/client/components/index.d.ts +8 -5
- package/dist/plugins/ui-builder/client/hooks/index.d.cts +5 -5
- package/dist/plugins/ui-builder/client/hooks/index.d.mts +5 -5
- package/dist/plugins/ui-builder/client/hooks/index.d.ts +5 -5
- package/dist/plugins/ui-builder/client/index.d.cts +151 -199
- package/dist/plugins/ui-builder/client/index.d.mts +151 -199
- package/dist/plugins/ui-builder/client/index.d.ts +151 -199
- package/dist/plugins/ui-builder/index.d.cts +11 -8
- package/dist/plugins/ui-builder/index.d.mts +11 -8
- package/dist/plugins/ui-builder/index.d.ts +11 -8
- package/dist/plugins/ui-builder/query-keys.d.cts +6 -6
- package/dist/plugins/ui-builder/query-keys.d.mts +6 -6
- package/dist/plugins/ui-builder/query-keys.d.ts +6 -6
- package/dist/react-router/index.cjs +2 -0
- package/dist/react-router/index.d.cts +41 -7
- package/dist/react-router/index.d.mts +41 -7
- package/dist/react-router/index.d.ts +41 -7
- package/dist/react-router/index.mjs +1 -0
- package/dist/shared/stack.0O62uXqP.d.ts +613 -0
- package/dist/shared/stack.0y6iTP03.d.ts +533 -0
- package/dist/shared/{stack.CbZenbej.d.cts → stack.1ukVJym7.d.cts} +3 -4
- package/dist/shared/{stack.CbZenbej.d.mts → stack.1ukVJym7.d.mts} +3 -4
- package/dist/shared/{stack.CbZenbej.d.ts → stack.1ukVJym7.d.ts} +3 -4
- package/dist/shared/stack.3Sr6qRtT.d.ts +507 -0
- package/dist/shared/{stack.9BAOaSqE.d.mts → stack.5_zzCejP.d.cts} +16 -14
- package/dist/shared/{stack.9BAOaSqE.d.ts → stack.5_zzCejP.d.mts} +16 -14
- package/dist/shared/{stack.9BAOaSqE.d.cts → stack.5_zzCejP.d.ts} +16 -14
- package/dist/shared/stack.B1UrNoVl.d.mts +533 -0
- package/dist/shared/{stack.B2xi4jj7.d.cts → stack.B1srlBud.d.mts} +2 -2
- package/dist/shared/stack.B3_aDcYL.d.cts +281 -0
- package/dist/shared/stack.B3_aDcYL.d.mts +281 -0
- package/dist/shared/stack.B3_aDcYL.d.ts +281 -0
- package/dist/shared/stack.B5yPgHsp.d.mts +507 -0
- package/dist/shared/stack.B8PG21zX.d.mts +764 -0
- package/dist/shared/stack.BFP_9pRX.d.cts +707 -0
- package/dist/shared/{stack.INBa9-TO.d.cts → stack.BGzgFx3R.d.cts} +5 -5
- package/dist/shared/stack.BJx1ZXrN.d.cts +118 -0
- package/dist/shared/{stack.7b3vsM8_.d.ts → stack.BK9Z2dcL.d.ts} +2 -2
- package/dist/shared/stack.BMHoxAn7.d.mts +707 -0
- package/dist/shared/stack.BMmvEBH_.d.ts +118 -0
- package/dist/shared/stack.BOZRaVpu.d.cts +1184 -0
- package/dist/shared/stack.BPLykw4s.d.ts +436 -0
- package/dist/shared/{stack.aqVZ6PEW.d.mts → stack.BRvqQWGt.d.cts} +40 -1
- package/dist/shared/{stack.aqVZ6PEW.d.cts → stack.BRvqQWGt.d.mts} +40 -1
- package/dist/shared/{stack.aqVZ6PEW.d.ts → stack.BRvqQWGt.d.ts} +40 -1
- package/dist/shared/stack.BSACE667.d.cts +23 -0
- package/dist/shared/stack.BYMentwB.d.cts +47 -0
- package/dist/shared/stack.BYMentwB.d.mts +47 -0
- package/dist/shared/stack.BYMentwB.d.ts +47 -0
- package/dist/shared/stack.Bt8hfw9o.d.ts +707 -0
- package/dist/shared/{stack.D7bewlgt.d.mts → stack.Bu2IPOLi.d.cts} +1 -0
- package/dist/shared/{stack.D7bewlgt.d.ts → stack.Bu2IPOLi.d.mts} +1 -0
- package/dist/shared/{stack.D7bewlgt.d.cts → stack.Bu2IPOLi.d.ts} +1 -0
- package/dist/shared/stack.BuxUQqL8.d.ts +408 -0
- package/dist/shared/stack.BzWGB5MG.d.cts +436 -0
- package/dist/shared/stack.C3bU9w6L.d.ts +351 -0
- package/dist/shared/stack.C4oVW2qK.d.cts +507 -0
- package/dist/shared/stack.CKXzdGiJ.d.cts +3 -0
- package/dist/shared/stack.CKXzdGiJ.d.mts +3 -0
- package/dist/shared/stack.CKXzdGiJ.d.ts +3 -0
- package/dist/shared/{stack.C3GBG8in.d.ts → stack.COrJrztD.d.cts} +1 -1
- package/dist/shared/{stack.C3GBG8in.d.cts → stack.COrJrztD.d.mts} +1 -1
- package/dist/shared/{stack.C3GBG8in.d.mts → stack.COrJrztD.d.ts} +1 -1
- package/dist/shared/stack.CX83YNuS.d.cts +408 -0
- package/dist/shared/stack.Cbd7sD5M.d.mts +118 -0
- package/dist/shared/{stack.B9NtGpAR.d.ts → stack.CcjENrr4.d.cts} +1 -5
- package/dist/shared/stack.CfK5NKlK.d.mts +613 -0
- package/dist/shared/{stack.3di7vQs6.d.mts → stack.CjCSDfWy.d.mts} +5 -5
- package/dist/shared/stack.Cmg7lzzy.d.cts +44 -0
- package/dist/shared/stack.Cmg7lzzy.d.mts +44 -0
- package/dist/shared/stack.Cmg7lzzy.d.ts +44 -0
- package/dist/shared/stack.CpE1mS3p.d.ts +331 -0
- package/dist/shared/stack.CskhFw3z.d.mts +23 -0
- package/dist/shared/stack.CvlC5kqe.d.cts +331 -0
- package/dist/shared/stack.CxKc9evq.d.ts +23 -0
- package/dist/shared/stack.CyalJ0j6.d.ts +764 -0
- package/dist/shared/stack.D6Pg-ufX.d.cts +764 -0
- package/dist/shared/{stack.lkebw2nj.d.mts → stack.DVEjWKCT.d.cts} +19 -5
- package/dist/shared/{stack.lkebw2nj.d.ts → stack.DVEjWKCT.d.mts} +19 -5
- package/dist/shared/{stack.lkebw2nj.d.cts → stack.DVEjWKCT.d.ts} +19 -5
- package/dist/shared/{stack.Cp_6mO5s.d.mts → stack.DbbvHbhn.d.mts} +1 -5
- package/dist/shared/stack.DiuRuzIs.d.cts +613 -0
- package/dist/shared/{stack.BMlLOMED.d.mts → stack.DjGixVx3.d.cts} +6 -2
- package/dist/shared/{stack.BMlLOMED.d.ts → stack.DjGixVx3.d.mts} +6 -2
- package/dist/shared/{stack.BMlLOMED.d.cts → stack.DjGixVx3.d.ts} +6 -2
- package/dist/shared/stack.DlBoNqYu.d.ts +1184 -0
- package/dist/shared/stack.DlCycSM-.d.mts +331 -0
- package/dist/shared/{stack.DycBcTeg.d.mts → stack.DmpPDPxA.d.cts} +2 -2
- package/dist/shared/{stack.CRelKJfH.d.ts → stack.Dpg_JjIo.d.ts} +5 -5
- package/dist/shared/stack.Dvy7FmaA.d.mts +1184 -0
- package/dist/shared/stack.DxHPKr2R.d.mts +436 -0
- package/dist/shared/stack.Egr3RWhA.d.mts +408 -0
- package/dist/shared/stack.Mak7pzIV.d.cts +533 -0
- package/dist/shared/stack.OYT8WU4n.d.mts +351 -0
- package/dist/shared/{stack.CPsYC2-Z.d.cts → stack.fdi94T4S.d.cts} +7 -7
- package/dist/shared/{stack.CPsYC2-Z.d.mts → stack.fdi94T4S.d.mts} +7 -7
- package/dist/shared/{stack.CPsYC2-Z.d.ts → stack.fdi94T4S.d.ts} +7 -7
- package/dist/shared/{stack.Dlgtumru.d.cts → stack.kaCV7vEL.d.ts} +1 -5
- package/dist/shared/stack.v2O65JqF.d.cts +351 -0
- package/dist/tanstack/index.cjs +2 -0
- package/dist/tanstack/index.d.cts +44 -14
- package/dist/tanstack/index.d.mts +44 -14
- package/dist/tanstack/index.d.ts +44 -14
- package/dist/tanstack/index.mjs +1 -0
- package/dist/tanstack/server.cjs +9 -0
- package/dist/tanstack/server.d.cts +15 -0
- package/dist/tanstack/server.d.mts +15 -0
- package/dist/tanstack/server.d.ts +15 -0
- package/dist/tanstack/server.mjs +7 -0
- package/package.json +203 -8
- package/src/__tests__/ai-chat-client-runtime.test.ts +481 -0
- package/src/__tests__/ai-chat-client-runtime.typecheck.tsx +130 -0
- package/src/__tests__/ai-chat-lifecycle-migrations.typecheck.ts +61 -0
- package/src/__tests__/ai-chat-query-keys.test.ts +125 -22
- package/src/__tests__/auth-provider.test.tsx +41 -314
- package/src/__tests__/auth-test-utils.ts +24 -0
- package/src/__tests__/authorization-client.test.tsx +767 -0
- package/src/__tests__/authorization-contraction.test.ts +182 -0
- package/src/__tests__/authorization-remote.test.ts +222 -0
- package/src/__tests__/authorization-server.test.ts +90 -0
- package/src/__tests__/authorization.test.ts +652 -0
- package/src/__tests__/authorization.typecheck.ts +671 -0
- package/src/__tests__/backend-plugin-factories.test.ts +54 -0
- package/src/__tests__/backend-plugin-factories.typecheck.ts +133 -0
- package/src/__tests__/client-plugin-ssr-loaders.test.ts +304 -138
- package/src/__tests__/client-runtime.test.ts +1021 -0
- package/src/__tests__/client-runtime.typecheck.ts +107 -0
- package/src/__tests__/client-stack-test-utils.ts +36 -0
- package/src/__tests__/content-lifecycle-migrations.typecheck.ts +122 -0
- package/src/__tests__/endpoint-inventory.test.ts +768 -0
- package/src/__tests__/entry-factories.test.tsx +104 -4
- package/src/__tests__/form-builder-query-keys.test.ts +32 -0
- package/src/__tests__/i18n-provider.test.tsx +4 -3
- package/src/__tests__/initial-identity-hydration.test.tsx +156 -0
- package/src/__tests__/initial-identity-layouts.test.tsx +204 -0
- package/src/__tests__/kanban-query-keys.test.ts +189 -2
- package/src/__tests__/managed-origin-hydration.browser.test.tsx +163 -0
- package/src/__tests__/media-query-keys.test.ts +91 -17
- package/src/__tests__/notify-provider.test.tsx +3 -2
- package/src/__tests__/package-metadata.test.ts +315 -0
- package/src/__tests__/page-component-overrides.test.tsx +3 -4
- package/src/__tests__/plugin-registration.test.tsx +183 -0
- package/src/__tests__/plugin-registration.typecheck.tsx +139 -0
- package/src/__tests__/plugins.test.tsx +72 -42
- package/src/__tests__/resource-factory.test.tsx +79 -2
- package/src/__tests__/resource-use-form.test.tsx +2 -2
- package/src/__tests__/resource-use-select.test.tsx +2 -4
- package/src/__tests__/router-overrides.test.tsx +20 -8
- package/src/__tests__/sitemap.test.ts +38 -22
- package/src/__tests__/stack-api.test.ts +39 -34
- package/src/__tests__/stack-auth.test.ts +44 -140
- package/src/__tests__/stack-constructors.test.ts +96 -0
- package/src/__tests__/stack-constructors.typecheck.ts +115 -0
- package/src/__tests__/use-list-state.test.tsx +7 -6
- package/src/__tests__/workflow-lifecycle-migrations.typecheck.ts +150 -0
- package/src/api/index.ts +204 -99
- package/src/authorization/client.tsx +310 -0
- package/src/authorization/index.ts +873 -0
- package/src/authorization/json.ts +70 -0
- package/src/authorization/remote.ts +234 -0
- package/src/authorization/server.ts +171 -0
- package/src/client/__tests__/server-origin.test.ts +119 -0
- package/src/client/components/compose.tsx +126 -18
- package/src/client/hooks/index.ts +12 -0
- package/src/client/hooks/use-list-state.ts +7 -13
- package/src/client/index.ts +105 -50
- package/src/client/runtime.ts +414 -0
- package/src/client/server.ts +174 -0
- package/src/context/auth.tsx +205 -154
- package/src/context/index.ts +10 -4
- package/src/context/provider.tsx +96 -57
- package/src/context/router.tsx +7 -0
- package/src/context/site-navigation.ts +52 -0
- package/src/next/index.tsx +2 -0
- package/src/next/layout.tsx +81 -0
- package/src/next/page.tsx +33 -12
- package/src/next/router.tsx +1 -1
- package/src/next/server.ts +5 -0
- package/src/plugin-registration.ts +70 -0
- package/src/plugins/ai-chat/__tests__/authorization.test.ts +2051 -0
- package/src/plugins/ai-chat/__tests__/chat-hooks.test.tsx +147 -0
- package/src/plugins/ai-chat/__tests__/chat-input-authorization.test.tsx +188 -0
- package/src/plugins/ai-chat/__tests__/client-sweep.test.tsx +1506 -34
- package/src/plugins/ai-chat/__tests__/hooks.test.tsx +131 -23
- package/src/plugins/ai-chat/api/getters.ts +2 -2
- package/src/plugins/ai-chat/api/index.ts +6 -1
- package/src/plugins/ai-chat/api/lifecycle-migrations.ts +20 -0
- package/src/plugins/ai-chat/api/operations.ts +1865 -0
- package/src/plugins/ai-chat/api/plugin.ts +78 -1168
- package/src/plugins/ai-chat/api/serializers.ts +30 -0
- package/src/plugins/ai-chat/client/components/chat-input.tsx +228 -129
- package/src/plugins/ai-chat/client/components/chat-interface.tsx +776 -183
- package/src/plugins/ai-chat/client/components/chat-layout.tsx +6 -7
- package/src/plugins/ai-chat/client/components/chat-message.tsx +1 -1
- package/src/plugins/ai-chat/client/components/chat-sidebar.tsx +57 -37
- package/src/plugins/ai-chat/client/components/pages/404-page.tsx +1 -1
- package/src/plugins/ai-chat/client/components/pages/chat-page.internal.tsx +5 -3
- package/src/plugins/ai-chat/client/components/pages/chat-page.tsx +56 -15
- package/src/plugins/ai-chat/client/components/shared/default-error.tsx +1 -1
- package/src/plugins/ai-chat/client/components/tool-call-display.tsx +1 -1
- package/src/plugins/ai-chat/client/hooks/ai-chat-resource.ts +1 -1
- package/src/plugins/ai-chat/client/hooks/chat-hooks.tsx +253 -20
- package/src/plugins/ai-chat/client/index.ts +1 -0
- package/src/plugins/ai-chat/client/navigation.ts +11 -0
- package/src/plugins/ai-chat/client/overrides.ts +47 -11
- package/src/plugins/ai-chat/client/plugin.tsx +208 -111
- package/src/plugins/ai-chat/permissions.ts +89 -0
- package/src/plugins/ai-chat/query-keys.ts +183 -25
- package/src/plugins/ai-chat/types.ts +7 -5
- package/src/plugins/api/create-endpoint.ts +40 -22
- package/src/plugins/api/endpoint-inventory.ts +206 -0
- package/src/plugins/api/index.ts +38 -4
- package/src/plugins/api/operation.ts +600 -0
- package/src/plugins/blog/__tests__/authorization.test.ts +1366 -0
- package/src/plugins/blog/__tests__/client-runtime.browser.test.tsx +257 -0
- package/src/plugins/blog/__tests__/client-runtime.test.ts +283 -0
- package/src/plugins/blog/__tests__/client-runtime.typecheck.tsx +98 -0
- package/src/plugins/blog/__tests__/client-sweep.test.tsx +212 -37
- package/src/plugins/blog/api/getters.ts +3 -3
- package/src/plugins/blog/api/index.ts +2 -0
- package/src/plugins/blog/api/lifecycle-migrations.ts +19 -0
- package/src/plugins/blog/api/mutations.ts +26 -5
- package/src/plugins/blog/api/operations.ts +727 -0
- package/src/plugins/blog/api/plugin.ts +99 -504
- package/src/plugins/blog/client/components/forms/image-field.tsx +2 -1
- package/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.tsx +2 -1
- package/src/plugins/blog/client/components/forms/post-forms.tsx +61 -33
- package/src/plugins/blog/client/components/pages/404-page.tsx +3 -1
- package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/edit-post-page.tsx +28 -5
- package/src/plugins/blog/client/components/pages/home-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/home-page.tsx +7 -4
- package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/new-post-page.tsx +5 -2
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/post-page.tsx +38 -4
- package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/tag-page.tsx +5 -1
- package/src/plugins/blog/client/components/shared/collapsible-tag-list.tsx +2 -1
- package/src/plugins/blog/client/components/shared/default-error.tsx +3 -1
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +5 -2
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/blog/client/components/shared/post-card.tsx +2 -1
- package/src/plugins/blog/client/components/shared/posts-list.tsx +2 -1
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +2 -1
- package/src/plugins/blog/client/components/shared/search-input.tsx +1 -1
- package/src/plugins/blog/client/constants.ts +2 -0
- package/src/plugins/blog/client/hooks/blog-resource.ts +2 -1
- package/src/plugins/blog/client/overrides.ts +1 -6
- package/src/plugins/blog/client/plugin.tsx +145 -129
- package/src/plugins/blog/permissions.ts +44 -0
- package/src/plugins/client/index.ts +108 -7
- package/src/plugins/client/resource/hooks.tsx +41 -18
- package/src/plugins/client/resource/internal.ts +77 -61
- package/src/plugins/client/resource/queries.ts +3 -4
- package/src/plugins/client/resource/use-form.ts +23 -20
- package/src/plugins/client/resource/use-select.ts +40 -34
- package/src/plugins/cms/__tests__/authorization.test.ts +2188 -0
- package/src/plugins/cms/__tests__/client-runtime.browser.test.tsx +245 -0
- package/src/plugins/cms/__tests__/client-runtime.test.ts +320 -0
- package/src/plugins/cms/__tests__/client-runtime.typecheck.tsx +208 -0
- package/src/plugins/cms/__tests__/client-sweep.test.tsx +202 -50
- package/src/plugins/cms/api/getters.ts +4 -4
- package/src/plugins/cms/api/index.ts +20 -0
- package/src/plugins/cms/api/lifecycle-migrations.ts +15 -0
- package/src/plugins/cms/api/mutations.ts +2 -2
- package/src/plugins/cms/api/operations.ts +2218 -0
- package/src/plugins/cms/api/plugin.ts +169 -1047
- package/src/plugins/cms/api/relations.ts +3 -1
- package/src/plugins/cms/client/components/forms/content-form.tsx +2 -1
- package/src/plugins/cms/client/components/forms/file-upload.tsx +3 -1
- package/src/plugins/cms/client/components/forms/relation-field.tsx +3 -1
- package/src/plugins/cms/client/components/inverse-relations-panel.tsx +29 -17
- package/src/plugins/cms/client/components/pages/404-page.tsx +7 -5
- package/src/plugins/cms/client/components/pages/content-editor-page.internal.tsx +19 -10
- package/src/plugins/cms/client/components/pages/content-editor-page.tsx +50 -12
- package/src/plugins/cms/client/components/pages/content-list-page.internal.tsx +48 -34
- package/src/plugins/cms/client/components/pages/content-list-page.tsx +8 -1
- package/src/plugins/cms/client/components/pages/dashboard-page.internal.tsx +15 -8
- package/src/plugins/cms/client/components/pages/dashboard-page.tsx +5 -1
- package/src/plugins/cms/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/cms/client/constants.ts +2 -0
- package/src/plugins/cms/client/hooks/cms-resource.ts +2 -1
- package/src/plugins/cms/client/index.ts +6 -1
- package/src/plugins/cms/client/overrides.ts +46 -6
- package/src/plugins/cms/client/plugin.tsx +135 -80
- package/src/plugins/cms/permissions.ts +43 -0
- package/src/plugins/cms/types.ts +174 -46
- package/src/plugins/comments/__tests__/authorization.test.ts +1570 -0
- package/src/plugins/comments/__tests__/client-runtime.browser.test.tsx +207 -0
- package/src/plugins/comments/__tests__/client-runtime.test.ts +224 -0
- package/src/plugins/comments/__tests__/client-runtime.typecheck.tsx +85 -0
- package/src/plugins/comments/__tests__/client-sweep.test.tsx +465 -79
- package/src/plugins/comments/api/getters.ts +19 -3
- package/src/plugins/comments/api/index.ts +2 -6
- package/src/plugins/comments/api/lifecycle-migrations.ts +20 -0
- package/src/plugins/comments/api/mutations.ts +261 -88
- package/src/plugins/comments/api/operations.ts +742 -0
- package/src/plugins/comments/api/plugin.ts +76 -548
- package/src/plugins/comments/client/components/comment-count.tsx +38 -5
- package/src/plugins/comments/client/components/comment-thread.tsx +154 -112
- package/src/plugins/comments/client/components/pages/moderation-page.internal.tsx +144 -78
- package/src/plugins/comments/client/components/pages/moderation-page.tsx +18 -2
- package/src/plugins/comments/client/components/pages/moderation-state.ts +13 -0
- package/src/plugins/comments/client/components/pages/my-comments-page.internal.tsx +38 -30
- package/src/plugins/comments/client/components/pages/my-comments-page.tsx +3 -1
- package/src/plugins/comments/client/components/pages/resource-comments-page.internal.tsx +29 -30
- package/src/plugins/comments/client/components/pages/resource-comments-page.tsx +10 -1
- package/src/plugins/comments/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/comments/client/components/shared/pagination.tsx +2 -1
- package/src/plugins/comments/client/constants.ts +2 -0
- package/src/plugins/comments/client/hooks/use-comments.tsx +430 -421
- package/src/plugins/comments/client/localization/comments-thread.ts +1 -0
- package/src/plugins/comments/client/plugin.tsx +113 -72
- package/src/plugins/comments/permissions.ts +68 -0
- package/src/plugins/comments/query-keys.ts +9 -10
- package/src/plugins/comments/schemas.ts +7 -8
- package/src/plugins/form-builder/__tests__/authorization.test.ts +1600 -0
- package/src/plugins/form-builder/__tests__/client-runtime.browser.test.tsx +255 -0
- package/src/plugins/form-builder/__tests__/client-runtime.test.ts +132 -0
- package/src/plugins/form-builder/__tests__/client-runtime.typecheck.tsx +77 -0
- package/src/plugins/form-builder/__tests__/client-sweep.test.tsx +350 -54
- package/src/plugins/form-builder/__tests__/form-renderer-authorization.test.tsx +162 -0
- package/src/plugins/form-builder/api/getters.ts +21 -5
- package/src/plugins/form-builder/api/index.ts +31 -0
- package/src/plugins/form-builder/api/lifecycle-migrations.ts +17 -0
- package/src/plugins/form-builder/api/operations.ts +1493 -0
- package/src/plugins/form-builder/api/plugin.ts +125 -632
- package/src/plugins/form-builder/api/query-key-defs.ts +7 -0
- package/src/plugins/form-builder/api/serializers.ts +1 -0
- package/src/plugins/form-builder/client/components/forms/form-renderer.tsx +49 -19
- package/src/plugins/form-builder/client/components/pages/404-page.tsx +9 -9
- package/src/plugins/form-builder/client/components/pages/form-builder-page.internal.tsx +54 -30
- package/src/plugins/form-builder/client/components/pages/form-builder-page.tsx +42 -9
- package/src/plugins/form-builder/client/components/pages/form-list-page.internal.tsx +46 -34
- package/src/plugins/form-builder/client/components/pages/form-list-page.tsx +6 -2
- package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +98 -64
- package/src/plugins/form-builder/client/components/pages/submissions-page.tsx +29 -9
- package/src/plugins/form-builder/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/form-builder/client/constants.ts +2 -0
- package/src/plugins/form-builder/client/hooks/form-builder-hooks.tsx +68 -4
- package/src/plugins/form-builder/client/hooks/form-builder-resource.ts +2 -1
- package/src/plugins/form-builder/client/hooks/index.tsx +1 -0
- package/src/plugins/form-builder/client/overrides.ts +1 -6
- package/src/plugins/form-builder/client/plugin.tsx +128 -96
- package/src/plugins/form-builder/permissions.ts +94 -0
- package/src/plugins/form-builder/query-keys.ts +28 -3
- package/src/plugins/form-builder/schemas.ts +9 -1
- package/src/plugins/form-builder/types.ts +173 -41
- package/src/plugins/kanban/__tests__/authorization.test.ts +1382 -0
- package/src/plugins/kanban/__tests__/client-runtime.browser.test.tsx +302 -0
- package/src/plugins/kanban/__tests__/client-runtime.test.ts +130 -0
- package/src/plugins/kanban/__tests__/client-runtime.typecheck.tsx +81 -0
- package/src/plugins/kanban/__tests__/client-sweep.test.tsx +418 -33
- package/src/plugins/kanban/__tests__/identity-partition.test.tsx +306 -0
- package/src/plugins/kanban/api/getters.ts +65 -50
- package/src/plugins/kanban/api/index.ts +55 -4
- package/src/plugins/kanban/api/lifecycle-migrations.ts +25 -0
- package/src/plugins/kanban/api/mutations.ts +3 -3
- package/src/plugins/kanban/api/operations.ts +2065 -0
- package/src/plugins/kanban/api/plugin.ts +83 -1013
- package/src/plugins/kanban/api/serializers.ts +26 -0
- package/src/plugins/kanban/client/components/forms/board-form.tsx +3 -1
- package/src/plugins/kanban/client/components/forms/column-form.tsx +3 -1
- package/src/plugins/kanban/client/components/forms/task-form.tsx +92 -74
- package/src/plugins/kanban/client/components/pages/404-page.tsx +6 -9
- package/src/plugins/kanban/client/components/pages/board-page.internal.tsx +57 -74
- package/src/plugins/kanban/client/components/pages/board-page.tsx +31 -7
- package/src/plugins/kanban/client/components/pages/boards-list-page.internal.tsx +54 -45
- package/src/plugins/kanban/client/components/pages/boards-list-page.tsx +2 -1
- package/src/plugins/kanban/client/components/pages/new-board-page.internal.tsx +8 -12
- package/src/plugins/kanban/client/components/pages/new-board-page.tsx +2 -1
- package/src/plugins/kanban/client/components/shared/column-content.tsx +61 -48
- package/src/plugins/kanban/client/components/shared/default-error.tsx +3 -1
- package/src/plugins/kanban/client/components/shared/kanban-board.tsx +6 -6
- package/src/plugins/kanban/client/components/shared/permission-access-any.tsx +32 -0
- package/src/plugins/kanban/client/components/shared/task-card.tsx +64 -20
- package/src/plugins/kanban/client/components/shared/user-avatar.tsx +3 -1
- package/src/plugins/kanban/client/constants.ts +2 -0
- package/src/plugins/kanban/client/hooks/kanban-hooks.tsx +55 -10
- package/src/plugins/kanban/client/hooks/kanban-resource.ts +2 -1
- package/src/plugins/kanban/client/overrides.ts +0 -5
- package/src/plugins/kanban/client/plugin.tsx +201 -113
- package/src/plugins/kanban/permissions.ts +100 -0
- package/src/plugins/kanban/query-keys.ts +61 -21
- package/src/plugins/kanban/schemas.ts +44 -18
- package/src/plugins/kanban/types.ts +381 -1
- package/src/plugins/media/__tests__/authorization.test.ts +1769 -0
- package/src/plugins/media/__tests__/client-runtime.browser.test.tsx +975 -0
- package/src/plugins/media/__tests__/client-runtime.test.ts +539 -0
- package/src/plugins/media/__tests__/client-runtime.typecheck.tsx +135 -0
- package/src/plugins/media/__tests__/client-sweep.test.tsx +292 -24
- package/src/plugins/media/__tests__/identity-partition.test.tsx +741 -0
- package/src/plugins/media/__tests__/plugin.test.ts +68 -28
- package/src/plugins/media/__tests__/query-key-defs.test.ts +32 -2
- package/src/plugins/media/api/adapters/vercel-blob.ts +84 -8
- package/src/plugins/media/api/getters.ts +6 -6
- package/src/plugins/media/api/index.ts +3 -0
- package/src/plugins/media/api/lifecycle-migrations.ts +11 -0
- package/src/plugins/media/api/mutations.ts +19 -13
- package/src/plugins/media/api/operations.ts +1873 -0
- package/src/plugins/media/api/plugin.ts +211 -899
- package/src/plugins/media/api/query-key-defs.ts +66 -4
- package/src/plugins/media/api/serializers.ts +4 -2
- package/src/plugins/media/api/storage-adapter.ts +22 -4
- package/src/plugins/media/asset-url.ts +14 -0
- package/src/plugins/media/client/components/media-picker/asset-card.tsx +105 -98
- package/src/plugins/media/client/components/media-picker/folder-tree.tsx +82 -60
- package/src/plugins/media/client/components/media-picker/index.tsx +235 -171
- package/src/plugins/media/client/components/media-picker/upload-tab.tsx +2 -10
- package/src/plugins/media/client/components/media-picker/url-tab.tsx +1 -8
- package/src/plugins/media/client/components/pages/library-page.internal.tsx +103 -82
- package/src/plugins/media/client/components/pages/library-page.tsx +4 -2
- package/src/plugins/media/client/components/upload-permission-check.tsx +75 -0
- package/src/plugins/media/client/constants.ts +2 -0
- package/src/plugins/media/client/hooks/media-resource.ts +2 -1
- package/src/plugins/media/client/hooks/use-media.tsx +292 -49
- package/src/plugins/media/client/index.ts +16 -3
- package/src/plugins/media/client/overrides.ts +6 -17
- package/src/plugins/media/client/plugin.tsx +188 -123
- package/src/plugins/media/client/upload.ts +170 -53
- package/src/plugins/media/db.ts +8 -0
- package/src/plugins/media/permissions.ts +61 -0
- package/src/plugins/media/query-keys.ts +63 -19
- package/src/plugins/media/types.ts +8 -2
- package/src/plugins/open-api/__tests__/route-introspection.test.ts +277 -0
- package/src/plugins/open-api/api/generator.ts +49 -8
- package/src/plugins/open-api/api/plugin.ts +36 -14
- package/src/plugins/route-docs/client/components/pages/docs-page.tsx +63 -23
- package/src/plugins/route-docs/client/constants.ts +2 -0
- package/src/plugins/route-docs/client/hooks.ts +23 -13
- package/src/plugins/route-docs/client/index.ts +7 -1
- package/src/plugins/route-docs/client/plugin.tsx +222 -145
- package/src/plugins/route-docs/client/schema.ts +31 -0
- package/src/plugins/route-docs/generator.ts +9 -5
- package/src/plugins/ui-builder/__tests__/client-sweep.test.tsx +427 -48
- package/src/plugins/ui-builder/client/components/page-renderer.tsx +58 -16
- package/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.tsx +47 -26
- package/src/plugins/ui-builder/client/components/pages/page-builder-page.tsx +43 -8
- package/src/plugins/ui-builder/client/components/pages/page-list-page.internal.tsx +38 -19
- package/src/plugins/ui-builder/client/components/pages/page-list-page.tsx +8 -2
- package/src/plugins/ui-builder/client/components/shared/default-error.tsx +2 -1
- package/src/plugins/ui-builder/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/ui-builder/client/constants.ts +2 -0
- package/src/plugins/ui-builder/client/hooks/ui-builder-resource.ts +2 -1
- package/src/plugins/ui-builder/client/index.ts +4 -1
- package/src/plugins/ui-builder/client/overrides.ts +16 -21
- package/src/plugins/ui-builder/client/plugin.tsx +119 -66
- package/src/plugins/ui-builder/client/registry.ts +3 -5
- package/src/plugins/ui-builder/types.ts +7 -4
- package/src/plugins/utils.ts +5 -1
- package/src/react-router/index.tsx +6 -0
- package/src/react-router/layout.ts +43 -0
- package/src/react-router/page.tsx +46 -17
- package/src/react-router/router.tsx +1 -1
- package/src/shared/auth-types.ts +19 -70
- package/src/shared/entry-factories.ts +12 -3
- package/src/shared/initial-identity.ts +73 -0
- package/src/shared/list-state.ts +12 -0
- package/src/shared/types.ts +1 -0
- package/src/tanstack/index.tsx +7 -0
- package/src/tanstack/layout.ts +36 -0
- package/src/tanstack/page.tsx +35 -13
- package/src/tanstack/router.tsx +1 -1
- package/src/tanstack/server.ts +18 -0
- package/src/types.ts +557 -65
- package/dist/shared/stack.80-y2TTR.d.mts +0 -840
- package/dist/shared/stack.B-hEIoUw.d.ts +0 -406
- package/dist/shared/stack.B8vdOMnQ.d.cts +0 -329
- package/dist/shared/stack.BISAZ5LX.d.mts +0 -492
- package/dist/shared/stack.BL5PvShn.d.mts +0 -193
- package/dist/shared/stack.Be1QIHEn.d.cts +0 -23
- package/dist/shared/stack.Be1QIHEn.d.mts +0 -23
- package/dist/shared/stack.Be1QIHEn.d.ts +0 -23
- package/dist/shared/stack.BjvOk_Bs.d.cts +0 -492
- package/dist/shared/stack.Bk5UB_BT.d.ts +0 -840
- package/dist/shared/stack.BozPgbrZ.d.cts +0 -201
- package/dist/shared/stack.BozPgbrZ.d.mts +0 -201
- package/dist/shared/stack.BozPgbrZ.d.ts +0 -201
- package/dist/shared/stack.BqTR6qi2.d.ts +0 -193
- package/dist/shared/stack.BvxHSZYT.d.cts +0 -406
- package/dist/shared/stack.C1ATQ3pd.d.ts +0 -416
- package/dist/shared/stack.C4_gEENS.d.cts +0 -97
- package/dist/shared/stack.C4_gEENS.d.mts +0 -97
- package/dist/shared/stack.C4_gEENS.d.ts +0 -97
- package/dist/shared/stack.C5Y5lViI.d.cts +0 -461
- package/dist/shared/stack.C8SwdUz8.d.ts +0 -461
- package/dist/shared/stack.CBsp9rDM.d.cts +0 -193
- package/dist/shared/stack.CMbX8Q5C.d.ts +0 -560
- package/dist/shared/stack.Cf-DbL1A.d.ts +0 -329
- package/dist/shared/stack.DHTvwoNG.d.mts +0 -329
- package/dist/shared/stack.DJaKVY7v.d.cts +0 -76
- package/dist/shared/stack.DJaKVY7v.d.mts +0 -76
- package/dist/shared/stack.DJaKVY7v.d.ts +0 -76
- package/dist/shared/stack.DKZMaVr6.d.cts +0 -416
- package/dist/shared/stack.DQq8DEIv.d.mts +0 -461
- package/dist/shared/stack.Dd-8shBE.d.ts +0 -492
- package/dist/shared/stack.Dj04W2c3.d.mts +0 -560
- package/dist/shared/stack.DrUBX-QE.d.cts +0 -34
- package/dist/shared/stack.DrUBX-QE.d.mts +0 -34
- package/dist/shared/stack.DrUBX-QE.d.ts +0 -34
- package/dist/shared/stack.H5B8miAV.d.cts +0 -840
- package/dist/shared/stack.aXdBOJAR.d.cts +0 -173
- package/dist/shared/stack.aXdBOJAR.d.mts +0 -173
- package/dist/shared/stack.aXdBOJAR.d.ts +0 -173
- package/dist/shared/stack.eq5eg1yt.d.cts +0 -560
- package/dist/shared/stack.f8Vke-eH.d.mts +0 -406
- package/dist/shared/stack.oBokjN_J.d.mts +0 -416
- package/dist/shared/{stack.B0muOwUF.d.cts → stack.Csi-4Mgz.d.cts} +8 -8
- package/dist/shared/{stack.B0muOwUF.d.mts → stack.Csi-4Mgz.d.mts} +8 -8
- package/dist/shared/{stack.B0muOwUF.d.ts → stack.Csi-4Mgz.d.ts} +8 -8
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useChat } from "@ai-sdk/react";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
useEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
useMemo,
|
|
9
|
+
useCallback,
|
|
10
|
+
useLayoutEffect,
|
|
11
|
+
useId,
|
|
12
|
+
} from "react";
|
|
13
|
+
import { hashKey, useQueryClient } from "@tanstack/react-query";
|
|
6
14
|
import { ChatMessage } from "./chat-message";
|
|
7
15
|
import { ChatInput, type AttachedFile } from "./chat-input";
|
|
8
16
|
import { StackAttribution } from "@workspace/ui/components/stack-attribution";
|
|
@@ -14,25 +22,31 @@ import {
|
|
|
14
22
|
} from "ai";
|
|
15
23
|
import { cn } from "@workspace/ui/lib/utils";
|
|
16
24
|
import {
|
|
17
|
-
|
|
25
|
+
PermissionCheck,
|
|
18
26
|
usePluginOverrides,
|
|
19
|
-
useBasePath,
|
|
20
27
|
useStack,
|
|
21
28
|
} from "@btst/stack/context";
|
|
22
|
-
import
|
|
29
|
+
import { aiChatPermissions } from "../../permissions";
|
|
30
|
+
import {
|
|
31
|
+
resolveAiChatApiUrl,
|
|
32
|
+
resolveAiChatMode,
|
|
33
|
+
resolveAiChatSiteLocation,
|
|
34
|
+
type AiChatPluginOverrides,
|
|
35
|
+
} from "../overrides";
|
|
23
36
|
import { useAiChatTranslation } from "../localization";
|
|
24
37
|
import { createApiClient } from "@btst/stack/plugins/client";
|
|
25
38
|
import type { AiChatApiRouter } from "../../api/plugin";
|
|
26
|
-
import { createAiChatQueryKeys } from "../../query-keys";
|
|
39
|
+
import { aiChatIdentityKey, createAiChatQueryKeys } from "../../query-keys";
|
|
27
40
|
import {
|
|
28
41
|
useConversation,
|
|
29
42
|
useConversations,
|
|
30
|
-
|
|
43
|
+
useAiChatIdentityPartition,
|
|
44
|
+
type SerializedMessage,
|
|
31
45
|
} from "../hooks/chat-hooks";
|
|
32
46
|
import { usePageAIContext } from "../context/page-ai-context";
|
|
47
|
+
import { navigateAiChatCrossOrigin } from "../navigation";
|
|
33
48
|
|
|
34
49
|
interface ChatInterfaceProps {
|
|
35
|
-
apiPath?: string;
|
|
36
50
|
initialMessages?: UIMessage[];
|
|
37
51
|
id?: string;
|
|
38
52
|
/** Variant: 'full' for full-page layout, 'widget' for embedded widget */
|
|
@@ -42,8 +56,203 @@ interface ChatInterfaceProps {
|
|
|
42
56
|
onMessagesChange?: (messages: UIMessage[]) => void;
|
|
43
57
|
}
|
|
44
58
|
|
|
59
|
+
type ChatAction = "send" | "edit" | "retry";
|
|
60
|
+
|
|
61
|
+
function reconcilePersistedMessageIds(
|
|
62
|
+
messages: UIMessage[],
|
|
63
|
+
persistedMessages: SerializedMessage[],
|
|
64
|
+
): UIMessage[] | null {
|
|
65
|
+
const userMessages = messages.filter((message) => message.role === "user");
|
|
66
|
+
const persistedUserMessages = persistedMessages.filter(
|
|
67
|
+
(message) => message.role === "user",
|
|
68
|
+
);
|
|
69
|
+
if (persistedUserMessages.length !== userMessages.length) return null;
|
|
70
|
+
const persistedIds = new Map<UIMessage, string>();
|
|
71
|
+
for (let index = 0; index < userMessages.length; index++) {
|
|
72
|
+
const message = userMessages[index];
|
|
73
|
+
const persisted = persistedUserMessages[index];
|
|
74
|
+
if (!message || !persisted) return null;
|
|
75
|
+
const serializedParts = JSON.stringify(message.parts);
|
|
76
|
+
const legacyText =
|
|
77
|
+
message.parts.length === 1 && message.parts[0]?.type === "text"
|
|
78
|
+
? message.parts[0].text
|
|
79
|
+
: undefined;
|
|
80
|
+
if (
|
|
81
|
+
persisted.content !== serializedParts &&
|
|
82
|
+
persisted.content !== legacyText
|
|
83
|
+
) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
persistedIds.set(message, persisted.id);
|
|
87
|
+
}
|
|
88
|
+
return messages.map((message) => ({
|
|
89
|
+
...message,
|
|
90
|
+
id: persistedIds.get(message) ?? message.id,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function persistedMessagesToUiMessages(
|
|
95
|
+
messages: readonly SerializedMessage[],
|
|
96
|
+
): UIMessage[] {
|
|
97
|
+
return messages
|
|
98
|
+
.filter((message) => message.role !== "data")
|
|
99
|
+
.map((message) => {
|
|
100
|
+
let parts: UIMessage["parts"];
|
|
101
|
+
try {
|
|
102
|
+
const parsed = JSON.parse(message.content);
|
|
103
|
+
parts = Array.isArray(parsed)
|
|
104
|
+
? parsed
|
|
105
|
+
: [{ type: "text" as const, text: message.content }];
|
|
106
|
+
} catch {
|
|
107
|
+
parts = [{ type: "text" as const, text: message.content }];
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
id: message.id,
|
|
111
|
+
role: message.role as "user" | "assistant" | "system",
|
|
112
|
+
parts,
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function ChatActionCheck({
|
|
118
|
+
publicMode,
|
|
119
|
+
action,
|
|
120
|
+
conversationId,
|
|
121
|
+
ownerId,
|
|
122
|
+
messageId,
|
|
123
|
+
toolNames = [],
|
|
124
|
+
routeName,
|
|
125
|
+
children,
|
|
126
|
+
}: {
|
|
127
|
+
publicMode: boolean;
|
|
128
|
+
action: ChatAction;
|
|
129
|
+
conversationId?: string;
|
|
130
|
+
ownerId?: string;
|
|
131
|
+
messageId?: string;
|
|
132
|
+
toolNames?: readonly string[];
|
|
133
|
+
routeName?: string;
|
|
134
|
+
children: (allowed: boolean) => React.ReactNode;
|
|
135
|
+
}) {
|
|
136
|
+
if (publicMode) return <>{children(true)}</>;
|
|
137
|
+
const base = {
|
|
138
|
+
...(conversationId ? { conversationId } : {}),
|
|
139
|
+
...(ownerId ? { ownerId } : {}),
|
|
140
|
+
};
|
|
141
|
+
const streamPermission = aiChatPermissions.stream.start({
|
|
142
|
+
...base,
|
|
143
|
+
createsConversation: !conversationId,
|
|
144
|
+
intent: action,
|
|
145
|
+
});
|
|
146
|
+
const messagePermission =
|
|
147
|
+
action === "send"
|
|
148
|
+
? aiChatPermissions.message.send({
|
|
149
|
+
...base,
|
|
150
|
+
createsConversation: !conversationId,
|
|
151
|
+
})
|
|
152
|
+
: action === "edit" && conversationId && messageId
|
|
153
|
+
? aiChatPermissions.message.edit({
|
|
154
|
+
conversationId,
|
|
155
|
+
...(ownerId ? { ownerId } : {}),
|
|
156
|
+
messageId,
|
|
157
|
+
})
|
|
158
|
+
: action === "retry" && conversationId && messageId
|
|
159
|
+
? aiChatPermissions.message.retry({
|
|
160
|
+
conversationId,
|
|
161
|
+
...(ownerId ? { ownerId } : {}),
|
|
162
|
+
messageId,
|
|
163
|
+
})
|
|
164
|
+
: null;
|
|
165
|
+
if (!messagePermission) return <>{children(false)}</>;
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<PermissionCheck permission={streamPermission}>
|
|
169
|
+
{(streamState) => (
|
|
170
|
+
<PermissionCheck permission={messagePermission}>
|
|
171
|
+
{(messageState) => {
|
|
172
|
+
const baseAllowed =
|
|
173
|
+
streamState.can &&
|
|
174
|
+
!streamState.isPending &&
|
|
175
|
+
!streamState.error &&
|
|
176
|
+
messageState.can &&
|
|
177
|
+
!messageState.isPending &&
|
|
178
|
+
!messageState.error;
|
|
179
|
+
const renderToolCheck = (allowed: boolean) => {
|
|
180
|
+
if (!allowed || toolNames.length === 0) return children(allowed);
|
|
181
|
+
return (
|
|
182
|
+
<PermissionCheck
|
|
183
|
+
permission={aiChatPermissions.tool.activate({
|
|
184
|
+
...base,
|
|
185
|
+
...(routeName ? { routeName } : {}),
|
|
186
|
+
toolNames: [...toolNames],
|
|
187
|
+
})}
|
|
188
|
+
>
|
|
189
|
+
{(toolState) =>
|
|
190
|
+
children(
|
|
191
|
+
toolState.can && !toolState.isPending && !toolState.error,
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
</PermissionCheck>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
if (action !== "send" || conversationId) {
|
|
198
|
+
return renderToolCheck(Boolean(baseAllowed));
|
|
199
|
+
}
|
|
200
|
+
return (
|
|
201
|
+
<PermissionCheck
|
|
202
|
+
permission={aiChatPermissions.conversation.create()}
|
|
203
|
+
>
|
|
204
|
+
{(createState) =>
|
|
205
|
+
renderToolCheck(
|
|
206
|
+
Boolean(baseAllowed) &&
|
|
207
|
+
createState.can &&
|
|
208
|
+
!createState.isPending &&
|
|
209
|
+
!createState.error,
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
</PermissionCheck>
|
|
213
|
+
);
|
|
214
|
+
}}
|
|
215
|
+
</PermissionCheck>
|
|
216
|
+
)}
|
|
217
|
+
</PermissionCheck>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function PermissionedChatMessage({
|
|
222
|
+
publicMode,
|
|
223
|
+
action,
|
|
224
|
+
conversationId,
|
|
225
|
+
ownerId,
|
|
226
|
+
messageId,
|
|
227
|
+
...messageProps
|
|
228
|
+
}: React.ComponentProps<typeof ChatMessage> & {
|
|
229
|
+
publicMode: boolean;
|
|
230
|
+
action?: "edit" | "retry";
|
|
231
|
+
conversationId?: string;
|
|
232
|
+
ownerId?: string;
|
|
233
|
+
messageId?: string;
|
|
234
|
+
}) {
|
|
235
|
+
if (!action) return <ChatMessage {...messageProps} />;
|
|
236
|
+
return (
|
|
237
|
+
<ChatActionCheck
|
|
238
|
+
publicMode={publicMode}
|
|
239
|
+
action={action}
|
|
240
|
+
conversationId={conversationId}
|
|
241
|
+
ownerId={ownerId}
|
|
242
|
+
messageId={messageId}
|
|
243
|
+
>
|
|
244
|
+
{(allowed) => (
|
|
245
|
+
<ChatMessage
|
|
246
|
+
{...messageProps}
|
|
247
|
+
onRetry={allowed ? messageProps.onRetry : undefined}
|
|
248
|
+
onEdit={allowed ? messageProps.onEdit : undefined}
|
|
249
|
+
/>
|
|
250
|
+
)}
|
|
251
|
+
</ChatActionCheck>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
45
255
|
export function ChatInterface({
|
|
46
|
-
apiPath = "/api/chat",
|
|
47
256
|
initialMessages,
|
|
48
257
|
id,
|
|
49
258
|
variant = "full",
|
|
@@ -52,26 +261,47 @@ export function ChatInterface({
|
|
|
52
261
|
}: ChatInterfaceProps) {
|
|
53
262
|
const {
|
|
54
263
|
localization: customLocalization,
|
|
55
|
-
headers,
|
|
56
|
-
mode,
|
|
57
264
|
showAttribution,
|
|
58
265
|
chatSuggestions,
|
|
59
266
|
} = usePluginOverrides<AiChatPluginOverrides, Partial<AiChatPluginOverrides>>(
|
|
60
|
-
"
|
|
267
|
+
"aiChat",
|
|
61
268
|
{ showAttribution: true },
|
|
62
269
|
);
|
|
63
|
-
const {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
270
|
+
const {
|
|
271
|
+
api,
|
|
272
|
+
basePath: stackBasePath,
|
|
273
|
+
plugins,
|
|
274
|
+
queryClient: stackQueryClient,
|
|
275
|
+
} = useStack();
|
|
276
|
+
const aiChatApi = plugins?.aiChat?.api;
|
|
277
|
+
const apiBaseURL = aiChatApi?.baseURL ?? api?.baseURL;
|
|
278
|
+
const apiBasePath = aiChatApi?.basePath ?? api?.basePath;
|
|
279
|
+
const browserHeaders = aiChatApi?.browserHeaders;
|
|
280
|
+
const credentials = aiChatApi?.credentials;
|
|
281
|
+
const resolvedApiPath = resolveAiChatApiUrl(apiBaseURL, apiBasePath);
|
|
282
|
+
const mode = resolveAiChatMode(plugins?.aiChat?.config);
|
|
283
|
+
const siteBaseURL = plugins?.aiChat?.site.baseURL;
|
|
284
|
+
const siteBasePath = plugins?.aiChat?.site.basePath ?? stackBasePath;
|
|
68
285
|
const isPublicMode = mode === "public";
|
|
69
286
|
|
|
70
287
|
// Read page AI context registered by the current page
|
|
71
288
|
const pageAIContext = usePageAIContext();
|
|
72
289
|
|
|
73
290
|
const tr = useAiChatTranslation(customLocalization);
|
|
74
|
-
const queryClient = useQueryClient();
|
|
291
|
+
const queryClient = useQueryClient(stackQueryClient);
|
|
292
|
+
const identityPartition = useAiChatIdentityPartition();
|
|
293
|
+
const chatInstanceId = useId();
|
|
294
|
+
const identityPartitionKey = hashKey([aiChatIdentityKey(identityPartition)]);
|
|
295
|
+
const latestIdentityPartitionKey = useRef(identityPartitionKey);
|
|
296
|
+
const identitySessionGeneration = useRef(0);
|
|
297
|
+
const [identitySessionVersion, setIdentitySessionVersion] = useState(0);
|
|
298
|
+
const activeStreamPartitionKey = useRef<string | undefined>(undefined);
|
|
299
|
+
const nextStreamRequestGeneration = useRef(0);
|
|
300
|
+
const latestStreamRequestGeneration = useRef(0);
|
|
301
|
+
const pendingStreamRequests = useRef<
|
|
302
|
+
Array<{ generation: number; identityPartitionKey: string }>
|
|
303
|
+
>([]);
|
|
304
|
+
const latestMessages = useRef<UIMessage[]>([]);
|
|
75
305
|
|
|
76
306
|
const conversationsListQueryKey = useMemo(() => {
|
|
77
307
|
// In public mode, we don't need conversation queries
|
|
@@ -79,24 +309,27 @@ export function ChatInterface({
|
|
|
79
309
|
const client = createApiClient<AiChatApiRouter>({
|
|
80
310
|
baseURL: apiBaseURL,
|
|
81
311
|
basePath: apiBasePath,
|
|
312
|
+
credentials,
|
|
82
313
|
});
|
|
83
|
-
const queries = createAiChatQueryKeys(client,
|
|
84
|
-
return queries.conversations.list().queryKey;
|
|
85
|
-
}, [
|
|
314
|
+
const queries = createAiChatQueryKeys(client, browserHeaders);
|
|
315
|
+
return queries.conversations.list(identityPartition).queryKey;
|
|
316
|
+
}, [
|
|
317
|
+
apiBaseURL,
|
|
318
|
+
apiBasePath,
|
|
319
|
+
browserHeaders,
|
|
320
|
+
credentials,
|
|
321
|
+
identityPartition,
|
|
322
|
+
isPublicMode,
|
|
323
|
+
]);
|
|
324
|
+
const latestIdentityPartition = useRef(identityPartition);
|
|
325
|
+
const latestConversationsListQueryKey = useRef(conversationsListQueryKey);
|
|
326
|
+
const latestHeaders = useRef(browserHeaders);
|
|
86
327
|
|
|
87
328
|
// Track the current conversation ID - initialized from prop, updated after first message
|
|
88
329
|
// In public mode, we don't track conversation IDs
|
|
89
330
|
const [currentConversationId, setCurrentConversationId] = useState<
|
|
90
331
|
string | undefined
|
|
91
332
|
>(isPublicMode ? undefined : id);
|
|
92
|
-
const { can: canPersistConversation, isPending: isPermissionPending } =
|
|
93
|
-
useCan({
|
|
94
|
-
resource: "ai-chat:conversation",
|
|
95
|
-
action: currentConversationId ? "update" : "create",
|
|
96
|
-
params: currentConversationId ? { id: currentConversationId } : undefined,
|
|
97
|
-
});
|
|
98
|
-
const canWrite =
|
|
99
|
-
isPublicMode || (!isPermissionPending && canPersistConversation);
|
|
100
333
|
// Track if we've sent the first message on a new chat (to trigger navigation)
|
|
101
334
|
const isFirstMessageSentRef = useRef(false);
|
|
102
335
|
const hasNavigatedRef = useRef(false);
|
|
@@ -120,6 +353,14 @@ export function ChatInterface({
|
|
|
120
353
|
|
|
121
354
|
// Fetch conversations list for navigation after first message (authenticated mode only)
|
|
122
355
|
const { conversations } = useConversations({ enabled: !isPublicMode });
|
|
356
|
+
const currentConversationOwnerId =
|
|
357
|
+
conversation?.userId ??
|
|
358
|
+
conversations.find((item) => item.id === currentConversationId)?.userId ??
|
|
359
|
+
(!isPublicMode &&
|
|
360
|
+
currentConversationId &&
|
|
361
|
+
typeof identityPartition === "object"
|
|
362
|
+
? identityPartition.id
|
|
363
|
+
: undefined);
|
|
123
364
|
|
|
124
365
|
// Use a ref to track the conversation ID for the transport body
|
|
125
366
|
// This ensures the transport always uses the latest value
|
|
@@ -147,6 +388,20 @@ export function ChatInterface({
|
|
|
147
388
|
// Start as initialized if there are no initialMessages to load
|
|
148
389
|
!initialMessages || initialMessages.length === 0,
|
|
149
390
|
);
|
|
391
|
+
const [input, setInput] = useState("");
|
|
392
|
+
const [attachedFiles, setAttachedFiles] = useState<AttachedFile[]>([]);
|
|
393
|
+
const [pendingEdit, setPendingEdit] = useState<{
|
|
394
|
+
text: string;
|
|
395
|
+
expectedLength: number;
|
|
396
|
+
identityPartitionKey: string;
|
|
397
|
+
streamRequestGeneration: number;
|
|
398
|
+
} | null>(null);
|
|
399
|
+
const [historySyncError, setHistorySyncError] = useState<Error | null>(null);
|
|
400
|
+
const [isHistorySyncRetrying, setIsHistorySyncRetrying] = useState(false);
|
|
401
|
+
useEffect(() => {
|
|
402
|
+
setHistorySyncError(null);
|
|
403
|
+
setIsHistorySyncRetrying(false);
|
|
404
|
+
}, [id, isPublicMode]);
|
|
150
405
|
|
|
151
406
|
// Ref to always have the latest pageAIContext in the transport callback
|
|
152
407
|
// without recreating the transport on every context change
|
|
@@ -156,58 +411,87 @@ export function ChatInterface({
|
|
|
156
411
|
}, [pageAIContext]);
|
|
157
412
|
|
|
158
413
|
// Memoize the transport to prevent recreation on every render
|
|
159
|
-
const transport = useMemo(
|
|
160
|
-
(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
414
|
+
const transport = useMemo(() => {
|
|
415
|
+
const trackedFetch = Object.assign(
|
|
416
|
+
async (
|
|
417
|
+
request: Parameters<typeof globalThis.fetch>[0],
|
|
418
|
+
init?: Parameters<typeof globalThis.fetch>[1],
|
|
419
|
+
) => {
|
|
420
|
+
const requestIdentityPartitionKey = latestIdentityPartitionKey.current;
|
|
421
|
+
const requestGeneration = latestStreamRequestGeneration.current;
|
|
422
|
+
const response = await globalThis.fetch(request, init);
|
|
423
|
+
if (
|
|
424
|
+
!isPublicMode &&
|
|
425
|
+
requestIdentityPartitionKey === latestIdentityPartitionKey.current &&
|
|
426
|
+
requestGeneration === latestStreamRequestGeneration.current
|
|
427
|
+
) {
|
|
428
|
+
const conversationId = response.headers.get("x-conversation-id");
|
|
429
|
+
if (conversationId) conversationIdRef.current = conversationId;
|
|
430
|
+
}
|
|
431
|
+
return response;
|
|
432
|
+
},
|
|
433
|
+
globalThis.fetch,
|
|
434
|
+
) as typeof globalThis.fetch;
|
|
435
|
+
return new DefaultChatTransport({
|
|
436
|
+
api: resolvedApiPath,
|
|
437
|
+
headers: browserHeaders,
|
|
438
|
+
credentials,
|
|
439
|
+
fetch: trackedFetch,
|
|
440
|
+
// In public mode, don't send conversationId
|
|
441
|
+
body: isPublicMode
|
|
442
|
+
? undefined
|
|
443
|
+
: () => ({ conversationId: conversationIdRef.current }),
|
|
444
|
+
// Handle edit operations and inject page context
|
|
445
|
+
prepareSendMessagesRequest: ({ messages: hookMessages }) => {
|
|
446
|
+
if (!isPublicMode) {
|
|
447
|
+
const generation = ++nextStreamRequestGeneration.current;
|
|
448
|
+
latestStreamRequestGeneration.current = generation;
|
|
449
|
+
const request = {
|
|
450
|
+
generation,
|
|
451
|
+
identityPartitionKey: latestIdentityPartitionKey.current,
|
|
452
|
+
};
|
|
453
|
+
pendingStreamRequests.current.push(request);
|
|
454
|
+
activeStreamPartitionKey.current = request.identityPartitionKey;
|
|
455
|
+
}
|
|
456
|
+
const currentPageContext = pageAIContextRef.current;
|
|
457
|
+
|
|
458
|
+
// Build page context fields to include in every request
|
|
459
|
+
const pageContextBody = currentPageContext?.pageDescription
|
|
460
|
+
? {
|
|
461
|
+
pageContext: currentPageContext.pageDescription,
|
|
462
|
+
availableTools: Object.keys(currentPageContext.clientTools ?? {}),
|
|
463
|
+
routeName: currentPageContext.routeName,
|
|
188
464
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
};
|
|
465
|
+
: {};
|
|
466
|
+
|
|
467
|
+
// If we're in an edit operation, use the truncated messages + new user message
|
|
468
|
+
if (editMessagesRef.current !== null) {
|
|
469
|
+
const newUserMessage = hookMessages[hookMessages.length - 1];
|
|
470
|
+
const messagesToSend = [...editMessagesRef.current];
|
|
471
|
+
if (newUserMessage) {
|
|
472
|
+
messagesToSend.push(newUserMessage);
|
|
198
473
|
}
|
|
199
|
-
//
|
|
474
|
+
// Clear the ref after use
|
|
475
|
+
editMessagesRef.current = null;
|
|
200
476
|
return {
|
|
201
477
|
body: {
|
|
202
|
-
messages:
|
|
478
|
+
messages: messagesToSend,
|
|
203
479
|
conversationId: conversationIdRef.current,
|
|
204
480
|
...pageContextBody,
|
|
205
481
|
},
|
|
206
482
|
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
483
|
+
}
|
|
484
|
+
// Normal case - use the messages as-is
|
|
485
|
+
return {
|
|
486
|
+
body: {
|
|
487
|
+
messages: hookMessages,
|
|
488
|
+
conversationId: conversationIdRef.current,
|
|
489
|
+
...pageContextBody,
|
|
490
|
+
},
|
|
491
|
+
};
|
|
492
|
+
},
|
|
493
|
+
});
|
|
494
|
+
}, [browserHeaders, credentials, isPublicMode, resolvedApiPath]);
|
|
211
495
|
|
|
212
496
|
// Use a ref so addToolOutput is always current inside the onToolCall closure
|
|
213
497
|
const addToolOutputRef = useRef<
|
|
@@ -222,11 +506,38 @@ export function ChatInterface({
|
|
|
222
506
|
setMessages,
|
|
223
507
|
regenerate,
|
|
224
508
|
addToolOutput,
|
|
509
|
+
stop,
|
|
225
510
|
} = useChat({
|
|
511
|
+
id: `${chatInstanceId}:${isPublicMode ? "public" : identitySessionVersion}`,
|
|
226
512
|
transport,
|
|
227
513
|
// Automatically resubmit after all client-side tool results are provided
|
|
228
|
-
sendAutomaticallyWhen:
|
|
514
|
+
sendAutomaticallyWhen: (options) =>
|
|
515
|
+
(isPublicMode ||
|
|
516
|
+
identitySessionVersion === identitySessionGeneration.current) &&
|
|
517
|
+
lastAssistantMessageIsCompleteWithToolCalls(options),
|
|
229
518
|
onToolCall: async ({ toolCall }) => {
|
|
519
|
+
const toolRequest = pendingStreamRequests.current.at(-1);
|
|
520
|
+
if (
|
|
521
|
+
!isPublicMode &&
|
|
522
|
+
(identitySessionVersion !== identitySessionGeneration.current ||
|
|
523
|
+
!toolRequest ||
|
|
524
|
+
toolRequest.identityPartitionKey !==
|
|
525
|
+
latestIdentityPartitionKey.current ||
|
|
526
|
+
toolRequest.generation !== latestStreamRequestGeneration.current ||
|
|
527
|
+
activeStreamPartitionKey.current !== toolRequest.identityPartitionKey)
|
|
528
|
+
) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
const toolIdentityPartitionKey =
|
|
532
|
+
toolRequest?.identityPartitionKey ?? latestIdentityPartitionKey.current;
|
|
533
|
+
const toolStreamRequestGeneration =
|
|
534
|
+
toolRequest?.generation ?? latestStreamRequestGeneration.current;
|
|
535
|
+
const toolRequestIsCurrent = () =>
|
|
536
|
+
isPublicMode ||
|
|
537
|
+
(identitySessionVersion === identitySessionGeneration.current &&
|
|
538
|
+
toolIdentityPartitionKey === latestIdentityPartitionKey.current &&
|
|
539
|
+
toolStreamRequestGeneration ===
|
|
540
|
+
latestStreamRequestGeneration.current);
|
|
230
541
|
// Dispatch client-side tool calls to the handler registered by the current page.
|
|
231
542
|
// In AI SDK v5, onToolCall returns void — addToolOutput must be called explicitly.
|
|
232
543
|
const toolName = toolCall.toolName;
|
|
@@ -234,6 +545,7 @@ export function ChatInterface({
|
|
|
234
545
|
if (handler) {
|
|
235
546
|
try {
|
|
236
547
|
const result = await handler(toolCall.input);
|
|
548
|
+
if (!toolRequestIsCurrent()) return;
|
|
237
549
|
// No await — avoids potential deadlocks with sendAutomaticallyWhen
|
|
238
550
|
addToolOutputRef.current?.({
|
|
239
551
|
tool: toolName,
|
|
@@ -241,6 +553,7 @@ export function ChatInterface({
|
|
|
241
553
|
output: result,
|
|
242
554
|
});
|
|
243
555
|
} catch (err) {
|
|
556
|
+
if (!toolRequestIsCurrent()) return;
|
|
244
557
|
addToolOutputRef.current?.({
|
|
245
558
|
tool: toolName,
|
|
246
559
|
toolCallId: toolCall.toolCallId,
|
|
@@ -275,58 +588,289 @@ export function ChatInterface({
|
|
|
275
588
|
},
|
|
276
589
|
onError: (err) => {
|
|
277
590
|
console.error("useChat onError:", err);
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
591
|
+
if (
|
|
592
|
+
!isPublicMode &&
|
|
593
|
+
identitySessionVersion !== identitySessionGeneration.current
|
|
594
|
+
) {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
const failedRequest = pendingStreamRequests.current[0];
|
|
598
|
+
const failedPartitionKey =
|
|
599
|
+
failedRequest?.identityPartitionKey ?? activeStreamPartitionKey.current;
|
|
600
|
+
if (
|
|
601
|
+
!isPublicMode &&
|
|
602
|
+
failedPartitionKey !== latestIdentityPartitionKey.current
|
|
603
|
+
) {
|
|
604
|
+
return;
|
|
283
605
|
}
|
|
606
|
+
// AI SDK invokes onFinish after onError. Keep this request queued so
|
|
607
|
+
// onFinish can reconcile a user message that the backend persisted before
|
|
608
|
+
// the provider or response stream failed.
|
|
284
609
|
},
|
|
285
610
|
onFinish: async () => {
|
|
286
611
|
// In public mode, skip all persistence-related operations
|
|
287
|
-
if (isPublicMode)
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
612
|
+
if (isPublicMode) {
|
|
613
|
+
activeStreamPartitionKey.current = undefined;
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
if (identitySessionVersion !== identitySessionGeneration.current) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
const finishedRequest = pendingStreamRequests.current.shift();
|
|
620
|
+
const finishingPartitionKey =
|
|
621
|
+
finishedRequest?.identityPartitionKey ??
|
|
622
|
+
activeStreamPartitionKey.current;
|
|
623
|
+
if (finishingPartitionKey !== latestIdentityPartitionKey.current) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
if (
|
|
627
|
+
!finishedRequest ||
|
|
628
|
+
finishedRequest.generation === latestStreamRequestGeneration.current
|
|
629
|
+
) {
|
|
630
|
+
activeStreamPartitionKey.current = undefined;
|
|
631
|
+
}
|
|
632
|
+
const identityIsCurrent = () =>
|
|
633
|
+
finishingPartitionKey === latestIdentityPartitionKey.current &&
|
|
634
|
+
(!finishedRequest ||
|
|
635
|
+
finishedRequest.generation === latestStreamRequestGeneration.current);
|
|
636
|
+
const finishingIdentityPartition = latestIdentityPartition.current;
|
|
637
|
+
const finishingConversationsListQueryKey =
|
|
638
|
+
latestConversationsListQueryKey.current;
|
|
639
|
+
const finishingHeaders = latestHeaders.current;
|
|
293
640
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
// Wait for the invalidation to complete and refetch conversations
|
|
299
|
-
await queryClient.refetchQueries({
|
|
300
|
-
queryKey: conversationsListQueryKey,
|
|
641
|
+
try {
|
|
642
|
+
// Invalidate conversation list to show new/updated conversations
|
|
643
|
+
await queryClient.invalidateQueries({
|
|
644
|
+
queryKey: finishingConversationsListQueryKey,
|
|
301
645
|
});
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
conversationIdRef.current = newConversation.id;
|
|
646
|
+
if (!identityIsCurrent()) return;
|
|
647
|
+
|
|
648
|
+
// If this was the first message on a new chat, update the URL without full navigation
|
|
649
|
+
// This avoids losing the in-memory messages during component remount
|
|
650
|
+
if (isFirstMessageSentRef.current && !hasNavigatedRef.current) {
|
|
651
|
+
const discoveredConversationId = conversationIdRef.current;
|
|
652
|
+
if (discoveredConversationId) {
|
|
653
|
+
hasNavigatedRef.current = true;
|
|
654
|
+
setCurrentConversationId(discoveredConversationId);
|
|
655
|
+
conversationIdRef.current = discoveredConversationId;
|
|
313
656
|
// Only update the URL in full-page mode; in widget mode the chat is
|
|
314
657
|
// embedded in another page and clobbering the URL is disruptive.
|
|
315
658
|
if (variant === "full") {
|
|
316
|
-
const
|
|
659
|
+
const newLocation = resolveAiChatSiteLocation(
|
|
660
|
+
{ baseURL: siteBaseURL, basePath: siteBasePath },
|
|
661
|
+
typeof window === "undefined"
|
|
662
|
+
? undefined
|
|
663
|
+
: window.location.origin,
|
|
664
|
+
"chat",
|
|
665
|
+
discoveredConversationId,
|
|
666
|
+
);
|
|
317
667
|
if (typeof window !== "undefined") {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
668
|
+
if (newLocation.crossOrigin) {
|
|
669
|
+
navigateAiChatCrossOrigin(newLocation.href, {
|
|
670
|
+
replace: true,
|
|
671
|
+
});
|
|
672
|
+
} else {
|
|
673
|
+
window.history.replaceState(
|
|
674
|
+
{ ...window.history.state },
|
|
675
|
+
"",
|
|
676
|
+
newLocation.path,
|
|
677
|
+
);
|
|
678
|
+
}
|
|
323
679
|
}
|
|
324
680
|
}
|
|
325
681
|
}
|
|
326
682
|
}
|
|
683
|
+
|
|
684
|
+
const persistedConversationId = conversationIdRef.current;
|
|
685
|
+
if (!persistedConversationId || !identityIsCurrent()) {
|
|
686
|
+
if (isFirstMessageSentRef.current) {
|
|
687
|
+
isFirstMessageSentRef.current = false;
|
|
688
|
+
hasNavigatedRef.current = false;
|
|
689
|
+
throw new Error(
|
|
690
|
+
"The persisted conversation id could not be discovered.",
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
const client = createApiClient<AiChatApiRouter>({
|
|
696
|
+
baseURL: apiBaseURL,
|
|
697
|
+
basePath: apiBasePath,
|
|
698
|
+
credentials,
|
|
699
|
+
});
|
|
700
|
+
const detailQuery = createAiChatQueryKeys(
|
|
701
|
+
client,
|
|
702
|
+
finishingHeaders,
|
|
703
|
+
).conversations.detail(
|
|
704
|
+
persistedConversationId,
|
|
705
|
+
finishingIdentityPartition,
|
|
706
|
+
);
|
|
707
|
+
await queryClient.cancelQueries({
|
|
708
|
+
queryKey: detailQuery.queryKey,
|
|
709
|
+
exact: true,
|
|
710
|
+
});
|
|
711
|
+
if (!identityIsCurrent()) return;
|
|
712
|
+
queryClient.removeQueries({
|
|
713
|
+
queryKey: detailQuery.queryKey,
|
|
714
|
+
exact: true,
|
|
715
|
+
});
|
|
716
|
+
const persistedConversation = await queryClient.fetchQuery({
|
|
717
|
+
...detailQuery,
|
|
718
|
+
staleTime: 0,
|
|
719
|
+
});
|
|
720
|
+
if (!identityIsCurrent() || !persistedConversation) return;
|
|
721
|
+
const reconciled = reconcilePersistedMessageIds(
|
|
722
|
+
latestMessages.current,
|
|
723
|
+
persistedConversation.messages,
|
|
724
|
+
);
|
|
725
|
+
if (!reconciled) {
|
|
726
|
+
throw new Error(
|
|
727
|
+
"Persisted chat history did not match the streamed transcript.",
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
setMessages(reconciled);
|
|
731
|
+
setHistorySyncError(null);
|
|
732
|
+
} catch (error) {
|
|
733
|
+
if (!identityIsCurrent()) return;
|
|
734
|
+
const syncError =
|
|
735
|
+
error instanceof Error ? error : new Error(String(error));
|
|
736
|
+
console.error("Failed to reconcile persisted chat history:", syncError);
|
|
737
|
+
setHistorySyncError(syncError);
|
|
738
|
+
setMessages([]);
|
|
327
739
|
}
|
|
328
740
|
},
|
|
329
741
|
});
|
|
742
|
+
const handleHistorySyncRetry = useCallback(async () => {
|
|
743
|
+
if (isPublicMode || isHistorySyncRetrying) return;
|
|
744
|
+
const retryConversationId = conversationIdRef.current;
|
|
745
|
+
if (!retryConversationId) {
|
|
746
|
+
setHistorySyncError(null);
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
const retryPartitionKey = latestIdentityPartitionKey.current;
|
|
751
|
+
const retrySessionGeneration = identitySessionGeneration.current;
|
|
752
|
+
const retryIsCurrent = () =>
|
|
753
|
+
retryPartitionKey === latestIdentityPartitionKey.current &&
|
|
754
|
+
retrySessionGeneration === identitySessionGeneration.current &&
|
|
755
|
+
retryConversationId === conversationIdRef.current;
|
|
756
|
+
setIsHistorySyncRetrying(true);
|
|
757
|
+
try {
|
|
758
|
+
const client = createApiClient<AiChatApiRouter>({
|
|
759
|
+
baseURL: apiBaseURL,
|
|
760
|
+
basePath: apiBasePath,
|
|
761
|
+
credentials,
|
|
762
|
+
});
|
|
763
|
+
const detailQuery = createAiChatQueryKeys(
|
|
764
|
+
client,
|
|
765
|
+
latestHeaders.current,
|
|
766
|
+
).conversations.detail(
|
|
767
|
+
retryConversationId,
|
|
768
|
+
latestIdentityPartition.current,
|
|
769
|
+
);
|
|
770
|
+
await queryClient.cancelQueries({
|
|
771
|
+
queryKey: detailQuery.queryKey,
|
|
772
|
+
exact: true,
|
|
773
|
+
});
|
|
774
|
+
if (!retryIsCurrent()) return;
|
|
775
|
+
queryClient.removeQueries({
|
|
776
|
+
queryKey: detailQuery.queryKey,
|
|
777
|
+
exact: true,
|
|
778
|
+
});
|
|
779
|
+
const persistedConversation = await queryClient.fetchQuery({
|
|
780
|
+
...detailQuery,
|
|
781
|
+
staleTime: 0,
|
|
782
|
+
});
|
|
783
|
+
if (!retryIsCurrent() || !persistedConversation) return;
|
|
784
|
+
if (isFirstMessageSentRef.current && !hasNavigatedRef.current) {
|
|
785
|
+
hasNavigatedRef.current = true;
|
|
786
|
+
setCurrentConversationId(retryConversationId);
|
|
787
|
+
if (variant === "full" && typeof window !== "undefined") {
|
|
788
|
+
const newLocation = resolveAiChatSiteLocation(
|
|
789
|
+
{ baseURL: siteBaseURL, basePath: siteBasePath },
|
|
790
|
+
window.location.origin,
|
|
791
|
+
"chat",
|
|
792
|
+
retryConversationId,
|
|
793
|
+
);
|
|
794
|
+
if (newLocation.crossOrigin) {
|
|
795
|
+
navigateAiChatCrossOrigin(newLocation.href, { replace: true });
|
|
796
|
+
} else {
|
|
797
|
+
window.history.replaceState(
|
|
798
|
+
{ ...window.history.state },
|
|
799
|
+
"",
|
|
800
|
+
newLocation.path,
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
setMessages(
|
|
806
|
+
persistedMessagesToUiMessages(persistedConversation.messages),
|
|
807
|
+
);
|
|
808
|
+
setHistorySyncError(null);
|
|
809
|
+
} catch (error) {
|
|
810
|
+
if (!retryIsCurrent()) return;
|
|
811
|
+
const syncError =
|
|
812
|
+
error instanceof Error ? error : new Error(String(error));
|
|
813
|
+
console.error("Failed to reload persisted chat history:", syncError);
|
|
814
|
+
setHistorySyncError(syncError);
|
|
815
|
+
} finally {
|
|
816
|
+
if (retryIsCurrent()) setIsHistorySyncRetrying(false);
|
|
817
|
+
}
|
|
818
|
+
}, [
|
|
819
|
+
apiBasePath,
|
|
820
|
+
apiBaseURL,
|
|
821
|
+
credentials,
|
|
822
|
+
isHistorySyncRetrying,
|
|
823
|
+
isPublicMode,
|
|
824
|
+
queryClient,
|
|
825
|
+
setMessages,
|
|
826
|
+
siteBasePath,
|
|
827
|
+
siteBaseURL,
|
|
828
|
+
variant,
|
|
829
|
+
]);
|
|
830
|
+
useLayoutEffect(() => {
|
|
831
|
+
latestMessages.current = messages;
|
|
832
|
+
}, [messages]);
|
|
833
|
+
|
|
834
|
+
const previousIdentityPartition = useRef(identityPartitionKey);
|
|
835
|
+
useLayoutEffect(() => {
|
|
836
|
+
const nextPartition = identityPartitionKey;
|
|
837
|
+
latestIdentityPartitionKey.current = nextPartition;
|
|
838
|
+
latestIdentityPartition.current = identityPartition;
|
|
839
|
+
latestConversationsListQueryKey.current = conversationsListQueryKey;
|
|
840
|
+
latestHeaders.current = browserHeaders;
|
|
841
|
+
if (isPublicMode) return;
|
|
842
|
+
if (previousIdentityPartition.current === nextPartition) return;
|
|
843
|
+
previousIdentityPartition.current = nextPartition;
|
|
844
|
+
activeStreamPartitionKey.current = undefined;
|
|
845
|
+
pendingStreamRequests.current = [];
|
|
846
|
+
identitySessionGeneration.current += 1;
|
|
847
|
+
setIdentitySessionVersion(identitySessionGeneration.current);
|
|
848
|
+
latestStreamRequestGeneration.current =
|
|
849
|
+
++nextStreamRequestGeneration.current;
|
|
850
|
+
void stop();
|
|
851
|
+
setMessages([]);
|
|
852
|
+
setInput("");
|
|
853
|
+
setAttachedFiles([]);
|
|
854
|
+
setPendingEdit(null);
|
|
855
|
+
setHistorySyncError(null);
|
|
856
|
+
setIsHistorySyncRetrying(false);
|
|
857
|
+
editMessagesRef.current = null;
|
|
858
|
+
isEditInProgressRef.current = false;
|
|
859
|
+
setIsMessagesInitialized(true);
|
|
860
|
+
setCurrentConversationId(id);
|
|
861
|
+
conversationIdRef.current = id;
|
|
862
|
+
isFirstMessageSentRef.current = false;
|
|
863
|
+
hasNavigatedRef.current = false;
|
|
864
|
+
}, [
|
|
865
|
+
conversationsListQueryKey,
|
|
866
|
+
browserHeaders,
|
|
867
|
+
id,
|
|
868
|
+
identityPartition,
|
|
869
|
+
identityPartitionKey,
|
|
870
|
+
isPublicMode,
|
|
871
|
+
setMessages,
|
|
872
|
+
stop,
|
|
873
|
+
]);
|
|
330
874
|
|
|
331
875
|
// Keep addToolOutputRef in sync so onToolCall always has the latest reference
|
|
332
876
|
useEffect(() => {
|
|
@@ -344,37 +888,14 @@ export function ChatInterface({
|
|
|
344
888
|
conversation.messages.length > 0 &&
|
|
345
889
|
messages.length === 0
|
|
346
890
|
) {
|
|
347
|
-
|
|
348
|
-
const uiMessages: UIMessage[] = conversation.messages
|
|
349
|
-
.filter((m) => m.role !== "data")
|
|
350
|
-
.map((m) => {
|
|
351
|
-
// Try to parse content as JSON parts (new format with images)
|
|
352
|
-
let parts: UIMessage["parts"];
|
|
353
|
-
try {
|
|
354
|
-
const parsed = JSON.parse(m.content);
|
|
355
|
-
if (Array.isArray(parsed)) {
|
|
356
|
-
parts = parsed;
|
|
357
|
-
} else {
|
|
358
|
-
// Fallback: wrap as text
|
|
359
|
-
parts = [{ type: "text" as const, text: m.content }];
|
|
360
|
-
}
|
|
361
|
-
} catch {
|
|
362
|
-
// Not JSON - legacy format, wrap as text
|
|
363
|
-
parts = [{ type: "text" as const, text: m.content }];
|
|
364
|
-
}
|
|
365
|
-
return {
|
|
366
|
-
id: m.id,
|
|
367
|
-
role: m.role as "user" | "assistant" | "system",
|
|
368
|
-
parts,
|
|
369
|
-
};
|
|
370
|
-
});
|
|
371
|
-
setMessages(uiMessages);
|
|
891
|
+
setMessages(persistedMessagesToUiMessages(conversation.messages));
|
|
372
892
|
}
|
|
373
893
|
}, [conversation, messages.length, setMessages]);
|
|
374
894
|
|
|
375
895
|
// Set initial messages on mount (for SSR hydration)
|
|
376
896
|
useEffect(() => {
|
|
377
897
|
if (
|
|
898
|
+
!isMessagesInitialized &&
|
|
378
899
|
initialMessages &&
|
|
379
900
|
initialMessages.length > 0 &&
|
|
380
901
|
messages.length === 0
|
|
@@ -383,10 +904,8 @@ export function ChatInterface({
|
|
|
383
904
|
// Mark as initialized - this is batched with setMessages so both take effect in the same render
|
|
384
905
|
setIsMessagesInitialized(true);
|
|
385
906
|
}
|
|
386
|
-
}, [initialMessages, setMessages, messages.length]);
|
|
907
|
+
}, [initialMessages, isMessagesInitialized, setMessages, messages.length]);
|
|
387
908
|
|
|
388
|
-
const [input, setInput] = useState("");
|
|
389
|
-
const [attachedFiles, setAttachedFiles] = useState<AttachedFile[]>([]);
|
|
390
909
|
const scrollRef = useRef<HTMLDivElement>(null);
|
|
391
910
|
|
|
392
911
|
// Track whether the user has manually scrolled away from the bottom.
|
|
@@ -453,7 +972,6 @@ export function ChatInterface({
|
|
|
453
972
|
files?: AttachedFile[],
|
|
454
973
|
) => {
|
|
455
974
|
e.preventDefault();
|
|
456
|
-
if (!canWrite) return;
|
|
457
975
|
const text = input.trim();
|
|
458
976
|
// Allow submit if there's text OR files
|
|
459
977
|
if (!text && (!files || files.length === 0)) return;
|
|
@@ -474,6 +992,8 @@ export function ChatInterface({
|
|
|
474
992
|
// Save current values before clearing - we'll restore them if send fails
|
|
475
993
|
const savedInput = input;
|
|
476
994
|
const savedFiles = files ? [...files] : [];
|
|
995
|
+
const sendIdentityPartitionKey = latestIdentityPartitionKey.current;
|
|
996
|
+
const sendIdentitySessionGeneration = identitySessionGeneration.current;
|
|
477
997
|
|
|
478
998
|
// Capture the message count before sending so we can restore to this
|
|
479
999
|
// exact point on failure. The SDK may append both a user message and a
|
|
@@ -485,8 +1005,10 @@ export function ChatInterface({
|
|
|
485
1005
|
// so we need to clear the input before the message appears to avoid duplicate text
|
|
486
1006
|
setInput("");
|
|
487
1007
|
setAttachedFiles([]);
|
|
1008
|
+
setHistorySyncError(null);
|
|
488
1009
|
|
|
489
1010
|
try {
|
|
1011
|
+
activeStreamPartitionKey.current = latestIdentityPartitionKey.current;
|
|
490
1012
|
// Use AI SDK's file attachment format
|
|
491
1013
|
// The SDK automatically converts supported file types (images, text) to the correct format
|
|
492
1014
|
if (files && files.length > 0) {
|
|
@@ -498,14 +1020,29 @@ export function ChatInterface({
|
|
|
498
1020
|
filename: file.filename,
|
|
499
1021
|
}));
|
|
500
1022
|
|
|
501
|
-
|
|
1023
|
+
const request = sendMessage({
|
|
502
1024
|
text: text || "", // AI SDK requires text, even if empty
|
|
503
1025
|
files: fileUIParts,
|
|
504
1026
|
});
|
|
1027
|
+
await request;
|
|
505
1028
|
} else {
|
|
506
|
-
|
|
1029
|
+
const request = sendMessage({ text });
|
|
1030
|
+
await request;
|
|
507
1031
|
}
|
|
508
1032
|
} catch (error) {
|
|
1033
|
+
if (
|
|
1034
|
+
activeStreamPartitionKey.current === sendIdentityPartitionKey &&
|
|
1035
|
+
sendIdentitySessionGeneration === identitySessionGeneration.current
|
|
1036
|
+
) {
|
|
1037
|
+
activeStreamPartitionKey.current = undefined;
|
|
1038
|
+
}
|
|
1039
|
+
if (
|
|
1040
|
+
!isPublicMode &&
|
|
1041
|
+
(sendIdentityPartitionKey !== latestIdentityPartitionKey.current ||
|
|
1042
|
+
sendIdentitySessionGeneration !== identitySessionGeneration.current)
|
|
1043
|
+
) {
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
509
1046
|
// Restore input on failure so user can retry
|
|
510
1047
|
setInput(savedInput);
|
|
511
1048
|
setAttachedFiles(savedFiles);
|
|
@@ -524,23 +1061,26 @@ export function ChatInterface({
|
|
|
524
1061
|
|
|
525
1062
|
// Handler for retrying/regenerating the last AI response
|
|
526
1063
|
const handleRetry = useCallback(() => {
|
|
1064
|
+
setHistorySyncError(null);
|
|
1065
|
+
activeStreamPartitionKey.current = latestIdentityPartitionKey.current;
|
|
527
1066
|
regenerate();
|
|
528
1067
|
}, [regenerate]);
|
|
529
1068
|
|
|
530
|
-
// Pending edit state - stores the text to send after messages are truncated
|
|
531
|
-
const [pendingEdit, setPendingEdit] = useState<{
|
|
532
|
-
text: string;
|
|
533
|
-
expectedLength: number;
|
|
534
|
-
} | null>(null);
|
|
535
|
-
|
|
536
1069
|
// Effect to send the edited message after React has processed the truncation
|
|
537
1070
|
useEffect(() => {
|
|
538
|
-
if (
|
|
1071
|
+
if (
|
|
1072
|
+
pendingEdit &&
|
|
1073
|
+
pendingEdit.identityPartitionKey === latestIdentityPartitionKey.current &&
|
|
1074
|
+
pendingEdit.streamRequestGeneration ===
|
|
1075
|
+
latestStreamRequestGeneration.current &&
|
|
1076
|
+
messages.length === pendingEdit.expectedLength
|
|
1077
|
+
) {
|
|
539
1078
|
const textToSend = pendingEdit.text;
|
|
540
1079
|
setPendingEdit(null);
|
|
541
1080
|
// Clear edit in progress flag - the new message will now be sent
|
|
542
1081
|
// and we want subsequent effects to work normally
|
|
543
1082
|
isEditInProgressRef.current = false;
|
|
1083
|
+
activeStreamPartitionKey.current = latestIdentityPartitionKey.current;
|
|
544
1084
|
sendMessage({ text: textToSend });
|
|
545
1085
|
}
|
|
546
1086
|
}, [messages.length, pendingEdit, sendMessage]);
|
|
@@ -548,6 +1088,7 @@ export function ChatInterface({
|
|
|
548
1088
|
// Handler for editing a user message - replaces the message and all subsequent messages
|
|
549
1089
|
const handleEditMessage = useCallback(
|
|
550
1090
|
(messageId: string, newText: string) => {
|
|
1091
|
+
setHistorySyncError(null);
|
|
551
1092
|
const messageIndex = messages.findIndex((m) => m.id === messageId);
|
|
552
1093
|
if (messageIndex === -1) return;
|
|
553
1094
|
|
|
@@ -565,7 +1106,12 @@ export function ChatInterface({
|
|
|
565
1106
|
editMessagesRef.current = truncatedMessages;
|
|
566
1107
|
|
|
567
1108
|
// Set the pending edit - the useEffect will send after truncation is processed
|
|
568
|
-
setPendingEdit({
|
|
1109
|
+
setPendingEdit({
|
|
1110
|
+
text: newText,
|
|
1111
|
+
expectedLength: messageIndex,
|
|
1112
|
+
identityPartitionKey: latestIdentityPartitionKey.current,
|
|
1113
|
+
streamRequestGeneration: latestStreamRequestGeneration.current,
|
|
1114
|
+
});
|
|
569
1115
|
|
|
570
1116
|
// Truncate the messages - React will batch this and the useEffect will fire after
|
|
571
1117
|
setMessages(truncatedMessages);
|
|
@@ -614,7 +1160,7 @@ export function ChatInterface({
|
|
|
614
1160
|
...pageSuggestions,
|
|
615
1161
|
...(chatSuggestions ?? []),
|
|
616
1162
|
];
|
|
617
|
-
return
|
|
1163
|
+
return allSuggestions.length > 0 ? (
|
|
618
1164
|
<div className="flex flex-wrap justify-center gap-2 pb-4 max-w-md mx-auto">
|
|
619
1165
|
{allSuggestions.map((suggestion, index) => (
|
|
620
1166
|
<button
|
|
@@ -632,8 +1178,27 @@ export function ChatInterface({
|
|
|
632
1178
|
</div>
|
|
633
1179
|
) : (
|
|
634
1180
|
messages.map((m, index) => (
|
|
635
|
-
<
|
|
1181
|
+
<PermissionedChatMessage
|
|
636
1182
|
key={m.id || `msg-${index}`}
|
|
1183
|
+
publicMode={isPublicMode}
|
|
1184
|
+
action={
|
|
1185
|
+
m.role === "user"
|
|
1186
|
+
? "edit"
|
|
1187
|
+
: m.role === "assistant" &&
|
|
1188
|
+
index === messages.length - 1
|
|
1189
|
+
? "retry"
|
|
1190
|
+
: undefined
|
|
1191
|
+
}
|
|
1192
|
+
conversationId={currentConversationId}
|
|
1193
|
+
ownerId={currentConversationOwnerId}
|
|
1194
|
+
messageId={
|
|
1195
|
+
m.role === "assistant"
|
|
1196
|
+
? [...messages]
|
|
1197
|
+
.slice(0, index)
|
|
1198
|
+
.reverse()
|
|
1199
|
+
.find((message) => message.role === "user")?.id
|
|
1200
|
+
: m.id
|
|
1201
|
+
}
|
|
637
1202
|
message={m}
|
|
638
1203
|
isStreaming={
|
|
639
1204
|
status === "streaming" &&
|
|
@@ -644,17 +1209,13 @@ export function ChatInterface({
|
|
|
644
1209
|
onRetry={
|
|
645
1210
|
// Only show retry on the last assistant message
|
|
646
1211
|
m.role === "assistant" && index === messages.length - 1
|
|
647
|
-
?
|
|
648
|
-
? handleRetry
|
|
649
|
-
: undefined
|
|
1212
|
+
? handleRetry
|
|
650
1213
|
: undefined
|
|
651
1214
|
}
|
|
652
1215
|
onEdit={
|
|
653
1216
|
// Allow editing user messages
|
|
654
1217
|
m.role === "user"
|
|
655
|
-
?
|
|
656
|
-
? (newText) => handleEditMessage(m.id, newText)
|
|
657
|
-
: undefined
|
|
1218
|
+
? (newText) => handleEditMessage(m.id, newText)
|
|
658
1219
|
: undefined
|
|
659
1220
|
}
|
|
660
1221
|
isRetrying={isLoading && m.role === "assistant"}
|
|
@@ -669,15 +1230,26 @@ export function ChatInterface({
|
|
|
669
1230
|
</div>
|
|
670
1231
|
</div>
|
|
671
1232
|
)}
|
|
672
|
-
{error && (
|
|
1233
|
+
{(error || historySyncError) && (
|
|
673
1234
|
<div className="flex items-center gap-2 text-destructive text-sm py-4 px-3 bg-destructive/10 rounded-md">
|
|
674
|
-
<span>
|
|
1235
|
+
<span className="flex-1">
|
|
675
1236
|
{tr(
|
|
676
1237
|
"CHAT_ERROR",
|
|
677
1238
|
"aiChat.chat.error",
|
|
678
1239
|
"Something went wrong. Please try again.",
|
|
679
1240
|
)}
|
|
680
1241
|
</span>
|
|
1242
|
+
{historySyncError && (
|
|
1243
|
+
<button
|
|
1244
|
+
type="button"
|
|
1245
|
+
data-testid="chat-history-retry"
|
|
1246
|
+
onClick={() => void handleHistorySyncRetry()}
|
|
1247
|
+
disabled={isHistorySyncRetrying}
|
|
1248
|
+
className="rounded-md border border-destructive/30 px-2.5 py-1 font-medium hover:bg-destructive/10 disabled:cursor-not-allowed disabled:opacity-50"
|
|
1249
|
+
>
|
|
1250
|
+
{tr("CHAT_RETRY", "aiChat.chat.retry", "Retry")}
|
|
1251
|
+
</button>
|
|
1252
|
+
)}
|
|
681
1253
|
</div>
|
|
682
1254
|
)}
|
|
683
1255
|
</div>
|
|
@@ -685,32 +1257,53 @@ export function ChatInterface({
|
|
|
685
1257
|
</div>
|
|
686
1258
|
</div>
|
|
687
1259
|
{/* Input Area */}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
"CHAT_PLACEHOLDER",
|
|
703
|
-
"aiChat.chat.placeholder",
|
|
704
|
-
"Type a message...",
|
|
1260
|
+
<ChatActionCheck
|
|
1261
|
+
publicMode={isPublicMode}
|
|
1262
|
+
action="send"
|
|
1263
|
+
conversationId={currentConversationId}
|
|
1264
|
+
ownerId={currentConversationOwnerId}
|
|
1265
|
+
toolNames={Object.keys(pageAIContext?.clientTools ?? {})}
|
|
1266
|
+
routeName={pageAIContext?.routeName}
|
|
1267
|
+
>
|
|
1268
|
+
{(allowed) =>
|
|
1269
|
+
allowed && !historySyncError ? (
|
|
1270
|
+
<div
|
|
1271
|
+
className={cn(
|
|
1272
|
+
"border-t bg-background p-4",
|
|
1273
|
+
isWidget ? "px-3 py-3" : "px-4",
|
|
705
1274
|
)}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
1275
|
+
>
|
|
1276
|
+
<div className={cn(!isWidget && "max-w-3xl mx-auto")}>
|
|
1277
|
+
<ChatInput
|
|
1278
|
+
key={isPublicMode ? "public" : identityPartitionKey}
|
|
1279
|
+
input={input}
|
|
1280
|
+
handleInputChange={handleInputChange}
|
|
1281
|
+
handleSubmit={handleSubmit}
|
|
1282
|
+
isLoading={isLoading}
|
|
1283
|
+
placeholder={tr(
|
|
1284
|
+
"CHAT_PLACEHOLDER",
|
|
1285
|
+
"aiChat.chat.placeholder",
|
|
1286
|
+
"Type a message...",
|
|
1287
|
+
)}
|
|
1288
|
+
variant={isWidget ? "compact" : "default"}
|
|
1289
|
+
onFilesAttached={setAttachedFiles}
|
|
1290
|
+
attachedFiles={attachedFiles}
|
|
1291
|
+
allowAttachments={!isPublicMode}
|
|
1292
|
+
attachmentPermissionFacts={{
|
|
1293
|
+
...(currentConversationId
|
|
1294
|
+
? { conversationId: currentConversationId }
|
|
1295
|
+
: {}),
|
|
1296
|
+
...(currentConversationOwnerId
|
|
1297
|
+
? { ownerId: currentConversationOwnerId }
|
|
1298
|
+
: {}),
|
|
1299
|
+
}}
|
|
1300
|
+
/>
|
|
1301
|
+
{showAttribution && <StackAttribution />}
|
|
1302
|
+
</div>
|
|
1303
|
+
</div>
|
|
1304
|
+
) : null
|
|
1305
|
+
}
|
|
1306
|
+
</ChatActionCheck>
|
|
714
1307
|
</>
|
|
715
1308
|
);
|
|
716
1309
|
}
|