Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🔧 chore: clean code

Innei6ff8efacb3d0
diff --git a/packages/types/package.json b/packages/types/package.json
index b567b73bae7..6ed9d809769 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -2,6 +2,7 @@
"name": "@lobechat/types",
"version": "1.0.0",
"private": true,
+ "type": "module",
"main": "./src/index.ts",
"dependencies": {
"@lobechat/model-runtime": "workspace:*",
diff --git a/src/services/_url.ts b/src/services/_url.ts
index 68f9d57b556..1a5bb5cc8d6 100644
--- a/src/services/_url.ts
+++ b/src/services/_url.ts
@@ -1,46 +1,67 @@
+import { withElectronProtocolIfElectron } from '@/const/protocol';
+
/* eslint-disable sort-keys-fix/sort-keys-fix */
export const API_ENDPOINTS = {
- oauth: '/api/auth',
+ oauth: withElectronProtocolIfElectron('/api/auth'),
- proxy: '/webapi/proxy',
+ proxy: withElectronProtocolIfElectron('/webapi/proxy'),
// plugins
- gateway: '/webapi/plugin/gateway',
+ gateway: withElectronProtocolIfElectron('/webapi/plugin/gateway'),
// trace
- trace: '/webapi/trace',
+ trace: withElectronProtocolIfElectron('/webapi/trace'),
// chat
- chat: (provider: string) => `/webapi/chat/${provider}`,
+ chat: (provider: string) => withElectronProtocolIfElectron(`/webapi/chat/${provider}`),
// models
- models: (provider: string) => `/webapi/models/${provider}`,
- modelPull: (provider: string) => `/webapi/models/${provider}/pull`,
+ models: (provider: string) => withElectronProtocolIfElectron(`/webapi/models/${provider}`),
+ modelPull: (provider: string) =>
+ withElectronProtocolIfElectron(`/webapi/models/${provider}/pull`),
// image
- images: (provider: string) => `/webapi/text-to-image/${provider}`,
+ images: (provider: string) => withElectronProtocolIfElectron(`/webapi/text-to-image/${provider}`),
// STT
- stt: '/webapi/stt/openai',
+ stt: withElectronProtocolIfElectron('/webapi/stt/openai'),
// TTS
- tts: '/webapi/tts/openai',
- edge: '/webapi/tts/edge',
- microsoft: '/webapi/tts/microsoft',
+ tts: withElectronProtocolIfElectron('/webapi/tts/openai'),
+ edge: withElectronProtocolIfElectron('/webapi/tts/edge'),
+ microsoft: withElectronProtocolIfElectron('/webapi/tts/microsoft'),
};
export const MARKET_OIDC_ENDPOINTS = {
+ // NOTE: `auth` is used to open a page in the system browser (desktop) / popup (web),
+ // so it must always be an HTTP(S) path joined with `NEXT_PUBLIC_MARKET_BASE_URL`.
+ // It MUST NOT be wrapped by the Electron backend protocol.
auth: '/lobehub-oidc/auth',
- token: '/market/oidc/token',
- userinfo: '/market/oidc/userinfo',
- handoff: '/market/oidc/handoff',
+ token: withElectronProtocolIfElectron('/market/oidc/token'),
+ userinfo: withElectronProtocolIfElectron('/market/oidc/userinfo'),
+ handoff: withElectronProtocolIfElectron('/market/oidc/handoff'),
+ // Same as `auth`: used as `redirect_uri` (must be a real web URL under market base).
desktopCallback: '/lobehub-oidc/callback/desktop',
};
export const MARKET_ENDPOINTS = {
- base: '/market',
- createAgent: '/market/agent/create',
- getAgentDetail: (identifier: string) => `/market/agent/${encodeURIComponent(identifier)}`,
- createAgentVersion: '/market/agent/versions/create',
+ base: withElectronProtocolIfElectron('/market'),
+ // Agent management
+ createAgent: withElectronProtocolIfElectron('/market/agent/create'),
+ getAgentDetail: (identifier: string) =>
+ withElectronProtocolIfElectron(`/market/agent/${encodeURIComponent(identifier)}`),
+ getOwnAgents: withElectronProtocolIfElectron('/market/agent/own'),
+ createAgentVersion: withElectronProtocolIfElectron('/market/agent/versions/create'),
+ // Agent status management
+ publishAgent: (identifier: string) =>
+ withElectronProtocolIfElectron(`/market/agent/${encodeURIComponent(identifier)}/publish`),
+ unpublishAgent: (identifier: string) =>
+ withElectronProtocolIfElectron(`/market/agent/${encodeURIComponent(identifier)}/unpublish`),
+ deprecateAgent: (identifier: string) =>
+ withElectronProtocolIfElectron(`/market/agent/${encodeURIComponent(identifier)}/deprecate`),
+ // User profile
+ getUserProfile: (username: string) =>
+ withElectronProtocolIfElectron(`/market/user/${encodeURIComponent(username)}`),
+ updateUserProfile: withElectronProtocolIfElectron('/market/user/me'),
};
diff --git a/src/services/tableViewer/client.ts b/src/services/tableViewer/client.ts
index 2c6a1ab82cc..c34ceeead2b 100644
--- a/src/services/tableViewer/client.ts
+++ b/src/services/tableViewer/client.ts
@@ -1,13 +1,16 @@
export class ClientService {
- getAllTables = async () => [];
+ getAllTables = async () => [
+ { count: 0, name: 'test' },
+ { count: 0, name: 'test2' },
+ ];
getTableDetails = async (tableName: string) => {
console.log('getTableDetails:', tableName);
- return [];
+ return [{ name: 'test' }];
};
getTableData = async (tableName: string) => {
console.log('getTableData:', tableName);
- return [];
+ return [{ name: 'test' }];
};
}
diff --git a/src/services/tableViewer/desktop.ts b/src/services/tableViewer/desktop.ts
deleted file mode 100644
index 237076ed560..00000000000
--- a/src/services/tableViewer/desktop.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { desktopClient } from '@/libs/trpc/client/desktop';
-
-export class DesktopService {
- getAllTables = async () => {
- return desktopClient.pgTable.getAllTables.query();
- };
-
- getTableDetails = async (tableName: string) => {
- return desktopClient.pgTable.getTableDetails.query({ tableName });
- };
-
- getTableData = async (tableName: string) => {
- return desktopClient.pgTable.getTableData.query({ page: 1, pageSize: 300, tableName });
- };
-}
diff --git a/src/services/tableViewer/index.ts b/src/services/tableViewer/index.ts
index edc6b269afd..53b1177762c 100644
--- a/src/services/tableViewer/index.ts
+++ b/src/services/tableViewer/index.ts
@@ -1,6 +1,3 @@
-import { isDesktop } from '@/const/version';
-
import { ClientService } from './client';
-import { DesktopService } from './desktop';
-export const tableViewerService = isDesktop ? new DesktopService() : new ClientService();
+export const tableViewerService = new ClientService();