跳到主要内容

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

浏览文件

agent-vm.sh

56 行 · 2.2 KB历史下载
1#!/usr/bin/env bash
2#
3# Runs agent-vm: in a release, the binary next to this script; in a clone,
4# the one `make` builds, built first when missing or when HEAD moved (a git
5# pull). `agent-vm.sh install` links the binary onto the PATH; the curl
6# installer runs it so.
7#
8# What 0.2 left behind keeps working through it: a link to this file on the
9# PATH (0.2's install), and a shell rc that sources it (0.1 and 0.2), which
10# gets an agent-vm function running it.
11
12# Sourced: nothing below runs in the user's shell, where set -e or exec would
13# end it.
14if [ -n "${ZSH_VERSION:-}" ]; then
15 case "${ZSH_EVAL_CONTEXT:-}" in
16 *:file*)
17 eval '_agent_vm_sh=${(%):-%x}'
18 _agent_vm_sh="$(cd -P -- "$(dirname -- "$_agent_vm_sh")" >/dev/null && pwd)/$(basename -- "$_agent_vm_sh")"
19 agent-vm() { bash "$_agent_vm_sh" "$@"; }
20 return 0 ;;
21 esac
22elif [ -n "${BASH_VERSION:-}" ] && [ "${BASH_SOURCE[0]}" != "$0" ]; then
23 _agent_vm_sh="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null && pwd)/$(basename -- "${BASH_SOURCE[0]}")"
24 agent-vm() { bash "$_agent_vm_sh" "$@"; }
25 return 0
26fi
27
28set -euo pipefail
29
30# This file's folder, through the links to it (0.2's on the PATH).
31src="${BASH_SOURCE[0]:-$0}"
32for _ in 1 2 3 4 5 6 7 8 9 10; do
33 [ -L "$src" ] || break
34 t="$(readlink "$src")"
35 case "$t" in /*) src="$t" ;; *) src="$(dirname "$src")/$t" ;; esac
36done
37dir="$(CDPATH= cd -P -- "$(dirname "$src")" >/dev/null && pwd)"
38
39# Windows (Git Bash): agent-vm.exe.
40exe=""
41case "$(uname -s)" in MINGW* | MSYS* | CYGWIN*) exe=.exe ;; esac
42
43if [ -f "$dir/agent-vm$exe" ]; then
44 exec "$dir/agent-vm$exe" "$@"
45fi
46
47bin="$dir/_output/bin/agent-vm$exe"
48head="$(git -C "$dir" rev-parse HEAD 2>/dev/null || echo none)"
49if [ ! -x "$bin" ] || [ "$(cat "$dir/_output/built-from" 2>/dev/null)" != "$head" ]; then
50 echo "agent-vm: building (Go needed, and on macOS the Xcode command line tools; a few minutes the first time)..." >&2
51 mkdir -p "$dir/_output"
52 make -C "$dir" agent-vm >"$dir/_output/build.log" 2>&1 \
53 || { tail -n 20 "$dir/_output/build.log" >&2; echo "agent-vm: the build failed, full log: $dir/_output/build.log" >&2; exit 1; }
54 echo "$head" > "$dir/_output/built-from"
55fi
56exec "$bin" "$@"