OpenClaw【六、openclaw.json 配置文件详解】

OpenClaw 配置文件详解

openclaw.json 是 OpenClaw 工具的核心配置文件,包含了系统各方面的设置。下面是对每个部分的详细介绍:

1. wizard 部分

"wizard": {
  "lastRunAt": "2026-03-15T13:29:37.520Z",
  "lastRunVersion": "2026.3.13",
  "lastRunCommand": "onboard",
  "lastRunMode": "local"
}
  • 功能:记录向导工具的运行历史
  • 参数说明
    • lastRunAt:上次运行时间
    • lastRunVersion:上次运行的 OpenClaw 版本
    • lastRunCommand:上次执行的命令(这里是 "onboard",即引导配置)
    • lastRunMode:上次运行模式(本地模式)

2. auth 部分

"auth": {
  "profiles": {
    "modelstudio:default": {
      "provider": "modelstudio",
      "mode": "api_key"
    }
  }
}
  • 功能:管理认证配置
  • 参数说明
    • profiles:认证配置文件
    • modelstudio:default:默认的 ModelStudio 认证配置
    • provider:认证提供者
    • mode:认证模式(API 密钥方式)

3. models 部分

"models": {
  "mode": "merge",
  "providers": {
    "modelstudio": {
      "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
      "api": "openai-completions",
      "models": [
        // 多个模型配置...
      ]
    }
  }
}
  • 功能:配置 AI 模型
  • 参数说明
    • mode:模型加载模式("merge" 表示合并模式)
    • providers:模型提供者配置
    • modelstudio:ModelStudio 提供者配置
    • baseUrl:API 基础地址
    • api:API 类型
    • models:可用模型列表,包含:
      • id:模型 ID
      • name:模型名称
      • reasoning:是否支持推理
      • input:支持的输入类型
      • cost:使用成本
      • contextWindow:上下文窗口大小
      • maxTokens:最大 token 数

4. agents 部分

"agents": {
  "defaults": {
    "model": {
      "primary": "modelstudio/qwen3.5-plus"
    },
    "models": {
      // 模型别名配置...
    },
    "workspace": "C:\\Users\\Administrator\\.openclaw\\workspace"
  }
}
  • 功能:配置智能代理
  • 参数说明
    • defaults:默认配置
    • model.primary:默认使用的主要模型
    • models:模型别名配置
    • workspace:工作目录路径

5. tools 部分

"tools": {
  "profile": "coding"
}
  • 功能:配置工具配置文件
  • 参数说明
    • profile:工具配置文件类型("coding" 表示编码相关)

6. commands 部分

"commands": {
  "native": "auto",
  "nativeSkills": "auto",
  "restart": true,
  "ownerDisplay": "raw"
}
  • 功能:配置命令行为
  • 参数说明
    • native:原生命令处理方式("auto" 表示自动)
    • nativeSkills:原生技能处理方式("auto" 表示自动)
    • restart:是否允许重启
    • ownerDisplay:所有者显示方式("raw" 表示原始格式)

7. session 部分

"session": {
  "dmScope": "per-channel-peer"
}
  • 功能:配置会话行为
  • 参数说明
    • dmScope:私聊范围("per-channel-peer" 表示按频道和用户)

8. hooks 部分

"hooks": {
  "internal": {
    "enabled": true,
    "entries": {
      "session-memory": {
        "enabled": true
      },
      "command-logger": {
        "enabled": true
      }
    }
  }
}
  • 功能:配置内部钩子
  • 参数说明
    • internal:内部钩子配置
    • enabled:是否启用
    • entries:钩子条目
      • session-memory:会话记忆钩子
      • command-logger:命令记录器钩子

9. gateway 部分

"gateway": {
  "port": 18789,
  "mode": "local",
  "bind": "loopback",
  "auth": {
    "mode": "token",
    "token": "89b1a0bd89a56622494a3c3692bdb1c115e2b1df56da67b9"
  },
  "tailscale": {
    "mode": "off",
    "resetOnExit": false
  },
  "nodes": {
    "denyCommands": [
      // 禁止的命令...
    ]
  }
}
  • 功能:配置网关服务
  • 参数说明
    • port:网关端口
    • mode:网关模式("local" 表示本地模式)
    • bind:绑定地址("loopback" 表示回环地址)
    • auth:认证配置
    • tailscale:Tailscale 配置
    • nodes:节点配置
      • denyCommands:禁止执行的命令列表

10. meta 部分

"meta": {
  "lastTouchedVersion": "2026.3.13",
  "lastTouchedAt": "2026-03-15T13:29:37.544Z"
}
  • 功能:元数据信息
  • 参数说明
    • lastTouchedVersion:上次修改的版本
    • lastTouchedAt:上次修改时间

总结

这个配置文件全面定义了 OpenClaw 的运行环境,包括:

  • 向导工具的历史记录
  • 认证配置
  • AI 模型的详细设置
  • 智能代理的默认配置
  • 工具和命令的行为
  • 会话管理
  • 内部钩子
  • 网关服务设置
  • 元数据信息

通过这些配置,OpenClaw 能够根据用户需求灵活调整其行为,提供个性化的 AI 辅助服务。

posted @ 2026-03-28 17:34  蓝迷梦  阅读(523)  评论(0)    收藏  举报