跳到主要内容

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

浏览文件

macos_cli.go

44 行 · 1.7 KB历史下载
1package workbench
2
3import (
4 "path"
5
6 "al.essio.dev/pkg/shellescape"
7)
8
9const macCLIInstall = "/usr/local/libexec/cage-cli"
10
11const macOSLegacyWorkspaceNotice = "此历史会话仍使用原来的客机目录,文件保留在虚拟 Mac 内。要使用与主机共享的默认工作区,请从默认工作区新建会话。"
12
13// Only a persisted terminal already bound to the old default workspace keeps
14// that directory. New sessions and other host projects use approved mounts.
15func (s *Server) macOSLegacyWorkspace(record *mobileRecord) string {
16 if s.macosGuest == nil || record == nil || !record.Terminal || record.Workspace != s.environmentDir() {
17 return ""
18 }
19 root := path.Join("/Users", s.macosGuest.User, ".local/share/cage/workspace")
20 if record.GuestWorkspace != path.Clean(record.GuestWorkspace) || !cliWorkspaceWithin(record.GuestWorkspace, root, false) {
21 return ""
22 }
23 return root
24}
25
26func (s *Server) cliWorkspace(workspace string) string {
27 if s.macosGuest == nil {
28 return guestPath(workspace)
29 }
30 return macOSProjectPath(s.macosGuest.User, workspace)
31}
32
33func (s *Server) cliHelperCommand(mode, argument string) string {
34 if s.macosGuest == nil {
35 return cliChannelCommand(mode, argument)
36 }
37 return shellescape.QuoteCommand([]string{macCLIInstall + "/bin/python3", "-I", macCLIInstall + "/macos-cli.py", mode, argument})
38}
39
40func (s *Server) macOSClaudeLaunch(workspace, payload string) string {
41 // The signed project helper rechecks the exact mount and its GUI user's
42 // approval before granting the CLI a controlling terminal and that cwd.
43 return "exec " + shellescape.QuoteCommand([]string{"/usr/local/libexec/cage-macos-terminal", "--claude", s.cliWorkspace(workspace), payload})
44}