cloudflare-mcp-smart-proxy 1.5.7 → 1.5.8
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/package.json +1 -1
- package/src/connector-bridge.js +4 -5
- package/src/router.js +22 -0
package/package.json
CHANGED
package/src/connector-bridge.js
CHANGED
|
@@ -75,10 +75,8 @@ export class ConnectorBridge {
|
|
|
75
75
|
const projectIdentity = await discoverProjectIdentity(this.workspaceRoot);
|
|
76
76
|
const response = await this.cloudClient.resolveWorkspace({ projectIdentity });
|
|
77
77
|
const resolution = response?.workspaceResolution;
|
|
78
|
-
if (!resolution
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
this.workspaceId = resolution.workspaceId;
|
|
78
|
+
if (!resolution) throw new Error('CloudMCP returned no workspace resolution result');
|
|
79
|
+
this.workspaceId = normalizeString(resolution.workspaceId);
|
|
82
80
|
this.state.projectIdentity = projectIdentity;
|
|
83
81
|
this.state.workspaceResolution = resolution;
|
|
84
82
|
return resolution;
|
|
@@ -107,7 +105,8 @@ export class ConnectorBridge {
|
|
|
107
105
|
return this.getBridgeStatus();
|
|
108
106
|
}
|
|
109
107
|
|
|
110
|
-
await this.resolveCurrentWorkspace();
|
|
108
|
+
const workspaceResolution = await this.resolveCurrentWorkspace();
|
|
109
|
+
if (!workspaceResolution.workspaceId) return this.getBridgeStatus();
|
|
111
110
|
try {
|
|
112
111
|
if (typeof this.cloudClient?.registerDevice === 'function') {
|
|
113
112
|
await this.ensureDeviceRegistration();
|
package/src/router.js
CHANGED
|
@@ -136,11 +136,25 @@ export class SmartRouter {
|
|
|
136
136
|
return 'cloud';
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
getWorkspaceWarnings() {
|
|
140
|
+
const resolution = this.localTools?.connectorBridge?.state?.workspaceResolution;
|
|
141
|
+
if (resolution?.workspaceId) return [];
|
|
142
|
+
return Array.isArray(resolution?.warnings) ? resolution.warnings : [];
|
|
143
|
+
}
|
|
144
|
+
|
|
139
145
|
/**
|
|
140
146
|
* 执行工具调用
|
|
141
147
|
*/
|
|
142
148
|
async executeTool(toolName, params) {
|
|
143
149
|
const route = this.routeTool(toolName);
|
|
150
|
+
const workspaceWarnings = this.getWorkspaceWarnings();
|
|
151
|
+
if (route === 'cloud' && workspaceWarnings.length) {
|
|
152
|
+
return {
|
|
153
|
+
objectType: 'connector_workspace_warning',
|
|
154
|
+
executed: false,
|
|
155
|
+
warnings: workspaceWarnings
|
|
156
|
+
};
|
|
157
|
+
}
|
|
144
158
|
|
|
145
159
|
if (route === 'local') {
|
|
146
160
|
return await this.localTools.execute(toolName, params);
|
|
@@ -288,6 +302,14 @@ export class SmartRouter {
|
|
|
288
302
|
* 获取所有工具列表(合并云端和本地)
|
|
289
303
|
*/
|
|
290
304
|
async getAllTools() {
|
|
305
|
+
const workspaceWarnings = this.getWorkspaceWarnings();
|
|
306
|
+
if (workspaceWarnings.length) {
|
|
307
|
+
const localTools = await this.localTools.listTools();
|
|
308
|
+
const recoveryTools = new Set(['connector_bridge_status', 'connector_discover_project_probe']);
|
|
309
|
+
return localTools
|
|
310
|
+
.filter((tool) => recoveryTools.has(tool.name))
|
|
311
|
+
.map((tool) => ({ ...tool, source: 'local' }));
|
|
312
|
+
}
|
|
291
313
|
const [cloudTools, localTools] = await Promise.all([
|
|
292
314
|
this.getCloudTools(),
|
|
293
315
|
this.localTools.listTools()
|