@allbluecn/web-app 0.6.3 → 0.7.1
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/package.json +26 -180
- package/src/__tests__/components/reference-inline.test.tsx +1 -1
- package/src/__tests__/setup.ts +1 -1
- package/src/__tests__/tag-badge.test.tsx +1 -1
- package/src/components/agents/schemas/agent-form.ts +1 -1
- package/src/components/animated-icons/layout-panel-top.tsx +1 -1
- package/src/components/auth/auth-layout.tsx +1 -1
- package/src/components/billing/__tests__/use-resource.test.tsx +1 -1
- package/src/components/billing/checkout-redirect.ts +1 -1
- package/src/components/billing/feature-gate.tsx +1 -1
- package/src/components/billing/subscription-provider.tsx +2 -2
- package/src/components/billing/use-feature.ts +1 -1
- package/src/components/billing/use-resource.ts +1 -1
- package/src/components/changelog/changelog-page.tsx +1 -1
- package/src/components/chat/ai-chat-history/utils/group-conversations.ts +1 -1
- package/src/components/chat/ai-citations/utils.ts +1 -1
- package/src/components/command/command-palette.tsx +1 -1
- package/src/components/forms/hooks/use-form-submit.ts +1 -1
- package/src/components/forms/schemas/common.ts +1 -1
- package/src/components/knowledge/editor/doc-header.tsx +4 -4
- package/src/components/knowledge/editor/knowledge-doc-editor.tsx +1 -1
- package/src/components/knowledge-public/knowledge-card.tsx +2 -2
- package/src/components/knowledge-public/knowledge-form-dialog.tsx +1 -1
- package/src/components/knowledge-public/sharers-avatar-group.tsx +1 -1
- package/src/components/layout/sidebar-03/__tests__/nav-workspace.test.tsx +1 -1
- package/src/components/layout/sidebar-03/nav-main.tsx +1 -1
- package/src/components/layout/sidebar-03/nav-notifications.tsx +1 -1
- package/src/components/layout/sidebar-03/user-menu.tsx +2 -2
- package/src/components/magicui/animated-theme-toggler.tsx +1 -1
- package/src/components/magicui/grid-pattern.tsx +1 -1
- package/src/components/mindmap/mindmap-doc-editor.tsx +4 -4
- package/src/components/notifications/settings-notifications.tsx +2 -2
- package/src/components/notifications/team-notifications.tsx +1 -1
- package/src/components/project/invite-member-dialog.tsx +1 -1
- package/src/components/project/project-activity-list.tsx +2 -2
- package/src/components/project/project-member-manager.tsx +1 -1
- package/src/components/project/schemas/create-project.ts +1 -1
- package/src/components/prototype/block/index.ts +22 -0
- package/src/components/prototype/component/Button.tsx +49 -0
- package/src/components/prototype/component/Card.tsx +49 -0
- package/src/components/prototype/component/GenericPrototype.tsx +42 -0
- package/src/components/prototype/component/Image.tsx +51 -0
- package/src/components/prototype/component/Input.tsx +45 -0
- package/src/components/prototype/component/Text.tsx +43 -0
- package/src/components/prototype/component/index.ts +102 -0
- package/src/components/prototype/component-preview.tsx +137 -0
- package/src/components/prototype/imported/.gitkeep +0 -0
- package/src/components/prototype/imported-registry.ts +25 -0
- package/src/components/prototype/index.ts +42 -0
- package/src/components/prototype/registry.ts +40 -0
- package/src/components/prototype/template/index.ts +22 -0
- package/src/components/prototype/types.ts +96 -0
- package/src/components/prototype/utils.ts +20 -0
- package/src/components/prototype/vite-env.d.ts +6 -0
- package/src/components/settings/language-selector.tsx +1 -1
- package/src/components/settings/personal-team/account/avatar/notion-avatar.tsx +2 -2
- package/src/components/settings/personal-team/team/team-member-list.tsx +1 -1
- package/src/components/share/prd/prd-share-client.tsx +1 -1
- package/src/components/share/prd/share-annotation-overlay.tsx +1 -1
- package/src/components/share/prd/share-comment-panel.tsx +1 -1
- package/src/components/share/prd/share-comment-review-panel.tsx +1 -1
- package/src/components/share/prd/share-directory-tree.tsx +1 -1
- package/src/components/share/prd/share-doc-view.tsx +1 -1
- package/src/components/share/prd/share-layout.tsx +1 -1
- package/src/components/share/prd/share-nav-bar.tsx +1 -1
- package/src/components/share/prd/share-password-gate.tsx +1 -1
- package/src/components/share/prd/share-prototype-view.tsx +1 -1
- package/src/components/share/prd/share-review-panel.tsx +1 -1
- package/src/components/share/prd/share-sse-listener.tsx +1 -1
- package/src/components/share/prd/share-theme-toggle.tsx +1 -1
- package/src/components/share/prd/version-share-client.tsx +1 -1
- package/src/components/shared/component-preview.tsx +1 -1
- package/src/components/shared/language-switcher.tsx +1 -1
- package/src/components/shared/name-confirm-dialog.tsx +1 -1
- package/src/components/shared/nav-float-button.tsx +1 -1
- package/src/components/shared/placeholder-page.tsx +1 -1
- package/src/components/story/columns.tsx +1 -1
- package/src/components/story/create-story-dialog.tsx +2 -2
- package/src/components/story/detail/__tests__/activity-timeline.test.tsx +1 -1
- package/src/components/story/detail/activity-timeline.tsx +1 -1
- package/src/components/story/detail/comment-item.tsx +1 -1
- package/src/components/story/detail/story-detail-body.tsx +2 -2
- package/src/components/story/display/__tests__/display-dropdown.test.tsx +1 -1
- package/src/components/story/display/group-resolver.tsx +1 -1
- package/src/components/story/filters/applied-filters.tsx +1 -1
- package/src/components/story/infinite-scroll-sentinel.tsx +1 -1
- package/src/components/story/inline-editors/assignee-editor.tsx +1 -1
- package/src/components/story/schemas/story-create.ts +1 -1
- package/src/components/story/views/kanban-card.tsx +1 -1
- package/src/components/story/views/view-types.ts +1 -1
- package/src/components/tiptap/__tests__/ai-extension.test.ts +120 -0
- package/src/components/tiptap/extension/ai-extension.ts +408 -0
- package/src/components/tiptap/extension/code-block-ellipsis-input-extension.ts +32 -0
- package/src/components/tiptap/extension/fullwidth-blockquote-extension.ts +31 -0
- package/src/components/tiptap/extension/indent-extension.ts +500 -0
- package/src/components/tiptap/extension/list-normalization-extension.ts +129 -0
- package/src/components/tiptap/extension/node-alignment-extension.ts +302 -0
- package/src/components/tiptap/extension/node-background-extension.ts +167 -0
- package/src/components/tiptap/extension/triple-click-block-selection-extension.ts +66 -0
- package/src/components/tiptap/extension/ui-state-extension.ts +114 -0
- package/src/components/tiptap/extensions/local-file/insert-local-file.ts +35 -0
- package/src/components/tiptap/extensions/local-file/local-file-node.ts +67 -0
- package/src/components/tiptap/global.d.ts +12 -0
- package/src/components/tiptap/hooks/use-composed-ref.ts +63 -0
- package/src/components/tiptap/hooks/use-cursor-visibility.ts +87 -0
- package/src/components/tiptap/hooks/use-element-rect.ts +179 -0
- package/src/components/tiptap/hooks/use-floating-element.ts +144 -0
- package/src/components/tiptap/hooks/use-floating-toolbar-visibility.ts +140 -0
- package/src/components/tiptap/hooks/use-is-breakpoint.ts +53 -0
- package/src/components/tiptap/hooks/use-isomorphic-layout-effect.ts +27 -0
- package/src/components/tiptap/hooks/use-menu-navigation.ts +212 -0
- package/src/components/tiptap/hooks/use-on-click-outside.ts +167 -0
- package/src/components/tiptap/hooks/use-tiptap-editor.ts +87 -0
- package/src/components/tiptap/hooks/use-ui-editor-state.ts +47 -0
- package/src/components/tiptap/hooks/use-window-size.ts +108 -0
- package/src/components/tiptap/icons/add-col-left-icon.tsx +47 -0
- package/src/components/tiptap/icons/add-col-right-icon.tsx +47 -0
- package/src/components/tiptap/icons/add-row-bottom-icon.tsx +47 -0
- package/src/components/tiptap/icons/add-row-top-icon.tsx +47 -0
- package/src/components/tiptap/icons/ai-sparkles-icon.tsx +49 -0
- package/src/components/tiptap/icons/align-bottom-icon.tsx +45 -0
- package/src/components/tiptap/icons/align-center-icon.tsx +55 -0
- package/src/components/tiptap/icons/align-center-vertical-icon.tsx +51 -0
- package/src/components/tiptap/icons/align-end-vertical-icon.tsx +51 -0
- package/src/components/tiptap/icons/align-justify-icon.tsx +55 -0
- package/src/components/tiptap/icons/align-left-icon.tsx +55 -0
- package/src/components/tiptap/icons/align-middle-icon.tsx +72 -0
- package/src/components/tiptap/icons/align-right-icon.tsx +55 -0
- package/src/components/tiptap/icons/align-start-vertical-icon.tsx +49 -0
- package/src/components/tiptap/icons/align-top-icon.tsx +45 -0
- package/src/components/tiptap/icons/alignment-icon.tsx +89 -0
- package/src/components/tiptap/icons/arrow-down-a-z-icon.tsx +51 -0
- package/src/components/tiptap/icons/arrow-down-icon.tsx +41 -0
- package/src/components/tiptap/icons/arrow-down-to-line-icon.tsx +45 -0
- package/src/components/tiptap/icons/arrow-down-z-a-icon.tsx +51 -0
- package/src/components/tiptap/icons/arrow-left-icon.tsx +41 -0
- package/src/components/tiptap/icons/arrow-right-icon.tsx +43 -0
- package/src/components/tiptap/icons/arrow-up-icon.tsx +43 -0
- package/src/components/tiptap/icons/at-sign-icon.tsx +43 -0
- package/src/components/tiptap/icons/ban-icon.tsx +43 -0
- package/src/components/tiptap/icons/blockquote-icon.tsx +61 -0
- package/src/components/tiptap/icons/bold-icon.tsx +43 -0
- package/src/components/tiptap/icons/check-ai-icon.tsx +49 -0
- package/src/components/tiptap/icons/check-icon.tsx +43 -0
- package/src/components/tiptap/icons/chevron-down-icon.tsx +43 -0
- package/src/components/tiptap/icons/chevron-right-icon.tsx +43 -0
- package/src/components/tiptap/icons/clipboard-icon.tsx +41 -0
- package/src/components/tiptap/icons/close-icon.tsx +41 -0
- package/src/components/tiptap/icons/code-block-icon.tsx +55 -0
- package/src/components/tiptap/icons/code2-icon.tsx +49 -0
- package/src/components/tiptap/icons/complete-sentence-icon.tsx +61 -0
- package/src/components/tiptap/icons/copy-icon.tsx +49 -0
- package/src/components/tiptap/icons/corner-down-left-icon.tsx +43 -0
- package/src/components/tiptap/icons/external-link-icon.tsx +45 -0
- package/src/components/tiptap/icons/grip-4-icon.tsx +41 -0
- package/src/components/tiptap/icons/grip-vertical-icon.tsx +61 -0
- package/src/components/tiptap/icons/heading-five-icon.tsx +45 -0
- package/src/components/tiptap/icons/heading-four-icon.tsx +45 -0
- package/src/components/tiptap/icons/heading-one-icon.tsx +45 -0
- package/src/components/tiptap/icons/heading-six-icon.tsx +47 -0
- package/src/components/tiptap/icons/heading-three-icon.tsx +53 -0
- package/src/components/tiptap/icons/heading-two-icon.tsx +45 -0
- package/src/components/tiptap/icons/highlighter-icon.tsx +43 -0
- package/src/components/tiptap/icons/image-caption-icon.tsx +55 -0
- package/src/components/tiptap/icons/image-icon.tsx +43 -0
- package/src/components/tiptap/icons/image-plus-icon.tsx +43 -0
- package/src/components/tiptap/icons/indent-decrease-icon.tsx +57 -0
- package/src/components/tiptap/icons/indent-increase-icon.tsx +57 -0
- package/src/components/tiptap/icons/italic-icon.tsx +41 -0
- package/src/components/tiptap/icons/languages-icon.tsx +51 -0
- package/src/components/tiptap/icons/link-icon.tsx +45 -0
- package/src/components/tiptap/icons/list-icon.tsx +73 -0
- package/src/components/tiptap/icons/list-indented-icon.tsx +73 -0
- package/src/components/tiptap/icons/list-ordered-icon.tsx +73 -0
- package/src/components/tiptap/icons/list-todo-icon.tsx +67 -0
- package/src/components/tiptap/icons/message-square-icon.tsx +43 -0
- package/src/components/tiptap/icons/message-square-plus-icon.tsx +49 -0
- package/src/components/tiptap/icons/mic-ai-icon.tsx +51 -0
- package/src/components/tiptap/icons/minus-icon.tsx +43 -0
- package/src/components/tiptap/icons/moon-star-icon.tsx +47 -0
- package/src/components/tiptap/icons/more-vertical-icon.tsx +55 -0
- package/src/components/tiptap/icons/move-horizontal-icon.tsx +41 -0
- package/src/components/tiptap/icons/network-icon.tsx +48 -0
- package/src/components/tiptap/icons/paint-bucket-icon.tsx +49 -0
- package/src/components/tiptap/icons/plus-icon.tsx +41 -0
- package/src/components/tiptap/icons/plus-small-icon.tsx +41 -0
- package/src/components/tiptap/icons/redo2-icon.tsx +43 -0
- package/src/components/tiptap/icons/refresh-ai-icon.tsx +51 -0
- package/src/components/tiptap/icons/refresh-ccw-icon.tsx +45 -0
- package/src/components/tiptap/icons/repeat-2-icon.tsx +43 -0
- package/src/components/tiptap/icons/rotate-ccw-icon.tsx +41 -0
- package/src/components/tiptap/icons/simplify-2-icon.tsx +41 -0
- package/src/components/tiptap/icons/smile-ai-icon.tsx +55 -0
- package/src/components/tiptap/icons/smile-plus-icon.tsx +43 -0
- package/src/components/tiptap/icons/square-x-icon.tsx +43 -0
- package/src/components/tiptap/icons/stop-circle-2-icon.tsx +43 -0
- package/src/components/tiptap/icons/strike-icon.tsx +45 -0
- package/src/components/tiptap/icons/subscript-icon.tsx +55 -0
- package/src/components/tiptap/icons/summarize-text-icon.tsx +53 -0
- package/src/components/tiptap/icons/sun-icon.tsx +75 -0
- package/src/components/tiptap/icons/superscript-icon.tsx +55 -0
- package/src/components/tiptap/icons/table-cell-merge-icon.tsx +61 -0
- package/src/components/tiptap/icons/table-cell-split-icon.tsx +61 -0
- package/src/components/tiptap/icons/table-column-icon.tsx +43 -0
- package/src/components/tiptap/icons/table-header-column-icon.tsx +45 -0
- package/src/components/tiptap/icons/table-header-row-icon.tsx +43 -0
- package/src/components/tiptap/icons/table-icon.tsx +43 -0
- package/src/components/tiptap/icons/table-row-icon.tsx +43 -0
- package/src/components/tiptap/icons/text-color-small-icon.tsx +43 -0
- package/src/components/tiptap/icons/text-extend-icon.tsx +53 -0
- package/src/components/tiptap/icons/text-reduce-icon.tsx +49 -0
- package/src/components/tiptap/icons/trash-icon.tsx +43 -0
- package/src/components/tiptap/icons/type-icon.tsx +41 -0
- package/src/components/tiptap/icons/underline-icon.tsx +43 -0
- package/src/components/tiptap/icons/undo2-icon.tsx +43 -0
- package/src/components/tiptap/icons/x-icon.tsx +41 -0
- package/src/components/tiptap/index.ts +1 -0
- package/src/components/tiptap/lib/advanced-utils.ts +388 -0
- package/src/components/tiptap/lib/ai-types.ts +41 -0
- package/src/components/tiptap/lib/collab-utils.ts +147 -0
- package/src/components/tiptap/lib/datetime.ts +1 -0
- package/src/components/tiptap/lib/fullwidth.ts +44 -0
- package/src/components/tiptap/lib/pacer.ts +95 -0
- package/src/components/tiptap/lib/utils/attr.ts +67 -0
- package/src/components/tiptap/lib/utils/constants.ts +46 -0
- package/src/components/tiptap/lib/utils/math.ts +23 -0
- package/src/components/tiptap/lib/utils/node.ts +136 -0
- package/src/components/tiptap/lib/utils/platform.ts +77 -0
- package/src/components/tiptap/lib/utils/schema.ts +75 -0
- package/src/components/tiptap/lib/utils/selection.ts +218 -0
- package/src/components/tiptap/lib/utils/url.ts +122 -0
- package/src/components/tiptap/lib/utils.ts +57 -0
- package/src/components/tiptap/mindmap/lib/__tests__/default-mindmap-data.test.ts +58 -0
- package/src/components/tiptap/mindmap/lib/default-mindmap-data.ts +36 -0
- package/src/components/tiptap/mindmap/mind-map.tsx +579 -0
- package/src/components/tiptap/mindmap/mindmap-fullscreen-dialog.tsx +52 -0
- package/src/components/tiptap/node/annotation-node/annotation-extension.ts +47 -0
- package/src/components/tiptap/node/annotation-node/annotation-node-view.tsx +185 -0
- package/src/components/tiptap/node/annotation-node/annotation-node.scss +77 -0
- package/src/components/tiptap/node/annotation-node/index.ts +2 -0
- package/src/components/tiptap/node/blockquote-node/blockquote-node.scss +37 -0
- package/src/components/tiptap/node/code-block-node/code-block-node.scss +54 -0
- package/src/components/tiptap/node/doc-card-extension.tsx +226 -0
- package/src/components/tiptap/node/heading-node/heading-node.scss +45 -0
- package/src/components/tiptap/node/horizontal-rule-node/horizontal-rule-node-extension.ts +31 -0
- package/src/components/tiptap/node/horizontal-rule-node/horizontal-rule-node.scss +25 -0
- package/src/components/tiptap/node/image-node/image-node-extension.ts +253 -0
- package/src/components/tiptap/node/image-node/image-node-floating.tsx +65 -0
- package/src/components/tiptap/node/image-node/image-node-view.scss +95 -0
- package/src/components/tiptap/node/image-node/image-node-view.tsx +363 -0
- package/src/components/tiptap/node/image-node/image-node.scss +35 -0
- package/src/components/tiptap/node/image-upload-node/image-upload-node-extension.ts +179 -0
- package/src/components/tiptap/node/image-upload-node/image-upload-node.scss +249 -0
- package/src/components/tiptap/node/image-upload-node/image-upload-node.tsx +570 -0
- package/src/components/tiptap/node/image-upload-node/index.tsx +18 -0
- package/src/components/tiptap/node/inline-node-selection.ts +42 -0
- package/src/components/tiptap/node/list-node/list-node.scss +208 -0
- package/src/components/tiptap/node/mention-extension.ts +163 -0
- package/src/components/tiptap/node/mindmap-node/mindmap-extension.ts +87 -0
- package/src/components/tiptap/node/mindmap-node/mindmap-node-view.tsx +61 -0
- package/src/components/tiptap/node/paragraph-node/paragraph-node.scss +1 -0
- package/src/components/tiptap/node/table-node/extensions/table-handle/helpers/create-image.ts +303 -0
- package/src/components/tiptap/node/table-node/extensions/table-handle/index.ts +19 -0
- package/src/components/tiptap/node/table-node/extensions/table-handle/table-handle-plugin.ts +863 -0
- package/src/components/tiptap/node/table-node/extensions/table-handle/table-handle.ts +67 -0
- package/src/components/tiptap/node/table-node/extensions/table-node-extension.ts +264 -0
- package/src/components/tiptap/node/table-node/hooks/use-table-handle-state.ts +88 -0
- package/src/components/tiptap/node/table-node/lib/tiptap-table-utils.ts +1306 -0
- package/src/components/tiptap/node/table-node/styles/prosemirror-table.scss +48 -0
- package/src/components/tiptap/node/table-node/styles/table-node.scss +211 -0
- package/src/components/tiptap/node/table-node/ui/table-add-row-column-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-add-row-column-button/table-add-row-column-button.tsx +117 -0
- package/src/components/tiptap/node/table-node/ui/table-add-row-column-button/use-table-add-row-column.ts +365 -0
- package/src/components/tiptap/node/table-node/ui/table-align-cell-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-align-cell-button/table-align-cell-button.tsx +144 -0
- package/src/components/tiptap/node/table-node/ui/table-align-cell-button/use-table-align-cell.ts +565 -0
- package/src/components/tiptap/node/table-node/ui/table-alignment-menu/index.tsx +18 -0
- package/src/components/tiptap/node/table-node/ui/table-alignment-menu/table-alignment-menu.tsx +177 -0
- package/src/components/tiptap/node/table-node/ui/table-cell-handle-menu/index.tsx +18 -0
- package/src/components/tiptap/node/table-node/ui/table-cell-handle-menu/table-cell-handle-menu.scss +121 -0
- package/src/components/tiptap/node/table-node/ui/table-cell-handle-menu/table-cell-handle-menu.tsx +227 -0
- package/src/components/tiptap/node/table-node/ui/table-clear-row-column-content-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-clear-row-column-content-button/table-clear-row-column-content-button.tsx +116 -0
- package/src/components/tiptap/node/table-node/ui/table-clear-row-column-content-button/use-table-clear-row-column-content.ts +487 -0
- package/src/components/tiptap/node/table-node/ui/table-delete-row-column-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-delete-row-column-button/table-delete-row-column-button.tsx +115 -0
- package/src/components/tiptap/node/table-node/ui/table-delete-row-column-button/use-table-delete-row-column.ts +283 -0
- package/src/components/tiptap/node/table-node/ui/table-duplicate-row-column-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-duplicate-row-column-button/table-duplicate-row-column-button.tsx +107 -0
- package/src/components/tiptap/node/table-node/ui/table-duplicate-row-column-button/use-table-duplicate-row-column.ts +424 -0
- package/src/components/tiptap/node/table-node/ui/table-extend-row-column-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-extend-row-column-button/table-extend-row-column-button.scss +36 -0
- package/src/components/tiptap/node/table-node/ui/table-extend-row-column-button/table-extend-row-column-button.tsx +272 -0
- package/src/components/tiptap/node/table-node/ui/table-extend-row-column-button/use-table-extend-row-column.ts +135 -0
- package/src/components/tiptap/node/table-node/ui/table-fit-to-width-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-fit-to-width-button/table-fit-to-width-button.tsx +113 -0
- package/src/components/tiptap/node/table-node/ui/table-fit-to-width-button/use-table-fit-to-width.ts +259 -0
- package/src/components/tiptap/node/table-node/ui/table-handle/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-handle/table-handle.tsx +179 -0
- package/src/components/tiptap/node/table-node/ui/table-handle/use-table-handle-positioning.ts +272 -0
- package/src/components/tiptap/node/table-node/ui/table-handle-menu/index.tsx +18 -0
- package/src/components/tiptap/node/table-node/ui/table-handle-menu/table-handle-menu.scss +54 -0
- package/src/components/tiptap/node/table-node/ui/table-handle-menu/table-handle-menu.tsx +765 -0
- package/src/components/tiptap/node/table-node/ui/table-header-row-column-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-header-row-column-button/table-header-row-column-button.tsx +114 -0
- package/src/components/tiptap/node/table-node/ui/table-header-row-column-button/use-table-header-row-column.ts +280 -0
- package/src/components/tiptap/node/table-node/ui/table-merge-split-cell-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-merge-split-cell-button/table-merge-split-cell-button.tsx +140 -0
- package/src/components/tiptap/node/table-node/ui/table-merge-split-cell-button/use-table-merge-split-cell.ts +305 -0
- package/src/components/tiptap/node/table-node/ui/table-move-row-column-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-move-row-column-button/table-move-row-column-button.tsx +138 -0
- package/src/components/tiptap/node/table-node/ui/table-move-row-column-button/use-table-move-row-column.ts +498 -0
- package/src/components/tiptap/node/table-node/ui/table-selection-overlay/index.tsx +18 -0
- package/src/components/tiptap/node/table-node/ui/table-selection-overlay/table-selection-overlay.tsx +590 -0
- package/src/components/tiptap/node/table-node/ui/table-selection-overlay/use-resize-overlay.ts +94 -0
- package/src/components/tiptap/node/table-node/ui/table-sort-row-column-button/index.tsx +19 -0
- package/src/components/tiptap/node/table-node/ui/table-sort-row-column-button/table-sort-row-column-button.tsx +115 -0
- package/src/components/tiptap/node/table-node/ui/table-sort-row-column-button/use-table-sort-row-column.ts +495 -0
- package/src/components/tiptap/node/table-node/ui/table-trigger-button/index.tsx +20 -0
- package/src/components/tiptap/node/table-node/ui/table-trigger-button/table-grid-selector.scss +98 -0
- package/src/components/tiptap/node/table-node/ui/table-trigger-button/table-grid-selector.tsx +236 -0
- package/src/components/tiptap/node/table-node/ui/table-trigger-button/table-trigger-button.tsx +147 -0
- package/src/components/tiptap/node/table-node/ui/table-trigger-button/use-table-trigger.ts +196 -0
- package/src/components/tiptap/node/toc-node/context/toc-context.tsx +214 -0
- package/src/components/tiptap/node/toc-node/extensions/toc-node-extension.ts +172 -0
- package/src/components/tiptap/node/toc-node/index.ts +20 -0
- package/src/components/tiptap/node/toc-node/toc-node.scss +105 -0
- package/src/components/tiptap/node/toc-node/toc-node.tsx +131 -0
- package/src/components/tiptap/node/toc-node/ui/toc-show-title-button/index.tsx +19 -0
- package/src/components/tiptap/node/toc-node/ui/toc-show-title-button/toc-show-title-button.tsx +113 -0
- package/src/components/tiptap/node/toc-node/ui/toc-show-title-button/toc-show-title.ts +228 -0
- package/src/components/tiptap/node/toc-node/ui/toc-sidebar/index.tsx +18 -0
- package/src/components/tiptap/node/toc-node/ui/toc-sidebar/toc-sidebar.scss +265 -0
- package/src/components/tiptap/node/toc-node/ui/toc-sidebar/toc-sidebar.tsx +272 -0
- package/src/components/tiptap/notion-like/data/content.json +1658 -0
- package/src/components/tiptap/notion-like/index.ts +2 -0
- package/src/components/tiptap/notion-like/notion-like-editor-header.scss +29 -0
- package/src/components/tiptap/notion-like/notion-like-editor-header.tsx +91 -0
- package/src/components/tiptap/notion-like/notion-like-editor-mobile-toolbar.tsx +704 -0
- package/src/components/tiptap/notion-like/notion-like-editor-theme-toggle.tsx +66 -0
- package/src/components/tiptap/notion-like/notion-like-editor-toolbar-floating.tsx +435 -0
- package/src/components/tiptap/notion-like/notion-like-editor.scss +181 -0
- package/src/components/tiptap/notion-like/notion-like-editor.tsx +589 -0
- package/src/components/tiptap/notion-like/setup-error-message/index.tsx +19 -0
- package/src/components/tiptap/notion-like/setup-error-message/setup-error-message.scss +108 -0
- package/src/components/tiptap/notion-like/setup-error-message/setup-error-message.tsx +116 -0
- package/src/components/tiptap/ui/ai-ask-button/ai-ask-button.tsx +124 -0
- package/src/components/tiptap/ui/ai-ask-button/index.tsx +19 -0
- package/src/components/tiptap/ui/ai-ask-button/use-ai-ask.ts +192 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-actions/ai-menu-actions.scss +11 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-actions/ai-menu-actions.tsx +103 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-actions/index.tsx +18 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-hooks.ts +325 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-input/ai-menu-input-hooks.ts +61 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-input/ai-menu-input-types.ts +32 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-input/ai-menu-input.scss +114 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-input/ai-menu-input.tsx +269 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-input/index.tsx +20 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-items/ai-menu-items-constants.ts +63 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-items/ai-menu-items-types.ts +64 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-items/ai-menu-items.tsx +381 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-items/index.tsx +20 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-items/language-selection-submenu.tsx +140 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-items/menu-action-renderer.tsx +105 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-items/tone-selection-submenu.tsx +125 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-types.ts +42 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu-utils.ts +255 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu.scss +101 -0
- package/src/components/tiptap/ui/ai-menu/ai-menu.tsx +427 -0
- package/src/components/tiptap/ui/ai-menu/index.tsx +25 -0
- package/src/components/tiptap/ui/blockquote-button/blockquote-button.tsx +143 -0
- package/src/components/tiptap/ui/blockquote-button/index.tsx +19 -0
- package/src/components/tiptap/ui/blockquote-button/use-blockquote.ts +290 -0
- package/src/components/tiptap/ui/code-block-button/code-block-button.tsx +143 -0
- package/src/components/tiptap/ui/code-block-button/index.tsx +19 -0
- package/src/components/tiptap/ui/code-block-button/use-code-block.ts +300 -0
- package/src/components/tiptap/ui/color-highlight-button/color-highlight-button.scss +49 -0
- package/src/components/tiptap/ui/color-highlight-button/color-highlight-button.tsx +188 -0
- package/src/components/tiptap/ui/color-highlight-button/index.tsx +19 -0
- package/src/components/tiptap/ui/color-highlight-button/use-color-highlight.ts +397 -0
- package/src/components/tiptap/ui/color-highlight-popover/color-highlight-popover.tsx +251 -0
- package/src/components/tiptap/ui/color-highlight-popover/index.tsx +18 -0
- package/src/components/tiptap/ui/color-menu/color-menu.tsx +228 -0
- package/src/components/tiptap/ui/color-menu/index.tsx +18 -0
- package/src/components/tiptap/ui/color-text-button/color-text-button.scss +52 -0
- package/src/components/tiptap/ui/color-text-button/color-text-button.tsx +168 -0
- package/src/components/tiptap/ui/color-text-button/index.tsx +19 -0
- package/src/components/tiptap/ui/color-text-button/use-color-text.ts +303 -0
- package/src/components/tiptap/ui/color-text-popover/color-text-popover.scss +40 -0
- package/src/components/tiptap/ui/color-text-popover/color-text-popover.tsx +471 -0
- package/src/components/tiptap/ui/color-text-popover/index.tsx +19 -0
- package/src/components/tiptap/ui/color-text-popover/use-color-text-popover.ts +295 -0
- package/src/components/tiptap/ui/copy-anchor-link-button/copy-anchor-link-button.tsx +136 -0
- package/src/components/tiptap/ui/copy-anchor-link-button/index.tsx +20 -0
- package/src/components/tiptap/ui/copy-anchor-link-button/use-copy-anchor-link.ts +282 -0
- package/src/components/tiptap/ui/copy-anchor-link-button/use-scroll-to-hash.ts +155 -0
- package/src/components/tiptap/ui/copy-to-clipboard-button/copy-to-clipboard-button.tsx +134 -0
- package/src/components/tiptap/ui/copy-to-clipboard-button/index.tsx +19 -0
- package/src/components/tiptap/ui/copy-to-clipboard-button/use-copy-to-clipboard.ts +275 -0
- package/src/components/tiptap/ui/delete-node-button/delete-node-button.tsx +132 -0
- package/src/components/tiptap/ui/delete-node-button/index.tsx +19 -0
- package/src/components/tiptap/ui/delete-node-button/use-delete-node.ts +259 -0
- package/src/components/tiptap/ui/doc-reference-floating/doc-reference-floating.tsx +120 -0
- package/src/components/tiptap/ui/doc-reference-interaction/doc-reference-interaction.tsx +209 -0
- package/src/components/tiptap/ui/drag-context-menu/drag-context-menu-types.ts +47 -0
- package/src/components/tiptap/ui/drag-context-menu/drag-context-menu.scss +15 -0
- package/src/components/tiptap/ui/drag-context-menu/drag-context-menu.tsx +558 -0
- package/src/components/tiptap/ui/drag-context-menu/index.tsx +19 -0
- package/src/components/tiptap/ui/duplicate-button/duplicate-button.tsx +132 -0
- package/src/components/tiptap/ui/duplicate-button/index.tsx +19 -0
- package/src/components/tiptap/ui/duplicate-button/use-duplicate.ts +240 -0
- package/src/components/tiptap/ui/emoji-dropdown-menu/emoji-dropdown-menu.tsx +124 -0
- package/src/components/tiptap/ui/emoji-dropdown-menu/index.tsx +18 -0
- package/src/components/tiptap/ui/emoji-menu/emoji-menu-utils.ts +53 -0
- package/src/components/tiptap/ui/emoji-menu/emoji-menu.scss +28 -0
- package/src/components/tiptap/ui/emoji-menu/emoji-menu.tsx +166 -0
- package/src/components/tiptap/ui/emoji-menu/index.tsx +19 -0
- package/src/components/tiptap/ui/emoji-trigger-button/emoji-trigger-button.tsx +146 -0
- package/src/components/tiptap/ui/emoji-trigger-button/index.tsx +19 -0
- package/src/components/tiptap/ui/emoji-trigger-button/use-emoji-trigger.ts +338 -0
- package/src/components/tiptap/ui/heading-button/heading-button.tsx +142 -0
- package/src/components/tiptap/ui/heading-button/index.tsx +19 -0
- package/src/components/tiptap/ui/heading-button/use-heading.ts +374 -0
- package/src/components/tiptap/ui/image-align-button/image-align-button.tsx +154 -0
- package/src/components/tiptap/ui/image-align-button/index.tsx +19 -0
- package/src/components/tiptap/ui/image-align-button/use-image-align.ts +313 -0
- package/src/components/tiptap/ui/image-caption-button/image-caption-button.tsx +109 -0
- package/src/components/tiptap/ui/image-caption-button/index.tsx +19 -0
- package/src/components/tiptap/ui/image-caption-button/use-image-caption.ts +232 -0
- package/src/components/tiptap/ui/image-download-button/image-download-button.tsx +141 -0
- package/src/components/tiptap/ui/image-download-button/index.tsx +19 -0
- package/src/components/tiptap/ui/image-download-button/use-image-download.ts +384 -0
- package/src/components/tiptap/ui/image-upload-button/image-upload-button.tsx +148 -0
- package/src/components/tiptap/ui/image-upload-button/index.tsx +19 -0
- package/src/components/tiptap/ui/image-upload-button/use-image-upload.ts +214 -0
- package/src/components/tiptap/ui/improve-dropdown/improve-dropdown.tsx +311 -0
- package/src/components/tiptap/ui/improve-dropdown/index.tsx +19 -0
- package/src/components/tiptap/ui/improve-dropdown/use-improve-dropdown.ts +294 -0
- package/src/components/tiptap/ui/indent-button/indent-button.tsx +148 -0
- package/src/components/tiptap/ui/indent-button/index.tsx +19 -0
- package/src/components/tiptap/ui/indent-button/use-indent.ts +217 -0
- package/src/components/tiptap/ui/link-popover/index.tsx +19 -0
- package/src/components/tiptap/ui/link-popover/link-popover.scss +16 -0
- package/src/components/tiptap/ui/link-popover/link-popover.tsx +333 -0
- package/src/components/tiptap/ui/link-popover/use-link-popover.ts +316 -0
- package/src/components/tiptap/ui/list-button/index.tsx +19 -0
- package/src/components/tiptap/ui/list-button/list-button.tsx +138 -0
- package/src/components/tiptap/ui/list-button/use-list.ts +370 -0
- package/src/components/tiptap/ui/mark-button/index.tsx +19 -0
- package/src/components/tiptap/ui/mark-button/mark-button.tsx +138 -0
- package/src/components/tiptap/ui/mark-button/use-mark.ts +247 -0
- package/src/components/tiptap/ui/mention-dropdown-menu/index.tsx +18 -0
- package/src/components/tiptap/ui/mention-dropdown-menu/mention-dropdown-menu.tsx +194 -0
- package/src/components/tiptap/ui/mention-trigger-button/index.tsx +19 -0
- package/src/components/tiptap/ui/mention-trigger-button/mention-trigger-button.tsx +137 -0
- package/src/components/tiptap/ui/mention-trigger-button/use-mention-trigger.ts +362 -0
- package/src/components/tiptap/ui/move-node-button/index.tsx +19 -0
- package/src/components/tiptap/ui/move-node-button/move-node-button.tsx +138 -0
- package/src/components/tiptap/ui/move-node-button/use-move-node.ts +230 -0
- package/src/components/tiptap/ui/reference-dropdown-menu/index.tsx +18 -0
- package/src/components/tiptap/ui/reference-dropdown-menu/reference-dropdown-menu.tsx +231 -0
- package/src/components/tiptap/ui/reset-all-formatting-button/index.tsx +19 -0
- package/src/components/tiptap/ui/reset-all-formatting-button/reset-all-formatting-button.tsx +144 -0
- package/src/components/tiptap/ui/reset-all-formatting-button/use-reset-all-formatting.ts +279 -0
- package/src/components/tiptap/ui/slash-command-trigger-button/index.tsx +19 -0
- package/src/components/tiptap/ui/slash-command-trigger-button/slash-command-trigger-button.tsx +143 -0
- package/src/components/tiptap/ui/slash-command-trigger-button/use-slash-command-trigger.ts +305 -0
- package/src/components/tiptap/ui/slash-dropdown-menu/index.tsx +19 -0
- package/src/components/tiptap/ui/slash-dropdown-menu/slash-dropdown-menu.scss +33 -0
- package/src/components/tiptap/ui/slash-dropdown-menu/slash-dropdown-menu.tsx +222 -0
- package/src/components/tiptap/ui/slash-dropdown-menu/use-slash-dropdown-menu.ts +498 -0
- package/src/components/tiptap/ui/text-align-button/index.tsx +19 -0
- package/src/components/tiptap/ui/text-align-button/text-align-button.tsx +160 -0
- package/src/components/tiptap/ui/text-align-button/use-text-align.ts +248 -0
- package/src/components/tiptap/ui/text-button/index.tsx +19 -0
- package/src/components/tiptap/ui/text-button/text-button.tsx +135 -0
- package/src/components/tiptap/ui/text-button/use-text.ts +308 -0
- package/src/components/tiptap/ui/turn-into-dropdown/index.tsx +19 -0
- package/src/components/tiptap/ui/turn-into-dropdown/turn-into-dropdown.tsx +243 -0
- package/src/components/tiptap/ui/turn-into-dropdown/use-turn-into-dropdown.ts +294 -0
- package/src/components/tiptap/ui/undo-redo-button/index.tsx +19 -0
- package/src/components/tiptap/ui/undo-redo-button/undo-redo-button.tsx +141 -0
- package/src/components/tiptap/ui/undo-redo-button/use-undo-redo.ts +207 -0
- package/src/components/tiptap/ui-primitive/avatar/avatar.scss +118 -0
- package/src/components/tiptap/ui-primitive/avatar/avatar.tsx +255 -0
- package/src/components/tiptap/ui-primitive/avatar/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/badge/badge-colors.scss +395 -0
- package/src/components/tiptap/ui-primitive/badge/badge-group.scss +16 -0
- package/src/components/tiptap/ui-primitive/badge/badge.scss +99 -0
- package/src/components/tiptap/ui-primitive/badge/badge.tsx +62 -0
- package/src/components/tiptap/ui-primitive/badge/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/button/button-colors.scss +429 -0
- package/src/components/tiptap/ui-primitive/button/button.scss +314 -0
- package/src/components/tiptap/ui-primitive/button/button.tsx +119 -0
- package/src/components/tiptap/ui-primitive/button/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/button-group/button-group.scss +79 -0
- package/src/components/tiptap/ui-primitive/button-group/button-group.tsx +89 -0
- package/src/components/tiptap/ui-primitive/button-group/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/card/card.scss +74 -0
- package/src/components/tiptap/ui-primitive/card/card.tsx +95 -0
- package/src/components/tiptap/ui-primitive/card/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/combobox/combobox.scss +90 -0
- package/src/components/tiptap/ui-primitive/combobox/combobox.tsx +231 -0
- package/src/components/tiptap/ui-primitive/combobox/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/dropdown-menu/dropdown-menu.scss +152 -0
- package/src/components/tiptap/ui-primitive/dropdown-menu/dropdown-menu.tsx +280 -0
- package/src/components/tiptap/ui-primitive/dropdown-menu/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/input/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/input/input.scss +41 -0
- package/src/components/tiptap/ui-primitive/input/input.tsx +33 -0
- package/src/components/tiptap/ui-primitive/input-group/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/input-group/input-group.scss +225 -0
- package/src/components/tiptap/ui-primitive/input-group/input-group.tsx +152 -0
- package/src/components/tiptap/ui-primitive/label/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/label/label.scss +20 -0
- package/src/components/tiptap/ui-primitive/label/label.tsx +34 -0
- package/src/components/tiptap/ui-primitive/menu/index.tsx +22 -0
- package/src/components/tiptap/ui-primitive/menu/menu-context.ts +35 -0
- package/src/components/tiptap/ui-primitive/menu/menu-hooks.ts +118 -0
- package/src/components/tiptap/ui-primitive/menu/menu-types.ts +75 -0
- package/src/components/tiptap/ui-primitive/menu/menu-utils.ts +80 -0
- package/src/components/tiptap/ui-primitive/menu/menu.scss +68 -0
- package/src/components/tiptap/ui-primitive/menu/menu.tsx +327 -0
- package/src/components/tiptap/ui-primitive/popover/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/popover/popover.scss +64 -0
- package/src/components/tiptap/ui-primitive/popover/popover.tsx +53 -0
- package/src/components/tiptap/ui-primitive/separator/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/separator/separator.scss +23 -0
- package/src/components/tiptap/ui-primitive/separator/separator.tsx +46 -0
- package/src/components/tiptap/ui-primitive/sidebar/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/sidebar/sidebar.scss +389 -0
- package/src/components/tiptap/ui-primitive/sidebar/sidebar.tsx +633 -0
- package/src/components/tiptap/ui-primitive/spacer/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/spacer/spacer.tsx +40 -0
- package/src/components/tiptap/ui-primitive/textarea/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/textarea/textarea.scss +42 -0
- package/src/components/tiptap/ui-primitive/textarea/textarea.tsx +32 -0
- package/src/components/tiptap/ui-primitive/textarea-autosize/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/textarea-autosize/textarea-autosize.tsx +34 -0
- package/src/components/tiptap/ui-primitive/toolbar/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/toolbar/toolbar.scss +98 -0
- package/src/components/tiptap/ui-primitive/toolbar/toolbar.tsx +139 -0
- package/src/components/tiptap/ui-primitive/tooltip/index.tsx +18 -0
- package/src/components/tiptap/ui-primitive/tooltip/tooltip.scss +43 -0
- package/src/components/tiptap/ui-primitive/tooltip/tooltip.tsx +257 -0
- package/src/components/tiptap/ui-utils/floating-element/floating-element-utils.ts +51 -0
- package/src/components/tiptap/ui-utils/floating-element/floating-element.tsx +397 -0
- package/src/components/tiptap/ui-utils/floating-element/index.tsx +19 -0
- package/src/components/tiptap/ui-utils/suggestion-menu/index.tsx +20 -0
- package/src/components/tiptap/ui-utils/suggestion-menu/suggestion-menu-fullwidth.ts +48 -0
- package/src/components/tiptap/ui-utils/suggestion-menu/suggestion-menu-types.ts +119 -0
- package/src/components/tiptap/ui-utils/suggestion-menu/suggestion-menu-utils.ts +107 -0
- package/src/components/tiptap/ui-utils/suggestion-menu/suggestion-menu.tsx +367 -0
- package/src/components/tiptap/virtual.d.ts +17 -0
- package/src/components/ui/alert-dialog.tsx +1 -1
- package/src/components/ui/badge.tsx +1 -1
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/card.tsx +1 -1
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/context-menu.tsx +1 -1
- package/src/components/ui/dialog.tsx +1 -1
- package/src/components/ui/dropdown-menu.tsx +1 -1
- package/src/components/ui/empty.tsx +1 -1
- package/src/components/ui/input.tsx +1 -1
- package/src/components/ui/label.tsx +1 -1
- package/src/components/ui/popover.tsx +1 -1
- package/src/components/ui/resizable.tsx +1 -1
- package/src/components/ui/select.tsx +1 -1
- package/src/components/ui/sidebar.tsx +1 -1
- package/src/components/ui/skeleton.tsx +1 -1
- package/src/components/ui/sonner.tsx +1 -1
- package/src/components/ui/spinner.tsx +1 -1
- package/src/components/ui/switch.tsx +1 -1
- package/src/components/ui/textarea.tsx +1 -1
- package/src/components/ui/tooltip.tsx +1 -1
- package/src/components/ui-shared/ai-command-button.tsx +36 -0
- package/src/components/ui-shared/ai-stream-text.tsx +37 -0
- package/src/components/ui-shared/alert-dialog.tsx +216 -0
- package/src/components/ui-shared/animated-theme-toggler.tsx +272 -0
- package/src/components/ui-shared/auth-client.ts +115 -0
- package/src/components/ui-shared/auth-layout.tsx +66 -0
- package/src/components/ui-shared/avatar.tsx +129 -0
- package/src/components/ui-shared/badge.tsx +66 -0
- package/src/components/ui-shared/button.tsx +84 -0
- package/src/components/ui-shared/card.tsx +120 -0
- package/src/components/ui-shared/checkbox.tsx +50 -0
- package/src/components/ui-shared/context-menu.tsx +280 -0
- package/src/components/ui-shared/dialog.tsx +183 -0
- package/src/components/ui-shared/dropdown-menu.tsx +286 -0
- package/src/components/ui-shared/empty.tsx +121 -0
- package/src/components/ui-shared/grid-pattern.tsx +87 -0
- package/src/components/ui-shared/index.ts +23 -0
- package/src/components/ui-shared/input.tsx +36 -0
- package/src/components/ui-shared/item.tsx +213 -0
- package/src/components/ui-shared/kbd.tsx +33 -0
- package/src/components/ui-shared/label.tsx +39 -0
- package/src/components/ui-shared/layout-panel-top.tsx +160 -0
- package/src/components/ui-shared/name-confirm-dialog.tsx +153 -0
- package/src/components/ui-shared/nav-float-button.tsx +301 -0
- package/src/components/ui-shared/notion-avatar.tsx +126 -0
- package/src/components/ui-shared/placeholder-page.tsx +42 -0
- package/src/components/ui-shared/popover.tsx +106 -0
- package/src/components/ui-shared/reference-inline.tsx +53 -0
- package/src/components/ui-shared/reference-search.tsx +52 -0
- package/src/components/ui-shared/resizable.tsx +67 -0
- package/src/components/ui-shared/select.tsx +207 -0
- package/src/components/ui-shared/separator.tsx +45 -0
- package/src/components/ui-shared/sheet.tsx +164 -0
- package/src/components/ui-shared/sidebar.tsx +708 -0
- package/src/components/ui-shared/skeleton.tsx +30 -0
- package/src/components/ui-shared/sonner.tsx +37 -0
- package/src/components/ui-shared/switch.tsx +48 -0
- package/src/components/ui-shared/textarea.tsx +35 -0
- package/src/components/ui-shared/timezone-provider.tsx +55 -0
- package/src/components/ui-shared/tooltip.tsx +72 -0
- package/src/components/ui-shared/use-mobile.ts +36 -0
- package/src/components/ui-shared/user-avatar.tsx +83 -0
- package/src/components/ui-shared/utils.ts +6 -0
- package/src/components/workspace/schemas/create-workspace.ts +1 -1
- package/src/hooks/use-entity-subscription.ts +1 -1
- package/src/hooks/use-notifications.ts +2 -2
- package/src/i18n/__tests__/detect.test.ts +48 -0
- package/src/i18n/__tests__/integration.test.tsx +32 -0
- package/src/i18n/__tests__/server.test.ts +33 -0
- package/src/i18n/client.ts +32 -0
- package/src/i18n/config.ts +114 -18
- package/src/i18n/detect.ts +43 -0
- package/src/i18n/locales/en/agents.json +134 -0
- package/src/i18n/locales/en/apps.json +6 -0
- package/src/i18n/locales/en/auth.json +90 -0
- package/src/i18n/locales/en/billing.json +78 -0
- package/src/i18n/locales/en/chat.json +194 -0
- package/src/i18n/locales/en/common.json +242 -0
- package/src/i18n/locales/en/dashboard.json +38 -0
- package/src/i18n/locales/en/design.json +70 -0
- package/src/i18n/locales/en/desktop.json +35 -0
- package/src/i18n/locales/en/display.json +37 -0
- package/src/i18n/locales/en/editor.json +304 -0
- package/src/i18n/locales/en/enterprise.json +1 -0
- package/src/i18n/locales/en/invite.json +56 -0
- package/src/i18n/locales/en/iterations.json +92 -0
- package/src/i18n/locales/en/knowledge.json +462 -0
- package/src/i18n/locales/en/mindmap.json +28 -0
- package/src/i18n/locales/en/notifications.json +79 -0
- package/src/i18n/locales/en/prd.json +51 -0
- package/src/i18n/locales/en/projects.json +140 -0
- package/src/i18n/locales/en/settings.json +428 -0
- package/src/i18n/locales/en/share.json +20 -0
- package/src/i18n/locales/en/story.json +923 -0
- package/src/i18n/locales/en/tags.json +42 -0
- package/src/i18n/locales/en/workspace.json +90 -0
- package/src/i18n/locales/zh/agents.json +134 -0
- package/src/i18n/locales/zh/apps.json +6 -0
- package/src/i18n/locales/zh/auth.json +90 -0
- package/src/i18n/locales/zh/billing.json +78 -0
- package/src/i18n/locales/zh/chat.json +194 -0
- package/src/i18n/locales/zh/common.json +242 -0
- package/src/i18n/locales/zh/dashboard.json +38 -0
- package/src/i18n/locales/zh/design.json +70 -0
- package/src/i18n/locales/zh/desktop.json +35 -0
- package/src/i18n/locales/zh/display.json +37 -0
- package/src/i18n/locales/zh/editor.json +304 -0
- package/src/i18n/locales/zh/enterprise.json +1 -0
- package/src/i18n/locales/zh/invite.json +56 -0
- package/src/i18n/locales/zh/iterations.json +92 -0
- package/src/i18n/locales/zh/knowledge.json +462 -0
- package/src/i18n/locales/zh/mindmap.json +28 -0
- package/src/i18n/locales/zh/notifications.json +79 -0
- package/src/i18n/locales/zh/prd.json +51 -0
- package/src/i18n/locales/zh/projects.json +140 -0
- package/src/i18n/locales/zh/settings.json +428 -0
- package/src/i18n/locales/zh/share.json +20 -0
- package/src/i18n/locales/zh/story.json +923 -0
- package/src/i18n/locales/zh/tags.json +42 -0
- package/src/i18n/locales/zh/workspace.json +90 -0
- package/src/i18n/server.ts +18 -0
- package/src/i18n/types.ts +5 -0
- package/src/lib/__tests__/ai-adapter.test.ts +5 -5
- package/src/lib/__tests__/cli-detector.test.ts +6 -6
- package/src/lib/__tests__/embedding.test.ts +1 -1
- package/src/lib/__tests__/module-registry.test.ts +1 -1
- package/src/lib/__tests__/provider-router.test.ts +2 -2
- package/src/lib/__tests__/rag.test.ts +1 -1
- package/src/lib/ai/__tests__/story-prompt.test.ts +1 -1
- package/src/lib/annotation-template.ts +33 -1
- package/src/lib/auth/auth-client.ts +1 -1
- package/src/lib/auth/auth.config.ts +1 -1
- package/src/lib/changelog/sdk-versions.ts +1 -8
- package/src/lib/collections/index.ts +1 -1
- package/src/lib/collections/knowledge/knowledge-bases-collection.ts +1 -1
- package/src/lib/collections/reference/bookmark-categories-collection.ts +1 -1
- package/src/lib/collections/reference/labels-collection.ts +1 -1
- package/src/lib/collections/reference/projects-collection.ts +1 -1
- package/src/lib/collections/reference/users-brief-collection.ts +1 -1
- package/src/lib/collections/reference/workspaces-collection.ts +1 -1
- package/src/lib/comment-utils.ts +47 -1
- package/src/lib/crypto/api-key-cipher.ts +1 -1
- package/src/lib/datetime.ts +130 -7
- package/src/lib/outline-utils.ts +57 -1
- package/src/lib/pacer.ts +96 -11
- package/src/lib/prd/__tests__/stack-layout.test.ts +1 -1
- package/src/lib/prd/stack-layout.ts +53 -1
- package/src/lib/prd-tree-utils.ts +94 -1
- package/src/lib/prototype-registry.ts +24 -1
- package/src/lib/query-client-seam.test.ts +19 -0
- package/src/lib/query-client-seam.ts +14 -0
- package/src/lib/rag.ts +1 -1
- package/src/lib/restore-version.ts +1 -1
- package/src/lib/router-context.ts +1 -1
- package/src/lib/share-events.ts +78 -1
- package/src/lib/sidebar-utils.ts +21 -1
- package/src/lib/sse-transport.ts +1 -1
- package/src/lib/stores/prd-canvas-store.ts +69 -1
- package/src/lib/tag-colors.ts +35 -1
- package/src/lib/time-format.ts +50 -1
- package/src/lib/utils.ts +1 -1
- package/src/plugins/core/context.ts +2 -0
- package/src/plugins/core/index.ts +1 -0
- package/src/plugins/core/inspiration/index.ts +17 -0
- package/src/plugins/core/inspiration/pages/inspiration-page.tsx +8 -0
- package/src/plugins/core/inspiration/routes.ts +12 -0
- package/src/plugins/core/inspiration/ui.tsx +28 -0
- package/src/plugins/core/prd/components/agent-input.tsx +193 -0
- package/src/plugins/core/prd/components/component-annotation-overlay/AnnotationOverlay.tsx +113 -0
- package/src/plugins/core/prd/components/component-editor/__tests__/field-utils.test.ts +93 -0
- package/src/plugins/core/prd/components/component-editor/collapsible-section.tsx +44 -0
- package/src/plugins/core/prd/components/component-editor/content-section.tsx +63 -0
- package/src/plugins/core/prd/components/component-editor/field-utils.ts +56 -0
- package/src/plugins/core/prd/components/component-editor/position-section.tsx +39 -0
- package/src/plugins/core/prd/components/component-editor/style-fields.tsx +187 -0
- package/src/plugins/core/prd/components/component-editor/use-field.ts +53 -0
- package/src/plugins/core/prd/components/component-thumbnail.tsx +109 -0
- package/src/plugins/core/prd/components/dialog/create-prd-dialog.tsx +148 -0
- package/src/plugins/core/prd/components/dialog/prd-detail-client.tsx +102 -0
- package/src/plugins/core/prd/components/element-context.ts +29 -0
- package/src/plugins/core/prd/components/index.ts +19 -0
- package/src/plugins/core/prd/components/page-version-panel/components/create-version-dialog.tsx +84 -0
- package/src/plugins/core/prd/components/page-version-panel/components/delete-version-dialog.tsx +61 -0
- package/src/plugins/core/prd/components/page-version-panel/components/edit-version-dialog.tsx +82 -0
- package/src/plugins/core/prd/components/page-version-panel/constants.tsx +23 -0
- package/src/plugins/core/prd/components/page-version-panel/types.ts +30 -0
- package/src/plugins/core/prd/components/page-version-panel.tsx +1100 -0
- package/src/plugins/core/prd/components/page-version-tree.tsx +308 -0
- package/src/plugins/core/prd/components/prd-agent-panel.tsx +429 -0
- package/src/plugins/core/prd/components/prd-comment-review-panel.tsx +227 -0
- package/src/plugins/core/prd/components/prd-component-editor-content.tsx +90 -0
- package/src/plugins/core/prd/components/prd-dashboard.tsx +302 -0
- package/src/plugins/core/prd/components/prd-doc-panel.tsx +116 -0
- package/src/plugins/core/prd/components/prd-editor-layout.tsx +466 -0
- package/src/plugins/core/prd/components/prd-filter-bar.tsx +103 -0
- package/src/plugins/core/prd/components/prd-left-sidebar.tsx +473 -0
- package/src/plugins/core/prd/components/prd-navigation.tsx +287 -0
- package/src/plugins/core/prd/components/prd-outline-tab.tsx +61 -0
- package/src/plugins/core/prd/components/prd-prototype-panel.tsx +142 -0
- package/src/plugins/core/prd/components/prd-right-sidebar.tsx +209 -0
- package/src/plugins/core/prd/components/prd-share-panel/components/single-version-share-card.tsx +201 -0
- package/src/plugins/core/prd/components/prd-share-panel/constants.ts +22 -0
- package/src/plugins/core/prd/components/prd-share-panel/types.ts +21 -0
- package/src/plugins/core/prd/components/prd-share-panel/utils.ts +30 -0
- package/src/plugins/core/prd/components/prd-share-panel.tsx +567 -0
- package/src/plugins/core/prd/components/prd-tree-page-tab.tsx +572 -0
- package/src/plugins/core/prd/components/prd-tree-reducer.ts +96 -0
- package/src/plugins/core/prd/components/prototype/IconPrototype.tsx +81 -0
- package/src/plugins/core/prd/components/prototype/PrototypeCanvas.tsx +411 -0
- package/src/plugins/core/prd/components/prototype/PrototypeElement.tsx +168 -0
- package/src/plugins/core/prd/components/prototype/ResizeHandles.tsx +95 -0
- package/src/plugins/core/prd/components/prototype/icon-components.ts +57 -0
- package/src/plugins/core/prd/components/prototype/imported/.gitkeep +0 -0
- package/src/plugins/core/prd/components/prototype/index.ts +31 -0
- package/src/plugins/core/prd/components/restore-version-dialog.tsx +76 -0
- package/src/plugins/core/prd/components/schemas/create-prd.ts +26 -0
- package/src/plugins/core/prd/components/share/prd-share-client.tsx +118 -0
- package/src/plugins/core/prd/components/share/share-annotation-overlay.tsx +122 -0
- package/src/plugins/core/prd/components/share/share-comment-panel.tsx +257 -0
- package/src/plugins/core/prd/components/share/share-comment-review-panel.tsx +75 -0
- package/src/plugins/core/prd/components/share/share-directory-tree.tsx +93 -0
- package/src/plugins/core/prd/components/share/share-doc-view.tsx +96 -0
- package/src/plugins/core/prd/components/share/share-layout.tsx +171 -0
- package/src/plugins/core/prd/components/share/share-nav-bar.tsx +72 -0
- package/src/plugins/core/prd/components/share/share-password-gate.tsx +90 -0
- package/src/plugins/core/prd/components/share/share-prototype-view.tsx +92 -0
- package/src/plugins/core/prd/components/share/share-review-panel.tsx +93 -0
- package/src/plugins/core/prd/components/share/share-sse-listener.tsx +76 -0
- package/src/plugins/core/prd/components/share/share-theme-toggle.tsx +57 -0
- package/src/plugins/core/prd/components/share/version-share-client.tsx +123 -0
- package/src/plugins/core/prd/components/tiptap/node/paragraph-node/paragraph-node.scss +286 -0
- package/src/plugins/core/prd/icon-picker-bridge.ts +41 -0
- package/src/plugins/core/prd/index.ts +40 -0
- package/src/plugins/core/prd/lib/ai/annotation-prompt.ts +66 -0
- package/src/plugins/core/prd/lib/restore-version.ts +53 -0
- package/src/plugins/core/prd/pages/prd-detail-page.tsx +88 -0
- package/src/plugins/core/prd/pages/prd-layout.tsx +28 -0
- package/src/plugins/core/prd/pages/share-prd-page.tsx +69 -0
- package/src/plugins/core/prd/prd-nav.tsx +92 -0
- package/src/plugins/core/prd/routes.tsx +103 -0
- package/src/plugins/core/prd/serverFns/ai/agent-conversations.ts +124 -0
- package/src/plugins/core/prd/serverFns/ai/fill-annotation.ts +80 -0
- package/src/plugins/core/prd/serverFns/ai/generate-prototype.ts +121 -0
- package/src/plugins/core/prd/serverFns/ai/providers.ts +528 -0
- package/src/plugins/core/prd/serverFns/comments.ts +109 -0
- package/src/plugins/core/prd/serverFns/components.ts +37 -0
- package/src/plugins/core/prd/serverFns/detail.ts +49 -0
- package/src/plugins/core/prd/serverFns/index.ts +14 -0
- package/src/plugins/core/prd/serverFns/page-versions.ts +137 -0
- package/src/plugins/core/prd/serverFns/pages.ts +164 -0
- package/src/plugins/core/prd/serverFns/prd.ts +164 -0
- package/src/plugins/core/prd/serverFns/reviews.ts +87 -0
- package/src/plugins/core/prd/serverFns/share/verify-password.ts +75 -0
- package/src/plugins/core/prd/serverFns/share/versions.ts +112 -0
- package/src/plugins/core/prd/serverFns/share.ts +119 -0
- package/src/plugins/core/prd/serverFns/shares-password.ts +189 -0
- package/src/plugins/core/prd/serverFns/shares.ts +336 -0
- package/src/plugins/core/prd/serverFns/versions.ts +277 -0
- package/src/plugins/core/prd/ui.ts +24 -0
- package/src/plugins/core/server/api-key-cipher.ts +61 -0
- package/src/plugins/core/server/rate-limit.ts +111 -0
- package/src/plugins/core/tags/__tests__/tags.test.ts +367 -0
- package/src/plugins/core/tags/index.ts +39 -0
- package/src/plugins/core/tags/nav-tag.tsx +137 -0
- package/src/plugins/core/tags/pages/tag-detail-page.tsx +31 -0
- package/src/plugins/core/tags/pages/tag-settings-page.tsx +34 -0
- package/src/plugins/core/tags/pages/tags-index-page.tsx +34 -0
- package/src/plugins/core/tags/routes.ts +65 -0
- package/src/plugins/core/tags/serverFns.ts +122 -0
- package/src/plugins/core/tags/tag-badge.tsx +57 -0
- package/src/plugins/core/tags/tag-color-classes.ts +61 -0
- package/src/plugins/core/tags/tag-color-picker.tsx +56 -0
- package/src/plugins/core/tags/tag-components-index.ts +23 -0
- package/src/plugins/core/tags/tag-manager.tsx +212 -0
- package/src/plugins/core/tags/tag-selector.tsx +169 -0
- package/src/plugins/core/tags/tags-collection.ts +40 -0
- package/src/plugins/core/tags/ui.ts +24 -0
- package/src/plugins/plugins.gen.ts +3 -3
- package/src/plugins/ui.gen.ts +1 -1
- package/src/providers/index.tsx +3 -3
- package/src/providers/timezone-provider.tsx +1 -1
- package/src/router.tsx +2 -2
- package/src/routes/__root.tsx +2 -2
- package/src/routes/_login/schemas/-auth.ts +1 -1
- package/src/routes/_nav/changelog/route.lazy.tsx +1 -1
- package/src/routes/_nav/changelog/route.tsx +1 -1
- package/src/routes/_nav/dashboard/-components/avatar-group.tsx +2 -2
- package/src/routes/_nav/dashboard/route.tsx +1 -1
- package/src/routes/_nav/inspiration/route.tsx +1 -1
- package/src/routes/_nav/notifications/route.tsx +1 -1
- package/src/routes/_nav/prd/$id/route.tsx +1 -1
- package/src/routes/_nav/prd/index.tsx +1 -1
- package/src/routes/_nav/prd/route.tsx +1 -1
- package/src/routes/_nav/projects/$projectId/index.lazy.tsx +1 -1
- package/src/routes/_nav/route.tsx +1 -1
- package/src/routes/_nav/settings/account/route.tsx +1 -1
- package/src/routes/_nav/settings/route.tsx +1 -1
- package/src/routes/_nav/tags/$id/route.tsx +1 -1
- package/src/routes/_nav/tags/index.tsx +1 -1
- package/src/routes/_nav/tags/route.tsx +1 -1
- package/src/routes/_nav/tags/settings/route.tsx +1 -1
- package/src/routes/api/auth/desktop-callback.ts +1 -1
- package/src/routes/api/chat.ts +2 -2
- package/src/routes/api/notifications/stream.ts +1 -1
- package/src/routes/api/story-ai.ts +1 -1
- package/src/routes/invite/$token/route.lazy.tsx +1 -1
- package/src/routes/server.ai-stream.ts +1 -1
- package/src/routes/share/$versionId/route.lazy.tsx +1 -1
- package/src/routes/share/prd/$prdId/route.tsx +1 -1
- package/src/server/__tests__/agent-client-graph.test.ts +8 -5
- package/src/server/__tests__/resource-registry.test.ts +1 -1
- package/src/server/ai-gateway/__tests__/conformance.test.ts +43 -0
- package/src/server/ai-gateway/__tests__/embedding-request.test.ts +84 -0
- package/src/server/ai-gateway/__tests__/embedding.test.ts +42 -0
- package/src/server/ai-gateway/__tests__/interrupt-store.test.ts +539 -0
- package/src/server/ai-gateway/__tests__/knowledge-scope.test.ts +207 -0
- package/src/server/ai-gateway/__tests__/label-suggest.test.ts +113 -0
- package/src/server/ai-gateway/__tests__/message-store.test.ts +197 -0
- package/src/server/ai-gateway/__tests__/rerank.test.ts +128 -0
- package/src/server/ai-gateway/__tests__/run-store.test.ts +378 -0
- package/src/server/ai-gateway/__tests__/runtime.test.ts +58 -0
- package/src/server/ai-gateway/__tests__/story-prompt.test.ts +34 -0
- package/src/server/ai-gateway/__tests__/tools-select.test.ts +103 -0
- package/src/server/ai-gateway/__tests__/unified-router.test.ts +124 -0
- package/src/server/ai-gateway/adapter.ts +255 -0
- package/src/server/ai-gateway/chat-handler.ts +238 -0
- package/src/server/ai-gateway/chat-stream-builder.ts +91 -0
- package/src/server/ai-gateway/connectivity-check.ts +148 -0
- package/src/server/ai-gateway/embedding.ts +67 -0
- package/src/server/ai-gateway/index.ts +111 -0
- package/src/server/ai-gateway/label-suggest.ts +126 -0
- package/src/server/ai-gateway/middlewares/index.ts +19 -0
- package/src/server/ai-gateway/middlewares/logger.ts +35 -0
- package/src/server/ai-gateway/middlewares/rate-limit.ts +40 -0
- package/src/server/ai-gateway/model-fetch.ts +168 -0
- package/src/server/ai-gateway/persistence/index.ts +36 -0
- package/src/server/ai-gateway/persistence/interrupt-store.ts +154 -0
- package/src/server/ai-gateway/persistence/message-store.ts +124 -0
- package/src/server/ai-gateway/persistence/run-store.ts +120 -0
- package/src/server/ai-gateway/ports.ts +71 -0
- package/src/server/ai-gateway/pro-services.ts +25 -0
- package/src/server/ai-gateway/provider-router.ts +238 -0
- package/src/server/ai-gateway/provider-tools.ts +42 -0
- package/src/server/ai-gateway/rerank.ts +63 -0
- package/src/server/ai-gateway/runtime.ts +42 -0
- package/src/server/ai-gateway/story-handler.ts +171 -0
- package/src/server/ai-gateway/story-prompt.ts +68 -0
- package/src/server/ai-gateway/tools/definitions.ts +99 -0
- package/src/server/ai-gateway/tools/delete-project.ts +39 -0
- package/src/server/ai-gateway/tools/index.ts +31 -0
- package/src/server/ai-gateway/tools/knowledge-scope.ts +56 -0
- package/src/server/ai-gateway/tools/select.ts +53 -0
- package/src/server/ai-gateway/tools/server.ts +198 -0
- package/src/server/ai-gateway/tools.ts +7 -0
- package/src/server/ai-gateway/types.ts +42 -0
- package/src/server/ai-gateway/unified-router.ts +180 -0
- package/src/server/ai-ports.ts +2 -2
- package/src/server/entitlements-token-client.ts +1 -1
- package/src/server/entitlements-token.ts +1 -1
- package/src/server/entitlements.ts +1 -1
- package/src/server/middlewares/rate-limit-server-fn.ts +1 -1
- package/src/server/notifications/event-bus.ts +1 -1
- package/src/server/notifications/notification-service.ts +3 -3
- package/src/server/resources.ts +1 -1
- package/src/server/serverFns/__tests__/knowledge-index.test.ts +1 -1
- package/src/server/serverFns/agents/agent-crud.ts +1 -1
- package/src/server/serverFns/agents/resolve-overrides.ts +2 -2
- package/src/server/serverFns/ai/agent-conversations.ts +1 -1
- package/src/server/serverFns/ai/fill-annotation.ts +1 -1
- package/src/server/serverFns/ai/generate-prototype.ts +1 -1
- package/src/server/serverFns/ai/providers.ts +1 -1
- package/src/server/serverFns/auth/session.ts +1 -1
- package/src/server/serverFns/billing.ts +1 -1
- package/src/server/serverFns/changelog/fetch.ts +1 -1
- package/src/server/serverFns/comments.ts +1 -1
- package/src/server/serverFns/components.ts +1 -1
- package/src/server/serverFns/knowledge-index-utils.ts +1 -1
- package/src/server/serverFns/locale.ts +1 -1
- package/src/server/serverFns/notifications.ts +1 -1
- package/src/server/serverFns/reviews.ts +1 -1
- package/src/server/serverFns/share/verify-password.ts +1 -1
- package/src/server/serverFns/share/versions.ts +1 -1
- package/src/server/serverFns/story/__tests__/label-suggest-fn.test.ts +2 -2
- package/src/server/serverFns/story/story-crud/label-suggest-core.ts +1 -1
- package/src/server/serverFns/translation.ts +1 -1
- package/src/shared/ai-cli/adapter.ts +59 -0
- package/src/shared/ai-cli/cli-detector.ts +64 -0
- package/src/start.ts +1 -1
- package/vite.shared.ts +1 -5
- package/src/lib/i18n/client.ts +0 -1
- package/src/lib/i18n/config.ts +0 -1
- package/src/lib/i18n/detect.ts +0 -1
- package/src/lib/i18n/server.ts +0 -1
- package/src/lib/i18n/types.ts +0 -1
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// AllBlue - 理想之海
|
|
4
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
5
|
+
//
|
|
6
|
+
// This program is free software: you can redistribute it and/or modify
|
|
7
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
// (at your option) any later version.
|
|
10
|
+
//
|
|
11
|
+
// This program is distributed in the hope that it will be useful,
|
|
12
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
// GNU Affero General Public License for more details.
|
|
15
|
+
//
|
|
16
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
20
|
+
|
|
21
|
+
vi.mock("@allbluecn/database", () => ({
|
|
22
|
+
prisma: {
|
|
23
|
+
chatRun: {
|
|
24
|
+
upsert: vi.fn(),
|
|
25
|
+
update: vi.fn(),
|
|
26
|
+
findUnique: vi.fn(),
|
|
27
|
+
findFirst: vi.fn(),
|
|
28
|
+
findMany: vi.fn(),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
vi.mock("@tanstack/ai", () => ({
|
|
34
|
+
defineRunStore: vi.fn((store) => store),
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
import { prisma } from "@allbluecn/database";
|
|
38
|
+
|
|
39
|
+
const mockPrisma = prisma as unknown as {
|
|
40
|
+
chatRun: {
|
|
41
|
+
upsert: ReturnType<typeof vi.fn>;
|
|
42
|
+
update: ReturnType<typeof vi.fn>;
|
|
43
|
+
findUnique: ReturnType<typeof vi.fn>;
|
|
44
|
+
findFirst: ReturnType<typeof vi.fn>;
|
|
45
|
+
findMany: ReturnType<typeof vi.fn>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
describe("runStore", () => {
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
vi.clearAllMocks();
|
|
52
|
+
mockPrisma.chatRun.findUnique.mockResolvedValue(null);
|
|
53
|
+
mockPrisma.chatRun.findFirst.mockResolvedValue(null);
|
|
54
|
+
mockPrisma.chatRun.findMany.mockResolvedValue([]);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("createOrResume creates a new run with status=running", async () => {
|
|
58
|
+
const createdRow = {
|
|
59
|
+
id: "run1",
|
|
60
|
+
threadId: "thread1",
|
|
61
|
+
userId: "user1",
|
|
62
|
+
status: "running",
|
|
63
|
+
startedAt: new Date(1000),
|
|
64
|
+
finishedAt: null,
|
|
65
|
+
detachedSince: null,
|
|
66
|
+
usage: null,
|
|
67
|
+
error: null,
|
|
68
|
+
};
|
|
69
|
+
mockPrisma.chatRun.upsert.mockResolvedValue(createdRow);
|
|
70
|
+
|
|
71
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
72
|
+
const record = await store.createOrResume({
|
|
73
|
+
runId: "run1",
|
|
74
|
+
threadId: "thread1",
|
|
75
|
+
startedAt: 1000,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(mockPrisma.chatRun.upsert).toHaveBeenCalledWith({
|
|
79
|
+
where: { id: "run1" },
|
|
80
|
+
create: {
|
|
81
|
+
id: "run1",
|
|
82
|
+
threadId: "thread1",
|
|
83
|
+
userId: "user1",
|
|
84
|
+
status: "running",
|
|
85
|
+
startedAt: new Date(1000),
|
|
86
|
+
},
|
|
87
|
+
update: {},
|
|
88
|
+
});
|
|
89
|
+
expect(record).toMatchObject({
|
|
90
|
+
runId: "run1",
|
|
91
|
+
threadId: "thread1",
|
|
92
|
+
status: "running",
|
|
93
|
+
startedAt: 1000,
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("createOrResume is idempotent for existing run", async () => {
|
|
98
|
+
const existingRow = {
|
|
99
|
+
id: "run1",
|
|
100
|
+
threadId: "thread1",
|
|
101
|
+
userId: "user1",
|
|
102
|
+
status: "running",
|
|
103
|
+
startedAt: new Date(5000),
|
|
104
|
+
finishedAt: null,
|
|
105
|
+
detachedSince: null,
|
|
106
|
+
usage: null,
|
|
107
|
+
error: null,
|
|
108
|
+
};
|
|
109
|
+
mockPrisma.chatRun.upsert.mockResolvedValue(existingRow);
|
|
110
|
+
|
|
111
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
112
|
+
const record = await store.createOrResume({
|
|
113
|
+
runId: "run1",
|
|
114
|
+
threadId: "thread1",
|
|
115
|
+
startedAt: 9999,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
expect(mockPrisma.chatRun.upsert).toHaveBeenCalledWith(
|
|
119
|
+
expect.objectContaining({
|
|
120
|
+
create: expect.objectContaining({
|
|
121
|
+
startedAt: new Date(9999),
|
|
122
|
+
}),
|
|
123
|
+
update: {},
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
expect(record).toMatchObject({
|
|
127
|
+
runId: "run1",
|
|
128
|
+
startedAt: 5000,
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("update modifies status and finishedAt", async () => {
|
|
133
|
+
const existingRow = {
|
|
134
|
+
id: "run1",
|
|
135
|
+
threadId: "thread1",
|
|
136
|
+
userId: "user1",
|
|
137
|
+
status: "running",
|
|
138
|
+
startedAt: new Date(1000),
|
|
139
|
+
finishedAt: null,
|
|
140
|
+
detachedSince: null,
|
|
141
|
+
usage: null,
|
|
142
|
+
error: null,
|
|
143
|
+
};
|
|
144
|
+
mockPrisma.chatRun.findUnique.mockResolvedValue(existingRow);
|
|
145
|
+
mockPrisma.chatRun.update.mockResolvedValue({} as any);
|
|
146
|
+
|
|
147
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
148
|
+
await store.update("run1", { status: "completed", finishedAt: 2000 });
|
|
149
|
+
|
|
150
|
+
expect(mockPrisma.chatRun.findUnique).toHaveBeenCalledWith({
|
|
151
|
+
where: { id: "run1" },
|
|
152
|
+
});
|
|
153
|
+
expect(mockPrisma.chatRun.update).toHaveBeenCalledWith({
|
|
154
|
+
where: { id: "run1" },
|
|
155
|
+
data: {
|
|
156
|
+
status: "completed",
|
|
157
|
+
finishedAt: new Date(2000),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("update no-ops for unknown runId without throwing", async () => {
|
|
163
|
+
mockPrisma.chatRun.findUnique.mockResolvedValue(null);
|
|
164
|
+
|
|
165
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
166
|
+
await expect(store.update("unknown", { status: "completed" })).resolves.toBe(
|
|
167
|
+
undefined,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
expect(mockPrisma.chatRun.findUnique).toHaveBeenCalledWith({
|
|
171
|
+
where: { id: "unknown" },
|
|
172
|
+
});
|
|
173
|
+
expect(mockPrisma.chatRun.update).not.toHaveBeenCalled();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("get returns known run", async () => {
|
|
177
|
+
const row = {
|
|
178
|
+
id: "run1",
|
|
179
|
+
threadId: "thread1",
|
|
180
|
+
userId: "user1",
|
|
181
|
+
status: "completed",
|
|
182
|
+
startedAt: new Date(1000),
|
|
183
|
+
finishedAt: new Date(2000),
|
|
184
|
+
detachedSince: null,
|
|
185
|
+
usage: { input: 100, output: 200 },
|
|
186
|
+
error: null,
|
|
187
|
+
};
|
|
188
|
+
mockPrisma.chatRun.findUnique.mockResolvedValue(row);
|
|
189
|
+
|
|
190
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
191
|
+
const record = await store.get("run1");
|
|
192
|
+
|
|
193
|
+
expect(mockPrisma.chatRun.findUnique).toHaveBeenCalledWith({
|
|
194
|
+
where: { id: "run1" },
|
|
195
|
+
});
|
|
196
|
+
expect(record).toMatchObject({
|
|
197
|
+
runId: "run1",
|
|
198
|
+
threadId: "thread1",
|
|
199
|
+
status: "completed",
|
|
200
|
+
startedAt: 1000,
|
|
201
|
+
finishedAt: 2000,
|
|
202
|
+
usage: { input: 100, output: 200 },
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("get returns null for unknown runId", async () => {
|
|
207
|
+
mockPrisma.chatRun.findUnique.mockResolvedValue(null);
|
|
208
|
+
|
|
209
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
210
|
+
const record = await store.get("nonexistent");
|
|
211
|
+
|
|
212
|
+
expect(mockPrisma.chatRun.findUnique).toHaveBeenCalledWith({
|
|
213
|
+
where: { id: "nonexistent" },
|
|
214
|
+
});
|
|
215
|
+
expect(record).toBeNull();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("findActiveRun returns latest running run for thread", async () => {
|
|
219
|
+
const runningRow = {
|
|
220
|
+
id: "run2",
|
|
221
|
+
threadId: "thread1",
|
|
222
|
+
userId: "user1",
|
|
223
|
+
status: "running",
|
|
224
|
+
startedAt: new Date(3000),
|
|
225
|
+
finishedAt: null,
|
|
226
|
+
detachedSince: null,
|
|
227
|
+
usage: null,
|
|
228
|
+
error: null,
|
|
229
|
+
};
|
|
230
|
+
mockPrisma.chatRun.findFirst.mockResolvedValue(runningRow);
|
|
231
|
+
|
|
232
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
233
|
+
const record = await store.findActiveRun("thread1");
|
|
234
|
+
|
|
235
|
+
expect(mockPrisma.chatRun.findFirst).toHaveBeenCalledWith({
|
|
236
|
+
where: {
|
|
237
|
+
threadId: "thread1",
|
|
238
|
+
userId: "user1",
|
|
239
|
+
status: { in: ["running", "interrupted"] },
|
|
240
|
+
},
|
|
241
|
+
orderBy: { startedAt: "desc" },
|
|
242
|
+
});
|
|
243
|
+
expect(record).toMatchObject({
|
|
244
|
+
runId: "run2",
|
|
245
|
+
status: "running",
|
|
246
|
+
startedAt: 3000,
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("findActiveRun returns null when no active run", async () => {
|
|
251
|
+
mockPrisma.chatRun.findFirst.mockResolvedValue(null);
|
|
252
|
+
|
|
253
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
254
|
+
const record = await store.findActiveRun("thread1");
|
|
255
|
+
|
|
256
|
+
expect(record).toBeNull();
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it("listByThread returns runs in ascending startedAt order", async () => {
|
|
260
|
+
const rows = [
|
|
261
|
+
{
|
|
262
|
+
id: "run1",
|
|
263
|
+
threadId: "thread1",
|
|
264
|
+
userId: "user1",
|
|
265
|
+
status: "completed",
|
|
266
|
+
startedAt: new Date(1000),
|
|
267
|
+
finishedAt: new Date(1500),
|
|
268
|
+
detachedSince: null,
|
|
269
|
+
usage: null,
|
|
270
|
+
error: null,
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
id: "run2",
|
|
274
|
+
threadId: "thread1",
|
|
275
|
+
userId: "user1",
|
|
276
|
+
status: "running",
|
|
277
|
+
startedAt: new Date(2000),
|
|
278
|
+
finishedAt: null,
|
|
279
|
+
detachedSince: null,
|
|
280
|
+
usage: null,
|
|
281
|
+
error: null,
|
|
282
|
+
},
|
|
283
|
+
];
|
|
284
|
+
mockPrisma.chatRun.findMany.mockResolvedValue(rows);
|
|
285
|
+
|
|
286
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
287
|
+
const records = await store.listByThread?.("thread1");
|
|
288
|
+
|
|
289
|
+
expect(mockPrisma.chatRun.findMany).toHaveBeenCalledWith({
|
|
290
|
+
where: { threadId: "thread1", userId: "user1" },
|
|
291
|
+
orderBy: { startedAt: "asc" },
|
|
292
|
+
});
|
|
293
|
+
expect(records).toHaveLength(2);
|
|
294
|
+
expect(records![0]).toMatchObject({ runId: "run1", startedAt: 1000 });
|
|
295
|
+
expect(records![1]).toMatchObject({ runId: "run2", startedAt: 2000 });
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it("update serializes error to JSON", async () => {
|
|
299
|
+
const existingRow = {
|
|
300
|
+
id: "run1",
|
|
301
|
+
threadId: "thread1",
|
|
302
|
+
userId: "user1",
|
|
303
|
+
status: "running",
|
|
304
|
+
startedAt: new Date(1000),
|
|
305
|
+
finishedAt: null,
|
|
306
|
+
detachedSince: null,
|
|
307
|
+
usage: null,
|
|
308
|
+
error: null,
|
|
309
|
+
};
|
|
310
|
+
mockPrisma.chatRun.findUnique.mockResolvedValue(existingRow);
|
|
311
|
+
mockPrisma.chatRun.update.mockResolvedValue({} as any);
|
|
312
|
+
|
|
313
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
314
|
+
await store.update("run1", {
|
|
315
|
+
error: { message: "timeout", code: "ETIMEDOUT" },
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
expect(mockPrisma.chatRun.update).toHaveBeenCalledWith({
|
|
319
|
+
where: { id: "run1" },
|
|
320
|
+
data: {
|
|
321
|
+
error: JSON.stringify({ message: "timeout", code: "ETIMEDOUT" }),
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it("rowToRecord parses error JSON from DB", async () => {
|
|
327
|
+
const row = {
|
|
328
|
+
id: "run1",
|
|
329
|
+
threadId: "thread1",
|
|
330
|
+
userId: "user1",
|
|
331
|
+
status: "failed",
|
|
332
|
+
startedAt: new Date(1000),
|
|
333
|
+
finishedAt: new Date(2000),
|
|
334
|
+
detachedSince: null,
|
|
335
|
+
usage: null,
|
|
336
|
+
error: JSON.stringify({ message: "fail", code: "EFAIL" }),
|
|
337
|
+
};
|
|
338
|
+
mockPrisma.chatRun.findUnique.mockResolvedValue(row);
|
|
339
|
+
|
|
340
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
341
|
+
const record = await store.get("run1");
|
|
342
|
+
|
|
343
|
+
expect(record).toMatchObject({
|
|
344
|
+
runId: "run1",
|
|
345
|
+
status: "failed",
|
|
346
|
+
finishedAt: 2000,
|
|
347
|
+
error: { message: "fail", code: "EFAIL" },
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it("listReclaimable returns detached running runs past TTL", async () => {
|
|
352
|
+
const row = {
|
|
353
|
+
id: "run1",
|
|
354
|
+
threadId: "thread1",
|
|
355
|
+
userId: "user1",
|
|
356
|
+
status: "running",
|
|
357
|
+
startedAt: new Date(1000),
|
|
358
|
+
finishedAt: null,
|
|
359
|
+
detachedSince: new Date(5000),
|
|
360
|
+
usage: null,
|
|
361
|
+
error: null,
|
|
362
|
+
};
|
|
363
|
+
mockPrisma.chatRun.findMany.mockResolvedValue([row]);
|
|
364
|
+
|
|
365
|
+
const store = (await import("../persistence/run-store")).runStore("user1");
|
|
366
|
+
const records = await store.listReclaimable?.({ now: 10000, ttlMs: 6000 });
|
|
367
|
+
|
|
368
|
+
expect(mockPrisma.chatRun.findMany).toHaveBeenCalledWith({
|
|
369
|
+
where: {
|
|
370
|
+
userId: "user1",
|
|
371
|
+
status: "running",
|
|
372
|
+
detachedSince: { lte: expect.any(Date) },
|
|
373
|
+
},
|
|
374
|
+
});
|
|
375
|
+
expect(records).toHaveLength(1);
|
|
376
|
+
expect(records![0]).toMatchObject({ runId: "run1", detachedSince: 5000 });
|
|
377
|
+
});
|
|
378
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// AllBlue - 理想之海
|
|
4
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
5
|
+
//
|
|
6
|
+
// This program is free software: you can redistribute it and/or modify
|
|
7
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
// (at your option) any later version.
|
|
10
|
+
//
|
|
11
|
+
// This program is distributed in the hope that it will be useful,
|
|
12
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
// GNU Affero General Public License for more details.
|
|
15
|
+
//
|
|
16
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
import { describe, it, expect, beforeEach } from "vitest"
|
|
20
|
+
import { registerGatewayPorts, getPorts, resetGatewayPortsForTest } from "../runtime"
|
|
21
|
+
|
|
22
|
+
describe("gateway runtime", () => {
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
resetGatewayPortsForTest()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it("未注册时 getPorts 抛出明确错误", () => {
|
|
28
|
+
expect(() => getPorts()).toThrowError(/\[ai-gateway\] ports 未注册/)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const fullPorts = {
|
|
32
|
+
keyCipher: { decrypt: (k: string) => k },
|
|
33
|
+
accessPolicy: { requireFeature: async () => undefined },
|
|
34
|
+
auth: { getSession: async () => null },
|
|
35
|
+
remoteAuth: { read: async () => null },
|
|
36
|
+
webSearch: { search: async () => ({ results: [] }) },
|
|
37
|
+
infra: {
|
|
38
|
+
ragSearch: async () => [],
|
|
39
|
+
indexDocumentEmbeddings: async () => 0,
|
|
40
|
+
resolveKnowledgeAiConfig: async () => null,
|
|
41
|
+
deleteEmbeddings: async () => undefined,
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
it("注册后 getPorts 返回注册的实现", () => {
|
|
46
|
+
const cipher = { decrypt: (k: string) => k }
|
|
47
|
+
registerGatewayPorts({ ...fullPorts, keyCipher: cipher } as never)
|
|
48
|
+
expect(getPorts().keyCipher).toBe(cipher)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it("重复注册幂等覆盖", () => {
|
|
52
|
+
const a = { decrypt: (k: string) => k }
|
|
53
|
+
const b = { decrypt: (k: string) => k }
|
|
54
|
+
registerGatewayPorts({ ...fullPorts, keyCipher: a } as never)
|
|
55
|
+
registerGatewayPorts({ keyCipher: b } as never)
|
|
56
|
+
expect(getPorts().keyCipher).toBe(b)
|
|
57
|
+
})
|
|
58
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// AllBlue - 理想之海
|
|
4
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
5
|
+
//
|
|
6
|
+
// This program is free software: you can redistribute it and/or modify
|
|
7
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
// (at your option) any later version.
|
|
10
|
+
//
|
|
11
|
+
// This program is distributed in the hope that it will be useful,
|
|
12
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
// GNU Affero General Public License for more details.
|
|
15
|
+
//
|
|
16
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
import { describe, it, expect } from "vitest"
|
|
20
|
+
import { buildStorySystemPrompt } from "../story-prompt"
|
|
21
|
+
|
|
22
|
+
describe("buildStorySystemPrompt labelHint", () => {
|
|
23
|
+
it("有标签时包含收束与 2-4 字规则", () => {
|
|
24
|
+
const p = buildStorySystemPrompt({ taskType: "create", requirement: "x", availableLabels: ["性能"] })
|
|
25
|
+
expect(p).toContain("优先从可用标签中选用")
|
|
26
|
+
expect(p).toContain("2-4 个汉字")
|
|
27
|
+
expect(p).toContain("性能")
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it("无标签时禁止输出 labelNames", () => {
|
|
31
|
+
const p = buildStorySystemPrompt({ taskType: "create", requirement: "x" })
|
|
32
|
+
expect(p).toContain("不要输出 labelNames 字段")
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { describe, it, expect } from "vitest"
|
|
3
|
+
import { AGENT_TOOL_KEYS, selectTools } from "../tools/select"
|
|
4
|
+
|
|
5
|
+
type MockTool = { name: string; value: string }
|
|
6
|
+
|
|
7
|
+
const allTools: MockTool[] = [
|
|
8
|
+
{ name: "knowledge_search", value: "ks" },
|
|
9
|
+
{ name: "document_action", value: "da" },
|
|
10
|
+
{ name: "user_data_query", value: "ud" },
|
|
11
|
+
{ name: "web_search", value: "ws" },
|
|
12
|
+
{ name: "reindex_knowledge_base", value: "rk" },
|
|
13
|
+
{ name: "delete_project", value: "dp" },
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
describe("AGENT_TOOL_KEYS", () => {
|
|
17
|
+
it("包含所有已注册的 agent 工具", () => {
|
|
18
|
+
expect(AGENT_TOOL_KEYS).toContain("knowledge_search")
|
|
19
|
+
expect(AGENT_TOOL_KEYS).toContain("document_action")
|
|
20
|
+
expect(AGENT_TOOL_KEYS).toContain("user_data_query")
|
|
21
|
+
expect(AGENT_TOOL_KEYS).toContain("web_search")
|
|
22
|
+
expect(AGENT_TOOL_KEYS).toContain("reindex_knowledge_base")
|
|
23
|
+
expect(AGENT_TOOL_KEYS).toContain("delete_project")
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it("恰好包含 6 个工具", () => {
|
|
27
|
+
expect(AGENT_TOOL_KEYS.length).toBe(6)
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
describe("selectTools", () => {
|
|
32
|
+
it("缺省 allowedKeys 时返回全量工具", () => {
|
|
33
|
+
const result = selectTools(allTools)
|
|
34
|
+
expect(result).toHaveLength(6)
|
|
35
|
+
expect(result).toEqual(allTools)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it("空数组 allowedKeys 时返回全量工具", () => {
|
|
39
|
+
const result = selectTools(allTools, [])
|
|
40
|
+
expect(result).toHaveLength(6)
|
|
41
|
+
expect(result.map((t) => t.name)).toEqual(allTools.map((t) => t.name))
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it("白名单过滤只保留匹配的工具(delete_project 除外)", () => {
|
|
45
|
+
const result = selectTools(allTools, ["knowledge_search", "web_search"])
|
|
46
|
+
expect(result.map((t) => t.name)).toEqual(["knowledge_search", "web_search", "delete_project"])
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it("delete_project 永留:即使不在白名单中也包含", () => {
|
|
50
|
+
const result = selectTools(allTools, ["knowledge_search"])
|
|
51
|
+
expect(result).toHaveLength(2)
|
|
52
|
+
expect(result.map((t) => t.name)).toEqual(["knowledge_search", "delete_project"])
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it("delete_project 在白名单中正常包含", () => {
|
|
56
|
+
const result = selectTools(allTools, ["knowledge_search", "delete_project"])
|
|
57
|
+
expect(result).toHaveLength(2)
|
|
58
|
+
expect(result.map((t) => t.name)).toEqual(["knowledge_search", "delete_project"])
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it("未知工具 key 被丢弃,不报错", () => {
|
|
62
|
+
const result = selectTools(allTools, ["knowledge_search", "nonexistent_tool"])
|
|
63
|
+
expect(result).toHaveLength(2)
|
|
64
|
+
expect(result.map((t) => t.name)).toEqual(["knowledge_search", "delete_project"])
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it("白名单全为空结果时仍保留 delete_project", () => {
|
|
68
|
+
const result = selectTools(allTools, ["nonexistent_a", "nonexistent_b"])
|
|
69
|
+
expect(result).toHaveLength(1)
|
|
70
|
+
expect(result[0].name).toBe("delete_project")
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it("输入为空数组时返回空数组", () => {
|
|
74
|
+
const result = selectTools([] as MockTool[])
|
|
75
|
+
expect(result).toEqual([])
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it("不修改原始数组(返回新数组)", () => {
|
|
79
|
+
const original = [...allTools]
|
|
80
|
+
selectTools(allTools, ["knowledge_search"])
|
|
81
|
+
expect(allTools).toEqual(original)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it("同步执行,不返回 Promise", () => {
|
|
85
|
+
const result = selectTools(allTools, ["web_search"])
|
|
86
|
+
expect(result).not.toBeInstanceOf(Promise)
|
|
87
|
+
expect(Array.isArray(result)).toBe(true)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it("保持原始顺序", () => {
|
|
91
|
+
const result = selectTools(allTools, ["web_search", "knowledge_search"])
|
|
92
|
+
expect(result.map((t) => t.name)).toEqual(["knowledge_search", "web_search", "delete_project"])
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it("别名 google_search 可匹配 web_search 白名单", () => {
|
|
96
|
+
const geminiTools: MockTool[] = [
|
|
97
|
+
{ name: "google_search", value: "gs" },
|
|
98
|
+
{ name: "knowledge_search", value: "ks" },
|
|
99
|
+
]
|
|
100
|
+
const result = selectTools(geminiTools, ["web_search", "knowledge_search"])
|
|
101
|
+
expect(result.map((t) => t.name)).toEqual(["google_search", "knowledge_search"])
|
|
102
|
+
})
|
|
103
|
+
})
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
3
|
+
|
|
4
|
+
vi.mock("../runtime", () => ({
|
|
5
|
+
getPorts: () => ({
|
|
6
|
+
remoteAuth: { read: async () => null },
|
|
7
|
+
accessPolicy: { requireFeature: async () => {} },
|
|
8
|
+
}),
|
|
9
|
+
}))
|
|
10
|
+
|
|
11
|
+
vi.mock('../provider-router', () => ({
|
|
12
|
+
resolveAiConfigForModel: vi.fn(),
|
|
13
|
+
resolveDefaultProviderConfig: vi.fn(),
|
|
14
|
+
}))
|
|
15
|
+
vi.mock('../adapter', () => ({
|
|
16
|
+
resolveAiConfig: vi.fn(),
|
|
17
|
+
createProviderAdapter: vi.fn(),
|
|
18
|
+
createAdapter: vi.fn(),
|
|
19
|
+
}))
|
|
20
|
+
vi.mock('@allblue/pro', () => ({
|
|
21
|
+
proModule: { isAvailable: false, hostedAi: null },
|
|
22
|
+
}))
|
|
23
|
+
vi.mock('@allbluecn/database', () => ({ prisma: {} }))
|
|
24
|
+
|
|
25
|
+
import { resolveUnifiedAiStream, NoAiAvailableError } from '../unified-router'
|
|
26
|
+
import {
|
|
27
|
+
resolveAiConfigForModel,
|
|
28
|
+
resolveDefaultProviderConfig,
|
|
29
|
+
} from '../provider-router'
|
|
30
|
+
import {
|
|
31
|
+
resolveAiConfig,
|
|
32
|
+
createProviderAdapter,
|
|
33
|
+
createAdapter,
|
|
34
|
+
} from '../adapter'
|
|
35
|
+
|
|
36
|
+
const mockResolveForModel = resolveAiConfigForModel as ReturnType<typeof vi.fn>
|
|
37
|
+
const mockResolveDefault = resolveDefaultProviderConfig as ReturnType<typeof vi.fn>
|
|
38
|
+
const mockResolveAiConfig = resolveAiConfig as ReturnType<typeof vi.fn>
|
|
39
|
+
const mockCreateProviderAdapter = createProviderAdapter as ReturnType<typeof vi.fn>
|
|
40
|
+
const mockCreateAdapter = createAdapter as ReturnType<typeof vi.fn>
|
|
41
|
+
|
|
42
|
+
describe('resolveUnifiedAiStream 决策树', () => {
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
vi.clearAllMocks()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('BYOK 模型路由优先:指定 model 且命中 → 用 BYOK', async () => {
|
|
48
|
+
mockResolveForModel.mockResolvedValue({
|
|
49
|
+
providerId: 'openai',
|
|
50
|
+
adapterKind: 'openai',
|
|
51
|
+
apiKey: 'sk-xxx',
|
|
52
|
+
baseUrl: null,
|
|
53
|
+
model: 'gpt-4o',
|
|
54
|
+
isLocal: false,
|
|
55
|
+
})
|
|
56
|
+
mockCreateProviderAdapter.mockResolvedValue({})
|
|
57
|
+
|
|
58
|
+
const req = {
|
|
59
|
+
userId: 'u1',
|
|
60
|
+
messages: [{ role: 'user' as const, content: 'hi' }],
|
|
61
|
+
model: 'gpt-4o',
|
|
62
|
+
}
|
|
63
|
+
await resolveUnifiedAiStream(req)
|
|
64
|
+
|
|
65
|
+
expect(mockResolveForModel).toHaveBeenCalledWith('u1', 'gpt-4o')
|
|
66
|
+
expect(mockResolveDefault).not.toHaveBeenCalled()
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('BYOK 默认配置兜底:无 model,但用户有 enabled provider → 用 BYOK', async () => {
|
|
70
|
+
mockResolveForModel.mockResolvedValue(null)
|
|
71
|
+
mockResolveDefault.mockResolvedValue({
|
|
72
|
+
providerId: 'anthropic',
|
|
73
|
+
adapterKind: 'anthropic',
|
|
74
|
+
apiKey: 'sk-yyy',
|
|
75
|
+
baseUrl: null,
|
|
76
|
+
model: 'claude-sonnet-4',
|
|
77
|
+
isLocal: false,
|
|
78
|
+
})
|
|
79
|
+
mockCreateProviderAdapter.mockResolvedValue({})
|
|
80
|
+
|
|
81
|
+
const req = {
|
|
82
|
+
userId: 'u1',
|
|
83
|
+
messages: [{ role: 'user' as const, content: 'hi' }],
|
|
84
|
+
}
|
|
85
|
+
await resolveUnifiedAiStream(req)
|
|
86
|
+
|
|
87
|
+
expect(mockResolveDefault).toHaveBeenCalledWith('u1')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('旧字段/env 兜底:新表无配置但有旧 aiApiKey → 用 BYOK(fallback)', async () => {
|
|
91
|
+
mockResolveForModel.mockResolvedValue(null)
|
|
92
|
+
mockResolveDefault.mockResolvedValue(null)
|
|
93
|
+
mockResolveAiConfig.mockResolvedValue({
|
|
94
|
+
provider: 'openrouter',
|
|
95
|
+
apiKey: 'sk-or-xxx',
|
|
96
|
+
model: 'openai/gpt-4o-mini',
|
|
97
|
+
source: 'env',
|
|
98
|
+
})
|
|
99
|
+
mockCreateAdapter.mockReturnValue({})
|
|
100
|
+
|
|
101
|
+
const req = {
|
|
102
|
+
userId: 'u1',
|
|
103
|
+
messages: [{ role: 'user' as const, content: 'hi' }],
|
|
104
|
+
}
|
|
105
|
+
await resolveUnifiedAiStream(req)
|
|
106
|
+
|
|
107
|
+
expect(mockResolveAiConfig).toHaveBeenCalledWith('u1')
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('开源版(hostedAi === null)+ 无 BYOK → 抛 NoAiAvailableError', async () => {
|
|
111
|
+
mockResolveForModel.mockResolvedValue(null)
|
|
112
|
+
mockResolveDefault.mockResolvedValue(null)
|
|
113
|
+
mockResolveAiConfig.mockResolvedValue(null)
|
|
114
|
+
|
|
115
|
+
const req = {
|
|
116
|
+
userId: 'u1',
|
|
117
|
+
messages: [{ role: 'user' as const, content: 'hi' }],
|
|
118
|
+
workspaceId: 'ws1',
|
|
119
|
+
}
|
|
120
|
+
await expect(resolveUnifiedAiStream(req)).rejects.toMatchObject({
|
|
121
|
+
name: 'NoAiAvailableError',
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
})
|