@lobehub/lobehub 2.0.0-next.311 → 2.0.0-next.313
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 +59 -0
- package/apps/desktop/src/main/controllers/AuthCtr.ts +75 -7
- package/changelog/v1.json +21 -0
- package/docs/usage/providers/internlm.mdx +2 -2
- package/docs/usage/providers/internlm.zh-CN.mdx +3 -3
- package/e2e/README.md +1 -1
- package/e2e/src/features/community/detail-pages.feature +2 -2
- package/e2e/src/features/community/interactions.feature +5 -5
- package/e2e/src/features/community/smoke.feature +1 -1
- package/e2e/src/steps/community/detail-pages.steps.ts +6 -4
- package/e2e/src/steps/community/interactions.steps.ts +3 -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-agent-builder/src/systemRole.ts +9 -0
- 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/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/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/public/favicon-32x-32-error.ico +0 -0
- package/public/favicon-32x32-done-dev.ico +0 -0
- package/public/favicon-32x32-done.ico +0 -0
- package/public/favicon-32x32-error-dev.ico +0 -0
- package/public/favicon-32x32-progress-dev.ico +0 -0
- package/public/favicon-32x32-progress.ico +0 -0
- package/public/favicon-done-dev.ico +0 -0
- package/public/favicon-done.ico +0 -0
- package/public/favicon-error-dev.ico +0 -0
- package/public/favicon-error.ico +0 -0
- package/public/favicon-progress-dev.ico +0 -0
- package/public/favicon-progress.ico +0 -0
- package/src/app/[variants]/(desktop)/desktop-onboarding/features/LoginStep.tsx +84 -26
- package/src/app/[variants]/(main)/_layout/DesktopAutoOidcOnFirstOpen.tsx +4 -0
- package/src/app/[variants]/(main)/agent/profile/features/Header/AgentPublishButton/PublishResultModal.tsx +1 -1
- package/src/app/[variants]/(main)/community/(detail)/_layout/Header.tsx +15 -3
- package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Overview/TagList.tsx +1 -1
- package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Related/index.tsx +2 -2
- package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/SystemRole/TagList.tsx +1 -1
- package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/SystemRole/index.tsx +1 -1
- package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Header.tsx +2 -2
- package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Sidebar/ActionButton/AddAgent.tsx +1 -1
- package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Sidebar/ActionButton/index.tsx +1 -1
- package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Sidebar/Related/index.tsx +2 -2
- package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/StatusPage/index.tsx +2 -2
- package/src/app/[variants]/(main)/community/(detail)/user/features/UserAgentCard.tsx +2 -2
- package/src/app/[variants]/(main)/community/(detail)/user/features/UserFavoriteAgents.tsx +1 -1
- package/src/app/[variants]/(main)/community/(list)/(home)/index.tsx +2 -2
- package/src/app/[variants]/(main)/community/(list)/(home)/loading.tsx +1 -1
- package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/Client.tsx +5 -1
- package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/features/Category/index.tsx +1 -1
- package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/features/List/Item.tsx +1 -1
- package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/features/MarketSourceSwitch.tsx +1 -1
- package/src/app/[variants]/(main)/community/_layout/Sidebar/Header/Nav.tsx +2 -2
- package/src/app/[variants]/(main)/home/features/CommunityAgents/List.tsx +1 -1
- package/src/app/[variants]/(main)/home/features/CommunityAgents/index.tsx +1 -1
- package/src/app/[variants]/(mobile)/_layout/index.tsx +1 -1
- package/src/app/[variants]/(mobile)/router/mobileRouter.config.tsx +6 -6
- package/src/app/[variants]/router/desktopRouter.config.tsx +8 -8
- package/src/app/[variants]/share/t/[id]/_layout/index.tsx +1 -1
- package/src/business/server/user.ts +4 -0
- package/src/features/CommandMenu/SearchResults.tsx +1 -1
- 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/navigation/routeMetadata.ts +1 -1
- 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/FaviconProvider.tsx +92 -0
- package/src/layout/GlobalProvider/index.tsx +15 -11
- package/src/layout/GlobalProvider/useUserStateRedirect.ts +37 -24
- package/src/libs/next/config/define-config.ts +1 -1
- 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/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 +7 -0
- package/src/server/services/sandbox/index.ts +120 -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 +31 -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/server/sitemap.test.ts +5 -5
- package/src/server/sitemap.ts +3 -3
- package/src/services/{codeInterpreter.ts → cloudSandbox.ts} +3 -3
- package/src/services/electron/remoteServer.ts +8 -0
- 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
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/DetailProvider.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Capabilities/Block.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Capabilities/Knowledge.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Capabilities/KnowledgeItem.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Capabilities/PluginItem.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Capabilities/Plugins.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Capabilities/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Nav.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Overview/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/Versions/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Details/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Sidebar/Related/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Sidebar/Summary/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Sidebar/TocList/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/features/Sidebar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(detail)/{assistant → agent}/loading.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/_layout/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/_layout/style.ts +0 -0
- /package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/features/Category/useCategory.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/features/List/TokenTag.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/features/List/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/index.tsx +0 -0
- /package/src/app/[variants]/(main)/community/(list)/{assistant → agent}/loading.tsx +0 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { BaseExecutor, type BuiltinToolContext, type BuiltinToolResult } from '@lobechat/types';
|
|
2
|
+
|
|
3
|
+
import { cloudSandboxService } from '@/services/cloudSandbox';
|
|
4
|
+
import { useUserStore } from '@/store/user';
|
|
5
|
+
import { userProfileSelectors } from '@/store/user/slices/auth/selectors';
|
|
6
|
+
|
|
7
|
+
import { CloudSandboxExecutionRuntime } from '../ExecutionRuntime';
|
|
8
|
+
import { CloudSandboxIdentifier } from '../manifest';
|
|
9
|
+
import {
|
|
10
|
+
CloudSandboxApiName,
|
|
11
|
+
type EditLocalFileParams,
|
|
12
|
+
type ExecuteCodeParams,
|
|
13
|
+
type ExportFileParams,
|
|
14
|
+
type GetCommandOutputParams,
|
|
15
|
+
type GlobLocalFilesParams,
|
|
16
|
+
type GrepContentParams,
|
|
17
|
+
type ISandboxService,
|
|
18
|
+
type KillCommandParams,
|
|
19
|
+
type ListLocalFilesParams,
|
|
20
|
+
type MoveLocalFilesParams,
|
|
21
|
+
type ReadLocalFileParams,
|
|
22
|
+
type RenameLocalFileParams,
|
|
23
|
+
type RunCommandParams,
|
|
24
|
+
type SandboxCallToolResult,
|
|
25
|
+
type SandboxExportFileResult,
|
|
26
|
+
type SearchLocalFilesParams,
|
|
27
|
+
type WriteLocalFileParams,
|
|
28
|
+
} from '../types';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Client-side Sandbox Service
|
|
32
|
+
* Wraps codeInterpreterService with bound context (topicId, userId)
|
|
33
|
+
*/
|
|
34
|
+
class ClientSandboxService implements ISandboxService {
|
|
35
|
+
private topicId: string;
|
|
36
|
+
private userId: string;
|
|
37
|
+
|
|
38
|
+
constructor(topicId: string) {
|
|
39
|
+
this.topicId = topicId;
|
|
40
|
+
// Get userId from user store - client-side auth
|
|
41
|
+
const userId = userProfileSelectors.userId(useUserStore.getState());
|
|
42
|
+
if (!userId) {
|
|
43
|
+
throw new Error('userId must be provided');
|
|
44
|
+
}
|
|
45
|
+
this.userId = userId;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async callTool(toolName: string, params: Record<string, any>): Promise<SandboxCallToolResult> {
|
|
49
|
+
return cloudSandboxService.callTool(toolName, params, {
|
|
50
|
+
topicId: this.topicId,
|
|
51
|
+
userId: this.userId,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async exportAndUploadFile(path: string, filename: string): Promise<SandboxExportFileResult> {
|
|
56
|
+
return cloudSandboxService.exportAndUploadFile(path, filename, this.topicId);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Cloud Sandbox Client Executor
|
|
62
|
+
*
|
|
63
|
+
* This executor handles Cloud Sandbox tool calls on the client side.
|
|
64
|
+
* It creates a CloudSandboxExecutionRuntime with a ClientSandboxService
|
|
65
|
+
* that has topicId bound at construction time.
|
|
66
|
+
*/
|
|
67
|
+
class CloudSandboxExecutor extends BaseExecutor<typeof CloudSandboxApiName> {
|
|
68
|
+
readonly identifier = CloudSandboxIdentifier;
|
|
69
|
+
protected readonly apiEnum = CloudSandboxApiName;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get or create a runtime for the given context
|
|
73
|
+
*/
|
|
74
|
+
private getRuntime(ctx: BuiltinToolContext): CloudSandboxExecutionRuntime {
|
|
75
|
+
const topicId = ctx.topicId;
|
|
76
|
+
|
|
77
|
+
if (!topicId) {
|
|
78
|
+
throw new Error('Can not init runtime with empty topicId');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const service = new ClientSandboxService(topicId);
|
|
82
|
+
return new CloudSandboxExecutionRuntime(service);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ==================== File Operations ====================
|
|
86
|
+
|
|
87
|
+
listLocalFiles = async (
|
|
88
|
+
params: ListLocalFilesParams,
|
|
89
|
+
ctx: BuiltinToolContext,
|
|
90
|
+
): Promise<BuiltinToolResult> => {
|
|
91
|
+
const runtime = this.getRuntime(ctx);
|
|
92
|
+
const result = await runtime.listLocalFiles(params);
|
|
93
|
+
return this.toBuiltinResult(result);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
readLocalFile = async (
|
|
97
|
+
params: ReadLocalFileParams,
|
|
98
|
+
ctx: BuiltinToolContext,
|
|
99
|
+
): Promise<BuiltinToolResult> => {
|
|
100
|
+
const runtime = this.getRuntime(ctx);
|
|
101
|
+
const result = await runtime.readLocalFile(params);
|
|
102
|
+
return this.toBuiltinResult(result);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
writeLocalFile = async (
|
|
106
|
+
params: WriteLocalFileParams,
|
|
107
|
+
ctx: BuiltinToolContext,
|
|
108
|
+
): Promise<BuiltinToolResult> => {
|
|
109
|
+
const runtime = this.getRuntime(ctx);
|
|
110
|
+
const result = await runtime.writeLocalFile(params);
|
|
111
|
+
return this.toBuiltinResult(result);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
editLocalFile = async (
|
|
115
|
+
params: EditLocalFileParams,
|
|
116
|
+
ctx: BuiltinToolContext,
|
|
117
|
+
): Promise<BuiltinToolResult> => {
|
|
118
|
+
const runtime = this.getRuntime(ctx);
|
|
119
|
+
const result = await runtime.editLocalFile(params);
|
|
120
|
+
return this.toBuiltinResult(result);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
searchLocalFiles = async (
|
|
124
|
+
params: SearchLocalFilesParams,
|
|
125
|
+
ctx: BuiltinToolContext,
|
|
126
|
+
): Promise<BuiltinToolResult> => {
|
|
127
|
+
const runtime = this.getRuntime(ctx);
|
|
128
|
+
const result = await runtime.searchLocalFiles(params);
|
|
129
|
+
return this.toBuiltinResult(result);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
moveLocalFiles = async (
|
|
133
|
+
params: MoveLocalFilesParams,
|
|
134
|
+
ctx: BuiltinToolContext,
|
|
135
|
+
): Promise<BuiltinToolResult> => {
|
|
136
|
+
const runtime = this.getRuntime(ctx);
|
|
137
|
+
const result = await runtime.moveLocalFiles(params);
|
|
138
|
+
return this.toBuiltinResult(result);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
renameLocalFile = async (
|
|
142
|
+
params: RenameLocalFileParams,
|
|
143
|
+
ctx: BuiltinToolContext,
|
|
144
|
+
): Promise<BuiltinToolResult> => {
|
|
145
|
+
const runtime = this.getRuntime(ctx);
|
|
146
|
+
const result = await runtime.renameLocalFile(params);
|
|
147
|
+
return this.toBuiltinResult(result);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// ==================== Code Execution ====================
|
|
151
|
+
|
|
152
|
+
executeCode = async (
|
|
153
|
+
params: ExecuteCodeParams,
|
|
154
|
+
ctx: BuiltinToolContext,
|
|
155
|
+
): Promise<BuiltinToolResult> => {
|
|
156
|
+
const runtime = this.getRuntime(ctx);
|
|
157
|
+
const result = await runtime.executeCode(params);
|
|
158
|
+
return this.toBuiltinResult(result);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// ==================== Shell Commands ====================
|
|
162
|
+
|
|
163
|
+
runCommand = async (
|
|
164
|
+
params: RunCommandParams,
|
|
165
|
+
ctx: BuiltinToolContext,
|
|
166
|
+
): Promise<BuiltinToolResult> => {
|
|
167
|
+
const runtime = this.getRuntime(ctx);
|
|
168
|
+
const result = await runtime.runCommand(params);
|
|
169
|
+
return this.toBuiltinResult(result);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
getCommandOutput = async (
|
|
173
|
+
params: GetCommandOutputParams,
|
|
174
|
+
ctx: BuiltinToolContext,
|
|
175
|
+
): Promise<BuiltinToolResult> => {
|
|
176
|
+
const runtime = this.getRuntime(ctx);
|
|
177
|
+
const result = await runtime.getCommandOutput(params);
|
|
178
|
+
return this.toBuiltinResult(result);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
killCommand = async (
|
|
182
|
+
params: KillCommandParams,
|
|
183
|
+
ctx: BuiltinToolContext,
|
|
184
|
+
): Promise<BuiltinToolResult> => {
|
|
185
|
+
const runtime = this.getRuntime(ctx);
|
|
186
|
+
const result = await runtime.killCommand(params);
|
|
187
|
+
return this.toBuiltinResult(result);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// ==================== Search & Find ====================
|
|
191
|
+
|
|
192
|
+
grepContent = async (
|
|
193
|
+
params: GrepContentParams,
|
|
194
|
+
ctx: BuiltinToolContext,
|
|
195
|
+
): Promise<BuiltinToolResult> => {
|
|
196
|
+
const runtime = this.getRuntime(ctx);
|
|
197
|
+
const result = await runtime.grepContent(params);
|
|
198
|
+
return this.toBuiltinResult(result);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
globLocalFiles = async (
|
|
202
|
+
params: GlobLocalFilesParams,
|
|
203
|
+
ctx: BuiltinToolContext,
|
|
204
|
+
): Promise<BuiltinToolResult> => {
|
|
205
|
+
const runtime = this.getRuntime(ctx);
|
|
206
|
+
const result = await runtime.globLocalFiles(params);
|
|
207
|
+
return this.toBuiltinResult(result);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// ==================== Export Operations ====================
|
|
211
|
+
|
|
212
|
+
exportFile = async (
|
|
213
|
+
params: ExportFileParams,
|
|
214
|
+
ctx: BuiltinToolContext,
|
|
215
|
+
): Promise<BuiltinToolResult> => {
|
|
216
|
+
const runtime = this.getRuntime(ctx);
|
|
217
|
+
const result = await runtime.exportFile(params);
|
|
218
|
+
return this.toBuiltinResult(result);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// ==================== Helper Methods ====================
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Convert BuiltinServerRuntimeOutput to BuiltinToolResult
|
|
225
|
+
*/
|
|
226
|
+
private toBuiltinResult(output: {
|
|
227
|
+
content: string;
|
|
228
|
+
error?: any;
|
|
229
|
+
state?: any;
|
|
230
|
+
success: boolean;
|
|
231
|
+
}): BuiltinToolResult {
|
|
232
|
+
if (!output.success) {
|
|
233
|
+
return {
|
|
234
|
+
content: output.content,
|
|
235
|
+
error: {
|
|
236
|
+
body: output.error,
|
|
237
|
+
message: output.content || 'Unknown error',
|
|
238
|
+
type: 'PluginServerError',
|
|
239
|
+
},
|
|
240
|
+
state: output.state,
|
|
241
|
+
success: false,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
content: output.content,
|
|
247
|
+
state: output.state,
|
|
248
|
+
success: true,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Export the executor instance for registration
|
|
254
|
+
export const cloudSandboxExecutor = new CloudSandboxExecutor();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API names for Cloud Sandbox tool
|
|
3
|
+
*/
|
|
4
|
+
export const CloudSandboxApiName = {
|
|
5
|
+
editLocalFile: 'editLocalFile',
|
|
6
|
+
executeCode: 'executeCode',
|
|
7
|
+
exportFile: 'exportFile',
|
|
8
|
+
getCommandOutput: 'getCommandOutput',
|
|
9
|
+
globLocalFiles: 'globLocalFiles',
|
|
10
|
+
grepContent: 'grepContent',
|
|
11
|
+
killCommand: 'killCommand',
|
|
12
|
+
listLocalFiles: 'listLocalFiles',
|
|
13
|
+
moveLocalFiles: 'moveLocalFiles',
|
|
14
|
+
readLocalFile: 'readLocalFile',
|
|
15
|
+
renameLocalFile: 'renameLocalFile',
|
|
16
|
+
runCommand: 'runCommand',
|
|
17
|
+
searchLocalFiles: 'searchLocalFiles',
|
|
18
|
+
writeLocalFile: 'writeLocalFile',
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
export type CloudSandboxApiNameType =
|
|
22
|
+
(typeof CloudSandboxApiName)[keyof typeof CloudSandboxApiName];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// ==================== File Operations Params ====================
|
|
2
|
+
|
|
3
|
+
export interface ListLocalFilesParams {
|
|
4
|
+
directoryPath: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface ReadLocalFileParams {
|
|
8
|
+
endLine?: number;
|
|
9
|
+
path: string;
|
|
10
|
+
startLine?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface WriteLocalFileParams {
|
|
14
|
+
content: string;
|
|
15
|
+
createDirectories?: boolean;
|
|
16
|
+
path: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface EditLocalFileParams {
|
|
20
|
+
all?: boolean;
|
|
21
|
+
path: string;
|
|
22
|
+
replace: string;
|
|
23
|
+
search: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SearchLocalFilesParams {
|
|
27
|
+
directory: string;
|
|
28
|
+
fileType?: string;
|
|
29
|
+
keyword?: string;
|
|
30
|
+
modifiedAfter?: string;
|
|
31
|
+
modifiedBefore?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface MoveLocalFilesParams {
|
|
35
|
+
operations: Array<{
|
|
36
|
+
destination: string;
|
|
37
|
+
source: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface RenameLocalFileParams {
|
|
42
|
+
newName: string;
|
|
43
|
+
oldPath: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface GlobLocalFilesParams {
|
|
47
|
+
directory?: string;
|
|
48
|
+
pattern: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ExportFileParams {
|
|
52
|
+
path: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ==================== Code Execution Params ====================
|
|
56
|
+
|
|
57
|
+
export interface ExecuteCodeParams {
|
|
58
|
+
code: string;
|
|
59
|
+
language?: 'javascript' | 'python' | 'typescript';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ==================== Shell Command Params ====================
|
|
63
|
+
|
|
64
|
+
export interface RunCommandParams {
|
|
65
|
+
background?: boolean;
|
|
66
|
+
command: string;
|
|
67
|
+
timeout?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface GetCommandOutputParams {
|
|
71
|
+
commandId: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface KillCommandParams {
|
|
75
|
+
commandId: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ==================== Search & Find Params ====================
|
|
79
|
+
|
|
80
|
+
export interface GrepContentParams {
|
|
81
|
+
directory: string;
|
|
82
|
+
filePattern?: string;
|
|
83
|
+
pattern: string;
|
|
84
|
+
recursive?: boolean;
|
|
85
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// ==================== Sandbox Service Interface ====================
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Result of calling a sandbox tool
|
|
5
|
+
*/
|
|
6
|
+
export interface SandboxCallToolResult {
|
|
7
|
+
error?: { message: string; name?: string };
|
|
8
|
+
result: any;
|
|
9
|
+
sessionExpiredAndRecreated?: boolean;
|
|
10
|
+
success: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Result of exporting and uploading a file from sandbox
|
|
15
|
+
*/
|
|
16
|
+
export interface SandboxExportFileResult {
|
|
17
|
+
error?: { message: string };
|
|
18
|
+
fileId?: string;
|
|
19
|
+
filename: string;
|
|
20
|
+
mimeType?: string;
|
|
21
|
+
size?: number;
|
|
22
|
+
success: boolean;
|
|
23
|
+
url?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Sandbox Service Interface - for dependency injection
|
|
28
|
+
*
|
|
29
|
+
* Context (topicId, userId) is bound at service creation time, not passed per-call.
|
|
30
|
+
* This allows CloudSandboxExecutionRuntime to work on both client and server:
|
|
31
|
+
* - Client: Implemented via tRPC client (codeInterpreterService)
|
|
32
|
+
* - Server: Implemented via MarketSDK directly (ServerSandboxService)
|
|
33
|
+
*/
|
|
34
|
+
export interface ISandboxService {
|
|
35
|
+
/**
|
|
36
|
+
* Call a sandbox tool
|
|
37
|
+
* @param toolName - The name of the tool to call (e.g., 'runCommand', 'writeLocalFile')
|
|
38
|
+
* @param params - The parameters for the tool
|
|
39
|
+
*/
|
|
40
|
+
callTool(toolName: string, params: Record<string, any>): Promise<SandboxCallToolResult>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Export a file from sandbox and upload to cloud storage
|
|
44
|
+
* @param path - The file path in the sandbox
|
|
45
|
+
* @param filename - The name of the file to export
|
|
46
|
+
*/
|
|
47
|
+
exportAndUploadFile(path: string, filename: string): Promise<SandboxExportFileResult>;
|
|
48
|
+
}
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API names for Cloud Sandbox tool
|
|
3
|
-
*/
|
|
4
|
-
export const CloudSandboxApiName = {
|
|
5
|
-
editLocalFile: 'editLocalFile',
|
|
6
|
-
executeCode: 'executeCode',
|
|
7
|
-
exportFile: 'exportFile',
|
|
8
|
-
getCommandOutput: 'getCommandOutput',
|
|
9
|
-
globLocalFiles: 'globLocalFiles',
|
|
10
|
-
grepContent: 'grepContent',
|
|
11
|
-
killCommand: 'killCommand',
|
|
12
|
-
listLocalFiles: 'listLocalFiles',
|
|
13
|
-
moveLocalFiles: 'moveLocalFiles',
|
|
14
|
-
readLocalFile: 'readLocalFile',
|
|
15
|
-
renameLocalFile: 'renameLocalFile',
|
|
16
|
-
runCommand: 'runCommand',
|
|
17
|
-
searchLocalFiles: 'searchLocalFiles',
|
|
18
|
-
writeLocalFile: 'writeLocalFile',
|
|
19
|
-
} as const;
|
|
20
|
-
|
|
21
|
-
export type CloudSandboxApiNameType =
|
|
22
|
-
(typeof CloudSandboxApiName)[keyof typeof CloudSandboxApiName];
|
|
23
|
-
|
|
24
1
|
// ==================== File Operations ====================
|
|
25
2
|
|
|
26
3
|
export interface ListLocalFilesState {
|
|
@@ -278,16 +278,16 @@ export const MemoryManifest: BuiltinToolManifest = {
|
|
|
278
278
|
},
|
|
279
279
|
},
|
|
280
280
|
required: [
|
|
281
|
+
'situation',
|
|
282
|
+
'reasoning',
|
|
281
283
|
'action',
|
|
284
|
+
'possibleOutcome',
|
|
282
285
|
'keyLearning',
|
|
283
|
-
'
|
|
286
|
+
'type',
|
|
284
287
|
'labels',
|
|
285
|
-
'possibleOutcome',
|
|
286
288
|
'problemSolvingScore',
|
|
287
|
-
'reasoning',
|
|
288
289
|
'scoreConfidence',
|
|
289
|
-
'
|
|
290
|
-
'type',
|
|
290
|
+
'knowledgeValueScore',
|
|
291
291
|
],
|
|
292
292
|
type: 'object',
|
|
293
293
|
},
|
|
@@ -21,7 +21,7 @@ describe('EditorRuntime - Real Cases', () => {
|
|
|
21
21
|
let mockTitleGetter: ReturnType<typeof vi.fn>;
|
|
22
22
|
|
|
23
23
|
beforeEach(() => {
|
|
24
|
-
editor = new Kernel();
|
|
24
|
+
editor = new Kernel() as unknown as IEditor;
|
|
25
25
|
editor.registerPlugins([CommonPlugin, MarkdownPlugin, ListPlugin, LitexmlPlugin]);
|
|
26
26
|
editor.initNodeEditor();
|
|
27
27
|
|
|
@@ -22,5 +22,9 @@ export type MainBroadcastParams<T extends MainBroadcastEventKey> = Parameters<
|
|
|
22
22
|
MainBroadcastEvents[T]
|
|
23
23
|
>[0];
|
|
24
24
|
|
|
25
|
-
export type {
|
|
25
|
+
export type {
|
|
26
|
+
AuthorizationPhase,
|
|
27
|
+
AuthorizationProgress,
|
|
28
|
+
MarketAuthorizationParams,
|
|
29
|
+
} from './remoteServer';
|
|
26
30
|
export type { OpenSettingsWindowOptions } from './windows';
|
|
@@ -2,11 +2,34 @@ export interface MarketAuthorizationParams {
|
|
|
2
2
|
authUrl: string;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Authorization phase for progress tracking
|
|
7
|
+
*/
|
|
8
|
+
export type AuthorizationPhase =
|
|
9
|
+
| 'browser_opened' // Browser has been opened for authorization
|
|
10
|
+
| 'waiting_for_auth' // Waiting for user to complete browser login
|
|
11
|
+
| 'verifying' // Received credentials, verifying with server
|
|
12
|
+
| 'cancelled'; // Authorization was cancelled by user
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Authorization progress info for UI updates
|
|
16
|
+
*/
|
|
17
|
+
export interface AuthorizationProgress {
|
|
18
|
+
/** Elapsed time in milliseconds since authorization started */
|
|
19
|
+
elapsed: number;
|
|
20
|
+
/** Maximum polling time in milliseconds */
|
|
21
|
+
maxPollTime: number;
|
|
22
|
+
/** Current authorization phase */
|
|
23
|
+
phase: AuthorizationPhase;
|
|
24
|
+
}
|
|
25
|
+
|
|
5
26
|
/**
|
|
6
27
|
* 从主进程广播的远程服务器相关事件
|
|
7
28
|
*/
|
|
8
29
|
export interface RemoteServerBroadcastEvents {
|
|
9
30
|
authorizationFailed: (params: { error: string }) => void;
|
|
31
|
+
/** Broadcast authorization progress for UI updates */
|
|
32
|
+
authorizationProgress: (params: AuthorizationProgress) => void;
|
|
10
33
|
authorizationRequired: (params: void) => void;
|
|
11
34
|
authorizationSuccessful: (params: void) => void;
|
|
12
35
|
remoteServerConfigUpdated: (params: void) => void;
|
|
@@ -14,7 +14,7 @@ const InternLM: ModelProviderCard = {
|
|
|
14
14
|
settings: {
|
|
15
15
|
disableBrowserRequest: true,
|
|
16
16
|
proxyUrl: {
|
|
17
|
-
placeholder: 'https://
|
|
17
|
+
placeholder: 'https://chat.intern-ai.org.cn/api/v1',
|
|
18
18
|
},
|
|
19
19
|
sdkType: 'openai',
|
|
20
20
|
showModelFetcher: true,
|
|
@@ -133,14 +133,6 @@ export interface CreateRouterRuntimeOptions<T extends Record<string, any> = any>
|
|
|
133
133
|
routers: Routers;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
const formatErrorMessage = (error: unknown): string => {
|
|
137
|
-
if (error instanceof Error) {
|
|
138
|
-
return error.name ? `${error.name}: ${error.message}` : error.message;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return String(error);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
136
|
export const createRouterRuntime = ({
|
|
145
137
|
id,
|
|
146
138
|
routers,
|
|
@@ -310,30 +302,28 @@ export const createRouterRuntime = ({
|
|
|
310
302
|
} catch (error) {
|
|
311
303
|
lastError = error;
|
|
312
304
|
|
|
313
|
-
const message = formatErrorMessage(error);
|
|
314
305
|
if (attempt < totalOptions) {
|
|
315
306
|
log(
|
|
316
|
-
'attempt failed
|
|
317
|
-
model,
|
|
307
|
+
'attempt %d/%d failed (model=%s apiType=%s channelId=%s remark=%s), trying next',
|
|
318
308
|
attempt,
|
|
319
309
|
totalOptions,
|
|
310
|
+
model,
|
|
320
311
|
resolvedApiType,
|
|
321
312
|
channelId ?? '',
|
|
322
313
|
remark ?? '',
|
|
323
|
-
message,
|
|
324
314
|
);
|
|
325
315
|
} else {
|
|
326
316
|
log(
|
|
327
|
-
'attempt failed
|
|
328
|
-
model,
|
|
317
|
+
'attempt %d/%d failed (model=%s apiType=%s channelId=%s remark=%s), no more fallbacks',
|
|
329
318
|
attempt,
|
|
330
319
|
totalOptions,
|
|
320
|
+
model,
|
|
331
321
|
resolvedApiType,
|
|
332
322
|
channelId ?? '',
|
|
333
323
|
remark ?? '',
|
|
334
|
-
message,
|
|
335
324
|
);
|
|
336
325
|
}
|
|
326
|
+
console.error(error);
|
|
337
327
|
}
|
|
338
328
|
}
|
|
339
329
|
|