@lobehub/lobehub 2.0.0-next.312 → 2.0.0-next.314
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 +51 -0
- package/apps/desktop/src/main/appBrowsers.ts +4 -1
- package/apps/desktop/src/main/controllers/AuthCtr.ts +75 -7
- package/apps/desktop/src/main/controllers/BrowserWindowsCtr.ts +15 -3
- package/apps/desktop/src/main/core/browser/Browser.ts +14 -4
- package/apps/desktop/src/main/core/browser/BrowserManager.ts +7 -2
- package/changelog/v1.json +18 -0
- package/docs/usage/providers/internlm.mdx +2 -2
- package/docs/usage/providers/internlm.zh-CN.mdx +3 -3
- package/e2e/src/steps/community/detail-pages.steps.ts +2 -2
- package/e2e/src/steps/community/interactions.steps.ts +6 -6
- package/e2e/src/steps/hooks.ts +19 -3
- package/locales/en-US/error.json +10 -1
- package/locales/en-US/subscription.json +1 -1
- package/locales/zh-CN/desktop-onboarding.json +5 -0
- package/locales/zh-CN/error.json +10 -1
- package/locales/zh-CN/subscription.json +1 -1
- package/package.json +1 -1
- package/packages/agent-runtime/src/agents/GeneralChatAgent.ts +14 -2
- package/packages/agent-runtime/src/agents/__tests__/GeneralChatAgent.test.ts +275 -1
- package/packages/builtin-tool-cloud-sandbox/package.json +1 -0
- package/packages/builtin-tool-cloud-sandbox/src/ExecutionRuntime/index.ts +105 -134
- package/packages/builtin-tool-cloud-sandbox/src/executor/index.ts +254 -0
- package/packages/builtin-tool-cloud-sandbox/src/index.ts +1 -0
- package/packages/builtin-tool-cloud-sandbox/src/types/api.ts +22 -0
- package/packages/builtin-tool-cloud-sandbox/src/types/index.ts +4 -0
- package/packages/builtin-tool-cloud-sandbox/src/types/params.ts +85 -0
- package/packages/builtin-tool-cloud-sandbox/src/types/service.ts +48 -0
- package/packages/builtin-tool-cloud-sandbox/src/{types.ts → types/state.ts} +0 -23
- package/packages/builtin-tool-memory/src/manifest.ts +5 -5
- package/packages/desktop-bridge/src/index.ts +5 -0
- package/packages/editor-runtime/src/__tests__/EditorRuntime.real.test.ts +1 -1
- package/packages/editor-runtime/src/__tests__/EditorRuntime.test.ts +1 -1
- package/packages/electron-client-ipc/src/events/index.ts +5 -1
- package/packages/electron-client-ipc/src/events/remoteServer.ts +23 -0
- package/packages/electron-client-ipc/src/types/window.ts +3 -2
- package/packages/memory-user-memory/src/schemas/index.ts +0 -1
- package/packages/model-bank/src/modelProviders/internlm.ts +1 -1
- package/packages/model-runtime/src/core/RouterRuntime/createRuntime.ts +5 -15
- package/packages/model-runtime/src/providers/internlm/index.test.ts +15 -15
- package/packages/model-runtime/src/providers/internlm/index.ts +1 -1
- package/packages/types/src/tool/intervention.ts +4 -2
- package/packages/types/src/user/preference.ts +1 -0
- package/src/app/[variants]/(desktop)/desktop-onboarding/_layout/index.tsx +6 -3
- package/src/app/[variants]/(desktop)/desktop-onboarding/components/OnboardingFooterActions.tsx +38 -0
- package/src/app/[variants]/(desktop)/desktop-onboarding/features/DataModeStep.tsx +19 -14
- package/src/app/[variants]/(desktop)/desktop-onboarding/features/LoginStep.tsx +121 -29
- package/src/app/[variants]/(desktop)/desktop-onboarding/features/PermissionsStep.tsx +19 -14
- package/src/app/[variants]/(desktop)/desktop-onboarding/index.tsx +8 -7
- package/src/app/[variants]/(main)/_layout/DesktopAutoOidcOnFirstOpen.tsx +4 -0
- package/src/app/manifest.ts +1 -1
- package/src/business/server/user.ts +4 -0
- package/src/features/Conversation/Messages/Task/Actions/index.tsx +0 -2
- package/src/features/Conversation/Messages/Task/index.tsx +1 -1
- package/src/features/Conversation/Messages/Tasks/shared/ProcessingState.tsx +0 -2
- package/src/features/Electron/titlebar/NavigationBar.tsx +1 -2
- package/src/features/NavPanel/components/NavPanelDraggable.tsx +0 -14
- package/src/features/ResourceManager/components/Explorer/ItemDropdown/useFileItemDropdown.tsx +4 -3
- package/src/features/SharePopover/index.tsx +5 -3
- package/src/hooks/useAppOrigin.ts +16 -0
- package/src/layout/GlobalProvider/useUserStateRedirect.ts +37 -24
- package/src/libs/trusted-client/index.ts +2 -5
- package/src/locales/default/desktop-onboarding.ts +5 -0
- package/src/locales/default/error.ts +11 -0
- package/src/locales/default/subscription.ts +1 -1
- package/src/server/manifest.ts +2 -2
- package/src/server/modules/AgentRuntime/RuntimeExecutors.ts +2 -0
- package/src/server/routers/lambda/user.ts +24 -10
- package/src/server/services/agentRuntime/AgentRuntimeService.test.ts +3 -0
- package/src/server/services/agentRuntime/AgentRuntimeService.ts +8 -5
- package/src/server/services/agentRuntime/types.ts +7 -0
- package/src/server/services/aiAgent/__tests__/execGroupSubAgentTask.test.ts +3 -0
- package/src/server/services/aiAgent/index.ts +10 -4
- package/src/server/services/market/index.ts +20 -0
- package/src/server/services/sandbox/index.ts +186 -0
- package/src/server/services/toolExecution/builtin.ts +12 -18
- package/src/server/services/toolExecution/index.ts +1 -1
- package/src/server/services/toolExecution/serverRuntimes/cloudSandbox.ts +38 -0
- package/src/server/services/toolExecution/serverRuntimes/index.ts +55 -0
- package/src/server/services/toolExecution/serverRuntimes/types.ts +14 -0
- package/src/server/services/toolExecution/serverRuntimes/webBrowsing.ts +20 -0
- package/src/server/services/toolExecution/types.ts +2 -0
- package/src/services/{codeInterpreter.ts → cloudSandbox.ts} +3 -3
- package/src/services/electron/remoteServer.ts +8 -0
- package/src/services/electron/system.ts +5 -5
- package/src/store/chat/agents/GroupOrchestration/__tests__/batch-exec-async-tasks.test.ts +626 -0
- package/src/store/chat/agents/GroupOrchestration/createGroupOrchestrationExecutors.ts +294 -0
- package/src/store/chat/slices/plugin/action.test.ts +0 -48
- package/src/store/chat/slices/plugin/actions/pluginTypes.ts +0 -131
- package/src/store/tool/slices/builtin/executors/index.ts +2 -0
- package/src/store/user/slices/settings/selectors/toolIntervention.test.ts +143 -0
- package/src/store/user/slices/settings/selectors/toolIntervention.ts +11 -2
- package/packages/memory-user-memory/src/schemas/jsonSchemas.ts +0 -37
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ISandboxService,
|
|
3
|
+
type SandboxCallToolResult,
|
|
4
|
+
type SandboxExportFileResult,
|
|
5
|
+
} from '@lobechat/builtin-tool-cloud-sandbox';
|
|
6
|
+
import { type CodeInterpreterToolName } from '@lobehub/market-sdk';
|
|
7
|
+
import debug from 'debug';
|
|
8
|
+
import { sha256 } from 'js-sha256';
|
|
9
|
+
|
|
10
|
+
import { FileS3 } from '@/server/modules/S3';
|
|
11
|
+
import { type FileService } from '@/server/services/file';
|
|
12
|
+
import { MarketService } from '@/server/services/market';
|
|
13
|
+
|
|
14
|
+
const log = debug('lobe-server:sandbox-service');
|
|
15
|
+
|
|
16
|
+
export interface ServerSandboxServiceOptions {
|
|
17
|
+
fileService: FileService;
|
|
18
|
+
marketService: MarketService;
|
|
19
|
+
topicId: string;
|
|
20
|
+
userId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Server-side Sandbox Service
|
|
25
|
+
*
|
|
26
|
+
* This service implements ISandboxService for server-side execution.
|
|
27
|
+
* Context (topicId, userId) is bound at construction time.
|
|
28
|
+
* It uses MarketService to call sandbox tools.
|
|
29
|
+
*
|
|
30
|
+
* Usage:
|
|
31
|
+
* - Used by BuiltinToolsExecutor when executing CloudSandbox tools on server
|
|
32
|
+
* - MarketService handles authentication via trustedClientToken
|
|
33
|
+
*/
|
|
34
|
+
export class ServerSandboxService implements ISandboxService {
|
|
35
|
+
private fileService: FileService;
|
|
36
|
+
private marketService: MarketService;
|
|
37
|
+
private topicId: string;
|
|
38
|
+
private userId: string;
|
|
39
|
+
|
|
40
|
+
constructor(options: ServerSandboxServiceOptions) {
|
|
41
|
+
this.fileService = options.fileService;
|
|
42
|
+
this.marketService = options.marketService;
|
|
43
|
+
this.topicId = options.topicId;
|
|
44
|
+
this.userId = options.userId;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Call a sandbox tool via MarketService
|
|
49
|
+
*/
|
|
50
|
+
async callTool(toolName: string, params: Record<string, any>): Promise<SandboxCallToolResult> {
|
|
51
|
+
log('Calling sandbox tool: %s with params: %O, topicId: %s', toolName, params, this.topicId);
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const response = await this.marketService
|
|
55
|
+
.getSDK()
|
|
56
|
+
.plugins.runBuildInTool(toolName as CodeInterpreterToolName, params as any, {
|
|
57
|
+
topicId: this.topicId,
|
|
58
|
+
userId: this.userId,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
log('Sandbox tool %s response: %O', toolName, response);
|
|
62
|
+
|
|
63
|
+
if (!response.success) {
|
|
64
|
+
return {
|
|
65
|
+
error: {
|
|
66
|
+
message: response.error?.message || 'Unknown error',
|
|
67
|
+
name: response.error?.code,
|
|
68
|
+
},
|
|
69
|
+
result: null,
|
|
70
|
+
sessionExpiredAndRecreated: false,
|
|
71
|
+
success: false,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
result: response.data?.result,
|
|
77
|
+
sessionExpiredAndRecreated: response.data?.sessionExpiredAndRecreated || false,
|
|
78
|
+
success: true,
|
|
79
|
+
};
|
|
80
|
+
} catch (error) {
|
|
81
|
+
log('Error calling sandbox tool %s: %O', toolName, error);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
error: {
|
|
85
|
+
message: (error as Error).message,
|
|
86
|
+
name: (error as Error).name,
|
|
87
|
+
},
|
|
88
|
+
result: null,
|
|
89
|
+
sessionExpiredAndRecreated: false,
|
|
90
|
+
success: false,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Export and upload a file from sandbox to S3
|
|
97
|
+
*
|
|
98
|
+
* Steps:
|
|
99
|
+
* 1. Generate S3 pre-signed upload URL
|
|
100
|
+
* 2. Call sandbox exportFile tool to upload file
|
|
101
|
+
* 3. Verify upload success and get metadata
|
|
102
|
+
* 4. Create persistent file record
|
|
103
|
+
*/
|
|
104
|
+
async exportAndUploadFile(path: string, filename: string): Promise<SandboxExportFileResult> {
|
|
105
|
+
log('Exporting file: %s from path: %s, topicId: %s', filename, path, this.topicId);
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
const s3 = new FileS3();
|
|
109
|
+
|
|
110
|
+
// Use date-based sharding for privacy compliance (GDPR, CCPA)
|
|
111
|
+
const today = new Date().toISOString().split('T')[0];
|
|
112
|
+
|
|
113
|
+
// Generate a unique key for the exported file
|
|
114
|
+
const key = `code-interpreter-exports/${today}/${this.topicId}/${filename}`;
|
|
115
|
+
|
|
116
|
+
// Step 1: Generate pre-signed upload URL
|
|
117
|
+
const uploadUrl = await s3.createPreSignedUrl(key);
|
|
118
|
+
log('Generated upload URL for key: %s', key);
|
|
119
|
+
|
|
120
|
+
// Step 2: Call sandbox's exportFile tool with the upload URL
|
|
121
|
+
const response = await this.marketService.exportFile({
|
|
122
|
+
path,
|
|
123
|
+
topicId: this.topicId,
|
|
124
|
+
uploadUrl,
|
|
125
|
+
userId: this.userId,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
log('Sandbox exportFile response: %O', response);
|
|
129
|
+
|
|
130
|
+
if (!response.success) {
|
|
131
|
+
return {
|
|
132
|
+
error: { message: response.error?.message || 'Failed to export file from sandbox' },
|
|
133
|
+
filename,
|
|
134
|
+
success: false,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const result = response.data?.result;
|
|
139
|
+
const uploadSuccess = result?.success !== false;
|
|
140
|
+
|
|
141
|
+
if (!uploadSuccess) {
|
|
142
|
+
return {
|
|
143
|
+
error: { message: result?.error || 'Failed to upload file from sandbox' },
|
|
144
|
+
filename,
|
|
145
|
+
success: false,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Step 3: Get file metadata from S3 to verify upload and get actual size
|
|
150
|
+
const metadata = await s3.getFileMetadata(key);
|
|
151
|
+
const fileSize = metadata.contentLength;
|
|
152
|
+
const mimeType = metadata.contentType || result?.mimeType || 'application/octet-stream';
|
|
153
|
+
|
|
154
|
+
// Step 4: Create persistent file record using FileService
|
|
155
|
+
// Generate a simple hash from the key (since we don't have the actual file content)
|
|
156
|
+
const fileHash = sha256(key + Date.now().toString());
|
|
157
|
+
|
|
158
|
+
const { fileId, url } = await this.fileService.createFileRecord({
|
|
159
|
+
fileHash,
|
|
160
|
+
fileType: mimeType,
|
|
161
|
+
name: filename,
|
|
162
|
+
size: fileSize,
|
|
163
|
+
url: key, // Store S3 key
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
log('Created file record: fileId=%s, url=%s', fileId, url);
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
fileId,
|
|
170
|
+
filename,
|
|
171
|
+
mimeType,
|
|
172
|
+
size: fileSize,
|
|
173
|
+
success: true,
|
|
174
|
+
url, // This is the permanent /f/:id URL
|
|
175
|
+
};
|
|
176
|
+
} catch (error) {
|
|
177
|
+
log('Error exporting file: %O', error);
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
error: { message: (error as Error).message },
|
|
181
|
+
filename,
|
|
182
|
+
success: false,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import { WebBrowsingManifest } from '@lobechat/builtin-tool-web-browsing';
|
|
2
|
-
import { WebBrowsingExecutionRuntime } from '@lobechat/builtin-tool-web-browsing/executionRuntime';
|
|
3
1
|
import { type LobeChatDatabase } from '@lobechat/database';
|
|
4
2
|
import { type ChatToolPayload } from '@lobechat/types';
|
|
5
3
|
import { safeParseJSON } from '@lobechat/utils';
|
|
6
4
|
import debug from 'debug';
|
|
7
5
|
|
|
8
6
|
import { MarketService } from '@/server/services/market';
|
|
9
|
-
import { SearchService } from '@/server/services/search';
|
|
10
7
|
|
|
11
|
-
import {
|
|
8
|
+
import { getServerRuntime, hasServerRuntime } from './serverRuntimes';
|
|
9
|
+
import { type IToolExecutor, type ToolExecutionContext, type ToolExecutionResult } from './types';
|
|
12
10
|
|
|
13
11
|
const log = debug('lobe-server:builtin-tools-executor');
|
|
14
12
|
|
|
15
|
-
const BuiltinToolServerRuntimes: Record<string, any> = {
|
|
16
|
-
[WebBrowsingManifest.identifier]: WebBrowsingExecutionRuntime,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
13
|
export class BuiltinToolsExecutor implements IToolExecutor {
|
|
20
14
|
private marketService: MarketService;
|
|
21
15
|
|
|
22
16
|
constructor(db: LobeChatDatabase, userId: string) {
|
|
23
17
|
this.marketService = new MarketService({ userInfo: { userId } });
|
|
24
18
|
}
|
|
25
|
-
|
|
19
|
+
|
|
20
|
+
async execute(
|
|
21
|
+
payload: ChatToolPayload,
|
|
22
|
+
context: ToolExecutionContext,
|
|
23
|
+
): Promise<ToolExecutionResult> {
|
|
26
24
|
const { identifier, apiName, arguments: argsStr, source } = payload;
|
|
27
25
|
const args = safeParseJSON(argsStr) || {};
|
|
28
26
|
|
|
@@ -43,19 +41,15 @@ export class BuiltinToolsExecutor implements IToolExecutor {
|
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!ServerRuntime) {
|
|
44
|
+
// Use server runtime registry (handles both pre-instantiated and per-request runtimes)
|
|
45
|
+
if (!hasServerRuntime(identifier)) {
|
|
50
46
|
throw new Error(`Builtin tool "${identifier}" is not implemented`);
|
|
51
47
|
}
|
|
52
48
|
|
|
53
|
-
const runtime =
|
|
54
|
-
searchService: new SearchService(),
|
|
55
|
-
});
|
|
49
|
+
const runtime = getServerRuntime(identifier, context);
|
|
56
50
|
|
|
57
51
|
if (!runtime[apiName]) {
|
|
58
|
-
throw new Error(`Builtin tool ${identifier}
|
|
52
|
+
throw new Error(`Builtin tool ${identifier}'s ${apiName} is not implemented`);
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
try {
|
|
@@ -64,7 +58,7 @@ export class BuiltinToolsExecutor implements IToolExecutor {
|
|
|
64
58
|
const error = e as Error;
|
|
65
59
|
console.error('Error executing builtin tool %s:%s: %O', identifier, apiName, error);
|
|
66
60
|
|
|
67
|
-
return { content: error.message, error
|
|
61
|
+
return { content: error.message, error, success: false };
|
|
68
62
|
}
|
|
69
63
|
}
|
|
70
64
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CloudSandboxExecutionRuntime,
|
|
3
|
+
CloudSandboxIdentifier,
|
|
4
|
+
} from '@lobechat/builtin-tool-cloud-sandbox';
|
|
5
|
+
|
|
6
|
+
import { FileService } from '@/server/services/file';
|
|
7
|
+
import { MarketService } from '@/server/services/market';
|
|
8
|
+
import { ServerSandboxService } from '@/server/services/sandbox';
|
|
9
|
+
|
|
10
|
+
import { type ServerRuntimeRegistration } from './types';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* CloudSandbox Server Runtime
|
|
14
|
+
* Per-request runtime (needs topicId, userId)
|
|
15
|
+
*/
|
|
16
|
+
export const cloudSandboxRuntime: ServerRuntimeRegistration = {
|
|
17
|
+
factory: (context) => {
|
|
18
|
+
if (!context.userId || !context.topicId) {
|
|
19
|
+
throw new Error('userId and topicId are required for Cloud Sandbox execution');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!context.serverDB) {
|
|
23
|
+
throw new Error('serverDB is required for Cloud Sandbox execution');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const marketService = new MarketService({ userInfo: { userId: context.userId } });
|
|
27
|
+
const fileService = new FileService(context.serverDB, context.userId);
|
|
28
|
+
const sandboxService = new ServerSandboxService({
|
|
29
|
+
fileService,
|
|
30
|
+
marketService,
|
|
31
|
+
topicId: context.topicId,
|
|
32
|
+
userId: context.userId,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return new CloudSandboxExecutionRuntime(sandboxService);
|
|
36
|
+
},
|
|
37
|
+
identifier: CloudSandboxIdentifier,
|
|
38
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Runtime Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all builtin tool server runtimes.
|
|
5
|
+
* Uses factory functions to support both:
|
|
6
|
+
* - Pre-instantiated runtimes (e.g., WebBrowsing - no per-request context needed)
|
|
7
|
+
* - Per-request runtimes (e.g., CloudSandbox - needs topicId, userId)
|
|
8
|
+
*/
|
|
9
|
+
import { type ToolExecutionContext } from '../types';
|
|
10
|
+
import { cloudSandboxRuntime } from './cloudSandbox';
|
|
11
|
+
import { type ServerRuntimeFactory, type ServerRuntimeRegistration } from './types';
|
|
12
|
+
import { webBrowsingRuntime } from './webBrowsing';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Registry of server runtime factories by identifier
|
|
16
|
+
*/
|
|
17
|
+
const serverRuntimeFactories = new Map<string, ServerRuntimeFactory>();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Register server runtimes
|
|
21
|
+
*/
|
|
22
|
+
const registerRuntimes = (runtimes: ServerRuntimeRegistration[]) => {
|
|
23
|
+
for (const runtime of runtimes) {
|
|
24
|
+
serverRuntimeFactories.set(runtime.identifier, runtime.factory);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Register all server runtimes
|
|
29
|
+
registerRuntimes([webBrowsingRuntime, cloudSandboxRuntime]);
|
|
30
|
+
|
|
31
|
+
// ==================== Registry API ====================
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get a server runtime by identifier
|
|
35
|
+
* @param identifier - The tool identifier
|
|
36
|
+
* @param context - Execution context (required for per-request runtimes)
|
|
37
|
+
*/
|
|
38
|
+
export const getServerRuntime = (identifier: string, context: ToolExecutionContext): any => {
|
|
39
|
+
const factory = serverRuntimeFactories.get(identifier);
|
|
40
|
+
return factory?.(context);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Check if a server runtime exists for the given identifier
|
|
45
|
+
*/
|
|
46
|
+
export const hasServerRuntime = (identifier: string): boolean => {
|
|
47
|
+
return serverRuntimeFactories.has(identifier);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get all registered server runtime identifiers
|
|
52
|
+
*/
|
|
53
|
+
export const getServerRuntimeIdentifiers = (): string[] => {
|
|
54
|
+
return Array.from(serverRuntimeFactories.keys());
|
|
55
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ToolExecutionContext } from '../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Factory function type for creating server runtimes
|
|
5
|
+
*/
|
|
6
|
+
export type ServerRuntimeFactory = (context: ToolExecutionContext) => any;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Server runtime registration object
|
|
10
|
+
*/
|
|
11
|
+
export interface ServerRuntimeRegistration {
|
|
12
|
+
factory: ServerRuntimeFactory;
|
|
13
|
+
identifier: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WebBrowsingManifest } from '@lobechat/builtin-tool-web-browsing';
|
|
2
|
+
import { WebBrowsingExecutionRuntime } from '@lobechat/builtin-tool-web-browsing/executionRuntime';
|
|
3
|
+
|
|
4
|
+
import { SearchService } from '@/server/services/search';
|
|
5
|
+
|
|
6
|
+
import { type ServerRuntimeRegistration } from './types';
|
|
7
|
+
|
|
8
|
+
// Pre-instantiated (no per-request context needed)
|
|
9
|
+
const runtime = new WebBrowsingExecutionRuntime({
|
|
10
|
+
searchService: new SearchService(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* WebBrowsing Server Runtime
|
|
15
|
+
* Pre-instantiated runtime (no per-request context needed)
|
|
16
|
+
*/
|
|
17
|
+
export const webBrowsingRuntime: ServerRuntimeRegistration = {
|
|
18
|
+
factory: () => runtime,
|
|
19
|
+
identifier: WebBrowsingManifest.identifier,
|
|
20
|
+
};
|
|
@@ -6,6 +6,8 @@ export interface ToolExecutionContext {
|
|
|
6
6
|
/** Server database for LobeHub Skills execution */
|
|
7
7
|
serverDB?: LobeChatDatabase;
|
|
8
8
|
toolManifestMap: Record<string, LobeToolManifest>;
|
|
9
|
+
/** Topic ID for sandbox session management */
|
|
10
|
+
topicId?: string;
|
|
9
11
|
userId?: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
@@ -6,9 +6,9 @@ import type {
|
|
|
6
6
|
ExportAndUploadFileResult,
|
|
7
7
|
} from '@/server/routers/tools/market';
|
|
8
8
|
|
|
9
|
-
class
|
|
9
|
+
class CloudSandboxService {
|
|
10
10
|
/**
|
|
11
|
-
* Call a cloud
|
|
11
|
+
* Call a cloud sandbox tool
|
|
12
12
|
* @param toolName - The name of the tool to call (e.g., 'runCommand', 'writeLocalFile')
|
|
13
13
|
* @param params - The parameters for the tool
|
|
14
14
|
* @param context - Session context containing userId and topicId for isolation
|
|
@@ -51,4 +51,4 @@ class CodeInterpreterService {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export const
|
|
54
|
+
export const cloudSandboxService = new CloudSandboxService();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type DataSyncConfig, type MarketAuthorizationParams } from '@lobechat/electron-client-ipc';
|
|
2
|
+
|
|
2
3
|
import { ensureElectronIpc } from '@/utils/electron/ipc';
|
|
3
4
|
|
|
4
5
|
class RemoteServerService {
|
|
@@ -36,6 +37,13 @@ class RemoteServerService {
|
|
|
36
37
|
requestMarketAuthorization = async (params: MarketAuthorizationParams) => {
|
|
37
38
|
return ensureElectronIpc().auth.requestMarketAuthorization(params);
|
|
38
39
|
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Cancel authorization
|
|
43
|
+
*/
|
|
44
|
+
cancelAuthorization = async () => {
|
|
45
|
+
return ensureElectronIpc().auth.cancelAuthorization();
|
|
46
|
+
};
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
export const remoteServerService = new RemoteServerService();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ElectronAppState,
|
|
3
|
-
|
|
3
|
+
WindowMinimumSizeParams,
|
|
4
4
|
WindowSizeParams,
|
|
5
5
|
} from '@lobechat/electron-client-ipc';
|
|
6
6
|
|
|
@@ -36,14 +36,14 @@ class ElectronSystemService {
|
|
|
36
36
|
return this.ipc.windows.minimizeWindow();
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
async setWindowResizable(params: WindowResizableParams): Promise<void> {
|
|
40
|
-
return this.ipc.windows.setWindowResizable(params);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
39
|
async setWindowSize(params: WindowSizeParams): Promise<void> {
|
|
44
40
|
return this.ipc.windows.setWindowSize(params);
|
|
45
41
|
}
|
|
46
42
|
|
|
43
|
+
async setWindowMinimumSize(params: WindowMinimumSizeParams): Promise<void> {
|
|
44
|
+
return this.ipc.windows.setWindowMinimumSize(params);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
47
|
async openExternalLink(url: string): Promise<void> {
|
|
48
48
|
return this.ipc.system.openExternalLink(url);
|
|
49
49
|
}
|