跳到主要内容

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

浏览文件

windows-host-enrollment.tests.ps1

25 行 · 1.4 KB历史下载
1#requires -Version 5.1
2$ErrorActionPreference = 'Stop'
3$parseErrors = $null
4$ast = [Management.Automation.Language.Parser]::ParseFile((Join-Path $PSScriptRoot 'windows-host-enrollment.ps1'), [ref]$null, [ref]$parseErrors)
5if ($parseErrors.Count) { throw $parseErrors[0] }
6$wait = $ast.Find({ param($node) $node -is [Management.Automation.Language.FunctionDefinitionAst] -and $node.Name -eq 'Wait-CageHostEnrollment' }, $true)
7. ([scriptblock]::Create($wait.Extent.Text))
8$script:requests = 0
9$worker = [pscustomobject]@{ HasExited = $false; ExitCode = 1 }
10function Invoke-CageHostEnrollment {
11 param($Context, $Request, $Secret)
12 $script:requests++
13 if ($script:failRequest) { $worker.HasExited = $true; throw 'Injected pipe failure' }
14 if ($Request.action -cne 'ready') { throw 'Unexpected enrollment request' }
15}
16Wait-CageHostEnrollment @{} $worker
17if ($script:requests -ne 1) { throw 'The ready handshake was not performed.' }
18$script:failRequest = $true
19$watch = [Diagnostics.Stopwatch]::StartNew()
20try { Wait-CageHostEnrollment @{} $worker; throw 'Worker failure was ignored.' }
21catch {
22 if ($_.Exception.Message -notlike '*enrollment_worker_exited*') { throw }
23}
24if ($script:requests -ne 2 -or $watch.Elapsed.TotalSeconds -gt 2) { throw 'An exited worker was retried until the ready timeout.' }
25Write-Output 'Passed ready handshake and early worker-exit reporting.'