diff --git a/src/langbot/pkg/persistence/migrations/dbm017_move_cloud_service_url.py b/src/langbot/pkg/persistence/migrations/dbm017_move_cloud_service_url.py new file mode 100644 index 00000000..180efd80 --- /dev/null +++ b/src/langbot/pkg/persistence/migrations/dbm017_move_cloud_service_url.py @@ -0,0 +1,25 @@ +from .. import migration + + +@migration.migration_class(17) +class MoveCloudServiceUrl(migration.DBMigration): + """迁移云服务 URL 配置""" + + async def upgrade(self): + """升级""" + if 'space' not in self.ap.instance_config.data: + self.ap.instance_config.data['space'] = { + 'url': 'https://space.langbot.app', + 'models_gateway_api_url': 'https://api.langbot.cloud', + 'oauth_authorize_url': 'https://space.langbot.app/auth/authorize', + 'disable_models_service': False, + } + + if 'plugin' in self.ap.instance_config.data: + self.ap.instance_config.data['plugin'].pop('cloud_service_url', None) + + await self.ap.instance_config.dump_config() + + async def downgrade(self): + """降级""" + pass diff --git a/src/langbot/pkg/utils/constants.py b/src/langbot/pkg/utils/constants.py index 1bb088a6..c72da997 100644 --- a/src/langbot/pkg/utils/constants.py +++ b/src/langbot/pkg/utils/constants.py @@ -2,7 +2,7 @@ import langbot semantic_version = f'v{langbot.__version__}' -required_database_version = 16 +required_database_version = 17 """Tag the version of the database schema, used to check if the database needs to be migrated""" debug_mode = False diff --git a/src/langbot/templates/config.yaml b/src/langbot/templates/config.yaml index afc70354..201eff59 100644 --- a/src/langbot/templates/config.yaml +++ b/src/langbot/templates/config.yaml @@ -69,7 +69,6 @@ plugin: enable: true runtime_ws_url: 'ws://langbot_plugin_runtime:5400/control/ws' enable_marketplace: true - cloud_service_url: 'https://space.langbot.app' display_plugin_debug_url: 'ws://localhost:5401/plugin/debug/ws' space: # Space service URL for OAuth and API diff --git a/web/src/app/home/plugins/components/plugin-installed/plugin-card/PluginCardComponent.tsx b/web/src/app/home/plugins/components/plugin-installed/plugin-card/PluginCardComponent.tsx index b29877c8..c15c349d 100644 --- a/web/src/app/home/plugins/components/plugin-installed/plugin-card/PluginCardComponent.tsx +++ b/web/src/app/home/plugins/components/plugin-installed/plugin-card/PluginCardComponent.tsx @@ -11,7 +11,7 @@ import { Settings, FileText, } from 'lucide-react'; -import { getCloudServiceClientSync } from '@/app/infra/http'; +import { getCloudServiceClientSync, systemInfo } from '@/app/infra/http'; import { httpClient } from '@/app/infra/http/HttpClient'; import { Button } from '@/components/ui/button'; import { @@ -203,6 +203,7 @@ export default function PluginCardComponent({ } else if (cardVO.install_source === 'marketplace') { window.open( getCloudServiceClientSync().getPluginMarketplaceURL( + systemInfo.cloud_service_url, cardVO.author, cardVO.name, ), diff --git a/web/src/app/infra/http/CloudServiceClient.ts b/web/src/app/infra/http/CloudServiceClient.ts index e45be7b0..61d71e28 100644 --- a/web/src/app/infra/http/CloudServiceClient.ts +++ b/web/src/app/infra/http/CloudServiceClient.ts @@ -81,8 +81,12 @@ export class CloudServiceClient extends BaseHttpClient { return `${this.baseURL}/api/v1/marketplace/plugins/${author}/${pluginName}/resources/assets/${filepath}`; } - public getPluginMarketplaceURL(author: string, name: string): string { - return `https://space.langbot.app/market/${author}/${name}`; + public getPluginMarketplaceURL( + cloud_service_url: string, + author: string, + name: string, + ): string { + return `${cloud_service_url}/market/${author}/${name}`; } public getLangBotReleases(): Promise {