跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

提交记录
新增.gitignore+1 −0看文件
@@ -0,0 +1 @@
1新增:.DS_Store
新增LICENSE+21 −0看文件
@@ -0,0 +1,21 @@
1新增:MIT License
2新增:
3新增:Copyright (c) 2026 Sylvain Zimmer
4新增:
5新增:Permission is hereby granted, free of charge, to any person obtaining a copy
6新增:of this software and associated documentation files (the "Software"), to deal
7新增:in the Software without restriction, including without limitation the rights
8新增:to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9新增:copies of the Software, and to permit persons to whom the Software is
10新增:furnished to do so, subject to the following conditions:
11新增:
12新增:The above copyright notice and this permission notice shall be included in all
13新增:copies or substantial portions of the Software.
14新增:
15新增:THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16新增:IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17新增:FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18新增:AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19新增:LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20新增:OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21新增:SOFTWARE.
新增README.md+99 −0看文件
@@ -0,0 +1,99 @@
1新增:# agent-vm
2新增:
3新增:Run AI coding agents inside sandboxed Linux VMs. The agent gets full autonomy while your host system stays safe.
4新增:
5新增:Uses [Lima](https://lima-vm.io/) to create lightweight Debian VMs on macOS and Linux. Ships with dev tools, Docker, and a headless Chrome browser with [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp) pre-configured.
6新增:
7新增:Currently supports [Claude Code](https://claude.ai/code). Other agents (Codex, etc.) can be added in the future.
8新增:
9新增:Feedbacks welcome!
10新增:
11新增:## Prerequisites
12新增:
13新增:- macOS or Linux
14新增:- [Lima](https://lima-vm.io/docs/installation/) (installed automatically via Homebrew if available)
15新增:- A [Claude subscription](https://claude.ai/) (Pro, Max, or Team)
16新增:
17新增:## Install
18新增:
19新增:```bash
20新增:git clone https://github.com/sylvinus/agent-vm.git
21新增:cd agent-vm
22新增:
23新增:# Add to your shell config
24新增:echo "source $(pwd)/claude-vm.sh" >> ~/.zshrc # zsh
25新增:echo "source $(pwd)/claude-vm.sh" >> ~/.bashrc # or bash
26新增:```
27新增:
28新增:## Usage
29新增:
30新增:### One-time setup
31新增:
32新增:```bash
33新增:claude-vm-setup
34新增:```
35新增:
36新增:Creates a VM template with dev tools, Docker, Chromium, and Claude Code pre-installed. You'll be prompted to authenticate Claude during setup.
37新增:
38新增:### Run Claude in a VM
39新增:
40新增:```bash
41新增:cd your-project
42新增:claude-vm
43新增:```
44新增:
45新增:Clones the template into a fresh VM, mounts your current directory, and runs `claude --dangerously-skip-permissions`. The VM is deleted when Claude exits.
46新增:
47新增:### Debug shell
48新增:
49新增:```bash
50新增:claude-vm-shell
51新增:```
52新增:
53新增:Same as `claude-vm` but drops you into a bash shell instead.
54新增:
55新增:## Customization
56新增:
57新增:### Per-user: `~/.claude-vm.setup.sh`
58新增:
59新增:Create this file in your home directory to install extra tools into the VM template. It runs once during `claude-vm-setup`, as the default VM user (with sudo available):
60新增:
61新增:```bash
62新增:# ~/.claude-vm.setup.sh
63新增:sudo apt-get install -y postgresql-client
64新增:pip install pandas numpy
65新增:```
66新增:
67新增:### Per-project: `.claude-vm.runtime.sh`
68新增:
69新增:Create this file at the root of any project. It runs inside the cloned VM each time you call `claude-vm`, just before Claude starts. Use it for project-specific setup like installing dependencies or starting services:
70新增:
71新增:```bash
72新增:# your-project/.claude-vm.runtime.sh
73新增:npm install
74新增:docker compose up -d
75新增:```
76新增:
77新增:## How it works
78新增:
79新增:1. **`claude-vm-setup`** creates a Debian 13 VM with Lima, installs dev tools + Chrome + Claude Code, and stops it as a reusable template
80新增:2. **`claude-vm`** clones the template, mounts your working directory read-write, runs optional `.claude-vm.runtime.sh`, then launches Claude with full permissions
81新增:3. On exit, the cloned VM is stopped and deleted. The template persists for reuse
82新增:
83新增:Ports opened inside the VM (e.g. by Docker containers) are automatically forwarded to your host by Lima.
84新增:
85新增:## What's in the VM
86新增:
87新增:| Category | Packages |
88新增:|----------|----------|
89新增:| Core | git, curl, wget, build-essential, jq |
90新增:| Python | python3, pip, venv |
91新增:| Node.js | Node.js 22 (via NodeSource) |
92新增:| Search | ripgrep, fd-find |
93新增:| Browser | Chromium (headless), xvfb |
94新增:| Containers | docker |
95新增:| AI | Claude Code, Chrome DevTools MCP server |
96新增:
97新增:## License
98新增:
99新增:MIT
新增claude-vm.sh+181 −0看文件
@@ -0,0 +1,181 @@
1新增:#!/usr/bin/env bash
2新增:#
3新增:# agent-vm / claude-vm: Run Claude Code inside a sandboxed Lima VM
4新增:# Part of https://github.com/sylvinus/agent-vm
5新增:#
6新增:# Source this file in your shell config:
7新增:# source /path/to/agent-vm/claude-vm.sh
8新增:#
9新增:# Functions:
10新增:# claude-vm-setup - Create the VM template (run once)
11新增:# claude-vm - Run Claude in a fresh VM with cwd mounted
12新增:# claude-vm-shell - Open a debug shell in a fresh VM
13新增:
14新增:CLAUDE_VM_TEMPLATE="claude-template"
15新增:
16新增:claude-vm-setup() {
17新增: if ! command -v limactl &>/dev/null; then
18新增: if command -v brew &>/dev/null; then
19新增: echo "Installing Lima..."
20新增: brew install lima
21新增: else
22新增: echo "Error: Lima is required. Install from https://lima-vm.io/docs/installation/" >&2
23新增: return 1
24新增: fi
25新增: fi
26新增:
27新增: limactl stop "$CLAUDE_VM_TEMPLATE" &>/dev/null
28新增: limactl delete "$CLAUDE_VM_TEMPLATE" --force &>/dev/null
29新增:
30新增: echo "Creating VM template..."
31新增: limactl create --name="$CLAUDE_VM_TEMPLATE" template:debian-13 \
32新增: --set '.mounts=[]' \
33新增: --disk=20 \
34新增: --memory=8 \
35新增: --tty=false
36新增: limactl start "$CLAUDE_VM_TEMPLATE"
37新增:
38新增: # Disable needrestart's interactive prompts
39新增: limactl shell "$CLAUDE_VM_TEMPLATE" sudo bash -c 'mkdir -p /etc/needrestart/conf.d && echo "\$nrconf{restart} = '"'"'a'"'"';" > /etc/needrestart/conf.d/no-prompt.conf'
40新增:
41新增: echo "Installing base packages..."
42新增: limactl shell "$CLAUDE_VM_TEMPLATE" sudo DEBIAN_FRONTEND=noninteractive apt-get update
43新增: limactl shell "$CLAUDE_VM_TEMPLATE" sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
44新增: git curl wget build-essential \
45新增: python3 python3-pip python3-venv \
46新增: jq ripgrep fd-find htop \
47新增: unzip zip \
48新增: docker.io
49新增:
50新增: # Add user to docker group
51新增: limactl shell "$CLAUDE_VM_TEMPLATE" bash -c 'sudo usermod -aG docker $(whoami)'
52新增:
53新增: # Install Node.js 22 (needed for MCP servers)
54新增: echo "Installing Node.js 22..."
55新增: limactl shell "$CLAUDE_VM_TEMPLATE" bash -c "curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -"
56新增: limactl shell "$CLAUDE_VM_TEMPLATE" sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
57新增:
58新增: # Install Chromium and dependencies for headless browsing
59新增: echo "Installing Chromium..."
60新增: limactl shell "$CLAUDE_VM_TEMPLATE" sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
61新增: chromium \
62新增: fonts-liberation \
63新增: xvfb
64新增: # Symlink so tools looking for google-chrome find Chromium
65新增: limactl shell "$CLAUDE_VM_TEMPLATE" sudo ln -sf /usr/bin/chromium /usr/bin/google-chrome
66新增: limactl shell "$CLAUDE_VM_TEMPLATE" sudo ln -sf /usr/bin/chromium /usr/bin/google-chrome-stable
67新增: limactl shell "$CLAUDE_VM_TEMPLATE" bash -c 'sudo mkdir -p /opt/google/chrome && sudo ln -sf /usr/bin/chromium /opt/google/chrome/chrome'
68新增:
69新增: # Install Claude Code
70新增: echo "Installing Claude Code..."
71新增: limactl shell "$CLAUDE_VM_TEMPLATE" bash -c "curl -fsSL https://claude.ai/install.sh | bash"
72新增: limactl shell "$CLAUDE_VM_TEMPLATE" bash -c 'echo "export PATH=\$HOME/.local/bin:\$HOME/.claude/local/bin:\$PATH" >> ~/.bashrc'
73新增:
74新增: # Authenticate Claude (saves token in template, inherited by clones)
75新增: echo "Setting up Claude authentication..."
76新增: limactl shell "$CLAUDE_VM_TEMPLATE" bash -lc "claude setup-token"
77新增:
78新增: # Configure Chrome DevTools MCP server for Claude
79新增: echo "Configuring Chrome MCP server..."
80新增: limactl shell "$CLAUDE_VM_TEMPLATE" bash << 'VMEOF'
81新增:CONFIG="$HOME/.claude.json"
82新增:if [ -f "$CONFIG" ]; then
83新增: jq '.mcpServers["chrome-devtools"] = {
84新增: "command": "npx",
85新增: "args": ["-y", "chrome-devtools-mcp@latest", "--headless=true", "--isolated=true"]
86新增: }' "$CONFIG" > "$CONFIG.tmp" && mv "$CONFIG.tmp" "$CONFIG"
87新增:else
88新增: cat > "$CONFIG" << 'JSON'
89新增:{
90新增: "mcpServers": {
91新增: "chrome-devtools": {
92新增: "command": "npx",
93新增: "args": ["-y", "chrome-devtools-mcp@latest", "--headless=true", "--isolated=true"]
94新增: }
95新增: }
96新增:}
97新增:JSON
98新增:fi
99新增:VMEOF
100新增:
101新增: # Run user's custom setup script if it exists
102新增: local user_setup="$HOME/.claude-vm.setup.sh"
103新增: if [ -f "$user_setup" ]; then
104新增: echo "Running custom setup from $user_setup..."
105新增: limactl shell "$CLAUDE_VM_TEMPLATE" bash < "$user_setup"
106新增: fi
107新增:
108新增: limactl stop "$CLAUDE_VM_TEMPLATE"
109新增:
110新增: echo "Template ready. Run 'claude-vm' in any project directory."
111新增:}
112新增:
113新增:claude-vm() {
114新增: local vm_name="claude-$(basename "$(pwd)" | tr -cs 'a-zA-Z0-9-' '-')-$$"
115新增: local host_dir="$(pwd)"
116新增:
117新增: if ! limactl list -q 2>/dev/null | grep -q "^${CLAUDE_VM_TEMPLATE}$"; then
118新增: echo "Error: Template VM not found. Run 'claude-vm-setup' first." >&2
119新增: return 1
120新增: fi
121新增:
122新增: _claude_vm_cleanup() {
123新增: echo "Cleaning up VM..."
124新增: limactl stop "$vm_name" &>/dev/null
125新增: limactl delete "$vm_name" --force &>/dev/null
126新增: }
127新增: trap _claude_vm_cleanup EXIT INT TERM
128新增:
129新增: echo "Starting VM '$vm_name'..."
130新增: limactl clone "$CLAUDE_VM_TEMPLATE" "$vm_name" \
131新增: --set ".mounts=[{\"location\":\"${host_dir}\",\"writable\":true}]" \
132新增: --tty=false &>/dev/null
133新增:
134新增: limactl start "$vm_name" &>/dev/null
135新增:
136新增: # Run project-specific runtime script if it exists
137新增: if [ -f "${host_dir}/.claude-vm.runtime.sh" ]; then
138新增: echo "Running project runtime setup..."
139新增: limactl shell --workdir "$host_dir" "$vm_name" bash -l < "${host_dir}/.claude-vm.runtime.sh"
140新增: fi
141新增:
142新增: limactl shell --workdir "$host_dir" "$vm_name" claude --dangerously-skip-permissions
143新增:
144新增: _claude_vm_cleanup
145新增: trap - EXIT INT TERM
146新增:}
147新增:
148新增:claude-vm-shell() {
149新增: local vm_name="claude-debug-$$"
150新增: local host_dir="$(pwd)"
151新增:
152新增: if ! limactl list -q 2>/dev/null | grep -q "^${CLAUDE_VM_TEMPLATE}$"; then
153新增: echo "Error: Template VM not found. Run 'claude-vm-setup' first." >&2
154新增: return 1
155新增: fi
156新增:
157新增: _claude_vm_shell_cleanup() {
158新增: echo "Cleaning up VM..."
159新增: limactl stop "$vm_name" &>/dev/null
160新增: limactl delete "$vm_name" --force &>/dev/null
161新增: }
162新增: trap _claude_vm_shell_cleanup EXIT INT TERM
163新增:
164新增: limactl clone "$CLAUDE_VM_TEMPLATE" "$vm_name" \
165新增: --set ".mounts=[{\"location\":\"${host_dir}\",\"writable\":true}]" \
166新增: --tty=false &>/dev/null
167新增:
168新增: limactl start "$vm_name" &>/dev/null
169新增:
170新增: # Run project-specific runtime script if it exists
171新增: if [ -f "${host_dir}/.claude-vm.runtime.sh" ]; then
172新增: limactl shell --workdir "$host_dir" "$vm_name" bash -l < "${host_dir}/.claude-vm.runtime.sh"
173新增: fi
174新增:
175新增: echo "VM: $vm_name | Dir: $host_dir"
176新增: echo "Type 'exit' to stop and delete the VM"
177新增: limactl shell --workdir "$host_dir" "$vm_name" bash -l
178新增:
179新增: _claude_vm_shell_cleanup
180新增: trap - EXIT INT TERM
181新增:}