跳到主要内容

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

提交记录
修改README.md+9 −2看文件
@@ -89,10 +89,17 @@ Each directory gets its own persistent VM. You can manage it with:
8989```bash
9090agent-vm status # Show status of all VMs (current dir marked with >)
9191agent-vm stop # Stop the VM (can be restarted later)
92删除:agent-vm destroy # Stop and permanently delete the VM
92新增:agent-vm rm # Stop and permanently delete the VM
9393agent-vm destroy-all # Stop and delete all agent-vm VMs
9494```
9595
96新增:To automatically destroy a VM after the agent exits (like `docker run --rm`):
97新增:
98新增:```bash
99新增:agent-vm --rm claude # Run Claude, then destroy the VM
100新增:agent-vm --rm run npm test # Run tests, then destroy the VM
101新增:```
102新增:
96103To resize an existing VM's disk or memory, just pass `--disk` or `--memory` again — the VM will be stopped, reconfigured, and restarted automatically:
97104
98105```bash
@@ -177,7 +184,7 @@ To add more MCP servers, add them to `~/.claude.json` in your `~/.agent-vm/setup
1771841. **`agent-vm setup`** creates a Debian 13 VM with Lima, runs `agent-vm.setup.sh` inside it to install dev tools + Chrome + agents, and stops it as a reusable base template
1781852. **`agent-vm claude|opencode|codex [args]`** clones the base template into a persistent per-directory VM, mounts your working directory, runs optional runtime scripts (`~/.agent-vm/runtime.sh` then `.agent-vm.runtime.sh`), then launches the agent with full permissions
1791863. The VM persists after exit. Running any agent command or `agent-vm shell` in the same directory reuses the same VM
180删除:4. Use `agent-vm stop` to stop the VM or `agent-vm destroy` to delete it
187新增:4. Use `agent-vm stop` to stop the VM or `agent-vm rm` to delete it. Use `--rm` to auto-delete after the command exits
181188
182189Each VM is fully isolated — agents must authenticate independently inside their VM (e.g. `claude login`). Credentials persist within the VM across restarts but are not shared between VMs or with the host.
183190
修改agent-vm.sh+42 −4看文件
@@ -13,7 +13,7 @@
1313# agent-vm codex - Run Codex CLI in a persistent VM for cwd
1414# agent-vm shell - Open a shell in the persistent VM for cwd
1515# agent-vm stop - Stop the VM for cwd
16删除:# agent-vm destroy - Stop and delete the VM for cwd
16新增:# agent-vm rm - Stop and delete the VM for cwd
1717# agent-vm list - List all agent-vm VMs
1818# agent-vm status - Show status of all VMs (current dir marked with >)
1919# agent-vm help - Show help
@@ -198,6 +198,8 @@ agent-vm() {
198198 vm_opts+=(--offline); shift ;;
199199 --readonly)
200200 vm_opts+=(--readonly); shift ;;
201新增: --rm)
202新增: vm_opts+=(--rm); shift ;;
201203 *)
202204 break ;;
203205 esac
@@ -228,7 +230,7 @@ agent-vm() {
228230 stop)
229231 _agent_vm_stop "$@"
230232 ;;
231删除: destroy)
233新增: rm|destroy)
232234 _agent_vm_destroy "$@"
233235 ;;
234236 destroy-all)
@@ -263,7 +265,7 @@ Commands:
263265 shell Open a shell in the VM for the current directory
264266 run <cmd> [args] Run a command in the VM for the current directory
265267 stop Stop the VM for the current directory
266删除: destroy Stop and delete the VM for the current directory
268新增: rm Stop and delete the VM for the current directory
267269 destroy-all Stop and delete all agent-vm VMs
268270 list List all agent-vm VMs
269271 status Show status of all VMs (current dir marked with >)
@@ -276,6 +278,7 @@ VM options (for claude, opencode, codex, shell, run):
276278 --reset Destroy and re-clone the VM from the base template
277279 --offline Block outbound internet (keeps host/VM communication)
278280 --readonly Mount the project directory as read-only
281新增: --rm Automatically destroy the VM after the command exits
279282
280283Examples:
281284 agent-vm setup # Create base VM
@@ -284,6 +287,7 @@ Examples:
284287 agent-vm codex # Run Codex in a VM
285288 agent-vm --disk 50 --memory 16 --cpus 8 claude # Custom resources
286289 agent-vm --reset claude # Fresh VM from base template
290新增: agent-vm --rm claude # Destroy VM after Claude exits
287291 agent-vm --offline claude # No internet access
288292 agent-vm --readonly shell # Read-only project mount
289293 agent-vm shell # Shell into the VM
@@ -405,6 +409,7 @@ _agent_vm_setup() {
405409_agent_vm_claude() {
406410 local vm_opts=()
407411 local args=()
412新增: local rm=""
408413 while [[ $# -gt 0 ]]; do
409414 case "$1" in
410415 --disk) vm_opts+=(--disk "$2"); shift 2 ;;
@@ -413,6 +418,7 @@ _agent_vm_claude() {
413418 --reset) vm_opts+=(--reset); shift ;;
414419 --offline) vm_opts+=(--offline); shift ;;
415420 --readonly) vm_opts+=(--readonly); shift ;;
421新增: --rm) rm=1; shift ;;
416422 *) args+=("$1"); shift ;;
417423 esac
418424 done
@@ -424,12 +430,17 @@ _agent_vm_claude() {
424430 _agent_vm_ensure_running "$vm_name" "$host_dir" "${vm_opts[@]}" || return 1
425431 _agent_vm_print_resources "$vm_name"
426432
433新增: local exit_code=0
427434 limactl shell --workdir "$host_dir" "$vm_name" claude --dangerously-skip-permissions "${args[@]}"
435新增: exit_code=$?
436新增: [[ -n "$rm" ]] && { echo "Removing VM..."; _agent_vm_destroy; }
437新增: return $exit_code
428438}
429439
430440_agent_vm_opencode() {
431441 local vm_opts=()
432442 local args=()
443新增: local rm=""
433444 while [[ $# -gt 0 ]]; do
434445 case "$1" in
435446 --disk) vm_opts+=(--disk "$2"); shift 2 ;;
@@ -438,6 +449,7 @@ _agent_vm_opencode() {
438449 --reset) vm_opts+=(--reset); shift ;;
439450 --offline) vm_opts+=(--offline); shift ;;
440451 --readonly) vm_opts+=(--readonly); shift ;;
452新增: --rm) rm=1; shift ;;
441453 *) args+=("$1"); shift ;;
442454 esac
443455 done
@@ -451,12 +463,17 @@ _agent_vm_opencode() {
451463
452464 # TODO: add --dangerously-skip-permissions once released
453465 # (waiting on https://github.com/anomalyco/opencode/pull/11833)
466新增: local exit_code=0
454467 limactl shell --tty --workdir "$host_dir" "$vm_name" opencode "${args[@]}"
468新增: exit_code=$?
469新增: [[ -n "$rm" ]] && { echo "Removing VM..."; _agent_vm_destroy; }
470新增: return $exit_code
455471}
456472
457473_agent_vm_codex() {
458474 local vm_opts=()
459475 local args=()
476新增: local rm=""
460477 while [[ $# -gt 0 ]]; do
461478 case "$1" in
462479 --disk) vm_opts+=(--disk "$2"); shift 2 ;;
@@ -465,6 +482,7 @@ _agent_vm_codex() {
465482 --reset) vm_opts+=(--reset); shift ;;
466483 --offline) vm_opts+=(--offline); shift ;;
467484 --readonly) vm_opts+=(--readonly); shift ;;
485新增: --rm) rm=1; shift ;;
468486 *) args+=("$1"); shift ;;
469487 esac
470488 done
@@ -476,11 +494,16 @@ _agent_vm_codex() {
476494 _agent_vm_ensure_running "$vm_name" "$host_dir" "${vm_opts[@]}" || return 1
477495 _agent_vm_print_resources "$vm_name"
478496
497新增: local exit_code=0
479498 limactl shell --workdir "$host_dir" "$vm_name" codex --full-auto "${args[@]}"
499新增: exit_code=$?
500新增: [[ -n "$rm" ]] && { echo "Removing VM..."; _agent_vm_destroy; }
501新增: return $exit_code
480502}
481503
482504_agent_vm_shell() {
483505 local vm_opts=()
506新增: local rm=""
484507 while [[ $# -gt 0 ]]; do
485508 case "$1" in
486509 --disk) vm_opts+=(--disk "$2"); shift 2 ;;
@@ -489,6 +512,7 @@ _agent_vm_shell() {
489512 --reset) vm_opts+=(--reset); shift ;;
490513 --offline) vm_opts+=(--offline); shift ;;
491514 --readonly) vm_opts+=(--readonly); shift ;;
515新增: --rm) rm=1; shift ;;
492516 *) shift ;;
493517 esac
494518 done
@@ -501,13 +525,22 @@ _agent_vm_shell() {
501525 _agent_vm_print_resources "$vm_name"
502526
503527 echo "VM: $vm_name | Dir: $host_dir"
504删除: echo "Type 'exit' to leave (VM keeps running). Use 'agent-vm stop' to stop it."
528新增: if [[ -n "$rm" ]]; then
529新增: echo "Type 'exit' to leave. VM will be destroyed after exit."
530新增: else
531新增: echo "Type 'exit' to leave (VM keeps running). Use 'agent-vm stop' to stop it."
532新增: fi
533新增: local exit_code=0
505534 limactl shell --workdir "$host_dir" "$vm_name" zsh -l
535新增: exit_code=$?
536新增: [[ -n "$rm" ]] && { echo "Removing VM..."; _agent_vm_destroy; }
537新增: return $exit_code
506538}
507539
508540_agent_vm_run() {
509541 local vm_opts=()
510542 local args=()
543新增: local rm=""
511544 while [[ $# -gt 0 ]]; do
512545 case "$1" in
513546 --disk) vm_opts+=(--disk "$2"); shift 2 ;;
@@ -516,6 +549,7 @@ _agent_vm_run() {
516549 --reset) vm_opts+=(--reset); shift ;;
517550 --offline) vm_opts+=(--offline); shift ;;
518551 --readonly) vm_opts+=(--readonly); shift ;;
552新增: --rm) rm=1; shift ;;
519553 *) args+=("$1"); shift ;;
520554 esac
521555 done
@@ -531,7 +565,11 @@ _agent_vm_run() {
531565 _agent_vm_ensure_running "$vm_name" "$host_dir" "${vm_opts[@]}" || return 1
532566 _agent_vm_print_resources "$vm_name"
533567
568新增: local exit_code=0
534569 limactl shell --workdir "$host_dir" "$vm_name" "${args[@]}"
570新增: exit_code=$?
571新增: [[ -n "$rm" ]] && { echo "Removing VM..."; _agent_vm_destroy; }
572新增: return $exit_code
535573}
536574
537575_agent_vm_stop() {