@lobehub/chat 1.82.10 → 1.83.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.desktop +1 -2
- package/.github/workflows/{release-desktop.yml → desktop-pr-build.yml} +59 -137
- package/.github/workflows/release-desktop-beta.yml +194 -0
- package/CHANGELOG.md +42 -0
- package/apps/desktop/.i18nrc.js +31 -0
- package/apps/desktop/Development.md +47 -0
- package/apps/desktop/README.md +6 -0
- package/apps/desktop/build/Icon-beta.icns +0 -0
- package/apps/desktop/build/Icon-nightly.icns +0 -0
- package/apps/desktop/build/Icon.icns +0 -0
- package/apps/desktop/build/entitlements.mac.plist +12 -0
- package/apps/desktop/build/favicon.ico +0 -0
- package/apps/desktop/build/icon-beta.png +0 -0
- package/apps/desktop/build/icon-dev.png +0 -0
- package/apps/desktop/build/icon-nightly.ico +0 -0
- package/apps/desktop/build/icon-nightly.png +0 -0
- package/apps/desktop/build/icon.ico +0 -0
- package/apps/desktop/build/icon.png +0 -0
- package/apps/desktop/dev-app-update.yml +6 -0
- package/apps/desktop/electron-builder.js +92 -0
- package/apps/desktop/electron.vite.config.ts +40 -0
- package/apps/desktop/package.json +72 -0
- package/apps/desktop/pnpm-workspace.yaml +5 -0
- package/apps/desktop/resources/error.html +136 -0
- package/apps/desktop/resources/locales/ar/common.json +32 -0
- package/apps/desktop/resources/locales/ar/dialog.json +31 -0
- package/apps/desktop/resources/locales/ar/menu.json +70 -0
- package/apps/desktop/resources/locales/bg-BG/common.json +32 -0
- package/apps/desktop/resources/locales/bg-BG/dialog.json +31 -0
- package/apps/desktop/resources/locales/bg-BG/menu.json +70 -0
- package/apps/desktop/resources/locales/de-DE/common.json +32 -0
- package/apps/desktop/resources/locales/de-DE/dialog.json +31 -0
- package/apps/desktop/resources/locales/de-DE/menu.json +70 -0
- package/apps/desktop/resources/locales/en-US/common.json +32 -0
- package/apps/desktop/resources/locales/en-US/dialog.json +31 -0
- package/apps/desktop/resources/locales/en-US/menu.json +70 -0
- package/apps/desktop/resources/locales/es-ES/common.json +32 -0
- package/apps/desktop/resources/locales/es-ES/dialog.json +31 -0
- package/apps/desktop/resources/locales/es-ES/menu.json +70 -0
- package/apps/desktop/resources/locales/fa-IR/common.json +32 -0
- package/apps/desktop/resources/locales/fa-IR/dialog.json +31 -0
- package/apps/desktop/resources/locales/fa-IR/menu.json +70 -0
- package/apps/desktop/resources/locales/fr-FR/common.json +32 -0
- package/apps/desktop/resources/locales/fr-FR/dialog.json +31 -0
- package/apps/desktop/resources/locales/fr-FR/menu.json +70 -0
- package/apps/desktop/resources/locales/it-IT/common.json +32 -0
- package/apps/desktop/resources/locales/it-IT/dialog.json +31 -0
- package/apps/desktop/resources/locales/it-IT/menu.json +70 -0
- package/apps/desktop/resources/locales/ja-JP/common.json +32 -0
- package/apps/desktop/resources/locales/ja-JP/dialog.json +31 -0
- package/apps/desktop/resources/locales/ja-JP/menu.json +70 -0
- package/apps/desktop/resources/locales/ko-KR/common.json +32 -0
- package/apps/desktop/resources/locales/ko-KR/dialog.json +31 -0
- package/apps/desktop/resources/locales/ko-KR/menu.json +70 -0
- package/apps/desktop/resources/locales/nl-NL/common.json +32 -0
- package/apps/desktop/resources/locales/nl-NL/dialog.json +31 -0
- package/apps/desktop/resources/locales/nl-NL/menu.json +70 -0
- package/apps/desktop/resources/locales/pl-PL/common.json +32 -0
- package/apps/desktop/resources/locales/pl-PL/dialog.json +31 -0
- package/apps/desktop/resources/locales/pl-PL/menu.json +70 -0
- package/apps/desktop/resources/locales/pt-BR/common.json +32 -0
- package/apps/desktop/resources/locales/pt-BR/dialog.json +31 -0
- package/apps/desktop/resources/locales/pt-BR/menu.json +70 -0
- package/apps/desktop/resources/locales/ru-RU/common.json +32 -0
- package/apps/desktop/resources/locales/ru-RU/dialog.json +31 -0
- package/apps/desktop/resources/locales/ru-RU/menu.json +70 -0
- package/apps/desktop/resources/locales/tr-TR/common.json +32 -0
- package/apps/desktop/resources/locales/tr-TR/dialog.json +31 -0
- package/apps/desktop/resources/locales/tr-TR/menu.json +70 -0
- package/apps/desktop/resources/locales/vi-VN/common.json +32 -0
- package/apps/desktop/resources/locales/vi-VN/dialog.json +31 -0
- package/apps/desktop/resources/locales/vi-VN/menu.json +70 -0
- package/apps/desktop/resources/locales/zh-CN/common.json +32 -0
- package/apps/desktop/resources/locales/zh-CN/dialog.json +31 -0
- package/apps/desktop/resources/locales/zh-CN/menu.json +70 -0
- package/apps/desktop/resources/locales/zh-TW/common.json +32 -0
- package/apps/desktop/resources/locales/zh-TW/dialog.json +31 -0
- package/apps/desktop/resources/locales/zh-TW/menu.json +70 -0
- package/apps/desktop/resources/splash.html +88 -0
- package/apps/desktop/scripts/i18nWorkflow/const.ts +18 -0
- package/apps/desktop/scripts/i18nWorkflow/genDefaultLocale.ts +35 -0
- package/apps/desktop/scripts/i18nWorkflow/genDiff.ts +57 -0
- package/apps/desktop/scripts/i18nWorkflow/index.ts +35 -0
- package/apps/desktop/scripts/i18nWorkflow/utils.ts +54 -0
- package/apps/desktop/scripts/pglite-server.ts +14 -0
- package/apps/desktop/src/common/routes.ts +78 -0
- package/apps/desktop/src/main/appBrowsers.ts +47 -0
- package/apps/desktop/src/main/const/dir.ts +29 -0
- package/apps/desktop/src/main/const/env.ts +3 -0
- package/apps/desktop/src/main/const/store.ts +22 -0
- package/apps/desktop/src/main/controllers/AuthCtr.ts +390 -0
- package/apps/desktop/src/main/controllers/BrowserWindowsCtr.ts +95 -0
- package/apps/desktop/src/main/controllers/DevtoolsCtr.ts +9 -0
- package/apps/desktop/src/main/controllers/LocalFileCtr.ts +380 -0
- package/apps/desktop/src/main/controllers/MenuCtr.ts +29 -0
- package/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts +335 -0
- package/apps/desktop/src/main/controllers/RemoteServerSyncCtr.ts +321 -0
- package/apps/desktop/src/main/controllers/ShortcutCtr.ts +19 -0
- package/apps/desktop/src/main/controllers/SystemCtr.ts +93 -0
- package/apps/desktop/src/main/controllers/UpdaterCtr.ts +43 -0
- package/apps/desktop/src/main/controllers/UploadFileCtr.ts +34 -0
- package/apps/desktop/src/main/controllers/_template.ts +9 -0
- package/apps/desktop/src/main/controllers/index.ts +58 -0
- package/apps/desktop/src/main/core/App.ts +370 -0
- package/apps/desktop/src/main/core/Browser.ts +345 -0
- package/apps/desktop/src/main/core/BrowserManager.ts +154 -0
- package/apps/desktop/src/main/core/I18nManager.ts +185 -0
- package/apps/desktop/src/main/core/IoCContainer.ts +12 -0
- package/apps/desktop/src/main/core/MenuManager.ts +64 -0
- package/apps/desktop/src/main/core/ShortcutManager.ts +173 -0
- package/apps/desktop/src/main/core/StoreManager.ts +89 -0
- package/apps/desktop/src/main/core/UpdaterManager.ts +321 -0
- package/apps/desktop/src/main/index.ts +5 -0
- package/apps/desktop/src/main/locales/default/common.ts +34 -0
- package/apps/desktop/src/main/locales/default/dialog.ts +33 -0
- package/apps/desktop/src/main/locales/default/index.ts +11 -0
- package/apps/desktop/src/main/locales/default/menu.ts +72 -0
- package/apps/desktop/src/main/locales/resources.ts +35 -0
- package/apps/desktop/src/main/menus/impls/BaseMenuPlatform.ts +10 -0
- package/apps/desktop/src/main/menus/impls/linux.ts +243 -0
- package/apps/desktop/src/main/menus/impls/macOS.ts +360 -0
- package/apps/desktop/src/main/menus/impls/windows.ts +226 -0
- package/apps/desktop/src/main/menus/index.ts +34 -0
- package/apps/desktop/src/main/menus/types.ts +28 -0
- package/apps/desktop/src/main/modules/fileSearch/impl/macOS.ts +577 -0
- package/apps/desktop/src/main/modules/fileSearch/index.ts +23 -0
- package/apps/desktop/src/main/modules/fileSearch/type.ts +27 -0
- package/apps/desktop/src/main/modules/updater/configs.ts +22 -0
- package/apps/desktop/src/main/modules/updater/utils.ts +33 -0
- package/apps/desktop/src/main/services/fileSearchSrv.ts +35 -0
- package/apps/desktop/src/main/services/fileSrv.ts +255 -0
- package/apps/desktop/src/main/services/index.ts +9 -0
- package/apps/desktop/src/main/shortcuts/config.ts +18 -0
- package/apps/desktop/src/main/shortcuts/index.ts +1 -0
- package/apps/desktop/src/main/types/fileSearch.ts +51 -0
- package/apps/desktop/src/main/types/store.ts +14 -0
- package/apps/desktop/src/main/utils/file-system.ts +15 -0
- package/apps/desktop/src/main/utils/logger.ts +44 -0
- package/apps/desktop/src/main/utils/next-electron-rsc.ts +383 -0
- package/apps/desktop/src/preload/electronApi.ts +18 -0
- package/apps/desktop/src/preload/index.ts +14 -0
- package/apps/desktop/src/preload/invoke.ts +10 -0
- package/apps/desktop/src/preload/routeInterceptor.ts +162 -0
- package/apps/desktop/tsconfig.json +21 -0
- package/changelog/v1.json +14 -0
- package/package.json +1 -1
- package/packages/electron-client-ipc/src/events/remoteServer.ts +11 -4
- package/packages/electron-client-ipc/src/types/dataSync.ts +15 -0
- package/packages/electron-client-ipc/src/types/index.ts +2 -1
- package/packages/electron-client-ipc/src/types/proxyTRPCRequest.ts +21 -0
- package/packages/electron-server-ipc/src/const.ts +3 -3
- package/packages/electron-server-ipc/src/ipcClient.test.ts +7 -6
- package/packages/electron-server-ipc/src/ipcClient.ts +17 -8
- package/packages/electron-server-ipc/src/ipcServer.ts +7 -3
- package/scripts/electronWorkflow/setDesktopVersion.ts +60 -43
- package/src/app/[variants]/(main)/_layout/Desktop/index.tsx +1 -1
- package/src/components/Analytics/Desktop.tsx +19 -0
- package/src/components/Analytics/index.tsx +3 -0
- package/src/database/core/db-adaptor.ts +4 -1
- package/src/database/core/electron.ts +317 -0
- package/src/{app/[variants]/(main)/_layout/Desktop/ElectronTitlebar/Connection/Mode.tsx → features/ElectronTitlebar/Connection/ConnectionMode.tsx} +24 -21
- package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/Connection/Option.tsx +3 -5
- package/src/{app/[variants]/(main)/_layout/Desktop/ElectronTitlebar/Connection/Sync.tsx → features/ElectronTitlebar/Connection/RemoteStatus.tsx} +10 -7
- package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/Connection/index.tsx +4 -4
- package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/UpdateModal.tsx +2 -1
- package/src/libs/trpc/client/async.ts +6 -0
- package/src/libs/trpc/client/edge.ts +6 -0
- package/src/libs/trpc/client/helpers/desktopRemoteRPCFetch.ts +72 -0
- package/src/libs/trpc/client/index.ts +1 -0
- package/src/libs/trpc/client/lambda.ts +10 -1
- package/src/libs/trpc/client/tools.ts +6 -0
- package/src/server/globalConfig/index.ts +0 -3
- package/src/server/modules/ElectronIPCClient/index.ts +3 -1
- package/src/server/routers/desktop/index.ts +2 -0
- package/src/server/routers/desktop/mcp.ts +47 -0
- package/src/server/routers/lambda/user.ts +38 -23
- package/src/server/routers/tools/mcp.ts +0 -6
- package/src/services/electron/remoteServer.ts +4 -4
- package/src/services/mcp.ts +17 -7
- package/src/services/upload.ts +9 -0
- package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +11 -2
- package/src/store/chat/slices/builtinTool/actions/localFile.ts +110 -53
- package/src/store/electron/actions/sync.ts +20 -19
- package/src/store/electron/initialState.ts +3 -3
- package/src/store/electron/selectors/sync.ts +6 -3
- package/src/store/electron/store.ts +2 -0
- package/src/store/file/slices/upload/action.ts +11 -3
- package/src/store/tool/selectors/tool.ts +10 -1
- package/src/utils/fetch/headers.ts +27 -0
- package/src/utils/fetch/index.ts +2 -0
- package/src/utils/fetch/request.ts +28 -0
- package/packages/electron-client-ipc/src/types/remoteServer.ts +0 -8
- /package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/Connection/Waiting.tsx +0 -0
- /package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/UpdateNotification.tsx +0 -0
- /package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/index.tsx +0 -0
@@ -1,20 +1,20 @@
|
|
1
|
-
import {
|
1
|
+
import { DataSyncConfig, ElectronAppState } from '@lobechat/electron-client-ipc';
|
2
2
|
|
3
3
|
export type RemoteServerError = 'CONFIG_ERROR' | 'AUTH_ERROR' | 'DISCONNECT_ERROR';
|
4
4
|
|
5
5
|
export interface ElectronState {
|
6
6
|
appState: ElectronAppState;
|
7
|
+
dataSyncConfig: DataSyncConfig;
|
7
8
|
isConnectingServer?: boolean;
|
8
9
|
isInitRemoteServerConfig: boolean;
|
9
10
|
isSyncActive?: boolean;
|
10
|
-
remoteServerConfig: RemoteServerConfig;
|
11
11
|
remoteServerSyncError?: { message?: string; type: RemoteServerError };
|
12
12
|
}
|
13
13
|
|
14
14
|
export const initialState: ElectronState = {
|
15
15
|
appState: {},
|
16
|
+
dataSyncConfig: { storageMode: 'local' },
|
16
17
|
isConnectingServer: false,
|
17
18
|
isInitRemoteServerConfig: false,
|
18
19
|
isSyncActive: false,
|
19
|
-
remoteServerConfig: { active: false, isSelfHosted: false },
|
20
20
|
};
|
@@ -1,9 +1,12 @@
|
|
1
1
|
import { ElectronState } from '../initialState';
|
2
2
|
|
3
|
-
const isSyncActive = (s: ElectronState) =>
|
4
|
-
|
5
|
-
|
3
|
+
const isSyncActive = (s: ElectronState) => s.dataSyncConfig.active;
|
4
|
+
|
5
|
+
const storageMode = (s: ElectronState) => s.dataSyncConfig.storageMode;
|
6
|
+
const remoteServerUrl = (s: ElectronState) => s.dataSyncConfig.remoteServerUrl || '';
|
6
7
|
|
7
8
|
export const electronSyncSelectors = {
|
8
9
|
isSyncActive,
|
10
|
+
remoteServerUrl,
|
11
|
+
storageMode,
|
9
12
|
};
|
@@ -4,9 +4,11 @@ import { StateCreator } from 'zustand/vanilla';
|
|
4
4
|
|
5
5
|
import { message } from '@/components/AntdStaticMethods';
|
6
6
|
import { LOBE_CHAT_CLOUD } from '@/const/branding';
|
7
|
-
import { isServerMode } from '@/const/version';
|
7
|
+
import { isDesktop, isServerMode } from '@/const/version';
|
8
8
|
import { fileService } from '@/services/file';
|
9
9
|
import { uploadService } from '@/services/upload';
|
10
|
+
import { getElectronStoreState } from '@/store/electron';
|
11
|
+
import { electronSyncSelectors } from '@/store/electron/selectors';
|
10
12
|
import { FileMetadata, UploadFileItem } from '@/types/files';
|
11
13
|
|
12
14
|
import { FileStore } from '../../store';
|
@@ -94,8 +96,14 @@ export const createFileUploadSlice: StateCreator<
|
|
94
96
|
}
|
95
97
|
// 2. if file don't exist, need upload files
|
96
98
|
else {
|
97
|
-
// if
|
98
|
-
|
99
|
+
// only if not enable sync
|
100
|
+
const state = getElectronStoreState();
|
101
|
+
const isSyncActive = electronSyncSelectors.isSyncActive(state);
|
102
|
+
|
103
|
+
if (isDesktop && !isSyncActive) {
|
104
|
+
metadata = await uploadService.uploadToDesktop(file);
|
105
|
+
} else if (isServerMode) {
|
106
|
+
// if is server mode, upload to server s3, or upload to client s3
|
99
107
|
metadata = await uploadService.uploadWithProgress(file, {
|
100
108
|
onProgress: (status, upload) => {
|
101
109
|
onStatusUpdate?.({
|
@@ -4,6 +4,8 @@ import { pluginPrompts } from '@/prompts/plugin';
|
|
4
4
|
import { MetaData } from '@/types/meta';
|
5
5
|
import { ChatCompletionTool } from '@/types/openai/chat';
|
6
6
|
import { LobeToolMeta } from '@/types/tool/tool';
|
7
|
+
import { globalAgentContextManager } from '@/utils/client/GlobalAgentContextManager';
|
8
|
+
import { hydrationPrompt } from '@/utils/promptTemplate';
|
7
9
|
import { genToolCallingName } from '@/utils/toolCall';
|
8
10
|
import { convertPluginManifestToToolsCalling } from '@/utils/toolManifest';
|
9
11
|
|
@@ -36,7 +38,14 @@ const enabledSystemRoles =
|
|
36
38
|
const meta = manifest.meta || {};
|
37
39
|
|
38
40
|
const title = pluginHelpers.getPluginTitle(meta) || manifest.identifier;
|
39
|
-
|
41
|
+
let systemRole = manifest.systemRole || pluginHelpers.getPluginDesc(meta);
|
42
|
+
|
43
|
+
// Use the global context manager to fill the template
|
44
|
+
if (systemRole) {
|
45
|
+
const context = globalAgentContextManager.getContext();
|
46
|
+
|
47
|
+
systemRole = hydrationPrompt(systemRole, context);
|
48
|
+
}
|
40
49
|
|
41
50
|
return {
|
42
51
|
apis: manifest.api.map((m) => ({
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/**
|
2
|
+
* 将 HeadersInit 转换为 Record<string, string>
|
3
|
+
* @param headersInit - Headers 初始化对象
|
4
|
+
* @returns 转换后的记录对象
|
5
|
+
*/
|
6
|
+
// eslint-disable-next-line no-undef
|
7
|
+
export const headersToRecord = (headersInit?: HeadersInit): Record<string, string> => {
|
8
|
+
const record: Record<string, string> = {};
|
9
|
+
if (!headersInit) {
|
10
|
+
return record;
|
11
|
+
}
|
12
|
+
if (headersInit instanceof Headers) {
|
13
|
+
headersInit.forEach((value, key) => {
|
14
|
+
record[key] = value;
|
15
|
+
});
|
16
|
+
} else if (Array.isArray(headersInit)) {
|
17
|
+
headersInit.forEach(([key, value]) => {
|
18
|
+
record[key] = value;
|
19
|
+
});
|
20
|
+
} else {
|
21
|
+
Object.assign(record, headersInit);
|
22
|
+
}
|
23
|
+
delete record['host'];
|
24
|
+
delete record['connection'];
|
25
|
+
delete record['content-length'];
|
26
|
+
return record;
|
27
|
+
};
|
package/src/utils/fetch/index.ts
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* 从请求体中获取数据
|
3
|
+
* @param body - 请求体
|
4
|
+
* @returns 转换后的请求体数据
|
5
|
+
*/
|
6
|
+
export const getRequestBody = async (
|
7
|
+
// eslint-disable-next-line no-undef
|
8
|
+
body?: BodyInit | null,
|
9
|
+
): Promise<string | ArrayBuffer | undefined> => {
|
10
|
+
if (!body) {
|
11
|
+
return undefined;
|
12
|
+
}
|
13
|
+
if (typeof body === 'string') {
|
14
|
+
return body;
|
15
|
+
}
|
16
|
+
if (body instanceof ArrayBuffer) {
|
17
|
+
return body;
|
18
|
+
}
|
19
|
+
if (ArrayBuffer.isView(body)) {
|
20
|
+
return body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength) as ArrayBuffer;
|
21
|
+
}
|
22
|
+
if (body instanceof Blob) {
|
23
|
+
return await body.arrayBuffer();
|
24
|
+
}
|
25
|
+
|
26
|
+
console.warn('不支持的 IPC 代理请求体类型:', typeof body);
|
27
|
+
throw new Error('不支持的 IPC 代理请求体类型');
|
28
|
+
};
|
File without changes
|
File without changes
|
File without changes
|