跳到主要内容

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

浏览文件

windows_mobile.go

66 行 · 2.1 KB历史下载
1package workbench
2
3import (
4 "errors"
5 "io/fs"
6 "net/url"
7 "path"
8 "path/filepath"
9 "strings"
10)
11
12// The host owns the record and live mount. No phone parameter supplies a guest
13// directory, project grant, or execution identity to the native CLI.
14func (s *Server) windowsConversationInput(record *mobileRecord, input map[string]any) error {
15 if s.windowsGuest == nil {
16 return nil
17 }
18 if _, err := s.projectWorkspace(record.Workspace); err != nil {
19 return err
20 }
21 project, err := s.windowsProjectForHost(record.Workspace)
22 if err != nil {
23 return err
24 }
25 input["workspace"], input["project_id"], input["grant"] = project.Path, project.ID, project.Grant
26 return nil
27}
28
29var errWindowsLegacyMobile = errors.New("这段历史来自尚未适配 Windows 的旧移动会话,记录已保留;请在原运行环境接续,或在 Windows 新建共享会话")
30
31func windowsCLIAbsolutePath(value string) bool {
32 return len(value) > 3 && ((value[0] >= 'A' && value[0] <= 'Z') || (value[0] >= 'a' && value[0] <= 'z')) && value[1] == ':' && (value[2] == '\\' || value[2] == '/')
33}
34
35func windowsMediaFileName(root, cwd, reference string) (string, error) {
36 value, err := url.PathUnescape(reference)
37 if err != nil || value == "" || len(value) > 4096 || strings.ContainsRune(value, 0) {
38 return "", fs.ErrInvalid
39 }
40 normalize := func(value string) string { return strings.ReplaceAll(value, "\\", "/") }
41 root, cwd, value = strings.TrimRight(normalize(root), "/"), normalize(cwd), normalize(value)
42 if !windowsCLIAbsolutePath(root) || strings.HasPrefix(value, "/") {
43 return "", fs.ErrPermission
44 }
45 if cwd == "" {
46 cwd = root
47 }
48 if !cliWorkspaceWithin(path.Clean(cwd), root, true) {
49 return "", fs.ErrPermission
50 }
51 if !windowsCLIAbsolutePath(value) {
52 if strings.Contains(value, ":") {
53 return "", fs.ErrPermission
54 }
55 value = path.Join(cwd, value)
56 }
57 value = path.Clean(value)
58 if !cliWorkspaceWithin(value, root, true) || len(value) <= len(root)+1 {
59 return "", fs.ErrPermission
60 }
61 name := value[len(root)+1:]
62 if !fs.ValidPath(name) || strings.Contains(name, ":") {
63 return "", fs.ErrPermission
64 }
65 return filepath.Localize(name)
66}