跳到主要内容

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

浏览文件

linux_guest_image.go

51 行 · 1.6 KB历史下载
1package workbench
2
3import (
4 "context"
5 "errors"
6 "os"
7 "path/filepath"
8 "runtime"
9
10 "github.com/sylvinus/agent-vm/internal/guestos"
11 "github.com/sylvinus/agent-vm/internal/hostimage"
12 "github.com/sylvinus/agent-vm/internal/limaembed"
13)
14
15func linuxGuestSystems(platform, arch string) []string {
16 if platform == "darwin" && arch == "arm64" || (platform == "windows" || platform == "linux") && arch == "amd64" {
17 return []string{guestos.Ubuntu2204}
18 }
19 return nil
20}
21
22func linuxGuestImagePlan(ctx context.Context, profile, system, arch string) (hostimage.Plan, error) {
23 if system != guestos.Ubuntu2204 || arch != "amd64" && arch != "arm64" {
24 return hostimage.Plan{}, errors.New("此主机暂不支持所选 Linux 客机镜像")
25 }
26 template, err := limaembed.ReadImageTemplate(system)
27 if err != nil {
28 return hostimage.Plan{}, err
29 }
30 home, err := os.UserHomeDir()
31 if err != nil {
32 return hostimage.Plan{}, err
33 }
34 identity := hostimage.Identity{System: system, Version: "22.04", Arch: arch}
35 // Resolution of a pinned Linux image is local. Downloads use the existing
36 // installer transport only after the user submits the installation.
37 return hostimage.Resolve(ctx, identity, filepath.Join(profile, "state", "guest-media", system), filepath.Join(home, "Downloads"), template, nil)
38}
39
40func (s *Server) installedLinuxSystem() (string, error) {
41 return hostimage.LinuxSystem(filepath.Join(s.profile, "state"))
42}
43
44func canInstallCatalogLinux(system string) bool {
45 for _, candidate := range linuxGuestSystems(runtime.GOOS, runtime.GOARCH) {
46 if system == candidate {
47 return true
48 }
49 }
50 return false
51}