@nextclaw/ui 0.12.10 → 0.12.12
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/CHANGELOG.md +103 -10
- package/dist/assets/api-DnPN4SyA.js +15 -0
- package/dist/assets/app-manager-provider-M7TngYxx.js +1 -0
- package/dist/assets/app-navigation.config-B5YIdRju.js +1 -0
- package/dist/assets/{book-open-DzdUViDm.js → book-open-B4mOKdz8.js} +1 -1
- package/dist/assets/channels-list-page-Cm-Bbu6u.js +8 -0
- package/dist/assets/chat-C0ZNZtS3.js +58 -0
- package/dist/assets/chat-page-CGHNhXaw.js +1 -0
- package/dist/assets/chunk-JZWAC4HX-BJer-fqD.js +3 -0
- package/dist/assets/config-split-page-B3PRA_AV.js +1 -0
- package/dist/assets/{createLucideIcon-dy5ie7Ox.js → createLucideIcon-C_GFKVuW.js} +1 -1
- package/dist/assets/desktop-update-config-Dfh-3uma.js +1 -0
- package/dist/assets/dialog-D-I7ONHQ.js +5 -0
- package/dist/assets/{dist-Cy7_j6hA.js → dist-DreLBS93.js} +1 -1
- package/dist/assets/doc-browser-CoKIUCJj.js +1 -0
- package/dist/assets/doc-browser-CwgI7ipB.js +1 -0
- package/dist/assets/doc-browser-DYKpRqe-.js +1 -0
- package/dist/assets/doc-browser-context-Dib9sS83.js +1 -0
- package/dist/assets/es2015-DMSUl3fm.js +41 -0
- package/dist/assets/{external-link-kZSAO8nT.js → external-link-DP2IJ7AM.js} +1 -1
- package/dist/assets/folder-BPwc278w.js +1 -0
- package/dist/assets/{hash-BHJC2Ovu.js → hash-CvcvtMBq.js} +1 -1
- package/dist/assets/i18n-BnNAQpVM.js +1 -0
- package/dist/assets/index-Bc6c1kIx.js +2 -0
- package/dist/assets/index-mRmSAB-e.css +1 -0
- package/dist/assets/key-round-BQXmPSxD.js +1 -0
- package/dist/assets/loader-circle-C6gg2m2a.js +1 -0
- package/dist/assets/{LogoBadge-hO7tY7hE.js → logo-badge-uB4SwANR.js} +1 -1
- package/dist/assets/{logos-B7gRObP8.js → logos-BcELLmYh.js} +1 -1
- package/dist/assets/marketplace-page-BCrS-jH6.js +49 -0
- package/dist/assets/marketplace-page-DVrlpB68.js +1 -0
- package/dist/assets/mcp-marketplace-page-CjrxT6wI.js +40 -0
- package/dist/assets/mcp-marketplace-page-pQ_A38fH.js +1 -0
- package/dist/assets/message-square-CLVODA23.js +1 -0
- package/dist/assets/model-config-D4myteLK.js +1 -0
- package/dist/assets/notice-card-DX_NEZTQ.js +1 -0
- package/dist/assets/play-DeNVUA5C.js +1 -0
- package/dist/assets/plus-BptLViq1.js +1 -0
- package/dist/assets/popover-Dm_NQ3Cs.js +1 -0
- package/dist/assets/provider-scoped-model-input-BLHImwI5.js +1 -0
- package/dist/assets/providers-list-DsBFslNi.js +1 -0
- package/dist/assets/{refresh-ccw-COVhNHtN.js → refresh-ccw-CeG203yU.js} +1 -1
- package/dist/assets/remote-CQQykOYe.js +1 -0
- package/dist/assets/{rotate-cw-oHMKJMC8.js → rotate-cw-F7aThvYj.js} +1 -1
- package/dist/assets/runtime-config-page-Bz9r68Rf.js +1 -0
- package/dist/assets/{save-EqJPOF0G.js → save-7ztImRj7.js} +1 -1
- package/dist/assets/search-DZSNKEGp.js +1 -0
- package/dist/assets/search-config-C-6KpgRQ.js +1 -0
- package/dist/assets/secrets-config-MiMElvpm.js +3 -0
- package/dist/assets/select-RgeHgn_-.js +1 -0
- package/dist/assets/sessions-config-page-0KNW9QC_.js +2 -0
- package/dist/assets/setting-row-vwm4XKv2.js +1 -0
- package/dist/assets/settings-DjvNMJde.js +1 -0
- package/dist/assets/skeleton-5Mg6vZHN.js +1 -0
- package/dist/assets/sparkles-CyDTgTM4.js +1 -0
- package/dist/assets/{status-dot-DpPtVzQT.js → status-dot-aQU9Mia4.js} +1 -1
- package/dist/assets/{tabs-custom-YcZUWn3o.js → tabs-custom-C4P7g4vR.js} +1 -1
- package/dist/assets/tag-chip-DGqz3TON.js +1 -0
- package/dist/assets/theme-provider-CUppbOyN.js +1 -0
- package/dist/assets/tooltip-DQlSKhZ_.js +1 -0
- package/dist/assets/{trash-2-mJT6oWa2.js → trash-2-C1cdqL6V.js} +1 -1
- package/dist/assets/use-config-CrsavfWZ.js +1 -0
- package/dist/assets/use-confirm-dialog-D1AnLFlc.js +1 -0
- package/dist/assets/use-infinite-scroll-loader-DZhv-rmv.js +1 -0
- package/dist/assets/use-viewport-layout-CytJAPWM.js +1 -0
- package/dist/assets/x-BjMO7v8q.js +1 -0
- package/dist/index.html +39 -22
- package/module-structure.config.json +7 -0
- package/package.json +5 -5
- package/src/app/components/app-manager-provider.tsx +20 -0
- package/src/{components/providers/I18nProvider.tsx → app/components/i18n-provider.tsx} +1 -1
- package/src/{components → app/components}/layout/app-layout.test.tsx +50 -3
- package/src/app/components/layout/app-layout.tsx +54 -0
- package/src/{components → app/components}/layout/page-layout.tsx +1 -1
- package/src/app/components/layout/runtime-status-entry.test.tsx +101 -0
- package/src/app/components/layout/runtime-status-entry.tsx +95 -0
- package/src/app/components/layout/settings-entry-page.test.tsx +65 -0
- package/src/app/components/layout/settings-entry-page.tsx +13 -0
- package/src/{components → app/components}/layout/sidebar-items.tsx +2 -2
- package/src/{components → app/components}/layout/sidebar.layout.test.tsx +19 -12
- package/src/{components/layout/Sidebar.tsx → app/components/layout/sidebar.tsx} +25 -89
- package/src/{components/providers/ThemeProvider.tsx → app/components/theme-provider.tsx} +2 -2
- package/src/app/configs/app-navigation.config.ts +246 -0
- package/src/{hooks → app/hooks}/use-realtime-query-bridge.ts +36 -20
- package/src/app/hooks/use-viewport-layout.ts +15 -0
- package/src/app/index.tsx +261 -0
- package/src/app/managers/app.manager.ts +12 -0
- package/src/app/managers/viewport-layout.manager.ts +73 -0
- package/src/app/stores/viewport-layout.store.ts +32 -0
- package/src/{test/setup.ts → app/test/vitest-setup.ts} +3 -3
- package/src/{account → features/account}/components/account-panel.tsx +19 -19
- package/src/{components/auth → features/account/components}/login-page.tsx +4 -4
- package/src/{hooks → features/account/hooks}/use-auth.test.ts +1 -1
- package/src/{hooks → features/account/hooks}/use-auth.ts +3 -3
- package/src/features/account/index.ts +7 -0
- package/src/{account → features/account}/managers/account.manager.ts +6 -6
- package/src/{components/agents → features/agents/components}/agent-dialogs.tsx +11 -11
- package/src/{components/agents → features/agents/components}/agents-page.test.tsx +12 -9
- package/src/{components/agents → features/agents/components}/agents-page.tsx +17 -17
- package/src/features/agents/index.ts +1 -0
- package/src/{components/config → features/channels/components}/channel-form-fields-section.tsx +11 -32
- package/src/{components/config/ChannelForm.test.tsx → features/channels/components/config/channel-form.test.tsx} +4 -4
- package/src/features/channels/components/config/channel-form.tsx +382 -0
- package/src/{components → features/channels/components}/config/weixin-channel-auth-section.test.tsx +6 -3
- package/src/features/channels/components/config/weixin-channel-auth-section.tsx +245 -0
- package/src/{hooks → features/channels/hooks}/use-channel-auth.ts +1 -1
- package/src/features/channels/index.ts +5 -0
- package/src/features/channels/pages/channels-list-page.test.tsx +288 -0
- package/src/{components/config/ChannelsList.tsx → features/channels/pages/channels-list-page.tsx} +57 -83
- package/src/{components/config/channel-form-fields.test.ts → features/channels/utils/channel-form-fields.utils.test.ts} +1 -1
- package/src/{components/config/channel-form-fields.ts → features/channels/utils/channel-form-fields.utils.ts} +1 -1
- package/src/{lib/channel-tutorials.ts → features/channels/utils/channel-tutorials.utils.ts} +2 -2
- package/src/{components/chat → features/chat/components}/chat-session-type-option-item.test.tsx +1 -1
- package/src/{components/chat → features/chat/components}/chat-session-type-option-item.tsx +4 -4
- package/src/{components/chat → features/chat/components}/chat-session-workspace-file-preview.test.tsx +4 -4
- package/src/{components/chat → features/chat/components}/chat-session-workspace-file-preview.tsx +12 -32
- package/src/{components/chat → features/chat/components}/chat-session-workspace-panel-nav.tsx +8 -20
- package/src/{components/chat → features/chat/components}/chat-session-workspace-panel.tsx +105 -65
- package/src/features/chat/components/chat-sidebar-list-mode-switch.tsx +28 -0
- package/src/{components/chat → features/chat/components}/chat-sidebar-project-groups.tsx +6 -6
- package/src/{components/chat → features/chat/components}/chat-sidebar-session-item.tsx +10 -10
- package/src/{components/chat/ChatWelcome.test.tsx → features/chat/components/chat-welcome.test.tsx} +1 -1
- package/src/{components/chat/ChatWelcome.tsx → features/chat/components/chat-welcome.tsx} +5 -10
- package/src/features/chat/components/config/sessions-config-detail-pane.tsx +244 -0
- package/src/{components/chat → features/chat/components/conversation}/chat-attachment-upload-limit.test.ts +1 -4
- package/src/features/chat/components/conversation/chat-conversation-header.tsx +146 -0
- package/src/{components/chat → features/chat/components/conversation}/chat-conversation-panel.test.tsx +41 -19
- package/src/{components/chat → features/chat/components/conversation}/chat-conversation-panel.tsx +28 -140
- package/src/{components/chat/containers → features/chat/components/conversation}/chat-input-bar.container.tsx +137 -128
- package/src/{components/chat/containers → features/chat/components/conversation}/chat-message-list.container.test.tsx +2 -2
- package/src/{components/chat/containers → features/chat/components/conversation}/chat-message-list.container.tsx +6 -6
- package/src/{components/chat → features/chat/components/conversation}/session-header/chat-session-header-actions.test.tsx +3 -3
- package/src/{components/chat → features/chat/components/conversation}/session-header/chat-session-header-actions.tsx +6 -6
- package/src/{components/chat → features/chat/components/conversation}/session-header/chat-session-header-menu-item.tsx +1 -1
- package/src/{components/chat → features/chat/components/conversation}/session-header/chat-session-project-badge.test.tsx +3 -3
- package/src/{components/chat → features/chat/components/conversation}/session-header/chat-session-project-badge.tsx +5 -5
- package/src/{components/chat → features/chat/components/conversation}/session-header/chat-session-project-dialog.tsx +2 -2
- package/src/features/chat/components/layout/chat-page-shell.test.tsx +61 -0
- package/src/{components/chat → features/chat/components/layout}/chat-page-shell.tsx +14 -17
- package/src/features/chat/components/layout/chat-sidebar-session-entry.tsx +82 -0
- package/src/features/chat/components/layout/chat-sidebar-toolbar.tsx +205 -0
- package/src/{components/chat/ChatSidebar.test.tsx → features/chat/components/layout/chat-sidebar.test.tsx} +59 -16
- package/src/features/chat/components/layout/chat-sidebar.tsx +415 -0
- package/src/{components/chat/presenter/chat-presenter-context.tsx → features/chat/components/providers/chat-presenter.provider.tsx} +10 -31
- package/src/{components/common → features/chat/components/session}/session-context-icon.tsx +5 -5
- package/src/{components/common/SessionRunBadge.tsx → features/chat/components/session/session-run-badge.tsx} +3 -3
- package/src/{components/chat → features/chat/components}/workspace/chat-session-workspace-file-breadcrumbs.tsx +5 -15
- package/src/{components/chat/chat-input/chat-input-bar.controller.test.tsx → features/chat/hooks/use-chat-input-bar-controller.test.tsx} +1 -1
- package/src/{components → features}/chat/hooks/use-chat-session-label.ts +3 -4
- package/src/{components → features}/chat/hooks/use-chat-session-project.test.tsx +19 -19
- package/src/features/chat/hooks/use-chat-session-project.ts +34 -0
- package/src/{components/chat/useChatSessionTypeState.test.tsx → features/chat/hooks/use-chat-session-type-state.test.tsx} +2 -2
- package/src/{components/chat/useChatSessionTypeState.ts → features/chat/hooks/use-chat-session-type-state.ts} +3 -16
- package/src/{components → features}/chat/hooks/use-chat-session-update.test.tsx +19 -21
- package/src/{components → features}/chat/hooks/use-chat-session-update.ts +5 -7
- package/src/features/chat/hooks/use-chat-sidebar-session-label-editor.ts +49 -0
- package/src/{components/chat/useHydratedNcpAgent.test.tsx → features/chat/hooks/use-hydrated-ncp-agent.test.tsx} +2 -2
- package/src/{components/chat/useNcpAgentRuntime.test.tsx → features/chat/hooks/use-ncp-agent-runtime.test.tsx} +1 -1
- package/src/{components/chat/ncp/page/ncp-chat-derived-state.ts → features/chat/hooks/use-ncp-chat-derived-state.ts} +8 -8
- package/src/{components/chat/ncp/ncp-chat-page-data.ts → features/chat/hooks/use-ncp-chat-page-data.ts} +137 -80
- package/src/{hooks → features/chat/hooks}/use-ncp-chat-session-types.ts +1 -1
- package/src/{components/chat/ncp/session-conversation → features/chat/hooks}/use-ncp-child-session-tabs-view.ts +7 -7
- package/src/{components/chat/ncp/session-conversation → features/chat/hooks}/use-ncp-session-conversation.test.tsx +55 -7
- package/src/features/chat/hooks/use-ncp-session-conversation.ts +121 -0
- package/src/{components/chat/ncp → features/chat/hooks}/use-ncp-session-list-view.ts +6 -6
- package/src/features/chat/index.ts +6 -0
- package/src/{components/chat → features/chat/managers}/chat-recent-models.manager.ts +1 -1
- package/src/{components/chat → features/chat/managers}/chat-recent-skills.manager.ts +1 -1
- package/src/{components → features}/chat/managers/chat-session-list.manager.test.ts +11 -7
- package/src/{components → features}/chat/managers/chat-session-list.manager.ts +8 -10
- package/src/{components/chat/chat-session-preference-sync.test.ts → features/chat/managers/chat-session-preference-sync.manager.test.ts} +18 -14
- package/src/{components/chat/chat-session-preference-sync.ts → features/chat/managers/chat-session-preference-sync.manager.ts} +7 -14
- package/src/{components → features}/chat/managers/chat-stream-actions.manager.ts +3 -2
- package/src/{components → features}/chat/managers/chat-ui.manager.ts +11 -3
- package/src/{components/chat/ncp/tests → features/chat/managers}/ncp-chat-input.manager.test.ts +55 -5
- package/src/{components/chat/ncp → features/chat/managers}/ncp-chat-input.manager.ts +28 -20
- package/src/{components/chat/ncp/ncp-chat.presenter.ts → features/chat/managers/ncp-chat-presenter.manager.ts} +5 -5
- package/src/{components/chat/ncp/tests → features/chat/managers}/ncp-chat-thread.manager.test.ts +11 -10
- package/src/{components/chat/ncp → features/chat/managers}/ncp-chat-thread.manager.ts +11 -13
- package/src/{lib → features/chat/managers}/recent-selection.manager.test.ts +1 -1
- package/src/{lib → features/chat/managers}/recent-selection.manager.ts +14 -14
- package/src/features/chat/pages/chat-page.tsx +6 -0
- package/src/{components/chat/chat-page-runtime.test.ts → features/chat/pages/ncp-chat-page.test.ts} +69 -4
- package/src/{components/chat/ncp → features/chat/pages}/ncp-chat-page.tsx +180 -109
- package/src/features/chat/pages/sessions-config-page.test.tsx +152 -0
- package/src/features/chat/pages/sessions-config-page.tsx +192 -0
- package/src/{components → features}/chat/stores/chat-input.store.ts +3 -3
- package/src/{components → features}/chat/stores/chat-session-list.store.ts +2 -4
- package/src/{components → features}/chat/stores/chat-thread.store.ts +3 -3
- package/src/features/chat/types/chat-input-bar.types.ts +44 -0
- package/src/{components/chat → features/chat/types}/chat-input.types.ts +1 -1
- package/src/features/chat/types/chat-message.types.ts +58 -0
- package/src/{components/chat/chat-stream/types.ts → features/chat/types/chat-stream.types.ts} +1 -1
- package/src/{components/chat/chat-composer-state.test.ts → features/chat/utils/chat-composer-state.utils.test.ts} +1 -1
- package/src/{components/chat/chat-composer-state.ts → features/chat/utils/chat-composer-state.utils.ts} +17 -19
- package/src/features/chat/utils/chat-inline-token.utils.test.ts +87 -0
- package/src/{components/chat → features/chat/utils}/chat-inline-token.utils.ts +22 -39
- package/src/{components/chat/adapters/chat-input-bar.adapter.test.ts → features/chat/utils/chat-input-bar.utils.test.ts} +2 -2
- package/src/{components/chat/adapters/chat-input-bar.adapter.ts → features/chat/utils/chat-input-bar.utils.ts} +18 -196
- package/src/features/chat/utils/chat-input-toolbar.utils.ts +191 -0
- package/src/{lib/chat-message.ts → features/chat/utils/chat-message-core.utils.ts} +1 -1
- package/src/{components/chat/adapters/chat-message-inline-content.adapter.ts → features/chat/utils/chat-message-inline-content.utils.ts} +2 -2
- package/src/features/chat/utils/chat-message-part.utils.ts +233 -0
- package/src/{components/chat/adapters/chat-message.session-request-tool-card.ts → features/chat/utils/chat-message-session-request-tool-card.utils.ts} +2 -2
- package/src/{components/chat/adapters/chat-message.session-spawn-tool-card.test.ts → features/chat/utils/chat-message-session-spawn-tool-card.utils.test.ts} +2 -2
- package/src/{components/chat/adapters/chat-message.summary-truncation.test.ts → features/chat/utils/chat-message-summary-truncation.utils.test.ts} +2 -2
- package/src/{components/chat/adapters/chat-message-tool-agent-id.test.ts → features/chat/utils/chat-message-tool-agent-id.utils.test.ts} +1 -1
- package/src/features/chat/utils/chat-message-tool-card.utils.ts +216 -0
- package/src/{components/chat/adapters/chat-message.adapter.test.ts → features/chat/utils/chat-message.utils.test.ts} +2 -2
- package/src/{components/chat/adapters/chat-message.adapter.ts → features/chat/utils/chat-message.utils.ts} +4 -4
- package/src/features/chat/utils/chat-runtime.utils.ts +235 -0
- package/src/{components/chat/chat-session-display.test.ts → features/chat/utils/chat-session-display.utils.test.ts} +2 -2
- package/src/{components/chat/chat-session-display.ts → features/chat/utils/chat-session-display.utils.ts} +5 -9
- package/src/{components/chat/chat-session-preference-governance.ts → features/chat/utils/chat-session-preference-governance.utils.ts} +51 -64
- package/src/{components/chat/chat-session-route.ts → features/chat/utils/chat-session-route.utils.ts} +1 -1
- package/src/{components/chat/adapters/file-operation/card.ts → features/chat/utils/file-operation/card.utils.ts} +3 -3
- package/src/{components/chat/adapters/file-operation/diff.ts → features/chat/utils/file-operation/diff.utils.ts} +9 -99
- package/src/features/chat/utils/file-operation/parsed-block.utils.ts +98 -0
- package/src/{components/chat/adapters/file-operation/record-readers.ts → features/chat/utils/file-operation/record-readers.utils.ts} +1 -1
- package/src/{components/chat/ncp/ncp-app-client-fetch.test.ts → features/chat/utils/ncp-app-client-fetch.utils.test.ts} +1 -1
- package/src/{components/chat/ncp/ncp-app-client-fetch.ts → features/chat/utils/ncp-app-client-fetch.utils.ts} +3 -0
- package/src/features/chat/utils/ncp-chat-input-availability.utils.test.ts +92 -0
- package/src/features/chat/utils/ncp-chat-input-availability.utils.ts +45 -0
- package/src/{components/chat/ncp/__tests__/ncp-session-adapter.cancelled-tool.test.ts → features/chat/utils/ncp-session-adapter.utils.cancelled-tool.test.ts} +2 -2
- package/src/{components/chat/ncp/ncp-session-adapter.test.ts → features/chat/utils/ncp-session-adapter.utils.test.ts} +3 -3
- package/src/{components/chat/ncp/ncp-session-adapter.ts → features/chat/utils/ncp-session-adapter.utils.ts} +3 -3
- package/src/{lib → features/chat/utils}/session-context.utils.test.ts +3 -3
- package/src/{lib → features/chat/utils}/session-context.utils.ts +3 -3
- package/src/{components/marketplace → features/marketplace/components}/marketplace-list-card.tsx +69 -124
- package/src/{components/marketplace → features/marketplace/components}/marketplace-localization.ts +1 -1
- package/src/{components/marketplace → features/marketplace/components}/marketplace-page-data.ts +2 -2
- package/src/features/marketplace/components/marketplace-page-detail.test.tsx +336 -0
- package/src/features/marketplace/components/marketplace-page-parts.tsx +121 -0
- package/src/{components/marketplace → features/marketplace/components}/marketplace-page.test.tsx +6 -6
- package/src/{components/marketplace → features/marketplace/components}/marketplace-page.tsx +92 -91
- package/src/{components/marketplace → features/marketplace/components}/mcp/mcp-marketplace-card.tsx +4 -4
- package/src/{components/marketplace → features/marketplace/components}/mcp/mcp-marketplace-dialogs.tsx +7 -7
- package/src/{components/marketplace → features/marketplace/components}/mcp/mcp-marketplace-doc.ts +3 -3
- package/src/{components/marketplace → features/marketplace/components}/mcp/mcp-marketplace-page.test.tsx +13 -9
- package/src/features/marketplace/components/mcp/mcp-marketplace-page.tsx +446 -0
- package/src/{hooks/useMarketplace.ts → features/marketplace/hooks/use-marketplace.ts} +5 -5
- package/src/{hooks/useMcpMarketplace.ts → features/marketplace/hooks/use-mcp-marketplace.ts} +3 -3
- package/src/features/marketplace/index.ts +26 -0
- package/src/{components/marketplace/marketplace-installed-cache.test.ts → features/marketplace/utils/marketplace-installed-cache.utils.test.ts} +2 -2
- package/src/{components/marketplace/marketplace-installed-cache.ts → features/marketplace/utils/marketplace-installed-cache.utils.ts} +1 -1
- package/src/{hooks/marketplace-list-pages.ts → features/marketplace/utils/marketplace-list-pages.utils.ts} +1 -1
- package/src/{pwa → features/pwa}/components/pwa-install-entry.test.tsx +2 -2
- package/src/{pwa → features/pwa}/components/pwa-install-entry.tsx +7 -7
- package/src/features/pwa/index.ts +4 -0
- package/src/{pwa/register-pwa.ts → features/pwa/managers/pwa-bootstrap.manager.ts} +2 -2
- package/src/{pwa → features/pwa}/managers/pwa-install.manager.test.ts +3 -3
- package/src/{pwa → features/pwa}/managers/pwa-install.manager.ts +5 -5
- package/src/{pwa → features/pwa}/managers/pwa-runtime.manager.ts +1 -1
- package/src/{pwa → features/pwa}/managers/pwa-shell-theme.manager.test.ts +1 -1
- package/src/{pwa → features/pwa}/managers/pwa-shell-theme.manager.ts +1 -1
- package/src/{pwa → features/pwa}/stores/pwa.store.ts +2 -2
- package/src/{components/remote → features/remote/components}/remote-access-page.test.tsx +5 -6
- package/src/{components/remote → features/remote/components}/remote-access-page.tsx +21 -19
- package/src/{hooks/useRemoteAccess.ts → features/remote/hooks/use-remote-access.ts} +3 -3
- package/src/features/remote/index.ts +27 -0
- package/src/{remote → features/remote}/managers/remote-access.manager.ts +6 -7
- package/src/{remote → features/remote/services}/remote-access-feedback.service.test.ts +3 -3
- package/src/{remote → features/remote/services}/remote-access-feedback.service.ts +2 -2
- package/src/{remote/remote-access.query.ts → features/remote/services/remote-access-query.service.ts} +2 -2
- package/src/{remote → features/remote}/stores/remote-access.store.ts +1 -1
- package/src/features/settings/hooks/use-language-preference.ts +30 -0
- package/src/features/settings/index.ts +2 -0
- package/src/features/settings/pages/language-settings-page.test.tsx +36 -0
- package/src/features/settings/pages/language-settings-page.tsx +56 -0
- package/src/features/system-status/components/config/runtime-agent-list-card.tsx +72 -0
- package/src/features/system-status/components/config/runtime-binding-list-card.tsx +85 -0
- package/src/features/system-status/components/config/runtime-config-editor.tsx +131 -0
- package/src/features/system-status/components/config/runtime-config-overview.tsx +16 -0
- package/src/features/system-status/components/config/runtime-entry-list-card.tsx +58 -0
- package/src/features/system-status/components/config/runtime-settings-card.tsx +73 -0
- package/src/{components/config → features/system-status/components}/desktop-update-config.test.tsx +12 -6
- package/src/features/system-status/components/desktop-update-config.tsx +219 -0
- package/src/features/system-status/components/runtime-control-card.test.tsx +213 -0
- package/src/features/system-status/components/runtime-control-card.tsx +260 -0
- package/src/{components/config → features/system-status/components}/runtime-presence-card.test.tsx +12 -16
- package/src/{components/config → features/system-status/components}/runtime-presence-card.tsx +38 -51
- package/src/features/system-status/components/runtime-security-card.tsx +263 -0
- package/src/{components/config → features/system-status/components}/security-config.tsx +3 -3
- package/src/features/system-status/hooks/use-system-status.ts +104 -0
- package/src/features/system-status/index.ts +4 -0
- package/src/features/system-status/managers/system-status.manager.bootstrap-polling.test.ts +126 -0
- package/src/features/system-status/managers/system-status.manager.test.ts +142 -0
- package/src/features/system-status/managers/system-status.manager.ts +511 -0
- package/src/features/system-status/pages/runtime-config-page.test.tsx +140 -0
- package/src/features/system-status/pages/runtime-config-page.tsx +15 -0
- package/src/features/system-status/stores/system-status.store.ts +32 -0
- package/src/features/system-status/types/system-status.types.ts +73 -0
- package/src/features/system-status/utils/runtime-config-agent.utils.ts +152 -0
- package/src/features/system-status/utils/system-status.utils.test.ts +132 -0
- package/src/features/system-status/utils/system-status.utils.ts +202 -0
- package/src/index.css +1 -1
- package/src/platforms/desktop/components/desktop-app-shell.tsx +52 -0
- package/src/platforms/desktop/index.ts +21 -0
- package/src/{desktop → platforms/desktop}/managers/desktop-presence.manager.ts +3 -3
- package/src/{desktop → platforms/desktop}/managers/desktop-update.manager.ts +3 -3
- package/src/{desktop → platforms/desktop}/stores/desktop-presence.store.ts +1 -1
- package/src/{desktop → platforms/desktop}/stores/desktop-update.store.ts +1 -1
- package/src/{desktop → platforms/desktop/types}/desktop-update.types.ts +4 -0
- package/src/platforms/mobile/components/chat-mobile-shell.tsx +20 -0
- package/src/platforms/mobile/components/mobile-app-shell.test.tsx +42 -0
- package/src/platforms/mobile/components/mobile-app-shell.tsx +48 -0
- package/src/platforms/mobile/components/mobile-bottom-nav.test.tsx +45 -0
- package/src/platforms/mobile/components/mobile-bottom-nav.tsx +71 -0
- package/src/platforms/mobile/components/mobile-settings-shell.tsx +39 -0
- package/src/platforms/mobile/components/mobile-topbar.tsx +41 -0
- package/src/platforms/mobile/index.ts +3 -0
- package/src/shared/components/__tests__/config-split-page.test.tsx +47 -0
- package/src/{components/common/AgentAvatar.tsx → shared/components/common/agent-avatar.tsx} +1 -1
- package/src/{components → shared/components}/common/agent-identity/agent-identity-avatar.tsx +2 -2
- package/src/shared/components/common/agent-identity/index.ts +3 -0
- package/src/{components → shared/components}/common/agent-identity/use-agent-identity.ts +3 -3
- package/src/{components/common/BrandHeader.tsx → shared/components/common/brand-header.tsx} +2 -2
- package/src/{components/common/KeyValueEditor.tsx → shared/components/common/key-value-editor.tsx} +4 -4
- package/src/{components/common/LogoBadge.tsx → shared/components/common/logo-badge.tsx} +1 -1
- package/src/{components/common/MaskedInput.tsx → shared/components/common/masked-input.tsx} +3 -3
- package/src/{components/common/ProviderScopedModelInput.tsx → shared/components/common/provider-scoped-model-input.tsx} +6 -6
- package/src/{components/common/SearchableModelInput.tsx → shared/components/common/searchable-model-input.tsx} +2 -2
- package/src/{components/common/StatusBadge.tsx → shared/components/common/status-badge.tsx} +3 -3
- package/src/{components → shared/components}/common/tag-input.tsx +3 -3
- package/src/{components → shared/components}/config/provider-form-support.ts +3 -3
- package/src/{components/config/ProviderForm.tsx → shared/components/config/provider-form.tsx} +14 -14
- package/src/{components → shared/components}/config/provider-models-section.tsx +7 -7
- package/src/{components → shared/components}/config/providers-list.test.tsx +19 -19
- package/src/{components/config/ProvidersList.tsx → shared/components/config/providers-list.tsx} +56 -54
- package/src/shared/components/config/secrets-config-form.tsx +407 -0
- package/src/shared/components/config/secrets-config.test.tsx +90 -0
- package/src/shared/components/config/secrets-config.tsx +25 -0
- package/src/{components/config → shared/components}/config-split-page.tsx +55 -9
- package/src/{components/config/CronConfig.tsx → shared/components/cron-config.tsx} +63 -96
- package/src/shared/components/doc-browser/doc-browser-context.test.tsx +102 -0
- package/src/{components/doc-browser/DocBrowserContext.tsx → shared/components/doc-browser/doc-browser-context.tsx} +98 -45
- package/src/shared/components/doc-browser/doc-browser.test.tsx +72 -0
- package/src/{components/doc-browser/DocBrowser.tsx → shared/components/doc-browser/doc-browser.tsx} +60 -34
- package/src/shared/components/doc-browser/index.ts +3 -0
- package/src/{components/doc-browser/useDocLinkInterceptor.ts → shared/components/doc-browser/use-doc-link-interceptor.ts} +1 -1
- package/src/{components/config/ModelConfig.test.tsx → shared/components/model-config.test.tsx} +4 -4
- package/src/shared/components/model-config.tsx +151 -0
- package/src/{components → shared/components}/path-picker/server-path-picker-dialog.test.tsx +3 -3
- package/src/{components → shared/components}/path-picker/server-path-picker-dialog.tsx +7 -7
- package/src/{components/config → shared/components}/provider-advanced-settings-section.tsx +5 -18
- package/src/{components/config → shared/components}/provider-auth-section.tsx +7 -24
- package/src/{components/config → shared/components}/provider-enabled-field.tsx +4 -8
- package/src/{components/config → shared/components}/provider-pill-selector.tsx +3 -15
- package/src/{components/config → shared/components}/provider-status-badge.tsx +3 -9
- package/src/{components/config/SearchConfig.test.tsx → shared/components/search-config.test.tsx} +3 -3
- package/src/shared/components/search-config.tsx +496 -0
- package/src/{components → shared/components}/ui/action-link.tsx +1 -1
- package/src/{components → shared/components}/ui/button.tsx +1 -1
- package/src/{components → shared/components}/ui/card.tsx +1 -1
- package/src/{components → shared/components}/ui/config-card.tsx +1 -1
- package/src/{components → shared/components}/ui/confirm-dialog.tsx +3 -3
- package/src/{components → shared/components}/ui/dialog.tsx +1 -1
- package/src/{components/ui/HighlightCard.tsx → shared/components/ui/highlight-card.tsx} +1 -1
- package/src/{components → shared/components}/ui/input.tsx +1 -1
- package/src/{components → shared/components}/ui/label.tsx +1 -1
- package/src/{components → shared/components}/ui/notice-card.tsx +1 -1
- package/src/{components → shared/components}/ui/popover.tsx +1 -1
- package/src/{components → shared/components}/ui/scroll-area.tsx +1 -1
- package/src/{components → shared/components}/ui/select.tsx +1 -1
- package/src/{components → shared/components}/ui/setting-row.tsx +1 -1
- package/src/{components → shared/components}/ui/skeleton.tsx +1 -1
- package/src/{components → shared/components}/ui/status-dot.tsx +1 -1
- package/src/{components → shared/components}/ui/switch.tsx +1 -1
- package/src/{components → shared/components}/ui/tabs-custom.tsx +2 -2
- package/src/{components → shared/components}/ui/tabs.tsx +1 -1
- package/src/{components → shared/components}/ui/tag-chip.tsx +1 -1
- package/src/{components → shared/components}/ui/textarea.tsx +1 -1
- package/src/{components → shared/components}/ui/tooltip.tsx +1 -1
- package/src/{hooks/agents/useAgents.ts → shared/hooks/use-agents.ts} +2 -2
- package/src/{hooks/useConfig.ts → shared/hooks/use-config.ts} +4 -4
- package/src/{hooks/useConfirmDialog.tsx → shared/hooks/use-confirm-dialog.tsx} +2 -2
- package/src/{hooks/server-path → shared/hooks}/use-server-path-browse.ts +1 -1
- package/src/{hooks/server-path → shared/hooks}/use-server-path-read.ts +1 -1
- package/src/{api → shared/lib/api}/api-base.test.ts +2 -2
- package/src/{api → shared/lib/api}/client.test.ts +2 -2
- package/src/{api → shared/lib/api}/client.ts +1 -1
- package/src/{api → shared/lib/api}/config.ts +10 -0
- package/src/shared/lib/api/index.ts +20 -0
- package/src/{api → shared/lib/api}/ncp-session-query-cache.test.ts +2 -2
- package/src/{api → shared/lib/api}/ncp-session-query-cache.ts +1 -1
- package/src/{api → shared/lib/api}/ncp-session.test.ts +3 -3
- package/src/{api → shared/lib/api}/raw-client.test.ts +1 -1
- package/src/{api/raw-client.ts → shared/lib/api/raw-client.utils.ts} +2 -0
- package/src/{api → shared/lib/api}/types.ts +40 -0
- package/src/{lib → shared/lib/app-resource-uri}/app-resource-uri.test.ts +1 -1
- package/src/{lib/config-hints.ts → shared/lib/config-hints/index.ts} +1 -1
- package/src/{lib/i18n.chat.ts → shared/lib/i18n/chat.ts} +8 -0
- package/src/{lib/i18n.ts → shared/lib/i18n/index.ts} +11 -11
- package/src/shared/lib/i18n/runtime/i18n-language-owner.test.ts +94 -0
- package/src/{lib/i18n-runtime → shared/lib/i18n/runtime}/i18n-language-owner.ts +15 -1
- package/src/{lib/provider-models.ts → shared/lib/provider-models/index.ts} +1 -1
- package/src/shared/lib/session-project/index.ts +2 -0
- package/src/{lib → shared/lib}/session-project/workspace-file-breadcrumb.test.ts +1 -1
- package/src/{lib → shared/lib}/session-project/workspace-file-breadcrumb.ts +1 -1
- package/src/{transport/app-client.ts → shared/lib/transport/app-client.service.ts} +11 -12
- package/src/{transport → shared/lib/transport}/app-client.test.ts +15 -5
- package/src/{transport → shared/lib/transport}/index.ts +1 -1
- package/src/{transport/local.transport.ts → shared/lib/transport/local-transport.service.ts} +19 -19
- package/src/{transport/remote.transport.ts → shared/lib/transport/remote-transport.service.ts} +14 -15
- package/src/{transport → shared/lib/transport}/remote.transport.test.ts +5 -5
- package/src/{transport → shared/lib/transport}/sse-stream.test.ts +2 -2
- package/src/{transport/sse-stream.ts → shared/lib/transport/sse-stream.utils.ts} +13 -11
- package/src/{transport → shared/lib/transport}/transport.types.ts +1 -1
- package/src/{lib/ui-document-title.ts → shared/lib/ui-document-title/index.ts} +1 -1
- package/tsconfig.json +20 -0
- package/vite.config.ts +62 -2
- package/vitest.config.ts +21 -1
- package/dist/assets/ChannelsList-M9FTK1Ak.js +0 -8
- package/dist/assets/DocBrowser-CH7-GxlL.js +0 -1
- package/dist/assets/DocBrowser-DMfr0Oow.js +0 -1
- package/dist/assets/DocBrowserContext-BXydqby-.js +0 -1
- package/dist/assets/ModelConfig-CNIgLf0e.js +0 -1
- package/dist/assets/ProviderScopedModelInput-B3HWP4oz.js +0 -1
- package/dist/assets/ProvidersList-CHjMnRhX.js +0 -1
- package/dist/assets/RuntimeConfig-psp8nMSG.js +0 -1
- package/dist/assets/SearchConfig-CSoKip1f.js +0 -1
- package/dist/assets/SecretsConfig-MEt6MjuD.js +0 -3
- package/dist/assets/SessionsConfig-DifCiXwR.js +0 -2
- package/dist/assets/app-query-client-9jNewezV.js +0 -1
- package/dist/assets/chat-page-CLp0UV0Y.js +0 -58
- package/dist/assets/chat-session-display-DsYHx0RZ.js +0 -1
- package/dist/assets/chunk-JZWAC4HX-C5dEc8hV.js +0 -3
- package/dist/assets/client-C-8fH7-c.js +0 -7
- package/dist/assets/config-CBScxsdV.js +0 -1
- package/dist/assets/config-split-page-BUout_Ak.js +0 -1
- package/dist/assets/desktop-update-config-2BS6BMkW.js +0 -1
- package/dist/assets/dist-BruyLa92.js +0 -9
- package/dist/assets/download-BD0ETkB-.js +0 -1
- package/dist/assets/i18n-CpTZLchQ.js +0 -1
- package/dist/assets/index-mW8W2FUu.css +0 -1
- package/dist/assets/index-zDZfXoI4.js +0 -6
- package/dist/assets/infiniteQueryBehavior-CyER9hv0.js +0 -1
- package/dist/assets/loader-circle-Bc2gCU33.js +0 -1
- package/dist/assets/marketplace-page-3qVMnF3d.js +0 -1
- package/dist/assets/marketplace-page-BhFIeQzI.js +0 -49
- package/dist/assets/mcp-marketplace-page-DYfteJ1D.js +0 -40
- package/dist/assets/page-layout-0UcO9H9Z.js +0 -1
- package/dist/assets/play-CKDjSQFL.js +0 -1
- package/dist/assets/plus-CG0QrVY_.js +0 -1
- package/dist/assets/refresh-cw-Bcv40SXy.js +0 -1
- package/dist/assets/remote-access-page-CWHG-sug.js +0 -1
- package/dist/assets/search-BCAlB8nz.js +0 -1
- package/dist/assets/security-config-Slh0Mayz.js +0 -1
- package/dist/assets/select-CVz0t7MF.js +0 -41
- package/dist/assets/setting-row-CbVHAuQt.js +0 -1
- package/dist/assets/skeleton-D5rdKvzy.js +0 -1
- package/dist/assets/switch-CM29eCAR.js +0 -1
- package/dist/assets/tag-chip-DMXdnLcj.js +0 -1
- package/dist/assets/use-infinite-scroll-loader-DJ1L81Dz.js +0 -1
- package/dist/assets/useConfirmDialog-BsVuqu1x.js +0 -1
- package/dist/assets/useMutation-CNcz2fgt.js +0 -1
- package/dist/assets/x-Czwxm82I.js +0 -1
- package/src/app.tsx +0 -271
- package/src/components/chat/ChatSidebar.tsx +0 -486
- package/src/components/chat/README.md +0 -2
- package/src/components/chat/adapters/chat-message-part.adapter.ts +0 -472
- package/src/components/chat/chat-inline-token.utils.test.ts +0 -87
- package/src/components/chat/chat-page.tsx +0 -6
- package/src/components/chat/chat-sidebar-list-mode-switch.tsx +0 -43
- package/src/components/chat/hooks/use-chat-session-project.ts +0 -35
- package/src/components/chat/index.ts +0 -1
- package/src/components/chat/ncp/README.md +0 -3
- package/src/components/chat/ncp/ncp-chat-page-data.test.ts +0 -79
- package/src/components/chat/ncp/session-conversation/use-ncp-session-conversation.ts +0 -72
- package/src/components/chat/nextclaw/index.ts +0 -23
- package/src/components/common/agent-identity/index.ts +0 -3
- package/src/components/config/ChannelForm.tsx +0 -338
- package/src/components/config/ChannelsList.test.tsx +0 -309
- package/src/components/config/ModelConfig.tsx +0 -156
- package/src/components/config/README.md +0 -2
- package/src/components/config/RuntimeConfig.tsx +0 -588
- package/src/components/config/SearchConfig.tsx +0 -513
- package/src/components/config/SecretsConfig.tsx +0 -469
- package/src/components/config/SessionsConfig.tsx +0 -437
- package/src/components/config/desktop-update-config.tsx +0 -271
- package/src/components/config/runtime-config-agent.utils.ts +0 -96
- package/src/components/config/runtime-control-card.test.tsx +0 -311
- package/src/components/config/runtime-control-card.tsx +0 -326
- package/src/components/config/runtime-security-card.tsx +0 -276
- package/src/components/config/weixin-channel-auth-section.tsx +0 -305
- package/src/components/doc-browser/index.ts +0 -3
- package/src/components/layout/AppLayout.tsx +0 -82
- package/src/components/layout/runtime-status-entry.test.tsx +0 -157
- package/src/components/layout/runtime-status-entry.tsx +0 -143
- package/src/components/marketplace/marketplace-page-parts.tsx +0 -94
- package/src/components/marketplace/mcp/mcp-marketplace-page.tsx +0 -414
- package/src/hooks/README.md +0 -3
- package/src/hooks/use-runtime-control.ts +0 -24
- package/src/hooks/useObservable.ts +0 -20
- package/src/lib/chat-runtime-utils.ts +0 -250
- package/src/presenter/app-presenter-context.tsx +0 -20
- package/src/presenter/app.presenter.ts +0 -12
- package/src/runtime-control/runtime-control.manager.ts +0 -118
- package/src/stores/ui.store.ts +0 -23
- /package/dist/assets/{config-hints-BhTmc9P1.js → config-hints-CPNzbMEp.js} +0 -0
- /package/src/{components/layout/Header.tsx → app/components/layout/header.tsx} +0 -0
- /package/src/{styles → app/styles}/design-system.css +0 -0
- /package/src/{account → features/account}/stores/account.store.ts +0 -0
- /package/src/{components/chat/chat-input/chat-input-bar.controller.ts → features/chat/hooks/use-chat-input-bar-controller.ts} +0 -0
- /package/src/{lib/session-run-status.ts → features/chat/types/session-run-status.types.ts} +0 -0
- /package/src/{components/chat/adapters/chat-message.partial-json.ts → features/chat/utils/chat-message-partial-json.utils.ts} +0 -0
- /package/src/{components/chat/adapters/chat-message-tool-agent-id.ts → features/chat/utils/chat-message-tool-agent-id.utils.ts} +0 -0
- /package/src/{components/chat/adapters/file-operation/line-builder.ts → features/chat/utils/file-operation/line-builder.utils.ts} +0 -0
- /package/src/{components/marketplace → features/marketplace/components}/marketplace-detail-doc.ts +0 -0
- /package/src/{pwa → features/pwa/types}/pwa.types.ts +0 -0
- /package/src/{pwa/pwa-install-banner.storage.ts → features/pwa/utils/pwa-install-banner.utils.ts} +0 -0
- /package/src/{hooks → shared/hooks}/use-infinite-scroll-loader.ts +0 -0
- /package/src/{api → shared/lib/api}/agents.ts +0 -0
- /package/src/{api → shared/lib/api}/api-base.ts +0 -0
- /package/src/{api → shared/lib/api}/auth.types.ts +0 -0
- /package/src/{api → shared/lib/api}/channel-auth.ts +0 -0
- /package/src/{api → shared/lib/api}/channel-auth.types.ts +0 -0
- /package/src/{api → shared/lib/api}/chat-session-type.types.ts +0 -0
- /package/src/{api → shared/lib/api}/marketplace.ts +0 -0
- /package/src/{api → shared/lib/api}/mcp-marketplace.ts +0 -0
- /package/src/{api → shared/lib/api}/ncp-attachments.ts +0 -0
- /package/src/{api → shared/lib/api}/ncp-session.ts +0 -0
- /package/src/{api → shared/lib/api}/remote.ts +0 -0
- /package/src/{api → shared/lib/api}/remote.types.ts +0 -0
- /package/src/{api → shared/lib/api}/runtime-control.ts +0 -0
- /package/src/{api → shared/lib/api}/runtime-control.types.ts +0 -0
- /package/src/{api → shared/lib/api}/server-path.ts +0 -0
- /package/src/{lib/app-resource-uri.ts → shared/lib/app-resource-uri/index.ts} +0 -0
- /package/src/{lib/i18n.agents.ts → shared/lib/i18n/agents.ts} +0 -0
- /package/src/{lib/i18n.channel-auth.ts → shared/lib/i18n/channel-auth.ts} +0 -0
- /package/src/{lib/i18n.channels.ts → shared/lib/i18n/channels.ts} +0 -0
- /package/src/{lib → shared/lib/i18n}/desktop-update-labels.utils.ts +0 -0
- /package/src/{lib/i18n.marketplace.ts → shared/lib/i18n/marketplace.ts} +0 -0
- /package/src/{lib/i18n.pwa.ts → shared/lib/i18n/pwa.ts} +0 -0
- /package/src/{lib/i18n.remote.ts → shared/lib/i18n/remote.ts} +0 -0
- /package/src/{lib/i18n-runtime → shared/lib/i18n/runtime}/i18n.path-picker.ts +0 -0
- /package/src/{lib/i18n.runtime-control.ts → shared/lib/i18n/runtime-control.ts} +0 -0
- /package/src/{lib/i18n.search.ts → shared/lib/i18n/search.ts} +0 -0
- /package/src/{lib/logos.ts → shared/lib/logos/index.ts} +0 -0
- /package/src/{lib → shared/lib}/session-project/session-project.utils.ts +0 -0
- /package/src/{lib/theme.ts → shared/lib/theme/index.ts} +0 -0
- /package/src/{transport/transport-websocket-url.ts → shared/lib/transport/transport-websocket-url.utils.ts} +0 -0
- /package/src/{lib/utils.ts → shared/lib/utils/index.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-CpTZLchQ.js";import{t as a}from"./createLucideIcon-dy5ie7Ox.js";import{t as o}from"./book-open-DzdUViDm.js";import{t as s}from"./external-link-kZSAO8nT.js";import{t as c}from"./plus-CG0QrVY_.js";import{t as l}from"./search-BCAlB8nz.js";import{t as u}from"./x-Czwxm82I.js";import{i as d,r as f,t as p}from"./DocBrowserContext-BXydqby-.js";var m=a(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ee=a(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),h=a(`GripVertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),g=a(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),_=a(`PanelRightOpen`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),v=e(n(),1),y=r();function b(){let{isOpen:e,mode:n,tabs:r,activeTabId:a,currentTab:b,currentUrl:x,navVersion:S,close:C,toggleMode:w,goBack:T,goForward:E,canGoBack:te,canGoForward:D,navigate:O,syncUrl:k,setActiveTab:A,closeTab:j,openNewTab:M}=d(),[N,P]=(0,v.useState)(``),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),[z,B]=(0,v.useState)(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[V,H]=(0,v.useState)({w:480,h:600}),[U,W]=(0,v.useState)(420),G=(0,v.useRef)(null),K=(0,v.useRef)(null),q=(0,v.useRef)(null),J=(0,v.useRef)(null),Y=(0,v.useRef)(S),X=b?.kind===`docs`;(0,v.useEffect)(()=>{if(!X){P(``);return}try{P(new URL(x).pathname)}catch{P(x)}},[x,a,X]),(0,v.useEffect)(()=>{if(X){if(S!==Y.current){Y.current=S;return}if(J.current?.contentWindow)try{let e=new URL(x).pathname;J.current.contentWindow.postMessage({type:`docs-navigate`,path:e},`*`)}catch{}}},[x,S,X]),(0,v.useEffect)(()=>{n===`floating`&&B(e=>({x:Math.max(40,window.innerWidth-V.w-40),y:e.y}))},[n,V.w]),(0,v.useEffect)(()=>{let e=e=>{X&&e.data?.type===`docs-route-change`&&typeof e.data.url==`string`&&k(e.data.url)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[k,X]);let Z=(0,v.useCallback)(e=>{if(e.preventDefault(),!X)return;let t=N.trim();t&&(t.startsWith(`/`)?O(`${p}${t}`):t.startsWith(`http`)?O(t):O(`${p}/${t}`))},[N,O,X]),ne=(0,v.useCallback)(e=>{n===`floating`&&(I(!0),G.current={startX:e.clientX,startY:e.clientY,startPosX:z.x,startPosY:z.y})},[n,z]);(0,v.useEffect)(()=>{if(!F)return;let e=e=>{G.current&&B({x:G.current.startPosX+(e.clientX-G.current.startX),y:G.current.startPosY+(e.clientY-G.current.startY)})},t=()=>{I(!1),G.current=null};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[F]);let Q=(0,v.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R(!0);let t=e.currentTarget.dataset.axis;K.current={startX:e.clientX,startY:e.clientY,startW:V.w,startH:V.h};let n=e=>{K.current&&H(n=>({w:t===`y`?n.w:Math.max(360,K.current.startW+(e.clientX-K.current.startX)),h:t===`x`?n.h:Math.max(400,K.current.startH+(e.clientY-K.current.startY))}))},r=()=>{R(!1),K.current=null,window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r)};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r)},[V]),re=(0,v.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R(!0),q.current={startX:e.clientX,startW:U};let t=e=>{if(!q.current)return;let t=q.current.startX-e.clientX;W(Math.max(320,Math.min(860,q.current.startW+t)))},n=()=>{R(!1),q.current=null,window.removeEventListener(`mousemove`,t),window.removeEventListener(`mouseup`,n)};window.addEventListener(`mousemove`,t),window.addEventListener(`mouseup`,n)},[U]),ie=(0,v.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R(!0);let t=e.clientX,n=V.w,r=z.x,i=e=>{let i=t-e.clientX,a=Math.max(360,n+i);H(e=>({...e,w:a})),B(e=>({...e,x:r-(a-n)}))},a=()=>{R(!1),window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},[V.w,z.x]);if(!e)return null;let $=n===`docked`;return(0,y.jsxs)(`div`,{className:i(`flex flex-col bg-white overflow-hidden relative`,$?`h-full border-l border-gray-200 shrink-0`:`rounded-2xl shadow-2xl border border-gray-200`),style:$?{width:U}:{position:`fixed`,left:z.x,top:z.y,width:V.w,height:V.h,zIndex:9999},children:[$&&(0,y.jsx)(`div`,{className:`absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors`,onMouseDown:re}),(0,y.jsxs)(`div`,{className:i(`flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none`,!$&&`cursor-grab active:cursor-grabbing`),onMouseDown:$?void 0:ne,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,y.jsx)(o,{className:`w-4 h-4 text-primary shrink-0`}),(0,y.jsx)(`span`,{className:`text-sm font-semibold text-gray-900 truncate`,children:t(`docBrowserTitle`)})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,y.jsx)(`button`,{onClick:w,className:`hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors`,title:t($?`docBrowserFloatMode`:`docBrowserDockMode`),children:$?(0,y.jsx)(g,{className:`w-3.5 h-3.5`}):(0,y.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(`button`,{onClick:C,className:`hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors`,title:t(`docBrowserClose`),children:(0,y.jsx)(u,{className:`w-3.5 h-3.5`})})]})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 py-2 bg-white border-b border-gray-100 overflow-x-auto custom-scrollbar`,children:[r.map(e=>(0,y.jsxs)(`div`,{className:i(`inline-flex items-center gap-1 h-7 px-1.5 rounded-lg text-xs border max-w-[220px] shrink-0 transition-colors`,e.id===a?`bg-blue-50 border-blue-300 text-blue-700`:`bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100`),children:[(0,y.jsx)(`button`,{type:`button`,onClick:()=>A(e.id),className:`truncate text-left px-1`,title:e.title,children:e.title||t(`docBrowserTabUntitled`)}),(0,y.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),j(e.id)},className:`rounded p-0.5 hover:bg-black/10`,"aria-label":t(`docBrowserCloseTab`),children:(0,y.jsx)(u,{className:`w-3 h-3`})})]},e.id)),(0,y.jsx)(`button`,{onClick:()=>M(void 0,{kind:`docs`,title:`Docs`}),className:`inline-flex items-center justify-center w-7 h-7 rounded-lg border border-gray-200 bg-white text-gray-600 hover:bg-gray-100 shrink-0`,title:t(`docBrowserNewTab`),children:(0,y.jsx)(c,{className:`w-3.5 h-3.5`})})]}),X&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:[(0,y.jsx)(`button`,{onClick:T,disabled:!te,className:`p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors`,children:(0,y.jsx)(m,{className:`w-4 h-4`})}),(0,y.jsx)(`button`,{onClick:E,disabled:!D,className:`p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors`,children:(0,y.jsx)(ee,{className:`w-4 h-4`})}),(0,y.jsxs)(`form`,{onSubmit:Z,className:`flex-1 relative`,children:[(0,y.jsx)(l,{className:`w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400`}),(0,y.jsx)(`input`,{type:`text`,value:N,onChange:e=>P(e.target.value),placeholder:t(`docBrowserSearchPlaceholder`),className:`w-full h-8 pl-8 pr-3 rounded-lg bg-gray-50 border border-gray-200 text-xs text-gray-700 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors placeholder:text-gray-400`})]})]}),(0,y.jsxs)(`div`,{className:`flex-1 relative overflow-hidden`,children:[(0,y.jsx)(`iframe`,{ref:J,src:x,className:`absolute inset-0 w-full h-full border-0`,title:b?.title||`NextClaw Docs`,sandbox:`allow-same-origin allow-scripts allow-popups allow-forms`,allow:`clipboard-read; clipboard-write`},`${a}:${S}`),(L||F)&&(0,y.jsx)(`div`,{className:`absolute inset-0 z-10`})]}),X&&f(x)&&(0,y.jsx)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0`,children:(0,y.jsxs)(`a`,{href:x,target:`_blank`,rel:`noopener noreferrer`,"data-doc-external":!0,className:`flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover font-medium transition-colors`,children:[t(`docBrowserOpenExternal`),(0,y.jsx)(s,{className:`w-3 h-3`})]})}),!$&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors`,onMouseDown:ie}),(0,y.jsx)(`div`,{className:`absolute top-0 right-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors`,onMouseDown:Q,"data-axis":`x`}),(0,y.jsx)(`div`,{className:`absolute bottom-0 left-0 h-1.5 w-full cursor-ns-resize z-20 hover:bg-primary/10 transition-colors`,onMouseDown:Q,"data-axis":`y`}),(0,y.jsx)(`div`,{className:`absolute bottom-0 right-0 w-4 h-4 cursor-se-resize z-30 flex items-center justify-center text-gray-300 hover:text-gray-500 transition-colors`,onMouseDown:Q,children:(0,y.jsx)(h,{className:`w-3 h-3 rotate-[-45deg]`})})]})]})}export{m as n,b as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,m as t,o as n,p as r}from"./i18n-CpTZLchQ.js";var i=e(t(),1),a=r(),o=`docs.nextclaw.io`,s=`nextclaw-docs.pages.dev`,c=new Set([o,`www.${o}`,s,`www.${s}`]),l=`https://${o}`,u=`/guide/getting-started`,d=(0,i.createContext)(null),f=0;function p(){return f+=1,`doc-tab-${Date.now()}-${f}`}function m(e){try{return new URL(e).pathname.replace(/\.html$/,``).replace(/\/$/,``)}catch{return e}}function h(e){return e===`zh`?`zh`:`en`}function g(e,t){let n=e.startsWith(`/`)?e:`/${e}`;return n===`/`||n===``?`/${t}/`:/^\/(en|zh)(\/|$)/.test(n)?n:`/${t}${n}`}function _(e){let t=h(n());try{let n=new URL(e,l);return c.has(n.hostname)&&(n.pathname=g(n.pathname,t)),n.toString()}catch{return new URL(`/${t}${u}`,l).toString()}}function v(){return _(u)}function y(e,t,n=`Docs`){try{let r=new URL(e,l);if(r.protocol===`data:`)return t===`docs`?n:`Detail`;let i=r.pathname.split(`/`).filter(Boolean),a=i[i.length-1]??n;return decodeURIComponent(a).replace(/[-_]/g,` `).slice(0,40)||n}catch{return n}}function b(e,t,n){let r=n?.trim()||y(e,t,t===`docs`?`Docs`:`Detail`);return{id:p(),kind:t,title:r,currentUrl:e,history:[e],historyIndex:0,navVersion:0}}function x(e,t){return{...e,tabs:e.tabs.map(n=>n.id===e.activeTabId?t(n):n)}}function S(){let e=(0,i.useContext)(d);if(!e)throw Error(`useDocBrowser must be used within DocBrowserProvider`);return e}function C(e){try{let t=new URL(e,window.location.origin);return c.has(t.hostname)}catch{return!1}}function w(e){return C(e)?`docs`:`content`}function T(e,t){return t===`docs`?_(e):e}function E(e){return e.url&&e.url.trim().length>0?T(e.url,e.kind):e.kind===`docs`?v():e.activeTab?.currentUrl??v()}function D({children:e}){let t=b(v(),`docs`,`Docs`),[n,r]=(0,i.useState)({isOpen:!1,mode:`docked`,tabs:[t],activeTabId:t.id}),o=(0,i.useMemo)(()=>n.tabs.find(e=>e.id===n.activeTabId)??n.tabs[0],[n.tabs,n.activeTabId]),s=(0,i.useCallback)((e,t)=>{r(n=>{let r=n.tabs.find(e=>e.id===n.activeTabId)??n.tabs[0],i=t?.kind??(e?w(e):r?.kind??`docs`),a=E({url:e,kind:i,activeTab:r});if(t?.newTab||!r||r.kind!==i){let e=b(a,i,t?.title);return{...n,isOpen:!0,tabs:[...n.tabs,e],activeTabId:e.id}}return{...x(n,e=>m(a)===m(e.currentUrl)?t?.title?{...e,title:t.title}:e:{...e,title:t?.title||e.title,kind:i,currentUrl:a,history:[...e.history.slice(0,e.historyIndex+1),a],historyIndex:e.historyIndex+1,navVersion:e.navVersion+1}),isOpen:!0}})},[]),c=(0,i.useCallback)(()=>{r(e=>({...e,isOpen:!1}))},[]),l=(0,i.useCallback)(()=>{r(e=>({...e,mode:e.mode===`floating`?`docked`:`floating`}))},[]),u=(0,i.useCallback)(e=>{r(t=>({...t,mode:e}))},[]),f=(0,i.useCallback)(e=>{r(t=>{if(!t.tabs.length){let e=b(v(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id,isOpen:!0}}return x(t,t=>{if(t.kind!==`docs`)return t;let n=T(e,`docs`);return m(n)===m(t.currentUrl)?t:{...t,currentUrl:n,history:[...t.history.slice(0,t.historyIndex+1),n],historyIndex:t.historyIndex+1,navVersion:t.navVersion+1}})})},[]),p=(0,i.useCallback)(e=>{r(t=>{if(!t.tabs.length){let e=b(v(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id}}return x(t,t=>t.kind!==`docs`||m(e)===m(t.currentUrl)?t:{...t,currentUrl:e,history:[...t.history.slice(0,t.historyIndex+1),e],historyIndex:t.historyIndex+1})})},[]),h=(0,i.useCallback)(()=>{r(e=>x(e,e=>{if(e.kind!==`docs`||e.historyIndex<=0)return e;let t=e.historyIndex-1;return{...e,historyIndex:t,currentUrl:e.history[t]}}))},[]),g=(0,i.useCallback)(()=>{r(e=>x(e,e=>{if(e.kind!==`docs`||e.historyIndex>=e.history.length-1)return e;let t=e.historyIndex+1;return{...e,historyIndex:t,currentUrl:e.history[t]}}))},[]),_=(0,i.useCallback)((e,t)=>{s(e,{...t??{},newTab:!0})},[s]),y=(0,i.useCallback)(e=>{r(t=>{if(t.tabs.length<=1){let e=b(v(),`docs`,`Docs`);return{...t,isOpen:!1,tabs:[e],activeTabId:e.id}}let n=t.tabs.findIndex(t=>t.id===e);if(n<0)return t;let r=t.tabs.filter(t=>t.id!==e),i=t.activeTabId===e?r[Math.max(0,n-1)]?.id??r[0].id:t.activeTabId;return{...t,tabs:r,activeTabId:i}})},[]),S=(0,i.useCallback)(e=>{r(t=>t.tabs.some(t=>t.id===e)?{...t,activeTabId:e,isOpen:!0}:t)},[]),C=!!(o&&o.kind===`docs`&&o.historyIndex>0),D=!!(o&&o.kind===`docs`&&o.historyIndex<o.history.length-1),O=(0,i.useMemo)(()=>({...n,currentTab:o,currentUrl:o?.currentUrl??v(),navVersion:o?.navVersion??0,open:s,close:c,toggleMode:l,setMode:u,navigate:f,syncUrl:p,goBack:h,goForward:g,openNewTab:_,closeTab:y,setActiveTab:S,canGoBack:C,canGoForward:D}),[n,o,s,c,l,u,f,p,h,g,_,y,S,C,D]);return(0,a.jsx)(d.Provider,{value:O,children:e})}export{S as i,D as n,C as r,l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r}from"./i18n-CpTZLchQ.js";import{r as i}from"./dist-BruyLa92.js";import{t as a}from"./book-open-DzdUViDm.js";import{a as o,n as s,t as c}from"./ProviderScopedModelInput-B3HWP4oz.js";import{t as l}from"./loader-circle-Bc2gCU33.js";import{t as u}from"./DocBrowserContext-BXydqby-.js";import{Ct as d,S as f,b as p,mt as m,nt as h,pt as g,x as _,z as v}from"./index-zDZfXoI4.js";import{t as y}from"./skeleton-D5rdKvzy.js";import{n as b,t as x}from"./page-layout-0UcO9H9Z.js";import{t as S}from"./config-hints-BhTmc9P1.js";var C=e(n(),1),w=r(),T=`provider/model`;function E(){let{data:e,isLoading:n}=p(),{data:r}=_(),{data:E}=f(),D=v(),[O,k]=(0,C.useState)(``),[A,j]=(0,C.useState)(``),M=E?.uiHints,N=S(`agents.defaults.model`,M),P=S(`agents.defaults.workspace`,M),F=(0,C.useMemo)(()=>s({meta:r,config:e,onlyConfigured:!0}),[e,r]);(0,C.useEffect)(()=>{e?.agents?.defaults&&(k((e.agents.defaults.model||``).trim()),j(e.agents.defaults.workspace||``))},[e]);let I=t(`modelIdentifierHelp`)||N?.help||``;return n?(0,w.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(y,{className:`h-8 w-32`}),(0,w.jsx)(y,{className:`h-4 w-48`})]}),(0,w.jsxs)(h,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mb-6`,children:[(0,w.jsx)(y,{className:`h-12 w-12 rounded-xl`}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(y,{className:`h-5 w-24`}),(0,w.jsx)(y,{className:`h-3 w-32`})]})]}),(0,w.jsx)(y,{className:`h-4 w-20 mb-2`}),(0,w.jsx)(y,{className:`h-10 w-full rounded-xl`})]}),(0,w.jsxs)(h,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,w.jsx)(y,{className:`h-5 w-24 mb-2`}),(0,w.jsx)(y,{className:`h-10 w-full rounded-xl`})]})]}):(0,w.jsxs)(b,{children:[(0,w.jsx)(x,{title:t(`modelPageTitle`),description:t(`modelPageDescription`)}),(0,w.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),D.mutate({model:O,workspace:A})},className:`space-y-8`,children:[(0,w.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-8`,children:[(0,w.jsxs)(`div`,{className:`p-8 rounded-2xl bg-white border border-gray-200 shadow-card`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,w.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white`,children:(0,w.jsx)(d,{className:`h-5 w-5`})}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`defaultModel`)})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(g,{htmlFor:`model`,className:`text-xs font-semibold text-gray-500 uppercase tracking-wider`,children:N?.label??`Model Name`}),(0,w.jsx)(c,{id:`model`,value:O,onChange:k,providerCatalog:F,modelPlaceholder:N?.placeholder??T}),(0,w.jsx)(`p`,{className:`text-xs text-gray-400`,children:I}),(0,w.jsxs)(`a`,{href:`${u}/guide/model-selection`,className:`inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors`,children:[(0,w.jsx)(a,{className:`h-3.5 w-3.5`}),t(`channelsGuideTitle`)]})]})]}),(0,w.jsxs)(`div`,{className:`p-8 rounded-2xl bg-white border border-gray-200 shadow-card`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,w.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white`,children:(0,w.jsx)(o,{className:`h-5 w-5`})}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:t(`workspace`)})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(g,{htmlFor:`workspace`,className:`text-xs font-semibold text-gray-500 uppercase tracking-wider`,children:P?.label??`Default Path`}),(0,w.jsx)(m,{id:`workspace`,value:A,onChange:e=>j(e.target.value),placeholder:P?.placeholder??`/path/to/workspace`,className:`rounded-xl`})]})]})]}),(0,w.jsx)(`div`,{className:`flex justify-end pt-4`,children:(0,w.jsx)(i,{type:`submit`,disabled:D.isPending,size:`lg`,children:D.isPending?(0,w.jsx)(l,{className:`h-5 w-5 animate-spin`}):t(`saveChanges`)})})]})]})}export{E as ModelConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-CpTZLchQ.js";import{a,i as o,k as s,n as c,r as l,t as u}from"./select-CVz0t7MF.js";import{t as d}from"./createLucideIcon-dy5ie7Ox.js";import{mt as f}from"./index-zDZfXoI4.js";var p=d(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),m=d(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),h=e(n(),1),g=r();function _(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function v({id:e,value:t,onChange:n,options:r,disabled:a=!1,placeholder:o,className:c,inputClassName:l,emptyText:u,createText:d,maxItems:m=1/0,onEnter:v}){let[y,b]=(0,h.useState)(!1);(0,h.useEffect)(()=>{a&&y&&b(!1)},[a,y]);let x=(0,h.useMemo)(()=>_(r),[r]),S=t.trim().toLowerCase(),C=(0,h.useMemo)(()=>{let e=x.map((e,t)=>({option:e,index:t}));S.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===S?0:n.startsWith(S)?1:n.includes(S)?2:3,a=r===S?0:r.startsWith(S)?1:r.includes(S)?2:3;return i===a?e.index-t.index:i-a});let t=e.map(e=>e.option);return Number.isFinite(m)?t.slice(0,Math.max(1,m)):t},[x,S,m]),w=t.trim().length>0&&x.some(e=>e===t.trim());return(0,g.jsxs)(`div`,{className:i(`relative`,c),onBlur:()=>{setTimeout(()=>b(!1),120)},children:[(0,g.jsx)(f,{id:e,value:t,disabled:a,onFocus:()=>{a||b(!0)},onChange:e=>{n(e.target.value),!y&&!a&&b(!0)},onKeyDown:e=>{e.key===`Enter`&&(v&&(e.preventDefault(),v()),b(!1))},placeholder:o,className:i(`pr-10`,l)}),(0,g.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(e=>!e),disabled:a,className:i(`absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center`,a?`cursor-not-allowed text-gray-300`:`text-gray-400 hover:text-gray-600`),"aria-label":`toggle model options`,children:(0,g.jsx)(p,{className:`h-4 w-4`})}),y&&!a&&(0,g.jsx)(`div`,{className:`absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg`,children:(0,g.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[!w&&t.trim().length>0&&(0,g.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(t.trim()),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,g.jsx)(s,{className:`h-4 w-4 text-transparent`}),(0,g.jsx)(`span`,{className:`truncate text-gray-700`,children:d?d.replace(`{value}`,t.trim()):t.trim()})]}),C.map(e=>(0,g.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(e),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,g.jsx)(s,{className:i(`h-4 w-4`,e===t.trim()?`text-primary`:`text-transparent`)}),(0,g.jsx)(`span`,{className:`truncate text-gray-700`,children:e})]},e)),C.length===0&&t.trim().length===0&&(0,g.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:u??`No models available`})]})})]})}var y=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]);function b(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function x(e,t){let n=e.trim(),r=t.trim();if(!n||!r)return n;let i=`${r}/`;return n.startsWith(i)?n.slice(i.length):n}function S(e,t){let n=e.trim();if(!n)return``;for(let e of t)n=x(n,e);return n.trim()}function C(e,t){let n=t.trim(),r=e.trim();return n?r?`${r}/${n}`:n:``}function w(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&y.has(t)?t:null}function T(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=w(n);!e||t.includes(e)||t.push(e)}return t}function E(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=S(r,t);if(!e)continue;let a=T(i?.supported);if(a.length===0)continue;let o=w(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function D(e,t,n){let r=S(t,n);return r?e[r]??null:null}function O(e,t){let n=e.trim();if(!n)return null;let r=null;for(let e of t)for(let t of e.aliases){let i=t.trim();i&&(n===i||n.startsWith(`${i}/`))&&(!r||i.length>r.score)&&(r={name:e.name,score:i.length})}if(r)return r.name;for(let e of t){let t=S(n,e.aliases);if(t&&b(e.models??[]).some(e=>e===t))return e.name}return null}function k(e){return e?e.enabled!==!1&&e.apiKeySet===!0:!1}function A(e){let{meta:t,config:n,onlyConfigured:r=!1}=e,i=(t?.providers??[]).map(e=>{let t=n?.providers?.[e.name],r=(e.modelPrefix||e.name||``).trim(),i=b([e.modelPrefix||``,e.name||``]),a=b((e.defaultModels??[]).map(e=>S(e,i))),o=b((t?.models??[]).map(e=>S(e,i))),s=b([...a,...o]),c=E(t?.modelThinking,i),l=t?.displayName?.trim(),u=k(t);return{name:e.name,displayName:l||e.displayName||e.name,prefix:r,aliases:i,models:s,modelThinking:c,configured:u}});return r?i.filter(e=>e.configured&&e.models.length>0):i}var j=`provider/model`;function M(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function N({id:e,value:n,onChange:r,providerCatalog:i,disabled:s=!1,providerPlaceholder:d,modelPlaceholder:p,className:m}){let[_,y]=(0,h.useState)(``),[b,x]=(0,h.useState)(``),w=i.length>0,T=p??j,E=(0,h.useMemo)(()=>new Map(i.map(e=>[e.name,e])),[i]),D=E.get(_),k=(0,h.useMemo)(()=>D?.aliases??[],[D]),A=(0,h.useMemo)(()=>M(D?.models??[]),[D]);return(0,h.useEffect)(()=>{let e=n.trim();if(!w){y(``),x(e);return}if(!e){x(``),y(e=>E.has(e)?e:``);return}let t=O(e,i)??``,r=E.get(t)?.aliases??[];y(t),x(t?S(e,r):e)},[w,i,E,n]),w?(0,g.jsxs)(`div`,{className:m,children:[(0,g.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,g.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,g.jsxs)(u,{value:_,onValueChange:e=>{let t=M(E.get(e)?.models??[])[0]??``;if(y(e),x(t),!t){r(``);return}r(C(E.get(e)?.prefix??e,t))},disabled:s,children:[(0,g.jsx)(o,{className:`h-10 w-full rounded-xl`,children:(0,g.jsx)(a,{placeholder:d??t(`providersSelectPlaceholder`)})}),(0,g.jsx)(c,{children:i.map(e=>(0,g.jsx)(l,{value:e.name,children:e.displayName},e.name))})]})}),(0,g.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,g.jsx)(v,{id:e,value:b,onChange:e=>{if(!D){let t=e.trim();x(t),r(t);return}let t=S(e,k);x(t),r(t?C(D.prefix,t):``)},options:A,disabled:s||!_,placeholder:T,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:t(`modelPickerNoOptions`),createText:t(`modelPickerUseCustom`)},_)]}),(0,g.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:t(`modelInputCustomHint`)})]}):(0,g.jsxs)(`div`,{className:m,children:[(0,g.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 px-4 py-3`,children:[(0,g.jsx)(`p`,{className:`text-sm font-semibold text-amber-950`,children:t(`providersEmptyTitle`)}),(0,g.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-amber-900`,children:t(`providersEmptyDescription`)})]}),(0,g.jsx)(f,{id:e,value:n,disabled:s,onChange:e=>r(e.target.value),placeholder:T,className:`mt-3 h-10 rounded-xl`}),(0,g.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:t(`modelInputCustomHint`)})]})}export{m as a,D as i,A as n,C as r,N as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,o as r,p as i,u as a}from"./i18n-CpTZLchQ.js";import{n as o,r as s}from"./dist-BruyLa92.js";import{s as c}from"./client-C-8fH7-c.js";import{O as l,a as u,i as d,n as f,r as p,t as m}from"./select-CVz0t7MF.js";import{t as h}from"./createLucideIcon-dy5ie7Ox.js";import{t as g}from"./plus-CG0QrVY_.js";import{t as _}from"./search-BCAlB8nz.js";import{t as v}from"./trash-2-mJT6oWa2.js";import{t as y}from"./x-Czwxm82I.js";import{C as b,D as x,F as ee,I as te,N as ne,S as re,V as ie,b as ae,d as oe,k as se,kt as S,l as ce,mt as C,pt as w,u as T,x as le}from"./index-zDZfXoI4.js";import{t as ue}from"./LogoBadge-hO7tY7hE.js";import{n as E,t as de}from"./page-layout-0UcO9H9Z.js";import{t as D}from"./tabs-custom-YcZUWn3o.js";import{t as O}from"./status-dot-DpPtVzQT.js";import{t as k}from"./config-hints-BhTmc9P1.js";import{a as fe,c as pe,i as A,n as me,o as he,r as j,s as ge,t as _e}from"./config-split-page-BUout_Ak.js";import{t as M}from"./switch-CM29eCAR.js";import{t as N}from"./setting-row-CbVHAuQt.js";var ve=h(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),ye=h(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),be=h(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),xe=h(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),P=e(n(),1),F=i();function Se({isSet:e,className:t,value:n,onChange:r,placeholder:i,...o}){let[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),f=typeof n==`string`&&n.length>0;return(0,F.jsxs)(`div`,{className:`relative`,children:[e&&!f&&!u?(0,F.jsx)(`div`,{onClick:()=>d(!0),className:a(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,t),children:`••••••••••••`}):(0,F.jsx)(C,{type:c?`text`:`password`,className:a(`pr-12`,t),value:n,onChange:r,onBlur:()=>{f||d(!1)},placeholder:i,autoFocus:u,...o}),(0,F.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||f)&&(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>l(!c),children:c?(0,F.jsx)(ye,{className:`h-4 w-4`}):(0,F.jsx)(be,{className:`h-4 w-4`})})})]})}function Ce({value:e,onChange:n,className:r}){let i=e?Object.entries(e):[],o=(e,t,r)=>{let a=[...i];a[e]=[t,r],n(Object.fromEntries(a))},c=()=>{n({...e,"":``})},l=e=>{let t=i.filter((t,n)=>n!==e);n(Object.fromEntries(t))};return(0,F.jsxs)(`div`,{className:a(`space-y-2`,r),children:[i.map(([e,n],r)=>(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(C,{type:`text`,value:e,onChange:e=>o(r,e.target.value,n),placeholder:t(`headerName`),className:`flex-1`}),(0,F.jsx)(C,{type:`text`,value:n,onChange:t=>o(r,e,t.target.value),placeholder:t(`headerValue`),className:`flex-1`}),(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,F.jsx)(v,{className:`h-4 w-4 text-red-500`})})]},r)),(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,F.jsx)(g,{className:`h-4 w-4 mr-2`}),t(`add`)]})]})}function we(e){let{value:t,onChange:n,options:r}=e;return(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function Te(e){let{showAdvanced:n,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:h,extraHeadersLabel:g,extraHeaders:_,onExtraHeadersChange:v}=e;return(0,F.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(xe,{className:`h-3.5 w-3.5`}),t(`providerAdvancedSettings`)]}),(0,F.jsx)(l,{className:`h-4 w-4 transition-transform ${n?`rotate-180`:``}`})]}),n?(0,F.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(w,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),c?(0,F.jsx)(we,{value:o,onChange:e=>s(e),options:h}):(0,F.jsxs)(m,{value:o,onValueChange:e=>s(e),children:[(0,F.jsx)(d,{className:`rounded-xl`,children:(0,F.jsx)(u,{})}),(0,F.jsx)(f,{children:h.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]})]}):null,(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(w,{className:`text-sm font-medium text-gray-900`,children:g}),(0,F.jsx)(Ce,{value:_,onChange:v}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerExtraHeadersHelpShort`)})]})]}):null]})}function Ee(e){let{providerAuth:n,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:c,resolvedAuthMethodId:l,onAuthMethodChange:h,onStartProviderAuth:g,onImportProviderAuthFromCli:_,startPending:v,importPending:y,authSessionId:b,authStatusMessage:x}=e;return n?.kind===`device_code`?(0,F.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,F.jsx)(w,{className:`text-sm font-medium text-gray-900`,children:n.displayName||t(`providerAuthSectionTitle`)}),r?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:r}):null,a>1?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(w,{className:`text-xs font-medium text-gray-700`,children:t(`providerAuthMethodLabel`)}),c?(0,F.jsx)(we,{value:l,onChange:h,options:i}):(0,F.jsxs)(m,{value:l,onValueChange:h,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white`,children:(0,F.jsx)(u,{placeholder:t(`providerAuthMethodPlaceholder`)})}),(0,F.jsx)(f,{children:i.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]}),o?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:o}):null]}):null,(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v||!!b,children:t(v?`providerAuthStarting`:b?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),n.supportsCliImport?(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:_,disabled:y,children:t(y?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,b?(0,F.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[t(`providerAuthSessionLabel`),`: `,b.slice(0,8),`…`]}):null]}),x?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:x}):null]}):null}function De(e){let{enabled:n,onChange:r}=e;return(0,F.jsx)(N,{tone:`muted`,title:t(`enabled`),control:(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-gray-500`,children:t(n?`enabled`:`disabled`)}),(0,F.jsx)(M,{checked:n,onCheckedChange:r})]})})}var Oe={enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},ke=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`],Ae=new Set(ke);function I(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function je(e,t){let n=I(e),r=I(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function Me(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function L(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function R(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=L(n,t))}return n.trim()}function Ne(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Pe(e,t){let n=[...e];for(let e of t)n.includes(e)||n.push(e);return n}function Fe(e,t){return t.length===0?e:t.every(t=>!e.includes(t))?Pe(e,t):t}function Ie(e,t){return Ne(e,t)?[]:e}function Le(e,t,n){t!==n&&(e.enabled=t)}function z(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&Ae.has(t)?t:null}function Re(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=z(n);!e||t.includes(e)||t.push(e)}return t}function ze(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=R(r,t);if(!e)continue;let a=Re(i?.supported);if(a.length===0)continue;let o=z(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function Be(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e=Re(i.supported);if(e.length===0)continue;let a=z(i.default);r[t]=a&&e.includes(a)?{supported:e,default:a}:{supported:e}}return r}function Ve(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!Ne([...o.supported].sort(),[...s.supported].sort())||(o.default??null)!==(s.default??null))return!1}return!0}function He(e){return t(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Ue(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function We(e){return e.required&&e.hasDefault&&e.optionCount>1&&e.optionCount<=3}function Ge(e){let{models:n,modelThinking:r,modelDraft:i,showModelInput:a,onModelDraftChange:o,onShowModelInputChange:c,onAddModel:l,onRemoveModel:h,onToggleModelThinkingLevel:_,onSetModelThinkingDefault:v,thinkingLevels:b,formatThinkingLevelLabel:x}=e;return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(w,{className:`text-sm font-medium text-gray-900`,children:t(`providerModelsTitle`)}),a?null:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,F.jsx)(g,{className:`h-3 w-3`}),t(`providerAddModel`)]})]}),a?(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(C,{value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(c(!1),o(``))},placeholder:t(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,F.jsx)(s,{type:`button`,size:`sm`,onClick:l,disabled:i.trim().length===0,children:t(`add`)}),(0,F.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{c(!1),o(``)},children:(0,F.jsx)(y,{className:`h-4 w-4`})})]}):null,n.length===0?(0,F.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,F.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`providerModelsEmptyShort`)}),a?null:(0,F.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:t(`providerAddFirstModel`)})]}):(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map(e=>{let n=r[e],i=n?.supported??[],a=n?.default??null;return(0,F.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5`,children:[(0,F.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,F.jsxs)(ce,{children:[(0,F.jsx)(oe,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":t(`providerModelThinkingTitle`),title:t(`providerModelThinkingTitle`),children:(0,F.jsx)(xe,{className:`h-3 w-3`})})}),(0,F.jsxs)(T,{className:`w-80 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:t(`providerModelThinkingTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingHint`)})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>_(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${i.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:x(t)},t))}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(w,{className:`text-xs font-medium text-gray-700`,children:t(`providerModelThinkingDefault`)}),(0,F.jsxs)(m,{value:a??`__none__`,onValueChange:t=>v(e,t===`__none__`?null:t),disabled:i.length===0,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,F.jsx)(u,{})}),(0,F.jsxs)(f,{children:[(0,F.jsx)(p,{value:`__none__`,children:t(`providerModelThinkingDefaultNone`)}),i.map(e=>(0,F.jsx)(p,{value:e,children:x(e)},e))]})]}),i.length===0?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":t(`remove`),children:(0,F.jsx)(y,{className:`h-3 w-3`})})]},e)})})]})}function Ke(e){return e.enabled?(0,F.jsx)(O,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?t(`statusReady`):t(`statusSetup`),className:e.className}):(0,F.jsx)(O,{status:`inactive`,label:t(`disabled`),className:e.className})}function qe({providerName:e,onProviderDeleted:n}){let i=c(),{data:a}=ae(),{data:l}=le(),{data:u}=re(),d=ie(),f=x(),p=te(),m=ee(),h=ne(),g=se(),[_,y]=(0,P.useState)(``),[b,oe]=(0,P.useState)(!0),[S,ce]=(0,P.useState)(``),[T,ue]=(0,P.useState)(null),[E,de]=(0,P.useState)(`auto`),[D,O]=(0,P.useState)([]),[A,j]=(0,P.useState)({}),[_e,M]=(0,P.useState)(``),[N,ye]=(0,P.useState)(``),[be,xe]=(0,P.useState)(!1),[Ce,we]=(0,P.useState)(!1),[Ae,L]=(0,P.useState)(null),[Pe,z]=(0,P.useState)(``),[Re,qe]=(0,P.useState)(``),B=(0,P.useRef)(null),V=l?.providers.find(t=>t.name===e),H=(e?a?.providers[e]:null)??Oe,Je=u?.uiHints,U=!!V?.isCustom,Ye=e?k(`providers.${e}.apiKey`,Je):void 0,Xe=e?k(`providers.${e}.apiBase`,Je):void 0,Ze=e?k(`providers.${e}.extraHeaders`,Je):void 0,Qe=e?k(`providers.${e}.wireApi`,Je):void 0,$e=V?.displayName||e||``,W=(H.displayName||``).trim()||$e,G=H.enabled!==!1,et=N.trim()||W||e||t(`providersSelectPlaceholder`),K=(0,P.useMemo)(()=>Me([V?.modelPrefix||e||``,e||``]),[e,V?.modelPrefix]),tt=V?.defaultApiBase||``,nt=H.apiBase||tt,rt=I(H.extraHeaders||null),it=H.wireApi||V?.defaultWireApi||`auto`,at=(0,P.useMemo)(()=>Me((V?.defaultModels??[]).map(e=>R(e,K))),[V?.defaultModels,K]),ot=(0,P.useMemo)(()=>Me((H.models??[]).map(e=>R(e,K))),[H.models,K]),q=(0,P.useMemo)(()=>Fe(at,ot),[at,ot]),J=(0,P.useMemo)(()=>Be(ze(H.modelThinking,K),q),[q,K,H.modelThinking]),Y=r(),st=V?.apiBaseHelp?.[Y]||V?.apiBaseHelp?.en||Xe?.help||t(`providerApiBaseHelp`),X=V?.auth,Z=X?.methods??[],Q=!!V?.supportsWireApi||U,ct=(0,P.useMemo)(()=>Z.map(e=>({value:e.id,label:e.label?.[Y]||e.label?.en||e.id})),[Z,Y]),lt=(0,P.useMemo)(()=>Ue({providerName:e,methods:Z,defaultMethodId:X?.defaultMethodId,language:Y}),[e,X?.defaultMethodId,Z,Y]),ut=(0,P.useMemo)(()=>{if(!Z.length)return``;let e=Re.trim();return e&&Z.some(t=>t.id===e)?e:lt||Z[0]?.id||``},[Re,lt,Z]),dt=(0,P.useMemo)(()=>Z.find(e=>e.id===ut),[Z,ut]),ft=We({required:X?.kind===`device_code`,hasDefault:!!X?.defaultMethodId?.trim(),optionCount:Z.length}),pt=(V?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:t(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),mt=We({required:Q,hasDefault:typeof V?.defaultWireApi==`string`&&V.defaultWireApi.length>0,optionCount:pt.length}),$=(0,P.useCallback)(()=>{B.current!==null&&(window.clearTimeout(B.current),B.current=null)},[]),ht=(0,P.useCallback)((n,r)=>{$(),B.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await h.mutateAsync({provider:e,data:{sessionId:n}});if(a.status===`pending`){z(t(`providerAuthWaitingBrowser`)),ht(n,a.nextPollMs??r);return}if(a.status===`authorized`){L(null),$(),z(t(`providerAuthCompleted`)),o.success(t(`providerAuthCompleted`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]});return}L(null),$(),z(a.message||`Authorization ${a.status}.`),o.error(a.message||`Authorization ${a.status}.`)}catch(e){L(null),$();let t=e instanceof Error?e.message:String(e);z(t),o.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,r))},[$,h,e,i]);(0,P.useEffect)(()=>{if(!e){y(``),oe(!0),ce(``),ue(null),de(`auto`),O([]),j({}),M(``),ye(``),L(null),z(``),qe(``),$();return}y(``),oe(G),ce(nt),ue(H.extraHeaders||null),de(it),O(q),j(J),M(``),ye(W),L(null),z(``),qe(lt),$()},[e,nt,G,H.extraHeaders,it,q,J,W,lt,$]),(0,P.useEffect)(()=>()=>$(),[$]),(0,P.useEffect)(()=>j(e=>Be(e,D)),[D]);let gt=(0,P.useMemo)(()=>e?_.trim().length>0||b!==G||S.trim()!==nt.trim()||!je(T,rt)||Q&&E!==it||!Ne(D,q)||!Ve(A,J)||U&&N.trim()!==W:!1,[e,_,b,G,S,nt,T,rt,Q,E,it,D,q,A,J,U,N,W]);return!e||!V?(0,F.jsx)(me,{children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:t(`providersSelectTitle`)}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:t(`providersSelectDescription`)})]})}):(0,F.jsxs)(fe,{children:[(0,F.jsx)(pe,{className:`px-6 py-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:et}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[U&&(0,F.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!e||!U)&&window.confirm(t(`providerDeleteConfirm`)))try{await f.mutateAsync({provider:e}),n?.(e)}catch{}},disabled:f.isPending,className:`text-gray-400 transition-colors hover:text-red-500`,title:t(`providerDelete`),children:(0,F.jsx)(v,{className:`h-4 w-4`})}),(0,F.jsx)(Ke,{enabled:G,apiKeySet:H.apiKeySet})]})]})}),(0,F.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=_.trim(),i=S.trim(),a=I(T),o=N.trim();U&&o!==W&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),Le(n,b,G),i!==nt.trim()&&(n.apiBase=i.length>0&&i!==tt?i:null),je(a,rt)||(n.extraHeaders=a),Q&&E!==it&&(n.wireApi=E),Ne(D,q)||(n.models=Ie(D,at)),Ve(A,J)||(n.modelThinking=Be(A,D)),d.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(he,{className:`space-y-5 px-6 py-5`,children:[(0,F.jsx)(De,{enabled:b,onChange:oe}),U&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(w,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:t(`providerDisplayName`)}),(0,F.jsx)(C,{id:`providerDisplayName`,type:`text`,value:N,onChange:e=>ye(e.target.value),placeholder:$e||t(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerDisplayNameHelpShort`)})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(w,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:Ye?.label??t(`apiKey`)}),(0,F.jsx)(Se,{id:`apiKey`,value:_,isSet:H.apiKeySet,onChange:e=>y(e.target.value),placeholder:Ye?.placeholder??t(`enterApiKey`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`leaveBlankToKeepUnchanged`)})]}),(0,F.jsx)(Ee,{providerAuth:X,providerAuthNote:X?.note?.[Y]||X?.note?.en||X?.displayName||``,providerAuthMethodOptions:ct,providerAuthMethodsCount:Z.length,selectedAuthMethodHint:dt?.hint?.[Y]||dt?.hint?.en||``,shouldUseAuthMethodPills:ft,resolvedAuthMethodId:ut,onAuthMethodChange:qe,onStartProviderAuth:async()=>{if(!(!e||X?.kind!==`device_code`))try{z(``);let n=await m.mutateAsync({provider:e,data:ut?{methodId:ut}:{}});if(!n.sessionId||!n.verificationUri)throw Error(t(`providerAuthStartFailed`));L(n.sessionId),z(`${t(`providerAuthOpenPrompt`)}${n.userCode}${t(`providerAuthOpenPromptSuffix`)}`),window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),ht(n.sessionId,n.intervalMs)}catch(e){let n=e instanceof Error?e.message:String(e);L(null),$(),z(n),o.error(`${t(`providerAuthStartFailed`)}: ${n}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||X?.kind!==`device_code`))try{$(),L(null);let n=await g.mutateAsync({provider:e});z(`${t(`providerAuthImportStatusPrefix`)}${n.expiresAt?` (expires: ${n.expiresAt})`:``}`),o.success(t(`providerAuthImportSuccess`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]})}catch(e){let n=e instanceof Error?e.message:String(e);z(n),o.error(`${t(`providerAuthImportFailed`)}: ${n}`)}},startPending:m.isPending,importPending:g.isPending,authSessionId:Ae,authStatusMessage:Pe}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(w,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Xe?.label??t(`apiBase`)}),(0,F.jsx)(C,{id:`apiBase`,type:`text`,value:S,onChange:e=>ce(e.target.value),placeholder:tt||Xe?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:st})]}),(0,F.jsx)(Ge,{models:D,modelThinking:A,modelDraft:_e,showModelInput:Ce,onModelDraftChange:M,onShowModelInputChange:we,onAddModel:()=>{let e=R(_e,K);if(e){if(D.includes(e)){M(``);return}O(t=>[...t,e]),M(``)}},onRemoveModel:e=>{O(t=>t.filter(t=>t!==e)),j(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{j(n=>{let r=n[e],i=r?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):ke.filter(e=>e===t||i.includes(e));if(a.length===0){let t={...n};return delete t[e],t}let o=r?.default&&a.includes(r.default)?r.default:void 0;return{...n,[e]:o?{supported:a,default:o}:{supported:a}}})},onSetModelThinkingDefault:(e,t)=>{j(n=>{let r=n[e];return!r||r.supported.length===0||t&&!r.supported.includes(t)?n:{...n,[e]:t?{supported:r.supported,default:t}:{supported:r.supported}}})},thinkingLevels:ke,formatThinkingLevelLabel:He}),(0,F.jsx)(Te,{showAdvanced:be,onShowAdvancedChange:xe,supportsWireApi:Q,wireApiLabel:Qe?.label??t(`wireApi`),wireApi:E,onWireApiChange:de,shouldUseWireApiPills:mt,wireApiSelectOptions:pt,extraHeadersLabel:Ze?.label??t(`extraHeaders`),extraHeaders:T,onExtraHeadersChange:ue})]}),(0,F.jsxs)(ge,{className:`flex items-center justify-between px-6 py-4`,children:[(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let n=R(D.find(e=>e.trim().length>0)??``,K),r={apiBase:S.trim(),extraHeaders:I(T),model:n||null};_.trim().length>0&&(r.apiKey=_.trim()),Q&&(r.wireApi=E);try{let n=await p.mutateAsync({provider:e,data:r});if(n.success){o.success(`${t(`providerTestConnectionSuccess`)} (${n.latencyMs}ms)`);return}let i=[`provider=${n.provider}`,`latency=${n.latencyMs}ms`];n.model&&i.push(`model=${n.model}`),o.error(`${t(`providerTestConnectionFailed`)}: ${n.message} | ${i.join(` | `)}`)}catch(e){let n=e instanceof Error?e.message:String(e);o.error(`${t(`providerTestConnectionFailed`)}: ${n}`)}},disabled:p.isPending,children:[(0,F.jsx)(ve,{className:`mr-1.5 h-4 w-4`}),p.isPending?t(`providerTestingConnection`):t(`providerTestConnection`)]}),(0,F.jsx)(s,{type:`submit`,disabled:d.isPending||!gt,children:d.isPending?t(`saving`):t(gt?`save`:`unchanged`)})]})]})]})}function B(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function V(e){return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let n=e.provider.name===`nextclaw`?1:0,r=t.provider.name===`nextclaw`?1:0;return n===r?e.index-t.index:n-r}).map(({provider:e})=>e)}function H(){let{data:e}=ae(),{data:n}=le(),{data:r}=re(),i=b(),[o,c]=(0,P.useState)(`installed`),[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)(``),p=(0,P.useMemo)(()=>V(n?.providers??[]),[n?.providers]),m=e?.providers??{},h=(0,P.useMemo)(()=>{let e=d.trim().toLowerCase();return p.filter(e=>o!==`installed`||!!(m[e.name]?.enabled!==!1&&m[e.name]?.apiKeySet)).filter(t=>e?(m[t.name]?.displayName?.trim()||t.displayName||t.name).toLowerCase().includes(e)||t.name.toLowerCase().includes(e):!0)},[o,p,m,d]);return(0,P.useEffect)(()=>{u(h.some(e=>e.name===l)?l:h[0]?.name)},[h,l]),!e||!n?(0,F.jsx)(`div`,{className:`p-8`,children:t(`providersLoading`)}):(0,F.jsxs)(E,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,F.jsx)(de,{title:t(`providersPageTitle`),description:t(`providersPageDescription`)}),(0,F.jsxs)(A,{className:`xl:min-h-0`,children:[(0,F.jsxs)(fe,{children:[(0,F.jsxs)(pe,{className:`space-y-3 px-4 pb-3 pt-4`,children:[(0,F.jsx)(D,{tabs:[{id:`installed`,label:t(`providersTabConfigured`),count:p.filter(e=>m[e.name]?.enabled!==!1&&m[e.name]?.apiKeySet).length},{id:`all`,label:t(`providersTabAll`),count:p.length}],activeTab:o,onChange:c,className:`mb-0`}),(0,F.jsxs)(s,{type:`button`,variant:`outline`,className:`w-full justify-center`,onClick:async()=>{try{let e=await i.mutateAsync({data:{}});c(`all`),f(``),u(e.name)}catch{}},disabled:i.isPending,children:[(0,F.jsx)(g,{className:`mr-2 h-4 w-4`}),i.isPending?t(`saving`):t(`providerAddCustom`)]})]}),(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,F.jsx)(C,{value:d,onChange:e=>f(e.target.value),placeholder:t(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,F.jsxs)(he,{className:`space-y-2 p-3`,children:[h.map(e=>{let n=m[e.name],i=n?.enabled!==!1,o=!!(i&&n?.apiKeySet),s=n?.displayName?.trim()||e.displayName||e.name,c=B(n?.apiBase||e.defaultApiBase||``)||k(`providers.${e.name}`,r?.uiHints)?.help||t(`providersDefaultDescription`);return(0,F.jsx)(_e,{onClick:()=>u(e.name),active:l===e.name,children:(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,F.jsx)(ue,{name:e.name,src:e.logo?`/logos/${e.logo}`:null,className:a(`h-10 w-10 rounded-lg border`,o?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,F.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:e.name[0]})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:s}),(0,F.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:c})]})]}),(0,F.jsx)(O,{status:i?o?`ready`:`setup`:`inactive`,label:t(i?o?`statusReady`:`statusSetup`:`disabled`),className:`min-w-[56px] justify-center`})]})},e.name)}),h.length===0?(0,F.jsx)(j,{icon:S,title:t(`providersNoMatch`)}):null]})]}),(0,F.jsx)(qe,{providerName:l,onProviderDeleted:e=>{e===l&&u(void 0)}})]})]})}export{H as ProvidersList};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r}from"./i18n-CpTZLchQ.js";import{n as i,r as a}from"./dist-BruyLa92.js";import{s as o}from"./client-C-8fH7-c.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-CVz0t7MF.js";import{t as f}from"./createLucideIcon-dy5ie7Ox.js";import{t as p}from"./loader-circle-Bc2gCU33.js";import{t as m}from"./play-CKDjSQFL.js";import{t as h}from"./plus-CG0QrVY_.js";import{t as g}from"./rotate-cw-oHMKJMC8.js";import{t as _}from"./save-EqJPOF0G.js";import{t as v}from"./trash-2-mJT6oWa2.js";import{H as y,S as b,_ as x,at as S,b as C,ft as w,it as T,lt as E,mt as D,nt as O,ot as k,rt as A,t as j,v as M,y as N}from"./index-zDZfXoI4.js";import{n as ee,t as P}from"./page-layout-0UcO9H9Z.js";import{t as F}from"./config-hints-BhTmc9P1.js";import{t as I}from"./switch-CM29eCAR.js";import{t as L}from"./setting-row-CbVHAuQt.js";var R=f(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),z=e(n(),1),B=r();function V(e){return t(e===`healthy`?`runtimeControlHealthy`:e===`starting-service`?`runtimeControlStartingService`:e===`restarting-service`?`runtimeControlRestartingService`:e===`stopping-service`?`runtimeControlStoppingService`:e===`restarting-app`?`runtimeControlRestartingApp`:e===`recovering`?`runtimeControlRecovering`:e===`failed`?`runtimeControlFailed`:`runtimeControlUnavailable`)}function H(e){return t(e===`running`?`runtimeControlServiceRunning`:e===`stopped`?`runtimeControlServiceStopped`:e===`starting`?`runtimeControlServiceStarting`:e===`stopping`?`runtimeControlServiceStopping`:e===`restarting`?`runtimeControlServiceRestarting`:`runtimeControlServiceUnknown`)}function U(e){return e.environment===`desktop-embedded`?t(`runtimeControlEnvironmentDesktop`):e.environment===`managed-local-service`?t(`runtimeControlEnvironmentManagedService`):e.environment===`self-hosted-web`?t(`runtimeControlEnvironmentSelfHosted`):t(`runtimeControlEnvironmentSharedWeb`)}function W(e){return e?[{action:`start-service`,capability:e.canStartService,label:t(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:t(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:t(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:t(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function G(e){return t(e===`start-service`?`runtimeControlStartingServiceHelp`:e===`restart-service`?`runtimeControlRestartingServiceHelp`:e===`stop-service`?`runtimeControlStoppingServiceHelp`:`runtimeControlRestartingAppHelp`)}function K(e){let{busy:t,icon:n}=e;return t?(0,B.jsx)(p,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,B.jsx)(m,{className:`mr-2 h-4 w-4`}):n===`square`?(0,B.jsx)(R,{className:`mr-2 h-4 w-4`}):(0,B.jsx)(g,{className:`mr-2 h-4 w-4`})}function q(){let e=o(),n=x(),r=M(),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(null),h=n.data,g=s??h?.lifecycle??`healthy`,_=l??h?.serviceState??`unknown`,v=d??h?.message??t(`runtimeControlDescription`),y=r.isPending||p!==null||g===`recovering`,b=W(h),C=h?.pendingRestart??null,w=()=>{c(null),u(null),f(null),m(null)},E=async n=>{let a=n===`start-service`?h?.canStartService:n===`stop-service`?h?.canStopService:h?.canRestartService;if(!a?.available){i.error(a?.reasonIfUnavailable??t(`runtimeControlLoadFailed`));return}if(!(n===`stop-service`&&a.requiresConfirmation&&!window.confirm(t(`runtimeControlStopServiceConfirm`)))){m(n),c(n===`start-service`?`starting-service`:n===`stop-service`?`stopping-service`:`restarting-service`),u(n===`start-service`?`starting`:n===`stop-service`?`stopping`:`restarting`),f(G(n));try{let a=await r.mutateAsync(n);if(i.success(a.message),n===`stop-service`)return;c(`recovering`),f(t(`runtimeControlRecoveringHelp`));let o=await N.waitForRecovery();e.setQueryData([`runtime-control`],o),await e.invalidateQueries({queryKey:[`runtime-control`]}),w(),i.success(t(`runtimeControlRecovered`))}catch(e){let r=e instanceof Error?e.message:t(`runtimeControlActionFailed`);c(`failed`),u(n===`stop-service`?`running`:`unknown`),f(r),m(null),i.error(`${t(`runtimeControlActionFailed`)}: ${r}`)}}},D=async()=>{if(!h?.canRestartApp.available){i.error(h?.canRestartApp.reasonIfUnavailable??t(`runtimeRestartAppUnavailable`));return}if(window.confirm(t(`runtimeControlRestartAppConfirm`))){m(`restart-app`),c(`restarting-app`),f(t(`runtimeControlRestartingAppHelp`));try{let e=await N.restartApp();i.success(e.message)}catch(e){let n=e instanceof Error?e.message:t(`runtimeControlActionFailed`);c(`failed`),f(n),m(null),i.error(`${t(`runtimeControlActionFailed`)}: ${n}`)}}};return(0,B.jsxs)(O,{children:[(0,B.jsxs)(S,{children:[(0,B.jsx)(k,{children:t(`runtimeControlTitle`)}),(0,B.jsx)(T,{children:t(`runtimeControlDescription`)})]}),(0,B.jsxs)(A,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`rounded-xl border border-gray-200 bg-gray-50 p-4 space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:H(_)}),(0,B.jsx)(`div`,{className:`text-xs text-gray-500`,children:h?U(h):t(`runtimeControlLoading`)})]}),(0,B.jsx)(`p`,{className:`text-sm text-gray-600`,children:v}),(0,B.jsx)(`div`,{className:`text-xs text-gray-500`,children:V(g)}),h?.managementHint?(0,B.jsx)(`p`,{className:`text-xs text-gray-500`,children:h.managementHint}):null,n.isError&&!y?(0,B.jsx)(`p`,{className:`text-sm text-amber-700`,children:n.error instanceof Error?n.error.message:t(`runtimeControlLoadFailed`)}):null]}),C?(0,B.jsxs)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 p-4 space-y-3`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:t(`runtimeControlPendingRestartTitle`)}),(0,B.jsx)(`p`,{className:`text-sm text-amber-800`,children:t(`runtimeControlPendingRestartDescription`)}),C.changedPaths.length>0?(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:t(`runtimeControlPendingRestartPaths`)}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.changedPaths.map(e=>(0,B.jsx)(`span`,{className:`rounded-full border border-amber-200 bg-white px-2.5 py-1 text-xs text-amber-800`,children:e},e))})]}):null]}):null,(0,B.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:b.map(e=>{let t=p===e.action,n=!e.capability.available||y;return(0,B.jsxs)(a,{type:`button`,variant:e.variant??`default`,onClick:()=>{if(e.action===`restart-app`){D();return}E(e.action)},disabled:n,children:[(0,B.jsx)(K,{icon:e.icon,busy:t}),e.label]},e.action)})}),b.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,B.jsx)(`p`,{className:`text-xs text-gray-500`,children:e.capability.reasonIfUnavailable},`${e.action}-reason`))]})]})}var J=E(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),Y=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}J.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();J.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){J.setState({supported:!0,initialized:!0,busyAction:null}),i.error(`${t(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{J.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let n=this.getDesktopApi();if(!n)throw Error(t(`runtimePresenceLaunchAtLoginUnavailable`));J.setState({busyAction:`saving-preferences`});try{let r=await n.updatePresencePreferences(e);return J.setState({supported:!0,initialized:!0,snapshot:r}),i.success(t(`runtimePresenceSaved`)),r}catch(e){throw i.error(`${t(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{J.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:t(`error`)}};function X(e){let{description:t,title:n}=e;return(0,B.jsx)(w,{tone:`neutral`,title:n,description:t})}function Z(){let e=x().data?.environment,n=J(e=>e.supported),r=J(e=>e.initialized),i=J(e=>e.busyAction),a=J(e=>e.snapshot);return(0,z.useEffect)(()=>{if(e===`desktop-embedded`){Y.start();return}Y.markUnsupported()},[e]),e===`desktop-embedded`?(0,B.jsxs)(O,{children:[(0,B.jsxs)(S,{children:[(0,B.jsx)(k,{children:t(`runtimePresenceTitle`)}),(0,B.jsx)(T,{children:t(`runtimePresenceDescription`)})]}),(0,B.jsxs)(A,{className:`space-y-4`,children:[(0,B.jsx)(w,{tone:`neutral`,title:t(`runtimePresenceBehaviorLabel`),description:a?.closeToBackground?t(`runtimePresenceBehaviorBackground`):t(`runtimePresenceBehaviorQuit`),className:`rounded-xl`}),!r||n&&!a?(0,B.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimePresenceLoading`)}):null,a?(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(L,{title:t(`runtimePresenceCloseToBackground`),description:t(`runtimePresenceCloseToBackgroundHelp`),control:(0,B.jsx)(I,{id:`runtime-presence-close-background`,"aria-label":t(`runtimePresenceCloseToBackground`),checked:a.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{Y.updatePreferences({closeToBackground:e})}})}),(0,B.jsx)(L,{title:t(`runtimePresenceLaunchAtLogin`),description:a.supportsLaunchAtLogin?t(`runtimePresenceLaunchAtLoginHelp`):a.launchAtLoginReason??t(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,B.jsx)(I,{id:`runtime-presence-launch-login`,"aria-label":t(`runtimePresenceLaunchAtLogin`),checked:a.launchAtLogin,disabled:!a.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{Y.updatePreferences({launchAtLogin:e})}})})]}):null]})]}):e===`managed-local-service`?(0,B.jsxs)(O,{children:[(0,B.jsxs)(S,{children:[(0,B.jsx)(k,{children:t(`runtimePresenceTitle`)}),(0,B.jsx)(T,{children:t(`runtimePresenceDescription`)})]}),(0,B.jsx)(A,{children:(0,B.jsx)(X,{title:t(`runtimePresenceManagedLocalTitle`),description:t(`runtimePresenceManagedLocalDescription`)})})]}):e===`self-hosted-web`?(0,B.jsxs)(O,{children:[(0,B.jsxs)(S,{children:[(0,B.jsx)(k,{children:t(`runtimePresenceTitle`)}),(0,B.jsx)(T,{children:t(`runtimePresenceDescription`)})]}),(0,B.jsx)(A,{children:(0,B.jsx)(X,{title:t(`runtimePresenceSelfHostedTitle`),description:t(`runtimePresenceSelfHostedDescription`)})})]}):e===`shared-web`?(0,B.jsxs)(O,{children:[(0,B.jsxs)(S,{children:[(0,B.jsx)(k,{children:t(`runtimePresenceTitle`)}),(0,B.jsx)(T,{children:t(`runtimePresenceDescription`)})]}),(0,B.jsx)(A,{children:(0,B.jsx)(X,{title:t(`runtimePresenceSharedTitle`),description:t(`runtimePresenceSharedDescription`)})})]}):(0,B.jsxs)(O,{children:[(0,B.jsxs)(S,{children:[(0,B.jsx)(k,{children:t(`runtimePresenceTitle`)}),(0,B.jsx)(T,{children:t(`runtimePresenceDescription`)})]}),(0,B.jsx)(A,{children:(0,B.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimePresenceLoading`)})})]})}function te(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function ne(){return{agentId:``,match:{channel:``,accountId:``}}}function re(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function ie(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function Q(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ae(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}var oe=[{value:`main`,label:`main`},{value:`per-peer`,label:`per-peer`},{value:`per-channel-peer`,label:`per-channel-peer`},{value:`per-account-channel-peer`,label:`per-account-channel-peer`}],se={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function ce(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(P,{title:t(`runtimePageTitle`),description:t(`runtimePageDescription`)}),(0,B.jsx)(q,{}),(0,B.jsx)(Z,{}),(0,B.jsx)(j,{})]})}function $(){let{data:e,isLoading:n}=C(),{data:r}=b(),o=y(),[f,p]=(0,z.useState)([]),[m,g]=(0,z.useState)([]),[x,w]=(0,z.useState)([]),[E,j]=(0,z.useState)(`per-channel-peer`),[M,N]=(0,z.useState)(2e5),[P,L]=(0,z.useState)(`native`);(0,z.useEffect)(()=>{e&&(p((e.agents.list??[]).map(re)),g((e.bindings??[]).map(ie)),w(Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)}))),j(e.session?.dmScope??`per-channel-peer`),N(e.agents.defaults.contextTokens??2e5),L(e.agents.defaults.engine??`native`))},[e]);let R=r?.uiHints,V=F(`session.dmScope`,R),H=F(`agents.defaults.contextTokens`,R),U=F(`agents.defaults.engine`,R),W=F(`agents.list.*.contextTokens`,R),G=F(`agents.list.*.engine`,R),K=F(`agents.list`,R),q=F(`bindings`,R),J=F(`agents.runtimes.entries`,R),Y=(0,z.useMemo)(()=>{let e=new Set([`main`]);return f.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[f]),X=(e,t)=>{p(n=>n.map((n,r)=>r===e?{...n,...t}:n))},Z=(e,t)=>{g(n=>n.map((n,r)=>r===e?t:n))},$=(e,t)=>{w(n=>n.map((n,r)=>r===e?{...n,...t}:n))},le=e=>{w(t=>t.filter((t,n)=>n!==e))};return n||!e?(0,B.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`runtimeLoading`)}):(0,B.jsxs)(ee,{className:`space-y-6`,children:[(0,B.jsx)(ce,{}),(0,B.jsxs)(O,{children:[(0,B.jsxs)(S,{children:[(0,B.jsx)(k,{children:V?.label??t(`dmScope`)}),(0,B.jsx)(T,{children:V?.help??t(`dmScopeHelp`)})]}),(0,B.jsxs)(A,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:H?.label??t(`defaultContextTokens`)}),(0,B.jsx)(D,{type:`number`,min:1e3,step:1e3,value:M,onChange:e=>N(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3))}),(0,B.jsx)(`p`,{className:`text-xs text-gray-500`,children:H?.help??t(`defaultContextTokensHelp`)})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:U?.label??t(`defaultEngine`)}),(0,B.jsx)(D,{value:P,onChange:e=>L(e.target.value),placeholder:t(`defaultEnginePlaceholder`)}),(0,B.jsx)(`p`,{className:`text-xs text-gray-500`,children:U?.help??t(`defaultEngineHelp`)})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:V?.label??t(`dmScope`)}),(0,B.jsxs)(d,{value:E,onValueChange:e=>j(e),children:[(0,B.jsx)(c,{children:(0,B.jsx)(s,{})}),(0,B.jsx)(l,{children:oe.map(e=>(0,B.jsx)(u,{value:e.value,children:e.label},e.value))})]})]})]})]}),(0,B.jsxs)(O,{children:[(0,B.jsxs)(S,{children:[(0,B.jsx)(k,{children:J?.label??`Runtime Entries`}),(0,B.jsx)(T,{children:J?.help??`统一管理可见的 runtime entry 与其配置。`})]}),(0,B.jsxs)(A,{className:`space-y-3`,children:[x.map((e,n)=>(0,B.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,B.jsx)(D,{value:e.id,onChange:e=>$(n,{id:e.target.value}),placeholder:`entry id,例如 hermes`}),(0,B.jsx)(D,{value:e.label??``,onChange:e=>$(n,{label:e.target.value}),placeholder:`展示名称,例如 Hermes`}),(0,B.jsx)(D,{value:e.type,onChange:e=>$(n,{type:e.target.value}),placeholder:`runtime type,例如 narp-stdio`}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-200 px-3 py-2`,children:[(0,B.jsx)(`span`,{className:`text-sm text-gray-700`,children:`Enabled`}),(0,B.jsx)(I,{checked:e.enabled!==!1,onCheckedChange:e=>$(n,{enabled:e})})]})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:`Config JSON`}),(0,B.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-gray-200 px-3 py-2 text-sm font-mono`,value:e.configText,onChange:e=>$(n,{configText:e.target.value}),spellCheck:!1})]}),(0,B.jsx)(`div`,{className:`flex justify-end`,children:(0,B.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>le(n),children:[(0,B.jsx)(v,{className:`mr-2 h-4 w-4`}),t(`deleteButton`)]})})]},`${n}-${e.id||`runtime-entry`}`)),(0,B.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>{w(e=>[...e,{id:``,enabled:!0,label:``,type:`narp-stdio`,config:se,configText:JSON.stringify(se,null,2)}])},children:[(0,B.jsx)(h,{className:`mr-2 h-4 w-4`}),`Add Runtime Entry`]})]})]}),(0,B.jsxs)(O,{children:[(0,B.jsxs)(S,{children:[(0,B.jsx)(k,{children:K?.label??t(`agentList`)}),(0,B.jsx)(T,{children:K?.help??t(`agentListHelp`)})]}),(0,B.jsxs)(A,{className:`space-y-3`,children:[f.map((e,n)=>(0,B.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,B.jsx)(D,{value:e.id,onChange:e=>X(n,{id:e.target.value}),placeholder:t(`agentIdPlaceholder`)}),(0,B.jsx)(D,{value:e.workspace??``,onChange:e=>X(n,{workspace:e.target.value}),placeholder:t(`workspaceOverridePlaceholder`)}),(0,B.jsx)(D,{value:e.model??``,onChange:e=>X(n,{model:e.target.value}),placeholder:t(`modelOverridePlaceholder`)}),(0,B.jsx)(D,{value:e.runtime??e.engine??``,onChange:e=>X(n,{runtime:e.target.value}),placeholder:G?.label??t(`engineOverridePlaceholder`)}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,B.jsx)(D,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>X(n,{contextTokens:Q(e.target.value)}),placeholder:W?.label??t(`contextTokensPlaceholder`)}),(0,B.jsx)(D,{type:`number`,min:1,value:e.maxToolIterations??``,onChange:e=>X(n,{maxToolIterations:Q(e.target.value)}),placeholder:t(`maxToolsPlaceholder`)})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,B.jsx)(I,{checked:!!e.default,onCheckedChange:e=>{if(!e){X(n,{default:!1});return}p(e=>e.map((e,t)=>({...e,default:t===n})))}}),(0,B.jsx)(`span`,{children:t(`defaultAgent`)})]}),(0,B.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>p(e=>e.filter((e,t)=>t!==n)),children:[(0,B.jsx)(v,{className:`h-4 w-4 mr-1`}),t(`remove`)]})]})]},`${n}-${e.id}`)),(0,B.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>p(e=>[...e,te()]),children:[(0,B.jsx)(h,{className:`h-4 w-4 mr-2`}),t(`addAgent`)]})]})]}),(0,B.jsxs)(O,{children:[(0,B.jsxs)(S,{children:[(0,B.jsx)(k,{children:q?.label??t(`bindings`)}),(0,B.jsx)(T,{children:q?.help??t(`bindingsHelp`)})]}),(0,B.jsxs)(A,{className:`space-y-3`,children:[m.map((e,n)=>{let r=e.match.peer?.kind??``;return(0,B.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,B.jsx)(D,{value:e.agentId,onChange:t=>Z(n,{...e,agentId:t.target.value}),placeholder:t(`targetAgentIdPlaceholder`)}),(0,B.jsx)(D,{value:e.match.channel,onChange:t=>Z(n,{...e,match:{...e.match,channel:t.target.value}}),placeholder:t(`channelPlaceholder`)}),(0,B.jsx)(D,{value:e.match.accountId??``,onChange:t=>Z(n,{...e,match:{...e.match,accountId:t.target.value}}),placeholder:t(`accountIdOptionalPlaceholder`)}),(0,B.jsxs)(d,{value:r||`__none__`,onValueChange:t=>{let r=t===`__none__`?``:t;if(!r){Z(n,{...e,match:{...e.match,peer:void 0}});return}Z(n,{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}})},children:[(0,B.jsx)(c,{children:(0,B.jsx)(s,{})}),(0,B.jsxs)(l,{children:[(0,B.jsx)(u,{value:`__none__`,children:t(`peerKindOptional`)}),(0,B.jsx)(u,{value:`direct`,children:`direct`}),(0,B.jsx)(u,{value:`group`,children:`group`}),(0,B.jsx)(u,{value:`channel`,children:`channel`})]})]}),(0,B.jsx)(D,{value:e.match.peer?.id??``,onChange:t=>Z(n,{...e,match:{...e.match,peer:r?{kind:r,id:t.target.value}:void 0}}),placeholder:t(`peerIdPlaceholder`)})]}),(0,B.jsx)(`div`,{className:`flex justify-end`,children:(0,B.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>g(e=>e.filter((e,t)=>t!==n)),children:[(0,B.jsx)(v,{className:`h-4 w-4 mr-1`}),t(`remove`)]})})]},`${n}-${e.agentId}`)}),(0,B.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>g(e=>[...e,ne()]),children:[(0,B.jsx)(h,{className:`h-4 w-4 mr-2`}),t(`addBinding`)]})]})]}),(0,B.jsx)(`div`,{className:`flex justify-end`,children:(0,B.jsxs)(a,{type:`button`,onClick:()=>{try{let e=f.map((e,n)=>{if(!e.id.trim())throw Error(t(`agentIdRequiredError`).replace(`{index}`,String(n)));return ae(e)}),n=e.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0){i.error(`${t(`duplicateAgentId`)}: ${n[0]}`);return}let r=m.map((e,n)=>{let r=e.agentId.trim(),i=e.match.channel.trim(),a=e.match.accountId?.trim()??``,o=e.match.peer?.kind,s=e.match.peer?.id?.trim()??``;if(!r)throw Error(t(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!Y.has(r))throw Error(`${t(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${r}`);if(!i)throw Error(t(`bindingChannelRequired`).replace(`{index}`,String(n)));let c={agentId:r,match:{channel:i}};if(a&&(c.match.accountId=a),o){if(!s)throw Error(t(`bindingPeerIdRequired`).replace(`{index}`,String(n)));c.match.peer={kind:o,id:s}}return c}),a=x.reduce((e,t,n)=>{let r=t.id.trim(),i=t.type.trim();if(!r)throw Error(`Runtime entry id is required at index ${n}.`);if(!i)throw Error(`Runtime entry type is required for "${r}".`);if(e[r])throw Error(`Duplicate runtime entry id: ${r}`);let a=t.configText.trim()?JSON.parse(t.configText):{};if(a&&(typeof a!=`object`||Array.isArray(a)))throw Error(`Runtime entry config for "${r}" must be a JSON object.`);return e[r]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:i,config:a??{}},e},{});o.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,M),engine:P.trim()||`native`},list:e,runtimes:{entries:a}},bindings:r,session:{dmScope:E}}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:o.isPending,children:[(0,B.jsx)(_,{className:`h-4 w-4 mr-2`}),o.isPending?t(`saving`):t(`saveRuntimeSettings`)]})})]})}export{$ as RuntimeConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r}from"./i18n-CpTZLchQ.js";import{r as i}from"./dist-BruyLa92.js";import{a,i as o,n as s,r as c,t as l}from"./select-CVz0t7MF.js";import{t as u}from"./external-link-kZSAO8nT.js";import{t as d}from"./search-BCAlB8nz.js";import{U as f,b as p,kt as m,mt as h,pt as g,x as _}from"./index-zDZfXoI4.js";import{n as v,t as y}from"./page-layout-0UcO9H9Z.js";import{a as b,c as x,i as S,n as C,o as w,s as T,t as E}from"./config-split-page-BUout_Ak.js";var D=e(n(),1),O=r(),k=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],A=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],j={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`};function M(e){return{activeProvider:e.provider,enabledProviders:e.enabledProviders,maxResults:String(e.defaults.maxResults),providers:{bocha:{apiKey:``,baseUrl:e.providers.bocha.baseUrl,summary:!!e.providers.bocha.summary,freshness:e.providers.bocha.freshness??`noLimit`},tavily:{apiKey:``,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth??`basic`,includeAnswer:!!e.providers.tavily.includeAnswer},brave:{apiKey:``,baseUrl:e.providers.brave.baseUrl}}}}function N(e){return{provider:e.activeProvider,enabledProviders:e.enabledProviders,defaults:{maxResults:Number(e.maxResults)||10},providers:{bocha:{apiKey:e.providers.bocha.apiKey||void 0,baseUrl:e.providers.bocha.baseUrl,summary:e.providers.bocha.summary,freshness:e.providers.bocha.freshness},tavily:{apiKey:e.providers.tavily.apiKey||void 0,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth,includeAnswer:e.providers.tavily.includeAnswer},brave:{apiKey:e.providers.brave.apiKey||void 0,baseUrl:e.providers.brave.baseUrl}}}}function P({label:e,value:t,onChange:n,placeholder:r,type:i=`text`,inputMode:a}){return(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(g,{children:e}),(0,O.jsx)(h,{type:i,value:t,onChange:e=>n(e.target.value),placeholder:r,inputMode:a,className:`rounded-xl`})]})}function F({label:e,value:n,options:r,onChange:i}){return(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(g,{children:e}),(0,O.jsxs)(l,{value:n,onValueChange:i,children:[(0,O.jsx)(o,{className:`rounded-xl`,children:(0,O.jsx)(a,{})}),(0,O.jsx)(s,{children:r.map(e=>(0,O.jsx)(c,{value:e.value,children:t(e.label)},e.value))})]})]})}function I({docsUrl:e}){return e?(0,O.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:(0,O.jsxs)(i,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,O.jsx)(u,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})}):null}function L(){let{data:e}=p(),{data:n}=_(),r=f(),u=(0,D.useMemo)(()=>n?.search??[],[n]),h=e?.search,[L,R]=(0,D.useState)(`bocha`),[z,B]=(0,D.useState)(null);(0,D.useEffect)(()=>{h&&(R(h.provider),B(M(h)))},[h]);let V=(e,t)=>{B(n=>n&&{...n,providers:{...n.providers,[e]:{...n.providers[e],...t}}})};if(!h||u.length===0||!z)return(0,O.jsx)(`div`,{className:`p-8`,children:t(`loading`)});let H=u.find(e=>e.name===L),U=h.providers[L],W=z.enabledProviders.includes(L),G=U?.docsUrl??H?.docsUrl;return(0,O.jsxs)(v,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,O.jsx)(y,{title:t(`searchPageTitle`),description:t(`searchPageDescription`)}),(0,O.jsxs)(S,{className:`xl:min-h-0`,children:[(0,O.jsxs)(b,{children:[(0,O.jsx)(x,{className:`px-4 py-4`,children:(0,O.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-gray-500`,children:t(`searchChannels`)})}),(0,O.jsx)(w,{className:`space-y-2 p-3`,children:u.map(e=>{let n=h.providers[e.name],r=z.enabledProviders.includes(e.name);return(0,O.jsx)(E,{onClick:()=>R(e.name),active:L===e.name,className:`p-3`,children:(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName}),(0,O.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-gray-500`,children:t(j[e.name])})]}),(0,O.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,O.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:n.apiKeySet?t(`searchStatusConfigured`):t(`searchStatusNeedsSetup`)}),r?(0,O.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:t(`searchProviderActivated`)}):null]})]})},e.name)})})]}),H?(0,O.jsx)(b,{children:(0,O.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),r.mutate({data:N(z)})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,O.jsx)(x,{className:`px-6 py-5`,children:(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,O.jsx)(d,{className:`h-5 w-5`})}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:H.displayName}),(0,O.jsx)(`p`,{className:`text-sm text-gray-500`,children:H.description})]})]}),(0,O.jsx)(i,{type:`button`,variant:W?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=W?z.enabledProviders.filter(e=>e!==L):[...z.enabledProviders,L],t={...z,enabledProviders:e};B(t),r.mutate({data:N(t)})},children:t(W?`searchProviderDeactivate`:`searchProviderActivate`)})]})}),(0,O.jsxs)(w,{className:`space-y-6 px-6 py-5`,children:[(0,O.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(g,{children:t(`searchActiveProvider`)}),(0,O.jsxs)(l,{value:z.activeProvider,onValueChange:e=>B({...z,activeProvider:e}),children:[(0,O.jsx)(o,{className:`rounded-xl`,children:(0,O.jsx)(a,{})}),(0,O.jsx)(s,{children:u.map(e=>(0,O.jsx)(c,{value:e.name,children:e.displayName},e.name))})]})]}),(0,O.jsx)(P,{label:t(`searchDefaultMaxResults`),value:z.maxResults,onChange:e=>B({...z,maxResults:e}),inputMode:`numeric`})]}),(()=>{if(L===`bocha`){let e=z.providers.bocha;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(P,{label:t(`apiKey`),value:e.apiKey,onChange:e=>V(`bocha`,{apiKey:e}),placeholder:h.providers.bocha.apiKeyMasked||t(`enterApiKey`),type:`password`}),(0,O.jsx)(P,{label:t(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>V(`bocha`,{baseUrl:e})}),(0,O.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,O.jsx)(F,{label:t(`searchProviderSummary`),value:e.summary?`true`:`false`,options:[{value:`true`,label:`enabled`},{value:`false`,label:`disabled`}],onChange:e=>V(`bocha`,{summary:e===`true`})}),(0,O.jsx)(F,{label:t(`searchProviderFreshness`),value:e.freshness,options:k,onChange:e=>V(`bocha`,{freshness:e})})]}),(0,O.jsx)(I,{docsUrl:G??`https://open.bocha.cn`})]})}if(L===`tavily`){let e=z.providers.tavily;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(P,{label:t(`apiKey`),value:e.apiKey,onChange:e=>V(`tavily`,{apiKey:e}),placeholder:h.providers.tavily.apiKeyMasked||t(`enterApiKey`),type:`password`}),(0,O.jsx)(P,{label:t(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>V(`tavily`,{baseUrl:e})}),(0,O.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,O.jsx)(F,{label:t(`searchProviderSearchDepth`),value:e.searchDepth,options:A,onChange:e=>V(`tavily`,{searchDepth:e})}),(0,O.jsx)(F,{label:t(`searchProviderIncludeAnswer`),value:e.includeAnswer?`true`:`false`,options:[{value:`true`,label:`enabled`},{value:`false`,label:`disabled`}],onChange:e=>V(`tavily`,{includeAnswer:e===`true`})})]}),(0,O.jsx)(I,{docsUrl:G})]})}let e=z.providers.brave;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(P,{label:t(`apiKey`),value:e.apiKey,onChange:e=>V(`brave`,{apiKey:e}),placeholder:h.providers.brave.apiKeyMasked||t(`enterApiKey`),type:`password`}),(0,O.jsx)(P,{label:t(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>V(`brave`,{baseUrl:e})})]})})()]}),(0,O.jsx)(T,{className:`flex justify-end px-6 py-4`,children:(0,O.jsxs)(i,{type:`submit`,disabled:r.isPending,children:[(0,O.jsx)(m,{className:`mr-2 h-4 w-4`}),r.isPending?t(`saving`):t(`saveChanges`)]})})]})}):(0,O.jsx)(C,{children:(0,O.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`searchNoProviderSelected`)})})]})]})}export{L as SearchConfig};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r}from"./i18n-CpTZLchQ.js";import{n as i,r as a}from"./dist-BruyLa92.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-CVz0t7MF.js";import{t as d}from"./plus-CG0QrVY_.js";import{t as f}from"./save-EqJPOF0G.js";import{t as p}from"./trash-2-mJT6oWa2.js";import{W as m,at as h,b as g,it as _,mt as v,nt as y,ot as b,pt as x,rt as S}from"./index-zDZfXoI4.js";import{n as C,t as w}from"./page-layout-0UcO9H9Z.js";import{t as T}from"./switch-CM29eCAR.js";var E=e(n(),1),D=r(),O=[`env`,`file`,`exec`];function k(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function A(){return{path:``,source:`env`,provider:``,id:``}}function j(e,t){return t.source===`env`?{...k(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...k(e),source:`file`,path:t.path}:{...k(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
|
|
2
|
-
`),cwd:t.cwd??``,timeoutMs:t.timeoutMs??5e3}}function M(e){return e.source===`env`?{source:`env`,...e.prefix.trim()?{prefix:e.prefix.trim()}:{}}:e.source===`file`?{source:`file`,path:e.path.trim(),format:`json`}:{source:`exec`,command:e.command.trim(),args:e.argsText.split(`
|
|
3
|
-
`).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function N(){let{data:e,isLoading:n}=g(),r=m(),[N,P]=(0,E.useState)(!0),[F,I]=(0,E.useState)(``),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)([]);(0,E.useEffect)(()=>{let t=e?.secrets;if(!t){P(!0),I(``),R(``),B(``),H([]),W([]);return}P(!!t.enabled),I(t.defaults.env??``),R(t.defaults.file??``),B(t.defaults.exec??``);let n=Object.entries(t.providers).map(([e,t])=>j(e,t)),r=Object.entries(t.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}));H(n),W(r)},[e?.secrets]);let G=(0,E.useMemo)(()=>{let e=V.map(e=>e.alias.trim()).filter(Boolean);return Array.from(new Set(e))},[V]),K=(e,t)=>{H(n=>n.map((n,r)=>r===e?{...n,...t}:n))},q=(e,t)=>{W(n=>n.map((n,r)=>r===e?{...n,...t}:n))};return n?(0,D.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`loading`)}):(0,D.jsxs)(C,{className:`space-y-6`,children:[(0,D.jsx)(w,{title:t(`secretsPageTitle`),description:t(`secretsPageDescription`)}),(0,D.jsxs)(y,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(b,{children:t(`secrets`)}),(0,D.jsx)(_,{children:t(`secretsEnabledHelp`)})]}),(0,D.jsxs)(S,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 p-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-gray-800`,children:t(`enabled`)}),(0,D.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`secretsEnabledHelp`)})]}),(0,D.jsx)(T,{checked:N,onCheckedChange:P})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(x,{children:t(`defaultEnvProvider`)}),(0,D.jsxs)(u,{value:F||`__none__`,onValueChange:e=>I(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(x,{children:t(`defaultFileProvider`)}),(0,D.jsxs)(u,{value:L||`__none__`,onValueChange:e=>R(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(x,{children:t(`defaultExecProvider`)}),(0,D.jsxs)(u,{value:z||`__none__`,onValueChange:e=>B(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]})]})]})]}),(0,D.jsxs)(y,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(b,{children:t(`secretProvidersTitle`)}),(0,D.jsx)(_,{children:t(`secretProvidersDescription`)})]}),(0,D.jsxs)(S,{className:`space-y-3`,children:[V.map((e,n)=>(0,D.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsx)(v,{value:e.alias,onChange:e=>K(n,{alias:e.target.value}),placeholder:t(`providerAlias`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>K(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>e.filter((e,t)=>t!==n)),children:[(0,D.jsx)(p,{className:`h-4 w-4 mr-2`}),t(`removeProvider`)]})]}),e.source===`env`&&(0,D.jsx)(v,{value:e.prefix,onChange:e=>K(n,{prefix:e.target.value}),placeholder:t(`envPrefix`)}),e.source===`file`&&(0,D.jsx)(v,{value:e.path,onChange:e=>K(n,{path:e.target.value}),placeholder:t(`secretFilePath`)}),e.source===`exec`&&(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(v,{value:e.command,onChange:e=>K(n,{command:e.target.value}),placeholder:t(`secretExecCommand`)}),(0,D.jsx)(`textarea`,{className:`min-h-[84px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`,value:e.argsText,onChange:e=>K(n,{argsText:e.target.value}),placeholder:t(`secretExecArgs`)}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,D.jsx)(v,{value:e.cwd,onChange:e=>K(n,{cwd:e.target.value}),placeholder:t(`secretExecCwd`)}),(0,D.jsx)(v,{type:`number`,min:1,value:e.timeoutMs,onChange:e=>K(n,{timeoutMs:Number.parseInt(e.target.value,10)||5e3}),placeholder:t(`secretExecTimeoutMs`)})]})]})]},`provider-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>[...e,k()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretProvider`)]})]})]}),(0,D.jsxs)(y,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(b,{children:t(`secretRefsTitle`)}),(0,D.jsx)(_,{children:t(`secretRefsDescription`)})]}),(0,D.jsxs)(S,{className:`space-y-3`,children:[U.map((e,n)=>(0,D.jsx)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,D.jsx)(v,{value:e.path,onChange:e=>q(n,{path:e.target.value}),placeholder:t(`secretConfigPath`)}),(0,D.jsx)(v,{value:e.id,onChange:e=>q(n,{id:e.target.value}),placeholder:t(`secretId`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>q(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,D.jsxs)(u,{value:e.provider||`__none__`,onValueChange:e=>q(n,{provider:e===`__none__`?``:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`secretProviderAlias`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]}),(0,D.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>e.filter((e,t)=>t!==n)),children:(0,D.jsx)(p,{className:`h-4 w-4`})})]})]})},`ref-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>[...e,A()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretRef`)]})]})]}),(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(a,{type:`button`,onClick:()=>{try{let e={};for(let[n,r]of V.entries()){let i=r.alias.trim();if(!i)throw Error(`${t(`providerAlias`)} #${n+1} ${t(`isRequired`)}`);if(e[i])throw Error(`${t(`providerAlias`)}: ${i} (${t(`duplicate`)})`);if(r.source===`file`&&!r.path.trim())throw Error(`${t(`secretFilePath`)} #${n+1} ${t(`isRequired`)}`);if(r.source===`exec`&&!r.command.trim())throw Error(`${t(`secretExecCommand`)} #${n+1} ${t(`isRequired`)}`);e[i]=M(r)}let n={};for(let[r,i]of U.entries()){let a=i.path.trim(),o=i.id.trim();if(!a)throw Error(`${t(`secretConfigPath`)} #${r+1} ${t(`isRequired`)}`);if(!o)throw Error(`${t(`secretId`)} #${r+1} ${t(`isRequired`)}`);let s=i.provider.trim();if(s&&!e[s])throw Error(`${t(`secretProviderAlias`)}: ${s} ${t(`notFound`)}`);n[a]={source:i.source,...s?{provider:s}:{},id:o}}r.mutate({data:{enabled:N,defaults:{env:F.trim()||null,file:L.trim()||null,exec:z.trim()||null},providers:e,refs:n}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:r.isPending,children:[(0,D.jsx)(f,{className:`h-4 w-4 mr-2`}),r.isPending?t(`saving`):t(`save`)]})})]})}export{N as SecretsConfig};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,n as r,p as i,t as a,u as o}from"./i18n-CpTZLchQ.js";import{r as s}from"./dist-BruyLa92.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-CVz0t7MF.js";import{t as p}from"./createLucideIcon-dy5ie7Ox.js";import{t as m}from"./hash-BHJC2Ovu.js";import{t as h}from"./refresh-cw-Bcv40SXy.js";import{t as g}from"./search-BCAlB8nz.js";import{i as _,l as v,n as y,t as b,u as x}from"./chat-session-display-DsYHx0RZ.js";import{A as ee,B as te,Dt as S,E as C,M as w,Mt as T,mt as E,wt as D}from"./index-zDZfXoI4.js";import{n as O,t as k}from"./page-layout-0UcO9H9Z.js";import{t as A}from"./useConfirmDialog-BsVuqu1x.js";var j=p(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),M=p(`Inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),N=e(n(),1),P=i(),F=`__unknown_channel__`;function I(e){return r(e)}function L(e){let t=e.indexOf(`:`);return t<=0?F:e.slice(0,t).trim()||F}function R(e){return e===F?t(`sessionsUnknownChannel`):e}function z(e){return e===`service`?`system`:e===`tool`?`tool`:e}function B(e){let t=[];for(let n of e.parts){if(n.type===`text`||n.type===`rich-text`||n.type===`reasoning`){t.push(n.text);continue}if(n.type===`tool-invocation`){let e=n.toolName?.trim()?`[${n.toolName.trim()}]`:`[tool]`;if(n.state===`result`&&typeof n.result==`string`&&n.result.trim()){t.push(`${e} ${n.result.trim()}`);continue}t.push(e)}}return t.join(`
|
|
2
|
-
`).trim()}function V({session:e,summary:t,channel:n,isSelected:r,onSelect:i}){let s=R(n),c=b(e);return(0,P.jsxs)(`button`,{onClick:i,className:o(`w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group`,r?`bg-brand-50 border border-brand-100/50`:`bg-transparent border border-transparent hover:bg-gray-50/80`),children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between mb-1.5`,children:[(0,P.jsx)(`div`,{className:o(`font-semibold truncate pr-2 flex-1 text-sm`,r?`text-brand-800`:`text-gray-900`),children:c}),(0,P.jsx)(`div`,{className:o(`text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize`,r?`bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]`:`bg-gray-100 text-gray-500`),children:s})]}),(0,P.jsxs)(`div`,{className:o(`flex items-center text-xs justify-between mt-2 font-medium`,r?`text-brand-600/80`:`text-gray-400`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:t.status===`running`?(0,P.jsx)(v,{status:`running`}):null}),(0,P.jsx)(j,{className:`w-3.5 h-3.5 opacity-70`}),(0,P.jsx)(`span`,{className:`truncate max-w-[100px]`,children:a(t.updatedAt)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(S,{className:`w-3.5 h-3.5 opacity-70`}),(0,P.jsx)(`span`,{children:t.messageCount})]})]})]})}function H({message:e}){let t=z(e.role),n=t===`user`,r=B(e);return(0,P.jsx)(`div`,{className:o(`flex w-full mb-6`,n?`justify-end`:`justify-start`),children:(0,P.jsxs)(`div`,{className:o(`max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm`,n?`bg-primary text-white rounded-tr-sm`:`bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50`),children:[(0,P.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:n?(0,P.jsx)(x,{className:`w-4 h-4 text-primary-100`}):(0,P.jsx)(T,{className:`w-4 h-4 text-gray-400`})}),(0,P.jsxs)(`div`,{className:`flex-1 space-y-1 overflow-x-hidden`,children:[(0,P.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 mb-2`,children:[(0,P.jsx)(`span`,{className:o(`font-semibold text-xs capitalize`,n?`text-primary-50`:`text-gray-900`),children:t}),(0,P.jsx)(`span`,{className:o(`text-[10px]`,n?`text-primary-200`:`text-gray-400`),children:I(e.timestamp)})]}),(0,P.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-relaxed text-[15px]`,children:r||`-`})]})]})})}function U(){let[e,n]=(0,N.useState)(``),[r]=(0,N.useState)(100),[i,a]=(0,N.useState)(null),[p,x]=(0,N.useState)(`all`),[T,j]=(0,N.useState)(``),[I,z]=(0,N.useState)(``),[B,U]=(0,N.useState)(!1),W=w({limit:r}),G=ee(i,300),K=te(),q=C(),{confirm:ne,ConfirmDialog:re}=A(),J=(0,N.useMemo)(()=>W.data?.sessions??[],[W.data?.sessions]),Y=(0,N.useMemo)(()=>_(J),[J]),X=(0,N.useMemo)(()=>new Map(J.map(e=>[e.sessionId,e])),[J]),Z=(0,N.useMemo)(()=>Y.filter(t=>p!==`all`&&L(t.key)!==p?!1:y(t,e)),[e,p,Y]),Q=(0,N.useMemo)(()=>Y.find(e=>e.key===i)??null,[i,Y]),$=(0,N.useMemo)(()=>i?X.get(i)??null:null,[i,X]),ie=(0,N.useMemo)(()=>{let e=new Set;for(let t of Y)e.add(L(t.key));return Array.from(e).sort((e,t)=>e===F?1:t===F?-1:e.localeCompare(t))},[Y]);return(0,N.useEffect)(()=>{i&&!X.has(i)&&a(null)},[i,X]),(0,N.useEffect)(()=>{Q?(j(Q.label||``),z(Q.preferredModel||``)):(j(``),z(``)),U(!1)},[Q]),(0,P.jsxs)(O,{fullHeight:!0,children:[(0,P.jsx)(k,{title:t(`sessionsPageTitle`),description:t(`sessionsPageDescription`)}),(0,P.jsxs)(`div`,{className:`flex-1 flex gap-6 min-h-0 relative`,children:[(0,P.jsxs)(`div`,{className:`w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden`,children:[(0,P.jsxs)(`div`,{className:`px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-400 uppercase tracking-wider`,children:[Y.length,` `,t(`sessionsListTitle`)]}),(0,P.jsx)(s,{variant:`ghost`,size:`icon`,className:`h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>W.refetch(),children:(0,P.jsx)(h,{className:o(`h-3.5 w-3.5`,W.isFetching&&`animate-spin`)})})]}),(0,P.jsxs)(f,{value:p,onValueChange:x,children:[(0,P.jsx)(l,{className:`w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700`,children:(0,P.jsx)(c,{placeholder:t(`sessionsAllChannels`)})}),(0,P.jsxs)(u,{className:`rounded-xl shadow-lg border-gray-100 max-w-[280px]`,children:[(0,P.jsx)(d,{value:`all`,className:`rounded-lg text-xs`,children:t(`sessionsAllChannels`)}),ie.map(e=>(0,P.jsx)(d,{value:e,className:`rounded-lg text-xs truncate pr-6`,children:R(e)},e))]})]}),(0,P.jsxs)(`div`,{className:`relative w-full`,children:[(0,P.jsx)(g,{className:`h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400`}),(0,P.jsx)(E,{value:e,onChange:e=>n(e.target.value),placeholder:t(`sessionsSearchPlaceholder`),className:`pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs`})]})]}),(0,P.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative`,children:W.isLoading?(0,P.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:t(`sessionsLoading`)}):Z.length===0?(0,P.jsxs)(`div`,{className:`text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4`,children:[(0,P.jsx)(M,{className:`w-8 h-8 mx-auto mb-2 text-gray-300`}),t(`sessionsEmpty`)]}):Z.map(e=>{let t=X.get(e.key);return t?(0,P.jsx)(V,{session:e,summary:t,channel:L(e.key),isSelected:i===e.key,onSelect:()=>a(e.key)},e.key):null})})]}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200`,children:[(K.isPending||q.isPending)&&(0,P.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20`,children:(0,P.jsx)(`div`,{className:`h-full bg-primary animate-pulse w-1/3 rounded-r-full`})}),i&&Q&&$?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,P.jsx)(`div`,{className:`h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0`,children:(0,P.jsx)(m,{className:`h-6 w-6`})}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-1.5`,children:[(0,P.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 tracking-tight`,children:b(Q)}),(0,P.jsx)(`span`,{className:`text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest`,children:R(L(Q.key))}),$.status===`running`?(0,P.jsx)(v,{status:`running`,className:`h-4 w-4`}):null]}),(0,P.jsx)(`div`,{className:`text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70`,title:i,children:i})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>U(!B),className:o(`h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold`,B?`bg-gray-100 text-gray-900`:`hover:bg-gray-50 hover:text-gray-900`),children:[(0,P.jsx)(D,{className:`w-3.5 h-3.5 mr-1.5`}),t(`sessionsMetadata`)]}),(0,P.jsx)(s,{variant:`outline`,size:`sm`,onClick:async()=>{i&&await ne({title:t(`sessionsDeleteConfirm`)+`?`,variant:`destructive`,confirmLabel:t(`sessionsDeleteConfirm`)})&&q.mutate({sessionId:i},{onSuccess:()=>a(null)})},className:`h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500`,children:t(`delete`)})]})]}),B&&(0,P.jsxs)(`div`,{className:`flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in`,children:[(0,P.jsx)(E,{placeholder:t(`sessionsLabelPlaceholder`),value:T,onChange:e=>j(e.target.value),className:`h-8 text-sm bg-white`}),(0,P.jsx)(E,{placeholder:t(`sessionsModelPlaceholder`),value:I,onChange:e=>z(e.target.value),className:`h-8 text-sm bg-white`}),(0,P.jsx)(s,{size:`sm`,onClick:()=>{i&&(K.mutate({sessionId:i,data:{label:T.trim()||null,preferredModel:I.trim()||null}}),U(!1))},className:`h-8 px-4 shrink-0 shadow-none`,disabled:K.isPending,children:t(`sessionsSaveMeta`)})]})]}),(0,P.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 relative [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[G.isLoading&&(0,P.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10`,children:(0,P.jsxs)(`div`,{className:`flex flex-col items-center gap-3 animate-pulse`,children:[(0,P.jsx)(h,{className:`w-6 h-6 text-primary animate-spin`}),(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-500`,children:t(`sessionsHistoryLoading`)})]})}),G.error&&(0,P.jsx)(`div`,{className:`text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm`,children:G.error.message}),!G.isLoading&&G.data?.messages.length===0&&(0,P.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-gray-400`,children:[(0,P.jsx)(S,{className:`w-12 h-12 mb-3 text-gray-300`}),(0,P.jsx)(`p`,{className:`text-sm`,children:t(`sessionsEmpty`)})]}),(0,P.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(G.data?.messages??[]).map(e=>(0,P.jsx)(H,{message:e},e.id))})]})]}):(0,P.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white`,children:[(0,P.jsx)(`div`,{className:`w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3`,children:(0,P.jsx)(M,{className:`h-8 w-8 text-gray-300 -rotate-3`})}),(0,P.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 mb-2`,children:t(`sessionsNoSelectionTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-center max-w-sm leading-relaxed`,children:t(`sessionsNoSelectionDescription`)})]})]})]}),(0,P.jsx)(re,{})]})}export{U as SessionsConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as e,C as t,E as n,S as r,T as i,b as a,c as o,d as s,f as c,k as l,m as u,p as d,w as f,x as p,y as m}from"./client-C-8fH7-c.js";import{r as h}from"./infiniteQueryBehavior-CyER9hv0.js";var g=class extends e{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new o({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=_(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=_(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=_(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=_(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){d.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>r(t,e))}findAll(e={}){return this.getAll().filter(t=>r(e,t))}notify(e){d.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return d.batch(()=>Promise.all(e.map(e=>e.continue().catch(f))))}};function _(e){return e.options.scope?.id}var v=class extends e{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??p(r,t),a=this.get(i);return a||(a=new s({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){d.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let n={exact:!0,...e};return this.getAll().find(e=>t(n,e))}findAll(e={}){let n=this.getAll();return Object.keys(e).length>0?n.filter(n=>t(e,n)):n}notify(e){d.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){d.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){d.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},y=new class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new v,this.#t=e.mutationCache||new g,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=u.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=c.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),i=r.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(n(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(i))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=m(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return d.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;d.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return d.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=d.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(f).catch(f)}invalidateQueries(e,t={}){return d.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=d.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(f)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(f)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(n(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(f).catch(f)}fetchInfiniteQuery(e){return e.behavior=h(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(f).catch(f)}ensureInfiniteQueryData(e){return e.behavior=h(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return c.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(a(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{i(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(a(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{i(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=p(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===l&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}}({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!0}}});export{y as t};
|