跳到主要内容

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

浏览文件

xdg-open

31 行 · 1.4 KB历史下载
1#!/usr/bin/python3
2import os
3from pathlib import Path
4import sys
5from urllib.parse import urlsplit
6
7def launch():
8 if len(sys.argv) != 2 or os.environ.get('DISPLAY') != ':79' or os.environ.get('XDG_RUNTIME_DIR') != '/run/cage-phone-desktop':
9 return 1
10 value = sys.argv[1]
11 if not value or len(value) > 8192 or any(ord(c) < 32 for c in value):
12 return 1
13 parsed = urlsplit(value)
14 if parsed.scheme == 'claude':
15 os.execv('/usr/bin/claude-desktop', ['claude-desktop', '--user-data-dir=' + str(Path.home() / 'DesktopProfile'), value])
16 host = parsed.hostname or ''
17 if parsed.scheme != 'https' or parsed.username or parsed.password or parsed.port not in (443, None):
18 return 1
19 if not any(host == d or host.endswith('.' + d) for d in ('anthropic.com', 'claude.ai', 'claude.com')):
20 return 1
21 port = (Path(os.environ['XDG_RUNTIME_DIR']) / 'proxy').read_text()
22 os.execv('/usr/bin/chromium', ['chromium', '--user-data-dir=' + str(Path.home() / 'LoginProfile'),
23 '--class=CagePhoneLogin', '--no-first-run', '--no-default-browser-check', '--disable-extensions',
24 '--disable-quic', '--force-webrtc-ip-handling-policy=disable_non_proxied_udp',
25 '--proxy-server=socks5://127.0.0.1:' + str(int(port)), '--proxy-bypass-list=<-loopback>',
26 '--disable-dev-shm-usage', '--lang=' + os.environ.get('CAGE_LANGUAGE', 'en-US'), '--app=' + value])
27
28try:
29 sys.exit(launch())
30except Exception:
31 sys.exit(1)