跳到主要内容

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

提交记录
修改agent-vm.sh+27 −6看文件
@@ -43,6 +43,20 @@ _agent_vm_running() {
4343 limactl list --format '{{.Name}} {{.Status}}' 2>/dev/null | grep -q "^${1} Running$"
4444}
4545
46新增:# Print VM resource details (CPUs, memory, disk)
47新增:_agent_vm_print_resources() {
48新增: local vm_name="$1"
49新增: local info
50新增: info=$(limactl list --format '{{.Name}}|{{.CPUs}}|{{.Memory}}|{{.Disk}}' 2>/dev/null | grep "^${vm_name}|" | head -1)
51新增: if [[ -n "$info" ]]; then
52新增: local cpus mem_bytes disk_bytes
53新增: IFS='|' read -r _ cpus mem_bytes disk_bytes <<< "$info"
54新增: local mem_gib=$((mem_bytes / 1073741824))
55新增: local disk_gib=$((disk_bytes / 1073741824))
56新增: echo " Resources: CPUs: ${cpus}, Memory: ${mem_gib} GiB, Disk: ${disk_gib} GiB"
57新增: fi
58新增:}
59新增:
4660# Ensure the VM for cwd exists and is running, creating/starting as needed
4761# Usage: _agent_vm_ensure_running <vm_name> <host_dir> [--disk GB] [--memory GB] [--reset]
4862_agent_vm_ensure_running() {
@@ -85,6 +99,7 @@ _agent_vm_ensure_running() {
8599 [[ -n "$memory" ]] && clone_args+=(--set ".memory=\"${memory}GiB\"")
86100 [[ -n "$cpus" ]] && clone_args+=(--set ".cpus=${cpus}")
87101 limactl clone "$AGENT_VM_TEMPLATE" "$vm_name" "${clone_args[@]}" &>/dev/null
102新增: _agent_vm_print_resources "$vm_name"
88103 # Record which base version this VM was cloned from
89104 local base_ver="$AGENT_VM_STATE_DIR/.agent-vm-base-version"
90105 if [[ -f "$base_ver" ]]; then
@@ -116,6 +131,7 @@ _agent_vm_ensure_running() {
116131 echo "$edit_output" >&2
117132 return 1
118133 fi
134新增: _agent_vm_print_resources "$vm_name"
119135 fi
120136
121137 # Warn if this VM was cloned from an older base
@@ -254,9 +270,9 @@ Commands:
254270 help Show this help
255271
256272VM options (for claude, opencode, codex, shell, run):
257删除: --disk GB VM disk size (default: 20)
258删除: --memory GB VM memory (default: 8)
259删除: --cpus N Number of CPUs (default: 4)
273新增: --disk GB VM disk size (default: 4)
274新增: --memory GB VM memory (default: 1)
275新增: --cpus N Number of CPUs (default: 1)
260276 --reset Destroy and re-clone the VM from the base template
261277 --offline Block outbound internet (keeps host/VM communication)
262278 --readonly Mount the project directory as read-only
@@ -287,9 +303,9 @@ EOF
287303}
288304
289305_agent_vm_setup() {
290删除: local disk=20
291删除: local memory=8
292删除: local cpus=""
306新增: local disk=4
307新增: local memory=1
308新增: local cpus=1
293309
294310 while [[ $# -gt 0 ]]; do
295311 case "$1" in
@@ -406,6 +422,7 @@ _agent_vm_claude() {
406422 vm_name="$(_agent_vm_name "$host_dir")"
407423
408424 _agent_vm_ensure_running "$vm_name" "$host_dir" "${vm_opts[@]}" || return 1
425新增: _agent_vm_print_resources "$vm_name"
409426
410427 limactl shell --workdir "$host_dir" "$vm_name" claude --dangerously-skip-permissions "${args[@]}"
411428}
@@ -430,6 +447,7 @@ _agent_vm_opencode() {
430447 vm_name="$(_agent_vm_name "$host_dir")"
431448
432449 _agent_vm_ensure_running "$vm_name" "$host_dir" "${vm_opts[@]}" || return 1
450新增: _agent_vm_print_resources "$vm_name"
433451
434452 # TODO: add --dangerously-skip-permissions once released
435453 # (waiting on https://github.com/anomalyco/opencode/pull/11833)
@@ -456,6 +474,7 @@ _agent_vm_codex() {
456474 vm_name="$(_agent_vm_name "$host_dir")"
457475
458476 _agent_vm_ensure_running "$vm_name" "$host_dir" "${vm_opts[@]}" || return 1
477新增: _agent_vm_print_resources "$vm_name"
459478
460479 limactl shell --workdir "$host_dir" "$vm_name" codex --full-auto "${args[@]}"
461480}
@@ -479,6 +498,7 @@ _agent_vm_shell() {
479498 vm_name="$(_agent_vm_name "$host_dir")"
480499
481500 _agent_vm_ensure_running "$vm_name" "$host_dir" "${vm_opts[@]}" || return 1
501新增: _agent_vm_print_resources "$vm_name"
482502
483503 echo "VM: $vm_name | Dir: $host_dir"
484504 echo "Type 'exit' to leave (VM keeps running). Use 'agent-vm stop' to stop it."
@@ -509,6 +529,7 @@ _agent_vm_run() {
509529 vm_name="$(_agent_vm_name "$host_dir")"
510530
511531 _agent_vm_ensure_running "$vm_name" "$host_dir" "${vm_opts[@]}" || return 1
532新增: _agent_vm_print_resources "$vm_name"
512533
513534 limactl shell --workdir "$host_dir" "$vm_name" "${args[@]}"
514535}