跳到主要内容

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

浏览文件

install-macos-browser.sh

76 行 · 4.3 KB历史下载
1#!/bin/bash
2# Run as the administrator inside the prepared virtual Mac. All media are local.
3set -euo pipefail
4export PATH=/usr/bin:/bin:/usr/sbin:/sbin
5[[ ( $# == 1 || ( $# == 2 && $2 == --update-tools ) ) && $EUID == 0 && $(sysctl -n hw.model) =~ ^VirtualMac[0-9]+,[0-9]+$ ]]
6[[ -f /var/db/cage-guest-os && ! -L /var/db/cage-guest-os && $(stat -f %u /var/db/cage-guest-os) == 0 && $(cat /var/db/cage-guest-os) == macos ]]
7media=$(cd "$1" && pwd)
8base=/usr/local/libexec
9tools="$base/cage-workbench-browser-4.145.0-pw1.65.0"
10mkdir -p "$base"
11stage=$(mktemp -d "$base/.cage-browser.XXXXXXXX")
12volume="$stage/volume"
13trap 'if mount | grep -Fq " on $volume ("; then hdiutil detach "$volume" >/dev/null; fi; rm -rf "$stage"' EXIT
14umask 022
15verify() {
16 [[ $(shasum -a 256 "$1" | cut -d' ' -f1) == "$2" ]] || { echo "Unexpected package digest: $1" >&2; exit 1; }
17}
18if [[ ! -x $tools/editor/lib/node || ! -f $tools/playwright/package.json ]]; then
19 mkdir -p "$stage/tools/editor" "$stage/tools/playwright"
20 cp "$media/editor.tgz" "$media/playwright.tgz" "$stage/"
21 verify "$stage/editor.tgz" a79774d8d34eed785c1f831bc0125f7534bc21a0039bef8e8a2aa32463f9421a
22 verify "$stage/playwright.tgz" 315247c55a793ca760b2f05bdcee0e6a53fd65b1f22d1d3de8323c8c9395add3
23 tar -xzf "$stage/editor.tgz" -C "$stage/tools/editor" --no-same-owner --strip-components 1
24 tar -xzf "$stage/playwright.tgz" -C "$stage/tools/playwright" --no-same-owner --strip-components 1
25 "$stage/tools/editor/lib/node" --version
26 mkdir -p "$tools"
27 for component in editor playwright; do
28 [[ ! -L $tools/$component ]]
29 if [[ -e $tools/$component ]]; then mv "$tools/$component" "$stage/previous-$component"; fi
30 if ! mv "$stage/tools/$component" "$tools/$component"; then
31 if [[ -d $stage/previous-$component ]]; then mv "$stage/previous-$component" "$tools/$component"; fi
32 exit 1
33 fi
34 done
35fi
36app='/Applications/Google Chrome.app'
37requirement='anchor apple generic and identifier "com.google.Chrome" and certificate leaf[subject.OU] = "EQHXZ8M8AV"'
38if [[ ! -e $app || ${2:-} == --update-tools ]]; then
39 cp "$media/chrome.dmg" "$stage/chrome.dmg"
40 mkdir "$volume"
41 hdiutil attach -readonly -nobrowse -noautoopen -mountpoint "$volume" "$stage/chrome.dmg" >/dev/null
42 spctl --assess --type execute "$volume/Google Chrome.app"
43 ditto --norsrc "$volume/Google Chrome.app" "$stage/Google Chrome.app"
44 codesign --verify --strict --deep -R="$requirement" "$stage/Google Chrome.app"
45 spctl --assess --type execute "$stage/Google Chrome.app"
46 install_chrome=yes
47 if [[ -e $app ]]; then
48 [[ -d $app && ! -L $app ]]
49 codesign --verify --strict -R="$requirement" "$app"
50 current=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$app/Contents/Info.plist")
51 incoming=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$stage/Google Chrome.app/Contents/Info.plist")
52 [[ $current =~ ^[0-9]+(\.[0-9]+)*$ && $incoming =~ ^[0-9]+(\.[0-9]+)*$ ]]
53 if ! /usr/bin/perl -e '@a=split(/\./,$ARGV[0]);@b=split(/\./,$ARGV[1]);for($i=0;$i<@a||$i<@b;$i++){exit(($a[$i]//0)>($b[$i]//0)?0:1) if ($a[$i]//0)!=($b[$i]//0)}exit 1' "$incoming" "$current"; then install_chrome=no; fi
54 fi
55 if [[ $install_chrome == yes ]]; then
56 if [[ -e $app ]]; then mv "$app" "$stage/previous-chrome.app"; fi
57 if ! mv "$stage/Google Chrome.app" "$app"; then
58 if [[ -d $stage/previous-chrome.app ]]; then mv "$stage/previous-chrome.app" "$app"; fi
59 exit 1
60 fi
61 fi
62fi
63codesign --verify --strict -R="$requirement" "$app"
64sources=$(cd "$(dirname "$0")" && pwd)
65install -m 644 "$sources/macos-browser.mjs" "$base/cage-macos-browser.mjs"
66install -m 755 "$sources/cage-macos-editor" "$base/cage-macos-editor"
67if [[ -f "$media/native-browser/macos-native-browser.mjs" ]]; then
68 cp -R "$media/native-browser" "$stage/controller"
69else
70 "$sources/package-macos-browser.sh" "$stage/controller"
71fi
72install -d "$tools/controller" "$tools/controller/modules" "$tools/controller/split-extension"
73install -m 644 "$stage/controller/"*.mjs "$tools/controller/"
74install -m 755 "$stage/controller/cage-tailnet" "$tools/controller/cage-tailnet"
75install -m 644 "$stage/controller/modules/"*.mjs "$tools/controller/modules/"
76install -m 644 "$stage/controller/split-extension/"* "$tools/controller/split-extension/"