跳到主要内容

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

提交记录

Merge pull request #67 from Lee-xeo/codex/ci-platform-fixtures

修复主线 Linux 容器测试与 Windows 安装接续检查

作者
Shihao Li
时间
2026/11/11 17:25
提交
28abdb0
这个版本的全部文件

这是一个合并提交,下面是和第一个上一提交相比的改动。

修改.github/workflows/linux-build.yml+2 −2看文件
@@ -29,12 +29,12 @@ jobs:
2929 image: ubuntu:22.04
3030 # docker-default AppArmor denies bubblewrap's private mount namespace.
3131 # Relax only this disposable outer container; WebKit keeps its sandbox.
32删除: options: --security-opt seccomp=unconfined --security-opt systempaths=unconfined --security-opt apparmor=unconfined
32新增: options: --init --security-opt seccomp=unconfined --security-opt systempaths=unconfined --security-opt apparmor=unconfined
3333 steps:
3434 - name: Install build and test dependencies
3535 run: |
3636 apt-get update
37删除: DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential pkg-config libgtk-3-dev libwebkit2gtk-4.1-dev libjson-glib-dev dpkg-dev curl ca-certificates git software-properties-common qemu-system-x86 qemu-utils ovmf openssh-client iproute2 dbus-x11 xvfb xauth fonts-noto-cjk zsh sudo
37新增: DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential pkg-config libgtk-3-dev libwebkit2gtk-4.1-dev libjson-glib-dev dpkg-dev curl ca-certificates git software-properties-common qemu-system-x86 qemu-utils ovmf openssh-client iproute2 dbus-x11 xvfb xauth fonts-noto-cjk zsh sudo tzdata
3838 # The supported 22.04 ABI predates safe.bareRepository. Use the Git
3939 # project's documented Ubuntu packages, preserving the runtime gate.
4040 add-apt-repository -y ppa:git-core/ppa
修改internal/workbench/claude_desktop_resize_unix_test.go+11 −5看文件
@@ -18,10 +18,15 @@ func TestDesktopResizeScriptAppliesTheViewersDensity(t *testing.T) {
1818 if runtime.GOOS != "linux" || err != nil {
1919 t.Skip("the script identifies its settings manager through /proc")
2020 }
21删除: // Go's temporary directory can be mounted noexec; the stand-ins must run.
22删除: root, err := os.MkdirTemp("/dev/shm", "cage-resize-")
21新增: // go test already executes its test binary from this filesystem. Both
22新增: // TMPDIR and /dev/shm can be mounted noexec independently of the Go build directory.
23新增: executable, err := os.Executable()
2324 if err != nil {
24删除: root = t.TempDir()
25新增: t.Fatal(err)
26新增: }
27新增: root, err := os.MkdirTemp(filepath.Dir(executable), "cage-resize-")
28新增: if err != nil {
29新增: t.Fatal(err)
2530 }
2631 t.Cleanup(func() { os.RemoveAll(root) })
2732 desktop, phone, bin := filepath.Join(root, "desktop"), filepath.Join(root, "phone"), filepath.Join(root, "bin")
@@ -40,9 +45,10 @@ func TestDesktopResizeScriptAppliesTheViewersDensity(t *testing.T) {
4045 data, _ := os.ReadFile(path)
4146 return string(data)
4247 }
43删除: write(filepath.Join(bin, "xrandr"), "#!/bin/sh\necho \"$*\" >> "+filepath.Join(root, "modes")+"\n", 0o700)
48新增: t.Setenv("CAGE_RESIZE_FIXTURE", root)
49新增: write(filepath.Join(bin, "xrandr"), "#!/bin/sh\necho \"$*\" >> \"$CAGE_RESIZE_FIXTURE/modes\"\n", 0o700)
4450 // The script signals a process named xsettingsd.
45删除: write(filepath.Join(bin, "xsettingsd"), "#!/bin/sh\ntrap 'echo reload >> "+filepath.Join(root, "reloads")+"' HUP\nwhile :; do sleep 1 & wait $!; done\n", 0o700)
51新增: write(filepath.Join(bin, "xsettingsd"), "#!/bin/sh\ntrap 'echo reload >> \"$CAGE_RESIZE_FIXTURE/reloads\"' HUP\nwhile :; do sleep 1 & wait $!; done\n", 0o700)
4652 resize := func(scale string) string {
4753 t.Helper()
4854 script := strings.NewReplacer("/run/cage-desktop", desktop, "/run/cage-phone-desktop", phone).Replace(desktopResizeScript(1000, 800, scale))
修改scripts/guest-os/setup-windows-guest.ps1+2 −0看文件
@@ -91,6 +91,8 @@ finally { if ($progressStream) { $progressStream.Dispose() } }
9191 try{
9292 if($context){Wait-CageHostEnrollment $context $worker}
9393 $process=Start-Process -FilePath (Join-Path ([Environment]::GetFolderPath('System')) 'WindowsPowerShell/v1.0/powershell.exe') -ArgumentList @('-NoLogo','-NoProfile','-ExecutionPolicy','RemoteSigned','-EncodedCommand',$encoded) -Verb RunAs -PassThru
94新增: # Windows PowerShell 5.1 must retain a handle before waiting to read ExitCode.
95新增: $null=$process.Handle
9496 if($context){Set-CageHostEnrollmentAdmin $context $process}
9597 Wait-CageWindowsInstaller $process $progressFile
9698 if($process.ExitCode -ne 0){throw 'Windows setup did not complete; existing VM and data were preserved.'}
修改scripts/guest-os/windows-host-enrollment.ps1+13 −1看文件
@@ -19,6 +19,7 @@ public static class Native {
1919 [DllImport("kernel32.dll",SetLastError=true)] public static extern bool GetNamedPipeServerProcessId(SafePipeHandle pipe,out uint pid);
2020 [DllImport("kernel32.dll",SetLastError=true)] static extern bool GetProcessTimes(IntPtr process,out FileTime created,out FileTime exited,out FileTime kernel,out FileTime user);
2121 [DllImport("kernel32.dll",CharSet=CharSet.Unicode,ExactSpelling=true,SetLastError=true)] static extern bool QueryFullProcessImageNameW(IntPtr process,uint flags,StringBuilder image,ref uint size);
22新增: [DllImport("kernel32.dll",CharSet=CharSet.Unicode,ExactSpelling=true,SetLastError=true)] static extern uint GetLongPathNameW(string path,StringBuilder expanded,uint capacity);
2223 [DllImport("advapi32.dll",SetLastError=true)] static extern bool OpenProcessToken(IntPtr process,uint access,out IntPtr token);
2324 [DllImport("advapi32.dll",SetLastError=true)] static extern bool GetTokenInformation(IntPtr token,int kind,IntPtr data,uint bytes,out uint needed);
2425 [DllImport("ntdll.dll")] static extern int NtQueryInformationProcess(IntPtr process,int kind,out Basic basic,uint bytes,out uint needed);
@@ -30,6 +31,17 @@ public static class Native {
3031 var p=OpenProcess(0x1000,false,pid);if(p==IntPtr.Zero)throw new InvalidOperationException("enrollment_peer_invalid");
3132 try {var value=new StringBuilder(32768);uint n=(uint)value.Capacity;if(!QueryFullProcessImageNameW(p,0,value,ref n))throw new InvalidOperationException("enrollment_peer_invalid");return value.ToString();}finally{CloseHandle(p);}
3233 }
34新增: static string LongPath(string path) {
35新增: var expanded=new StringBuilder(32768);
36新增: uint n=GetLongPathNameW(path,expanded,(uint)expanded.Capacity);
37新增: if(n==0||n>=expanded.Capacity)throw new InvalidOperationException("enrollment_image_path_unavailable");
38新增: return expanded.ToString();
39新增: }
40新增: public static bool SameImagePath(string actual,string expected) {
41新增: if(string.Equals(actual,expected,StringComparison.OrdinalIgnoreCase))return true;
42新增: // The kernel may report an 8.3 path for a process started by a long path.
43新增: return string.Equals(LongPath(actual),LongPath(expected),StringComparison.OrdinalIgnoreCase);
44新增: }
3345 public static uint Parent(uint pid) {
3446 var p=OpenProcess(0x1000,false,pid);if(p==IntPtr.Zero)throw new InvalidOperationException("enrollment_peer_invalid");
3547 try {Basic value;uint n;if(NtQueryInformationProcess(p,0,out value,(uint)Marshal.SizeOf(typeof(Basic)),out n)!=0)throw new InvalidOperationException("enrollment_peer_invalid");return checked((uint)value.Parent.ToInt64());}finally{CloseHandle(p);}
@@ -49,7 +61,7 @@ function Assert-CageHostEnrollmentPeer($Context,$Stream) {
4961 [uint32]$serverPID=0
5062 if(![Cage.HostEnrollment.Native]::GetNamedPipeServerProcessId($Stream.SafePipeHandle,[ref]$serverPID) -or $serverPID -ne $Context.WorkerPID){throw 'The original host enrollment peer could not be verified.'}
5163 if([Cage.HostEnrollment.Native]::Started($serverPID) -ne [long]$Context.WorkerStarted -or
52删除: [Cage.HostEnrollment.Native]::Image($serverPID) -ine $Context.WorkerExe -or
64新增: ![Cage.HostEnrollment.Native]::SameImagePath([Cage.HostEnrollment.Native]::Image($serverPID),$Context.WorkerExe) -or
5365 [Cage.HostEnrollment.Native]::UserSID($serverPID) -cne $Context.HostSID -or
5466 [Cage.HostEnrollment.Native]::Parent($serverPID) -ne $Context.OwnerPID -or
5567 [Cage.HostEnrollment.Native]::Started([uint32]$Context.OwnerPID) -ne [long]$Context.OwnerStarted -or
修改scripts/guest-os/windows-iso-setup.tests.ps1+1 −0看文件
@@ -84,6 +84,7 @@ try {
8484 $encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command))
8585 $child = Start-Process -FilePath (Get-Process -Id $PID).Path -ArgumentList @('-NoLogo','-NoProfile','-NonInteractive','-EncodedCommand',$encoded) -RedirectStandardOutput $stdout -RedirectStandardError $stderr -PassThru
8686 try {
87新增: $null = $child.Handle
8788 $forwarded = @(Wait-CageWindowsInstaller $child $progressFile)
8889 Assert-Check ($child.ExitCode -eq 0) ('Encoded installer wrapper failed. '+[IO.File]::ReadAllText($stderr))
8990 Assert-Check ($forwarded[-1] -ceq 'CAGE_GUEST_STAGE windows-11 oobe') 'The actual child could not publish its final stage.'