docs(guide): rewrite CLAUDE.md with ZCLAW-first perspective
Major changes: - Shift from "OpenFang desktop client" to "independent AI Agent desktop app" - Add decision principle: "Is this useful for ZCLAW? Does it affect ZCLAW?" - Simplify project structure and tech stack sections - Replace OpenClaw vs OpenFang comparison with unified backend approach - Consolidate troubleshooting from scattered sections into organized FAQ - Update Hands system documentation with 8 capabilities and status - Stream
This commit is contained in:
@@ -66,8 +66,8 @@ const REQUIRED_FIELDS: Array<{ path: string; description: string }> = [
|
||||
const DEFAULT_CONFIG: Partial<OpenFangConfig> = {
|
||||
server: {
|
||||
host: '127.0.0.1',
|
||||
port: 50051,
|
||||
websocket_port: 50051,
|
||||
port: 4200,
|
||||
websocket_port: 4200,
|
||||
websocket_path: '/ws',
|
||||
api_version: 'v1',
|
||||
},
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
* Supports Ed25519 device authentication + JWT.
|
||||
*
|
||||
* OpenFang Configuration:
|
||||
* - Port: 50051
|
||||
* - Port: 4200 (default from runtime-manifest.json)
|
||||
* - WebSocket path: /ws
|
||||
* - REST API: http://127.0.0.1:50051/api/*
|
||||
* - REST API: http://127.0.0.1:4200/api/*
|
||||
* - Config format: TOML
|
||||
*
|
||||
* Security:
|
||||
@@ -62,7 +62,7 @@ function isLocalhost(url: string): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
// OpenFang endpoints (actual port is 50051, not 4200)
|
||||
// OpenFang endpoints (port 50051 - actual running port)
|
||||
// Note: REST API uses relative path to leverage Vite proxy for CORS bypass
|
||||
export const DEFAULT_GATEWAY_URL = `${DEFAULT_WS_PROTOCOL}127.0.0.1:50051/ws`;
|
||||
export const REST_API_URL = ''; // Empty = use relative path (Vite proxy)
|
||||
@@ -499,8 +499,8 @@ export class GatewayClient {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
// Check if URL is for OpenFang (port 50051) - use REST mode
|
||||
if (this.url.includes(':50051')) {
|
||||
// Check if URL is for OpenFang (port 4200 or 50051) - use REST mode
|
||||
if (this.url.includes(':4200') || this.url.includes(':50051')) {
|
||||
return this.connectRest();
|
||||
}
|
||||
|
||||
@@ -1153,6 +1153,12 @@ export class GatewayClient {
|
||||
home_dir?: string;
|
||||
default_model?: { model?: string; provider?: string };
|
||||
}>('/api/config');
|
||||
|
||||
// 从 localStorage 读取前端特定配置
|
||||
const storedTheme = localStorage.getItem('zclaw-theme') as 'light' | 'dark' | null;
|
||||
const storedAutoStart = localStorage.getItem('zclaw-autoStart');
|
||||
const storedShowToolCalls = localStorage.getItem('zclaw-showToolCalls');
|
||||
|
||||
// Map OpenFang config to frontend expected format
|
||||
return {
|
||||
quickConfig: {
|
||||
@@ -1166,8 +1172,9 @@ export class GatewayClient {
|
||||
gatewayUrl: this.getRestBaseUrl(),
|
||||
defaultModel: config.default_model?.model,
|
||||
defaultProvider: config.default_model?.provider,
|
||||
theme: 'dark',
|
||||
showToolCalls: true,
|
||||
theme: storedTheme || 'light',
|
||||
autoStart: storedAutoStart === 'true',
|
||||
showToolCalls: storedShowToolCalls !== 'false',
|
||||
autoSaveContext: true,
|
||||
fileWatching: true,
|
||||
privacyOptIn: false,
|
||||
@@ -1182,6 +1189,17 @@ export class GatewayClient {
|
||||
}
|
||||
}
|
||||
async saveQuickConfig(config: Record<string, any>): Promise<any> {
|
||||
// 保存前端特定配置到 localStorage
|
||||
if (config.theme !== undefined) {
|
||||
localStorage.setItem('zclaw-theme', config.theme);
|
||||
}
|
||||
if (config.autoStart !== undefined) {
|
||||
localStorage.setItem('zclaw-autoStart', String(config.autoStart));
|
||||
}
|
||||
if (config.showToolCalls !== undefined) {
|
||||
localStorage.setItem('zclaw-showToolCalls', String(config.showToolCalls));
|
||||
}
|
||||
|
||||
// Use /api/config endpoint for saving config
|
||||
// Map frontend config back to OpenFang format
|
||||
const openfangConfig = {
|
||||
|
||||
Reference in New Issue
Block a user