跳到主要内容

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

浏览文件

exit_samples.go

43 行 · 1.4 KB历史下载
1package workbench
2
3import (
4 "fmt"
5 "strings"
6
7 "github.com/sylvinus/agent-vm/internal/diagnostics"
8 "github.com/sylvinus/agent-vm/internal/usererror"
9)
10
11// All guest platforms return the same observation contract. Do not infer a
12// transport failure from an unavailable sample or expose raw guest output.
13func incompleteExitSamples(hostIP string, hostErr error, terminal networkObservation, terminalErr error, browser networkObservation, browserErr error) string {
14 var missing []string
15 for _, sample := range []struct {
16 name string
17 observation networkObservation
18 err error
19 }{
20 {"宿主", networkObservation{Status: 200, IP: hostIP}, hostErr},
21 {"虚拟机终端", terminal, terminalErr},
22 {"浏览器", browser, browserErr},
23 } {
24 var reason string
25 switch {
26 case sample.err != nil:
27 reason = diagnostics.Redact(usererror.Display("读取采样", sample.err, "请重新检测。").Error())
28 case sample.observation.Status == 0:
29 reason = "没有收到检测通道的响应"
30 case sample.observation.Status != 200:
31 reason = fmt.Sprintf("检测通道返回 HTTP %d,未取得出口地址", sample.observation.Status)
32 case sample.observation.IP == "":
33 reason = "检测通道没有返回出口地址"
34 }
35 if reason != "" {
36 missing = append(missing, sample.name+":"+reason)
37 }
38 }
39 if len(missing) == 0 {
40 return ""
41 }
42 return "出口采样不完整,无法确认配置范围(" + strings.Join(missing, ";") + ")"
43}