Friends
Configure per-user sessions with sandbox isolation, friend profiles, and relationship awareness.
Core Concepts
- - UserId: Lowercase unique identifier (e.g.,
alice, bob). Used in session keys, filenames, and cross-references. - Session: One session per user, named
agent:<agentId>:<mainKey> where mainKey typically contains the userId. - Sandbox: Optional Docker isolation per session, configured in
openclaw.json. - FRIENDS/: User profile directory (one file per user, named
{userId}.md). - RELATIONS/: Relationship directory (files named
{userId1}-{userId2}.md, alphabetically sorted, can be mutiple users).
Example Workspace Structure
CODEBLOCK0
USER.md
Registry of all users. The assistant reads this to identify users and extract userId and Name.
Format:
CODEBLOCK1
Note: userId is unique and in lower case. Use Role to determine sandbox configuration in openclaw.json.
FRIENDS/
User profiles. One Markdown file per user, named {userId}.md.
Content is flexible. Common sections include:
CODEBLOCK2
RELATIONS/
Interpersonal relationships. Files named {userId1}-{userId2}.md (alphabetical order, can be mutiple users).
Content is flexible. Example:
CODEBLOCK3
AGENTS.md
Instructions for the assistant. Add this section:
CODEBLOCK4
Session Configuration
Each user gets an isolated session with configurable sandbox and tool permissions. Configure via openclaw.json.
Administrator Configuration
Full access, no sandbox restrictions:
CODEBLOCK5
Guest Configuration
Sandboxed session with isolated workspace. Guest can read/write/execute in their own directory only:
CODEBLOCK6
Directory Setup:
CODEBLOCK7
Notes:
- - Guest sees
/workspace as their root (isolated from main workspace) - Can read/write/execute freely within their directory
- Cannot access USER.md, FRIENDS/, RELATIONS/, or other guests' data
Configuration Options
Sandbox:
- -
mode: "off" | "all" — Disable or enable sandbox - INLINECODE19 :
"session" — One container per user session - INLINECODE21 :
"none" | "ro" | "rw" — Workspace file access
Tools:
- -
allow: Array of permitted tool names - INLINECODE26 : Array of prohibited tool names (overrides allow)
Routing:
- -
bindings[].match.session.regex: Match session key pattern (e.g., alice$ matches sessions ending with "alice")
Friends
配置具有沙箱隔离、好友档案和关系感知的每用户会话。
核心概念
- - UserId:小写唯一标识符(例如 alice、bob)。用于会话键、文件名和交叉引用。
- Session:每个用户一个会话,命名为 agent::,其中 mainKey 通常包含用户ID。
- Sandbox:可选的每会话 Docker 隔离,在 openclaw.json 中配置。
- FRIENDS/:用户档案目录(每个用户一个文件,命名为 {userId}.md)。
- RELATIONS/:关系目录(文件命名为 {userId1}-{userId2}.md,按字母顺序排序,可包含多个用户)。
示例工作区结构
workspace/
├── USER.md # 带权限的用户注册表
├── AGENTS.md # 面向助手的多用户指南
├── FRIENDS/
│ ├── alice.md # alice 的档案
│ └── bob.md # bob 的档案
├── RELATIONS/
│ └── alice-bob.md # alice 和 bob 之间的关系
├── private/ # 仅管理员可访问的文件(可选)
...
USER.md
所有用户的注册表。助手读取此文件以识别用户并提取 userId 和 Name。
格式:
markdown
用户注册表
用户
alice
- - UserId: alice
- Name: Alice
- Role: administrator
bob
- - UserId: bob
- Name: Bob
- Role: guest
注意: userId 是唯一的且为小写。使用 Role 确定 openclaw.json 中的沙箱配置。
FRIENDS/
用户档案。每个用户一个 Markdown 文件,命名为 {userId}.md。
内容灵活。常见部分包括:
markdown
Alice
信息
- - UserId: alice
- Name: Alice
- Role: administrator
- Emails: alice@example.com
...
助手关系
- - 用户偏好如何与助手互动
- 偏好的沟通风格
- 正在进行的项目或兴趣
备注
关于用户的自由形式信息。
RELATIONS/
人际关系。文件命名为 {userId1}-{userId2}.md(按字母顺序,可包含多个用户)。
内容灵活。示例:
markdown
Alice & Bob
用户
关系
合作项目的朋友。
信息共享
AGENTS.md
面向助手的指令。添加此部分:
markdown
用户识别
当会话启动时(在 /new 之后):
- 1. 通过 session_status 获取当前会话
- 从会话键中提取 userId(例如 agent:main:alice → alice)
- 读取 FRIENDS/{userId}.md 获取用户档案
- 读取 RELATIONS/{userId}.md 获取涉及该用户的所有关系
- 按名称问候用户
跨用户边界
- - 默认:信息不在用户之间流动
- 例外:仅在 RELATIONS/ 中明确定义时
会话配置
每个用户获得一个隔离的会话,具有可配置的沙箱和工具权限。通过 openclaw.json 配置。
管理员配置
完全访问,无沙箱限制:
json5
{
agents: {
defaults: {
workspace: ~/.openclaw/workspace,
},
list: [
{
id: main,
// 管理员:无沙箱,允许所有工具
sandbox: { mode: off },
},
],
},
bindings: [
// 将管理员会话路由到无沙箱的主代理
{ agentId: main, match: { session: { regex: alice$ } } },
],
}
访客配置
带隔离工作区的沙箱会话。访客只能在其自己的目录中读/写/执行:
json5
{
agents: {
defaults: {
workspace: ~/.openclaw/workspace,
},
list: [
{
id: main,
// 访客:启用沙箱,隔离目录
sandbox: {
mode: all,
scope: session,
workspaceAccess: none, // 不挂载主工作区
docker: {
binds: [
// 将访客自己的目录挂载为 /workspace
~/.openclaw/workspace/guests/bob:/workspace:rw
]
}
},
tools: {
allow: [read, write, edit, exec, process],
deny: [browser, canvas, nodes, cron, gateway],
},
},
],
},
bindings: [
// 将访客会话路由到沙箱代理
{ agentId: main, match: { session: { regex: bob$ } } },
],
}
目录设置:
bash
mkdir -p ~/.openclaw/workspace/guests/bob
注意:
- - 访客将 /workspace 视为其根目录(与主工作区隔离)
- 可在其目录内自由读/写/执行
- 无法访问 USER.md、FRIENDS/、RELATIONS/ 或其他访客的数据
配置选项
沙箱:
- - mode:off | all — 禁用或启用沙箱
- scope:session — 每个用户会话一个容器
- workspaceAccess:none | ro | rw — 工作区文件访问权限
工具:
- - allow:允许的工具名称数组
- deny:禁止的工具名称数组(覆盖 allow)
路由:
- - bindings[].match.session.regex:匹配会话键模式(例如 alice$ 匹配以 alice 结尾的会话)