debug
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClaudeClaw Container & Sandbox Debugging
ClaudeClaw 容器与沙箱调试指南
This guide covers debugging the agent execution system (container and sandbox runtimes).
本指南涵盖Agent执行系统(容器与沙箱运行时)的调试方法。
Architecture Overview
架构概述
Host (macOS) Container (Linux VM)
─────────────────────────────────────────────────────────────
src/orchestrator/container-runner.ts agent/runner/
│ │
│ spawns container │ runs Claude Agent SDK
│ with volume mounts │ with MCP servers
│ │
├── data/env/env ──────────────> /workspace/env-dir/env
├── groups/{folder} ───────────> /workspace/group
├── data/ipc/{folder} ────────> /workspace/ipc
├── data/sessions/{folder}/.claude/ ──> /home/node/.claude/ (isolated per-group)
└── (main only) project root ──> /workspace/projectImportant: The container runs as user with . Session files must be mounted to (not ) for session resumption to work.
nodeHOME=/home/node/home/node/.claude//root/.claude/Host (macOS) Container (Linux VM)
─────────────────────────────────────────────────────────────
src/orchestrator/container-runner.ts agent/runner/
│ │
│ spawns container │ runs Claude Agent SDK
│ with volume mounts │ with MCP servers
│ │
├── data/env/env ──────────────> /workspace/env-dir/env
├── groups/{folder} ───────────> /workspace/group
├── data/ipc/{folder} ────────> /workspace/ipc
├── data/sessions/{folder}/.claude/ ──> /home/node/.claude/ (isolated per-group)
└── (main only) project root ──> /workspace/project重要提示: 容器以用户运行,。会话文件必须挂载到(而非)才能正常恢复会话。
nodeHOME=/home/node/home/node/.claude//root/.claude/Log Locations
日志位置
| Log | Location | Content |
|---|---|---|
| Main app logs | | Host-side WhatsApp, routing, container spawning |
| Main app errors | | Host-side errors |
| Container run logs | | Per-run: input, mounts, stderr, stdout |
| Claude sessions | | Claude Code session history |
| 日志类型 | 路径 | 内容 |
|---|---|---|
| 主应用日志 | | 主机端WhatsApp、路由、容器启动相关日志 |
| 主应用错误日志 | | 主机端错误信息 |
| 容器运行日志 | | 单次运行日志:输入、挂载、stderr、stdout |
| Claude会话日志 | | Claude Code会话历史 |
Enabling Debug Logging
启用调试日志
Set for verbose output:
LOG_LEVEL=debugbash
undefined设置以获取详细输出:
LOG_LEVEL=debugbash
undefinedFor development
开发环境
LOG_LEVEL=debug npm run dev
LOG_LEVEL=debug npm run dev
For launchd service (macOS), add to plist EnvironmentVariables:
macOS launchd服务,添加到plist的EnvironmentVariables:
<key>LOG_LEVEL</key>
<string>debug</string>
<key>LOG_LEVEL</key>
<string>debug</string>
For systemd service (Linux), add to unit [Service] section:
Linux systemd服务,添加到单元的[Service]部分:
Environment=LOG_LEVEL=debug
Environment=LOG_LEVEL=debug
Debug level shows:
- Full mount configurations
- Container command arguments
- Real-time container stderr
调试级别会显示:
- 完整挂载配置
- 容器命令参数
- 实时容器stderr输出Common Issues
常见问题
1. "Claude Code process exited with code 1"
1.「Claude Code进程退出,代码为1」
Check the container log file in
groups/{folder}/logs/container-*.logCommon causes:
检查容器日志文件:
groups/{folder}/logs/container-*.log常见原因:
Missing Authentication
认证信息缺失
Invalid API key · Please run /loginFix: Ensure file exists with either OAuth token or API key:
.envbash
cat .env # Should show one of:Invalid API key · Please run /login修复方案: 确保文件存在OAuth令牌或API密钥:
.envbash
cat .env # 应包含以下其中一项:CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-... (subscription)
CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-... (订阅版)
ANTHROPIC_API_KEY=sk-ant-api03-... (pay-per-use)
ANTHROPIC_API_KEY=sk-ant-api03-... (按量付费版)
undefinedundefinedRoot User Restriction
根用户限制
--dangerously-skip-permissions cannot be used with root/sudo privilegesFix: Container must run as non-root user. Check Dockerfile has .
USER node--dangerously-skip-permissions cannot be used with root/sudo privileges修复方案: 容器必须以非根用户运行。检查Dockerfile中是否包含指令。
USER node2. Environment Variables Not Passing
2. 环境变量未传递
Runtime note: Environment variables passed via may be lost when using (interactive/piped stdin).
-e-iWorkaround: The system extracts only authentication variables (, ) from and mounts them for sourcing inside the container. Other env vars are not exposed.
CLAUDE_CODE_OAUTH_TOKENANTHROPIC_API_KEY.envTo verify env vars are reaching the container:
bash
echo '{}' | docker run -i \
-v $(pwd)/data/env:/workspace/env-dir:ro \
--entrypoint /bin/bash claudeclaw-agent:latest \
-c 'export $(cat /workspace/env-dir/env | xargs); echo "OAuth: ${#CLAUDE_CODE_OAUTH_TOKEN} chars, API: ${#ANTHROPIC_API_KEY} chars"'运行时说明: 使用传递的环境变量在使用(交互式/管道标准输入)时可能丢失。
-e-i解决方法: 系统仅从中提取认证变量(、)并挂载到容器内部供读取。其他环境变量不会暴露。
.envCLAUDE_CODE_OAUTH_TOKENANTHROPIC_API_KEY验证环境变量是否到达容器:
bash
echo '{}' | docker run -i \
-v $(pwd)/data/env:/workspace/env-dir:ro \
--entrypoint /bin/bash claudeclaw-agent:latest \
-c 'export $(cat /workspace/env-dir/env | xargs); echo "OAuth: ${#CLAUDE_CODE_OAUTH_TOKEN} chars, API: ${#ANTHROPIC_API_KEY} chars"'3. Mount Issues
3. 挂载问题
Container mount notes:
- Docker supports both and
-vsyntax--mount - Use suffix for readonly mounts:
:robash# Readonly -v /path:/container/path:ro # Read-write -v /path:/container/path
To check what's mounted inside a container:
bash
docker run --rm --entrypoint /bin/bash claudeclaw-agent:latest -c 'ls -la /workspace/'Expected structure:
/workspace/
├── env-dir/env # Environment file (CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY)
├── group/ # Current group folder (cwd)
├── project/ # Project root (main channel only)
├── global/ # Global CLAUDE.md (non-main only)
├── ipc/ # Inter-process communication
│ ├── messages/ # Outgoing WhatsApp messages
│ ├── tasks/ # Scheduled task commands
│ ├── current_tasks.json # Read-only: scheduled tasks visible to this group
│ └── available_groups.json # Read-only: WhatsApp groups for activation (main only)
└── extra/ # Additional custom mounts容器挂载说明:
- Docker支持和
-v两种语法--mount - 使用后缀设置只读挂载:
:robash# 只读 -v /path:/container/path:ro # 读写 -v /path:/container/path
检查容器内部挂载情况:
bash
docker run --rm --entrypoint /bin/bash claudeclaw-agent:latest -c 'ls -la /workspace/'预期结构:
/workspace/
├── env-dir/env # 环境文件(CLAUDE_CODE_OAUTH_TOKEN或ANTHROPIC_API_KEY)
├── group/ # 当前分组目录(工作目录)
├── project/ # 项目根目录(仅主频道)
├── global/ # 全局CLAUDE.md(非主频道)
├── ipc/ # 进程间通信目录
│ ├── messages/ # 待发送WhatsApp消息
│ ├── tasks/ # 定时任务命令
│ ├── current_tasks.json # 只读:当前分组可见的定时任务
│ └── available_groups.json # 只读:可激活的WhatsApp分组(仅主频道)
└── extra/ # 额外自定义挂载4. Permission Issues
4. 权限问题
The container runs as user (uid 1000). Check ownership:
nodebash
docker run --rm --entrypoint /bin/bash claudeclaw-agent:latest -c '
whoami
ls -la /workspace/
ls -la /app/
'All of and should be owned by .
/workspace//app/node容器以用户(uid 1000)运行。检查文件所有权:
nodebash
docker run --rm --entrypoint /bin/bash claudeclaw-agent:latest -c '
whoami
ls -la /workspace/
ls -la /app/
'/workspace//app/node5. Session Not Resuming / "Claude Code process exited with code 1"
5. 会话无法恢复 /「Claude Code进程退出,代码为1」
If sessions aren't being resumed (new session ID every time), or Claude Code exits with code 1 when resuming:
Root cause: The SDK looks for sessions at . Inside the container, , so it looks at .
$HOME/.claude/projects/HOME=/home/node/home/node/.claude/projects/Check the mount path:
bash
undefined如果会话无法恢复(每次生成新会话ID),或恢复会话时Claude Code退出并返回代码1:
根本原因: SDK在路径下查找会话。容器内部,因此会查找。
$HOME/.claude/projects/HOME=/home/node/home/node/.claude/projects/检查挂载路径:
bash
undefinedIn container-runner.ts, verify mount is to /home/node/.claude/, NOT /root/.claude/
在container-runner.ts中,验证挂载路径为/home/node/.claude/,而非/root/.claude/
grep -A3 "Claude sessions" src/orchestrator/container-runner.ts
**Verify sessions are accessible:**
```bash
docker run --rm --entrypoint /bin/bash \
-v ~/.claude:/home/node/.claude \
claudeclaw-agent:latest -c '
echo "HOME=$HOME"
ls -la $HOME/.claude/projects/ 2>&1 | head -5
'Fix: Ensure mounts to :
container-runner.ts/home/node/.claude/typescript
mounts.push({
hostPath: claudeDir,
containerPath: '/home/node/.claude', // NOT /root/.claude
readonly: false
});grep -A3 "Claude sessions" src/orchestrator/container-runner.ts
**验证会话可访问性:**
```bash
docker run --rm --entrypoint /bin/bash \
-v ~/.claude:/home/node/.claude \
claudeclaw-agent:latest -c '
echo "HOME=$HOME"
ls -la $HOME/.claude/projects/ 2>&1 | head -5
'修复方案: 确保挂载到:
container-runner.ts/home/node/.claude/typescript
mounts.push({
hostPath: claudeDir,
containerPath: '/home/node/.claude', // 不要写成/root/.claude
readonly: false
});6. MCP Server Failures
6. MCP服务器启动失败
If an MCP server fails to start, the agent may exit. Check the container logs for MCP initialization errors.
如果MCP服务器启动失败,Agent可能会退出。检查容器日志中的MCP初始化错误信息。
Manual Container Testing
手动容器测试
Test the full agent flow:
测试完整Agent流程:
bash
undefinedbash
undefinedSet up env file
创建环境文件目录
mkdir -p data/env groups/test
cp .env data/env/env
mkdir -p data/env groups/test
cp .env data/env/env
Run test query
运行测试查询
echo '{"prompt":"What is 2+2?","groupFolder":"test","chatJid":"test@g.us","isMain":false}' |
docker run -i
-v $(pwd)/data/env:/workspace/env-dir:ro
-v $(pwd)/groups/test:/workspace/group
-v $(pwd)/data/ipc:/workspace/ipc
claudeclaw-agent:latest
docker run -i
-v $(pwd)/data/env:/workspace/env-dir:ro
-v $(pwd)/groups/test:/workspace/group
-v $(pwd)/data/ipc:/workspace/ipc
claudeclaw-agent:latest
undefinedecho '{"prompt":"What is 2+2?","groupFolder":"test","chatJid":"test@g.us","isMain":false}' |
docker run -i
-v $(pwd)/data/env:/workspace/env-dir:ro
-v $(pwd)/groups/test:/workspace/group
-v $(pwd)/data/ipc:/workspace/ipc
claudeclaw-agent:latest
docker run -i
-v $(pwd)/data/env:/workspace/env-dir:ro
-v $(pwd)/groups/test:/workspace/group
-v $(pwd)/data/ipc:/workspace/ipc
claudeclaw-agent:latest
undefinedTest Claude Code directly:
直接测试Claude Code:
bash
docker run --rm --entrypoint /bin/bash \
-v $(pwd)/data/env:/workspace/env-dir:ro \
claudeclaw-agent:latest -c '
export $(cat /workspace/env-dir/env | xargs)
claude -p "Say hello" --dangerously-skip-permissions --allowedTools ""
'bash
docker run --rm --entrypoint /bin/bash \
-v $(pwd)/data/env:/workspace/env-dir:ro \
claudeclaw-agent:latest -c '
export $(cat /workspace/env-dir/env | xargs)
claude -p "Say hello" --dangerously-skip-permissions --allowedTools ""
'Interactive shell in container:
进入容器交互式shell:
bash
docker run --rm -it --entrypoint /bin/bash claudeclaw-agent:latestbash
docker run --rm -it --entrypoint /bin/bash claudeclaw-agent:latestSDK Options Reference
SDK选项参考
The agent-runner uses these Claude Agent SDK options:
typescript
query({
prompt: input.prompt,
options: {
cwd: '/workspace/group',
allowedTools: ['Bash', 'Read', 'Write', ...],
permissionMode: 'bypassPermissions',
allowDangerouslySkipPermissions: true, // Required with bypassPermissions
settingSources: ['project'],
mcpServers: { ... }
}
})Important: is required when using . Without it, Claude Code exits with code 1.
allowDangerouslySkipPermissions: truepermissionMode: 'bypassPermissions'Agent-runner使用以下Claude Agent SDK选项:
typescript
query({
prompt: input.prompt,
options: {
cwd: '/workspace/group',
allowedTools: ['Bash', 'Read', 'Write', ...],
permissionMode: 'bypassPermissions',
allowDangerouslySkipPermissions: true, // 使用bypassPermissions时必须设置
settingSources: ['project'],
mcpServers: { ... }
}
})重要提示: 使用时必须设置。否则Claude Code会以代码1退出。
permissionMode: 'bypassPermissions'allowDangerouslySkipPermissions: trueRebuilding After Changes
修改后重新构建
bash
undefinedbash
undefinedRebuild main app
重新构建主应用
npm run build
npm run build
Rebuild container (use --no-cache for clean rebuild)
重新构建容器(使用--no-cache进行干净构建)
./src/runtimes/docker/build.sh
./src/runtimes/docker/build.sh
Or force full rebuild
或强制完全重新构建
docker builder prune -af
./src/runtimes/docker/build.sh
undefineddocker builder prune -af
./src/runtimes/docker/build.sh
undefinedChecking Container Image
检查容器镜像
bash
undefinedbash
undefinedList images
列出镜像
docker images
docker images
Check what's in the image
检查镜像内容
docker run --rm --entrypoint /bin/bash claudeclaw-agent:latest -c '
echo "=== Node version ==="
node --version
echo "=== Claude Code version ==="
claude --version
echo "=== Installed packages ==="
ls /app/node_modules/
'
undefineddocker run --rm --entrypoint /bin/bash claudeclaw-agent:latest -c '
echo "=== Node版本 ==="
node --version
echo "=== Claude Code版本 ==="
claude --version
echo "=== 已安装包 ==="
ls /app/node_modules/
'
undefinedSession Persistence
会话持久化
Claude sessions are stored per-group in for security isolation. Each group has its own session directory, preventing cross-group access to conversation history.
data/sessions/{group}/.claude/Critical: The mount path must match the container user's HOME directory:
- Container user:
node - Container HOME:
/home/node - Mount target: (NOT
/home/node/.claude/)/root/.claude/
To clear sessions:
bash
undefinedClaude会话按分组存储在中,实现安全隔离。每个分组拥有独立的会话目录,防止跨分组访问对话历史。
data/sessions/{group}/.claude/关键注意事项: 挂载路径必须与容器用户的HOME目录匹配:
- 容器用户:
node - 容器HOME:
/home/node - 挂载目标:(而非
/home/node/.claude/)/root/.claude/
清除会话:
bash
undefinedClear all sessions for all groups
清除所有分组的会话
rm -rf data/sessions/
rm -rf data/sessions/
Clear sessions for a specific group
清除特定分组的会话
rm -rf data/sessions/{groupFolder}/.claude/
rm -rf data/sessions/{groupFolder}/.claude/
Also clear the session ID from ClaudeClaw's tracking (stored in SQLite)
同时清除ClaudeClaw跟踪的会话ID(存储在SQLite中)
sqlite3 store/messages.db "DELETE FROM sessions WHERE group_folder = '{groupFolder}'"
To verify session resumption is working, check the logs for the same session ID across messages:
```bash
grep "Session initialized" logs/claudeclaw.log | tail -5sqlite3 store/messages.db "DELETE FROM sessions WHERE group_folder = '{groupFolder}'"
验证会话恢复功能是否正常,检查日志中同一分组的连续消息是否使用相同会话ID:
```bash
grep "Session initialized" logs/claudeclaw.log | tail -5Should show the SAME session ID for consecutive messages in the same group
同一分组的连续消息应显示相同的会话ID
undefinedundefinedIPC Debugging
IPC调试
The container communicates back to the host via files in :
/workspace/ipc/bash
undefined容器通过目录下的文件与主机通信:
/workspace/ipc/bash
undefinedCheck pending messages
检查待发送消息
ls -la data/ipc/messages/
ls -la data/ipc/messages/
Check pending task operations
检查待处理任务操作
ls -la data/ipc/tasks/
ls -la data/ipc/tasks/
Read a specific IPC file
读取特定IPC文件
cat data/ipc/messages/*.json
cat data/ipc/messages/*.json
Check available groups (main channel only)
检查可用分组(仅主频道)
cat data/ipc/main/available_groups.json
cat data/ipc/main/available_groups.json
Check current tasks snapshot
检查当前任务快照
cat data/ipc/{groupFolder}/current_tasks.json
**IPC file types:**
- `messages/*.json` - Agent writes: outgoing WhatsApp messages
- `tasks/*.json` - Agent writes: task operations (schedule, pause, resume, cancel, refresh_groups)
- `current_tasks.json` - Host writes: read-only snapshot of scheduled tasks
- `available_groups.json` - Host writes: read-only list of WhatsApp groups (main only)cat data/ipc/{groupFolder}/current_tasks.json
**IPC文件类型:**
- `messages/*.json` - Agent写入:待发送WhatsApp消息
- `tasks/*.json` - Agent写入:任务操作(调度、暂停、恢复、取消、刷新分组)
- `current_tasks.json` - 主机写入:只读定时任务快照
- `available_groups.json` - 主机写入:只读WhatsApp分组列表(仅主频道)Sandbox Runtime Debugging
沙箱运行时调试
If is set, agents run via instead of containers.
RUNTIME=sandbox@anthropic-ai/sandbox-runtime如果设置,Agent将通过而非容器运行。
RUNTIME=sandbox@anthropic-ai/sandbox-runtimeSandbox Architecture
沙箱架构
Host (macOS/Linux)
───────────────────────────────────────────
src/orchestrator/sandbox-runner.ts
│
│ spawns sandboxed process via srt CLI
│ with kernel-enforced filesystem/network
│
├── CLAUDECLAW_GROUP_DIR → groups/{folder}
├── CLAUDECLAW_IPC_DIR → data/ipc/{folder}
├── CLAUDECLAW_PROJECT_DIR → project root (read-only)
├── CLAUDECLAW_GLOBAL_DIR → groups/global (read-only)
└── CLAUDECLAW_EXTRA_DIR → additional mountsHost (macOS/Linux)
───────────────────────────────────────────
src/orchestrator/sandbox-runner.ts
│
│ spawns sandboxed process via srt CLI
│ with kernel-enforced filesystem/network
│
├── CLAUDECLAW_GROUP_DIR → groups/{folder}
├── CLAUDECLAW_IPC_DIR → data/ipc/{folder}
├── CLAUDECLAW_PROJECT_DIR → project root (read-only)
├── CLAUDECLAW_GLOBAL_DIR → groups/global (read-only)
└── CLAUDECLAW_EXTRA_DIR → additional mountsSandbox-Specific Issues
沙箱特定问题
EPERM on all operations: The srt settings JSON file requires ALL fields including empty arrays (). Omit any field and the entire settings file silently fails validation — zero error messages.
allowRead: []Agent runner won't start (tsx/EPERM): Sandbox blocks Unix sockets needed by . Fix: pre-compile with , run with plain .
tsxcd agent/runner && npx tscnodeAgent can't find paths: Check that env vars are set in . The agent runner falls back to if env vars are missing.
CLAUDECLAW_*_DIRsandbox-runner.ts/workspace/*Stale sessions after runtime switch: Switching a group between container and sandbox leaves stale session IDs. Fix:
sqlite3 store/messages.db "DELETE FROM sessions"Network blocked: Verify in the generated settings file includes . Check for the last generated settings file.
allowedDomainsapi.anthropic.comdata/sandbox-settings/Credential issues: Sandbox passes real credentials via env vars (not through the credential proxy). Ensure or is in .
ANTHROPIC_API_KEYCLAUDE_CODE_OAUTH_TOKEN.env所有操作均返回EPERM: srt设置JSON文件需要包含所有字段,包括空数组(如)。省略任何字段会导致整个设置文件静默验证失败,且无错误提示。
allowRead: []Agent runner无法启动(tsx/EPERM): 沙箱阻止了所需的Unix套接字。修复方案:预编译代码(),使用普通运行。
tsxcd agent/runner && npx tscnodeAgent无法找到路径: 检查中是否设置了环境变量。如果缺少这些变量,Agent runner会回退到路径。
sandbox-runner.tsCLAUDECLAW_*_DIR/workspace/*切换运行时后会话失效: 在容器与沙箱之间切换分组会留下失效的会话ID。修复方案:
sqlite3 store/messages.db "DELETE FROM sessions"网络被阻止: 验证生成的设置文件中包含。检查目录下最新生成的设置文件。
allowedDomainsapi.anthropic.comdata/sandbox-settings/凭证问题: 沙箱通过环境变量传递真实凭证(而非通过凭证代理)。确保文件中包含或。
.envANTHROPIC_API_KEYCLAUDE_CODE_OAUTH_TOKENQuick Diagnostic Script
快速诊断脚本
Run this to check common issues:
bash
echo "=== Checking ClaudeClaw Agent Setup ==="
echo -e "\n1. Authentication configured?"
[ -f .env ] && (grep -q "CLAUDE_CODE_OAUTH_TOKEN=sk-" .env || grep -q "ANTHROPIC_API_KEY=sk-" .env) && echo "OK" || echo "MISSING - add CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY to .env"
echo -e "\n2. Env file copied for container?"
[ -f data/env/env ] && echo "OK" || echo "MISSING - will be created on first run"
echo -e "\n3. Container runtime running?"
docker info &>/dev/null && echo "OK" || echo "NOT RUNNING - start Docker Desktop (macOS) or sudo systemctl start docker (Linux)"
echo -e "\n4. Container image exists?"
echo '{}' | docker run -i --entrypoint /bin/echo claudeclaw-agent:latest "OK" 2>/dev/null || echo "MISSING - run ./src/runtimes/docker/build.sh"
echo -e "\n5. Session mount path correct?"
grep -q "/home/node/.claude" src/orchestrator/container-runner.ts 2>/dev/null && echo "OK" || echo "WRONG - should mount to /home/node/.claude/, not /root/.claude/"
echo -e "\n6. Groups directory?"
ls -la groups/ 2>/dev/null || echo "MISSING - run setup"
echo -e "\n7. Recent container logs?"
ls -t groups/*/logs/container-*.log 2>/dev/null | head -3 || echo "No container logs yet"
echo -e "\n8. Session continuity working?"
SESSIONS=$(grep "Session initialized" logs/claudeclaw.log 2>/dev/null | tail -5 | awk '{print $NF}' | sort -u | wc -l)
[ "$SESSIONS" -le 2 ] && echo "OK (recent sessions reusing IDs)" || echo "CHECK - multiple different session IDs, may indicate resumption issues"运行以下脚本检查常见问题:
bash
echo "=== 检查ClaudeClaw Agent配置 ==="
echo -e "\n1. 认证已配置?"
[ -f .env ] && (grep -q "CLAUDE_CODE_OAUTH_TOKEN=sk-" .env || grep -q "ANTHROPIC_API_KEY=sk-" .env) && echo "正常" || echo "缺失 - 请在.env中添加CLAUDE_CODE_OAUTH_TOKEN或ANTHROPIC_API_KEY"
echo -e "\n2. 环境文件已复制到容器目录?"
[ -f data/env/env ] && echo "正常" || echo "缺失 - 首次运行时会自动创建"
echo -e "\n3. 容器运行时已启动?"
docker info &>/dev/null && echo "正常" || echo "未运行 - 启动Docker Desktop(macOS)或执行sudo systemctl start docker(Linux)"
echo -e "\n4. 容器镜像存在?"
echo '{}' | docker run -i --entrypoint /bin/echo claudeclaw-agent:latest "正常" 2>/dev/null || echo "缺失 - 运行./src/runtimes/docker/build.sh"
echo -e "\n5. 会话挂载路径正确?"
grep -q "/home/node/.claude" src/orchestrator/container-runner.ts 2>/dev/null && echo "正常" || echo "错误 - 应挂载到/home/node/.claude/,而非/root/.claude/"
echo -e "\n6. 分组目录存在?"
ls -la groups/ 2>/dev/null || echo "缺失 - 执行初始化设置"
echo -e "\n7. 最近的容器日志?"
ls -t groups/*/logs/container-*.log 2>/dev/null | head -3 || echo "暂无容器日志"
echo -e "\n8. 会话连续性正常?"
SESSIONS=$(grep "Session initialized" logs/claudeclaw.log 2>/dev/null | tail -5 | awk '{print $NF}' | sort -u | wc -l)
[ "$SESSIONS" -le 2 ] && echo "正常(最近会话复用ID)" || echo "需检查 - 存在多个不同会话ID,可能表示恢复功能异常"