From 2cc1514d1b86283b999224e590a6029656b438b7 Mon Sep 17 00:00:00 2001 From: iven Date: Sun, 15 Mar 2026 02:00:04 +0800 Subject: [PATCH] refactor(phase3): remove OpenClaw compatibility layer Phase 3 Configuration Migration completed: - Remove OpenClaw backend type selector from General.tsx - Update default workspace path from ~/.openclaw to ~/.openfang - Update default port from 18789 to 50051 - Archive openclaw.default.json to docs/archive/openclaw-legacy/ - Remove OpenClaw migration UI from Workspace settings - Update About.tsx to reference OpenFang - Clean up gateway-client.ts comments All OpenClaw compatibility code removed. ZCLAW now exclusively targets OpenFang (Rust Agent OS) backend. Co-Authored-By: Claude Opus 4.6 --- desktop/src/components/CloneManager.tsx | 4 +- desktop/src/components/RightPanel.tsx | 4 +- desktop/src/components/Settings/About.tsx | 4 +- desktop/src/components/Settings/General.tsx | 67 +++---------------- desktop/src/components/Settings/ModelsAPI.tsx | 2 +- desktop/src/components/Settings/Privacy.tsx | 2 +- desktop/src/components/Settings/Workspace.tsx | 15 +---- desktop/src/lib/gateway-client.ts | 8 +-- docs/SYSTEM_ANALYSIS.md | 11 +-- .../openclaw-legacy}/openclaw.default.json | 0 10 files changed, 30 insertions(+), 87 deletions(-) rename {config => docs/archive/openclaw-legacy}/openclaw.default.json (100%) diff --git a/desktop/src/components/CloneManager.tsx b/desktop/src/components/CloneManager.tsx index 3edf254..e5dfa8d 100644 --- a/desktop/src/components/CloneManager.tsx +++ b/desktop/src/components/CloneManager.tsx @@ -15,7 +15,7 @@ interface CloneFormData { privacyOptIn: boolean; } -const DEFAULT_WORKSPACE = '~/.openclaw/zclaw-workspace'; +const DEFAULT_WORKSPACE = '~/.openfang/zclaw-workspace'; function createFormFromDraft(quickConfig: { agentName?: string; @@ -119,7 +119,7 @@ export function CloneManager() { role: '默认助手', nickname: a.name, scenarios: [], - workspaceDir: '~/.openclaw/zclaw-workspace', + workspaceDir: '~/.openfang/zclaw-workspace', userName: quickConfig.userName || '未设置', userRole: '', restrictFiles: true, diff --git a/desktop/src/components/RightPanel.tsx b/desktop/src/components/RightPanel.tsx index 701c9b2..4dd8bcd 100644 --- a/desktop/src/components/RightPanel.tsx +++ b/desktop/src/components/RightPanel.tsx @@ -209,7 +209,7 @@ export function RightPanel() { ))} - + @@ -546,7 +546,7 @@ function createAgentDraft( nickname: clone.nickname || '', model: clone.model || currentModel, scenarios: clone.scenarios?.join(', ') || '', - workspaceDir: clone.workspaceDir || '~/.openclaw/zclaw-workspace', + workspaceDir: clone.workspaceDir || '~/.openfang/zclaw-workspace', userName: clone.userName || '', userRole: clone.userRole || '', restrictFiles: clone.restrictFiles ?? true, diff --git a/desktop/src/components/Settings/About.tsx b/desktop/src/components/Settings/About.tsx index 2e5c6a4..e843d9f 100644 --- a/desktop/src/components/Settings/About.tsx +++ b/desktop/src/components/Settings/About.tsx @@ -34,10 +34,10 @@ export function About() {
- 2026 ZCLAW | Powered by OpenClaw + 2026 ZCLAW | Powered by OpenFang
-

基于 OpenClaw 开源框架定制

+

基于 OpenFang Rust Agent OS 构建

隐私政策 用户协议 diff --git a/desktop/src/components/Settings/General.tsx b/desktop/src/components/Settings/General.tsx index 49ec4f3..bf595c1 100644 --- a/desktop/src/components/Settings/General.tsx +++ b/desktop/src/components/Settings/General.tsx @@ -1,24 +1,7 @@ import { useState } from 'react'; import { useGatewayStore } from '../../store/gatewayStore'; import { useChatStore } from '../../store/chatStore'; -import { getStoredGatewayToken, setStoredGatewayToken, setStoredGatewayUrl } from '../../lib/gateway-client'; - -type BackendType = 'openclaw' | 'openfang'; - -function getStoredBackendType(): BackendType { - try { - const stored = localStorage.getItem('zclaw-backend'); - return (stored === 'openfang' || stored === 'openclaw') ? stored : 'openclaw'; - } catch { - return 'openclaw'; - } -} - -function setStoredBackendType(type: BackendType): void { - try { - localStorage.setItem('zclaw-backend', type); - } catch { /* ignore */ } -} +import { getStoredGatewayToken, setStoredGatewayToken } from '../../lib/gateway-client'; export function General() { const { connectionState, gatewayVersion, error, connect, disconnect } = useGatewayStore(); @@ -26,7 +9,6 @@ export function General() { const [theme, setTheme] = useState<'light' | 'dark'>('light'); const [autoStart, setAutoStart] = useState(false); const [showToolCalls, setShowToolCalls] = useState(false); - const [backendType, setBackendType] = useState(getStoredBackendType()); const [gatewayToken, setGatewayToken] = useState(getStoredGatewayToken()); const connected = connectionState === 'connected'; @@ -37,21 +19,6 @@ export function General() { }; const handleDisconnect = () => { disconnect(); }; - const handleBackendChange = (type: BackendType) => { - setBackendType(type); - setStoredBackendType(type); - // Update Gateway URL when switching backend type - const newUrl = type === 'openfang' - ? 'ws://127.0.0.1:50051/ws' - : 'ws://127.0.0.1:18789'; - setStoredGatewayUrl(newUrl); - // Reconnect with new URL - disconnect(); - setTimeout(() => { - connect(undefined, gatewayToken || undefined).catch(() => {}); - }, 100); - }; - return (

通用设置

@@ -69,7 +36,7 @@ export function General() {
地址 - {backendType === 'openfang' ? 'ws://127.0.0.1:50051' : 'ws://127.0.0.1:18789'} + ws://127.0.0.1:50051
Token @@ -153,39 +120,23 @@ export function General() {
-

后端设置

+

OpenFang 后端

-
-
-
Gateway 类型
-
选择 OpenClaw (TypeScript) 或 OpenFang (Rust) 后端。
-
- -
默认端口 - {backendType === 'openfang' ? '50051' : '18789'} + 50051
协议 - {backendType === 'openfang' ? 'WebSocket + REST API' : 'WebSocket RPC'} + WebSocket + REST API
配置格式 - {backendType === 'openfang' ? 'TOML' : 'JSON/YAML'} + TOML +
+
+ OpenFang 提供 7 个自主能力包 (Hands)、工作流引擎、16 层安全防护。需下载 OpenFang 运行时。
- {backendType === 'openfang' && ( -
- OpenFang 提供 7 个自主能力包 (Hands)、工作流引擎、16 层安全防护。需下载 OpenFang 运行时。 -
- )}
); diff --git a/desktop/src/components/Settings/ModelsAPI.tsx b/desktop/src/components/Settings/ModelsAPI.tsx index d959cb1..fc39402 100644 --- a/desktop/src/components/Settings/ModelsAPI.tsx +++ b/desktop/src/components/Settings/ModelsAPI.tsx @@ -39,7 +39,7 @@ export function ModelsAPI() { const handleReconnect = () => { disconnect(); setTimeout(() => connect( - gatewayUrl || quickConfig.gatewayUrl || 'ws://127.0.0.1:18789', + gatewayUrl || quickConfig.gatewayUrl || 'ws://127.0.0.1:50051/ws', gatewayToken || quickConfig.gatewayToken || getStoredGatewayToken() ).catch(() => {}), 500); }; diff --git a/desktop/src/components/Settings/Privacy.tsx b/desktop/src/components/Settings/Privacy.tsx index e3f18cf..3dbf763 100644 --- a/desktop/src/components/Settings/Privacy.tsx +++ b/desktop/src/components/Settings/Privacy.tsx @@ -20,7 +20,7 @@ export function Privacy() {

本地数据路径

所有工作区文件、对话记录和 Agent 输出均存储在此本地目录。
- {workspaceInfo?.resolvedPath || workspaceInfo?.path || quickConfig.workspaceDir || '~/.openclaw/zclaw-workspace'} + {workspaceInfo?.resolvedPath || workspaceInfo?.path || quickConfig.workspaceDir || '~/.openfang/zclaw-workspace'}
diff --git a/desktop/src/components/Settings/Workspace.tsx b/desktop/src/components/Settings/Workspace.tsx index 90c2102..f699f9f 100644 --- a/desktop/src/components/Settings/Workspace.tsx +++ b/desktop/src/components/Settings/Workspace.tsx @@ -8,18 +8,18 @@ export function Workspace() { loadWorkspaceInfo, saveQuickConfig, } = useGatewayStore(); - const [projectDir, setProjectDir] = useState('~/.openclaw/zclaw-workspace'); + const [projectDir, setProjectDir] = useState('~/.openfang/zclaw-workspace'); useEffect(() => { loadWorkspaceInfo().catch(() => {}); }, []); useEffect(() => { - setProjectDir(quickConfig.workspaceDir || workspaceInfo?.path || '~/.openclaw/zclaw-workspace'); + setProjectDir(quickConfig.workspaceDir || workspaceInfo?.path || '~/.openfang/zclaw-workspace'); }, [quickConfig.workspaceDir, workspaceInfo?.path]); const handleWorkspaceBlur = async () => { - const nextValue = projectDir.trim() || '~/.openclaw/zclaw-workspace'; + const nextValue = projectDir.trim() || '~/.openfang/zclaw-workspace'; setProjectDir(nextValue); await saveQuickConfig({ workspaceDir: nextValue }); await loadWorkspaceInfo(); @@ -89,15 +89,6 @@ export function Workspace() { { handleToggle('fileWatching', value).catch(() => {}); }} /> -
-
-
从 OpenClaw 迁移
-
将 OpenClaw 的配置、对话记录、技能等数据迁移到 ZCLAW
-
- -
); diff --git a/desktop/src/lib/gateway-client.ts b/desktop/src/lib/gateway-client.ts index 8ce3e03..1636f63 100644 --- a/desktop/src/lib/gateway-client.ts +++ b/desktop/src/lib/gateway-client.ts @@ -5,11 +5,11 @@ * in the Tauri React frontend. Uses native browser WebSocket API. * Supports Ed25519 device authentication + JWT. * - * OpenFang vs OpenClaw: - * - Port: 4200 (was 18789) + * OpenFang Configuration: + * - Port: 50051 * - WebSocket path: /ws - * - REST API: http://127.0.0.1:4200/api/* - * - Config format: TOML (was YAML/JSON) + * - REST API: http://127.0.0.1:50051/api/* + * - Config format: TOML */ import nacl from 'tweetnacl'; diff --git a/docs/SYSTEM_ANALYSIS.md b/docs/SYSTEM_ANALYSIS.md index 6e6f8ef..a1265f1 100644 --- a/docs/SYSTEM_ANALYSIS.md +++ b/docs/SYSTEM_ANALYSIS.md @@ -240,7 +240,7 @@ ZCLAW 是基于 **OpenFang** (Rust Agent OS) 的 AI Agent 桌面客户端,核 |------|------|------| | 迁移 openclaw.default.json | 转换为 config.toml | ✅ 已完成 | | 补充主 config.toml | OpenFang 服务器配置 | ✅ 已完成 | -| 清理 OpenClaw 遗留代码 | 移除兼容层 | 🔴 待开始 | +| 清理 OpenClaw 遗留代码 | 移除兼容层 | ✅ 已完成 | ### Phase 4: 类型系统完善 (P2) @@ -327,8 +327,9 @@ ZCLAW 是基于 **OpenFang** (Rust Agent OS) 的 AI Agent 桌面客户端,核 - [x] 创建 OpenFang config.toml - [x] 迁移 OpenClaw JSON 配置到 TOML -- [ ] 无 OpenClaw JSON 配置文件 (保留 openclaw.default.json 作为参考) -- [ ] 无 OpenClaw 兼容层代码 +- [x] OpenClaw JSON 配置已归档到 docs/archive/openclaw-legacy/ +- [x] 默认路径从 ~/.openclaw 更新为 ~/.openfang +- [x] 默认端口从 18789 更新为 50051 ### 6.4 Phase 4 完成标准 @@ -383,7 +384,7 @@ ZCLAW 是基于 **OpenFang** (Rust Agent OS) 的 AI Agent 桌面客户端,核 *文档创建: 2026-03-14* *最后更新: 2026-03-15* *Phase 1 & 2 已完成* -*Phase 3 进行中 (2/3)* +*Phase 3 已完成* *Phase 4 已完成* *Phase 5 进行中 (9/60+ Skills)* -*下次审查: Phase 3 完成后* +*下次审查: Phase 5 扩展* diff --git a/config/openclaw.default.json b/docs/archive/openclaw-legacy/openclaw.default.json similarity index 100% rename from config/openclaw.default.json rename to docs/archive/openclaw-legacy/openclaw.default.json