跳到主要内容

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

浏览文件

claude-window-windows.tests.ps1

32 行 · 1.7 KB历史下载
1#requires -Version 5.1
2# Test frame rejection and output handling without accessing any desktop.
3$ErrorActionPreference = 'Stop'
4. (Join-Path $PSScriptRoot 'claude-window-windows.ps1')
5
6if ($PSVersionTable.PSEdition -eq 'Desktop') {
7 Add-Type -TypeDefinition $cageWindowSource -ReferencedAssemblies System.Drawing
8} else {
9 $references = @((Get-ChildItem "$PSHOME/ref/*.dll").FullName) + @([Drawing.Bitmap].Assembly.Location)
10 $references += @((Get-ChildItem "$PSHOME/System.Private.Windows.*.dll").FullName)
11 Add-Type -TypeDefinition $cageWindowSource -ReferencedAssemblies $references
12}
13
14if ([CageClaudeWindow]::FrameProblem([int[]]@()) -ne 'empty_frame' -or
15 [CageClaudeWindow]::FrameProblem([int[]]@(0, 0x010204)) -ne 'black_frame' -or
16 [CageClaudeWindow]::FrameProblem([int[]]@(0xFAFAFA, 0xFBFBFB)) -ne 'uniform_frame' -or
17 [CageClaudeWindow]::FrameProblem([int[]]@(0xFAFAFA, 0x111111))) {
18 throw 'Blank or nonuniform frame classification failed.'
19}
20
21$output = Join-Path ([IO.Path]::GetTempPath()) ("cage-window-" + [guid]::NewGuid() + ".png")
22if ((Get-ClaudeCapturePath $output) -ne [IO.Path]::GetFullPath($output)) { throw 'Failed to accept a temporary PNG.' }
23try {
24 [IO.File]::WriteAllText($output, 'preserve')
25 foreach ($bad in @($output, "$output.txt", [IO.Path]::Combine([IO.Path]::GetDirectoryName($output), '..', 'outside.png'))) {
26 $rejected = $false
27 try { $null = Get-ClaudeCapturePath $bad } catch { $rejected = $true }
28 if (!$rejected) { throw "Accepted invalid output: $bad" }
29 }
30 if ([IO.File]::ReadAllText($output) -cne 'preserve') { throw 'Existing output was changed.' }
31} finally { [IO.File]::Delete($output) }
32Write-Output 'Passed simulated Claude window frame and output-path checks.'