跳到主要内容

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

提交记录

release: 准备 v0.1.5-alpha.2 三平台预发行

支持在界面中组合跨来源中转与最终出口,保留未应用草稿,统一代理延迟说明并整合 IP 变化规则。修复网络检查的出口规则入口。 改善环境安装失败后的恢复、镜像续传和工具缓存,保留个人配置与持久虚拟机数据。更新宣传片源码、横竖版界面素材与社交配图。 本地通过完整 Go 测试、相关 race 检查、前端 50 项测试、发布流程 48 项测试,以及代理链真实入口检查。三平台最终产物由同一发布提交构建并分别记录验收范围。 Signed-off-by: Lee-xeo <[email protected]>

作者
Lee-xeo
时间
2026/11/06 00:43
提交
0aa4a0f
上一个
1b18ec7
这个版本的全部文件
修改.gitignore+9 −0看文件
@@ -25,3 +25,12 @@ dist
2525*.p12
2626*.keychain-db
2727/promo/out/
28新增:
29新增:# Local diagnostics and UI design/acceptance workspaces. Public media lives in promo/.
30新增:/output/
31新增:/ui/.oil-ui/
32新增:/ui/_output/
33新增:
34新增:# Rendered promo export; reproducible source and assets are in promo/.
35新增:/claude-cage-promo.mp4
36新增:/.vite/
修改README.md+2 −2看文件
@@ -54,7 +54,7 @@ Cage 支持 macOS、Windows 和 Linux:macOS 14+ 的 Apple Silicon Mac、Window
5454
5555安装包随附工作台和代理核心,日常使用无需安装 Go、Node.js、Docker 或 Clash。首次启动仍需联网下载 Linux 镜像与开发工具;Cage 不提供代理服务或 Claude 账户。
5656
57删除:当前版本为 `0.1.5-alpha.1`。源码、主页与发行物公开;安装包的签名、公证和验收范围以对应 Release 说明为准。干净机器安装、macOS 14 实机兼容性、真实 Claude 授权与模型请求仍需完整验收。
57新增:当前版本为 `0.1.5-alpha.2`。源码、主页与发行物公开;安装包的签名、公证和验收范围以对应 Release 说明为准。干净机器安装、macOS 14 实机兼容性、真实 Claude 授权与模型请求仍需完整验收。
5858
5959支持应用内更新的 macOS 和 Windows 版本通过所选代理下载,无直连回退;安装前请保存并停止任务。macOS 要求同一发布者的 Developer ID 签名并通过 Apple 验证,Windows 要求可信 Authenticode 签名和相同发布者公钥。Windows 未签名预览版和 Linux 系统包需手动更新。详见[升级与卸载](docs/getting-started.md#升级与卸载)。
6060
@@ -62,7 +62,7 @@ Cage 支持 macOS、Windows 和 Linux:macOS 14+ 的 Apple Silicon Mac、Window
6262
6363### 1. 选择代理
6464
65删除:点击首页“配置网络与代理”,再点击“添加来源”,导入 Clash/Mihomo YAML 订阅或本地 YAML 文件,在“节点”中选择一个节点。没有可用代理时,可以明确勾选“通过主机网络下载这份订阅”,或直接导入本地文件。后续可从“设置 → 网络与代理”管理节点。
65新增:点击首页“配置网络与代理”,再点击“添加来源”,导入 Clash/Mihomo YAML 订阅或本地 YAML 文件,在“节点”中选择最终出口并点击“应用代理”。需要通过中转连接住宅代理时,选择“链式代理”,按顺序选择中转与最终出口。没有可用代理时,可以明确勾选“通过主机网络下载这份订阅”,或直接导入本地文件。后续可从“设置 → 网络与代理”管理节点。
6666
6767### 2. 启动环境
6868
修改VERSION+1 −1看文件
@@ -1 +1 @@
1删除:0.1.5-alpha.1
1新增:0.1.5-alpha.2
修改agent-vm.setup.sh+50 −4看文件
@@ -25,9 +25,47 @@ export DEBIAN_FRONTEND=noninteractive
2525# stdin (dpkg asking about a changed config file, an npm install script)
2626# would swallow the lines after it, which then never run.
2727apt_get() {
28删除: sudo env DEBIAN_FRONTEND=noninteractive apt-get "$@" </dev/null
28新增: local status before=''
29新增: if [[ "${CLAUDE_CAGE:-}" == 1 ]]; then
30新增: before="$(awk '$1 == "oom_kill" {print $2}' /proc/vmstat)"
31新增: fi
32新增: if sudo env DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 -o Acquire::http::Timeout=60 -o Acquire::https::Timeout=60 "$@" </dev/null; then
33新增: return 0
34新增: else
35新增: status=$?
36新增: fi
37新增: if [[ "${CLAUDE_CAGE:-}" == 1 ]]; then
38新增: printf 'APT failed (exit %s); guest memory evidence follows. oom_kill before=%s\n' "$status" "$before" >&2
39新增: apt-get --version | head -n 1 >&2 || true
40新增: awk '/^(MemTotal|MemAvailable|SwapTotal|SwapFree):/' /proc/meminfo >&2 || true
41新增: awk '$1 == "oom_kill" {print "oom_kill after=" $2}' /proc/vmstat >&2 || true
42新增: ps -eo pid,rss,comm --sort=-rss | head -n 12 >&2 || true
43新增: sudo timeout 5 journalctl -k -b --no-pager -n 40 --grep='Out of memory|Killed process|oom-kill' >&2 || true
44新增: printf 'Retry preserves the build VM and package cache. Export diagnostics if installation fails again.\n' >&2
45新增: fi
46新增: return "$status"
2947}
3048
49新增:# Download completely before replacing a repository key. A failed request must
50新增:# leave the previously trusted key usable on the next setup attempt.
51新增:install_repository_key() (
52新增: set -euo pipefail
53新增: local url="$1" target="$2" stage replacement=''
54新增: stage="$(mktemp)"
55新增: trap 'rm -f "$stage"; if [ -n "$replacement" ]; then sudo rm -f "$replacement"; fi' EXIT
56新增: curl --proto '=https' --proto-redir '=https' --tlsv1.2 --fail --location --show-error --silent \
57新增: --retry 3 --retry-all-errors --retry-max-time 120 --connect-timeout 15 --max-time 30 "$url" -o "$stage" </dev/null
58新增: test -s "$stage"
59新增: if [[ "$target" == *.asc ]]; then
60新增: grep -q '^-----BEGIN PGP PUBLIC KEY BLOCK-----' "$stage"
61新增: grep -q '^-----END PGP PUBLIC KEY BLOCK-----' "$stage"
62新增: fi
63新增: replacement="$(sudo mktemp "${target}.XXXXXX")"
64新增: sudo install -m 0644 -o root -g root "$stage" "$replacement"
65新增: sudo mv -f "$replacement" "$target"
66新增: replacement=''
67新增:)
68新增:
3169# Component toggles. The host wizard prepends `export` lines for these before
3270# piping the script in. Members of the default install set (everything except
3371# Ruby/Rust/Go/Pi/Playwright MCP/code-server and its extensions) default to 1 so running this
@@ -100,6 +138,14 @@ echo '$nrconf{restart} = '"'"'a'"'"';' | sudo tee /etc/needrestart/conf.d/no-pro
100138# avahi-daemon, upower, Vulkan drivers), some of them running daemons. The
101139# recommended packages that are used are listed by name instead.
102140echo "Installing base packages..."
141新增:if [[ "${CLAUDE_CAGE:-}" == 1 ]]; then
142新增: # This runs in the guest, through its configured DNS and proxy-only route.
143新增: echo "Checking guest DNS for Debian packages..."
144新增: if ! timeout 30 getent ahostsv4 deb.debian.org >/dev/null; then
145新增: echo 'Guest DNS could not resolve deb.debian.org. Check Cage Network & Proxy / DNS settings, apply and retry. Host internet access alone does not verify guest DNS.' >&2
146新增: exit 1
147新增: fi
148新增:fi
103149apt_get update
104150apt_get install -y --no-install-recommends \
105151 git curl jq zsh \
@@ -191,7 +237,7 @@ if [[ "$INSTALL_DOCKER" == "1" ]]; then
191237 # Install Docker from official repo (includes docker compose)
192238 echo "Installing Docker..."
193239 sudo install -m 0755 -d /etc/apt/keyrings
194删除: sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
240新增: install_repository_key https://download.docker.com/linux/debian/gpg /etc/apt/keyrings/docker.asc
195241 sudo chmod a+r /etc/apt/keyrings/docker.asc
196242 echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
197243 apt_get update
@@ -211,7 +257,7 @@ if [[ "$INSTALL_NODE" == "1" ]]; then
211257 # keeps apt on NodeSource's nodejs over Debian's older one.
212258 echo "Installing Node.js 24..."
213259 sudo install -m 0755 -d /etc/apt/keyrings
214删除: sudo curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o /etc/apt/keyrings/nodesource.asc
260新增: install_repository_key https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key /etc/apt/keyrings/nodesource.asc
215261 sudo chmod a+r /etc/apt/keyrings/nodesource.asc
216262 echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.com/node_24.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list > /dev/null
217263 printf 'Package: nodejs\nPin: origin deb.nodesource.com\nPin-Priority: 600\n' | sudo tee /etc/apt/preferences.d/nodejs > /dev/null
@@ -236,7 +282,7 @@ if [[ "$INSTALL_GH" == "1" ]]; then
236282 # Install GitHub CLI from official repo
237283 echo "Installing GitHub CLI..."
238284 sudo mkdir -p -m 755 /etc/apt/keyrings
239删除: wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
285新增: install_repository_key https://cli.github.com/packages/githubcli-archive-keyring.gpg /etc/apt/keyrings/githubcli-archive-keyring.gpg
240286 sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
241287 echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
242288 apt_get update
修改docs/design/managed-proxy.md+16 −4看文件
@@ -4,7 +4,7 @@
44
55## 用户怎样使用
66
7删除:用户安装 Cage 后,在应用内添加代理订阅或导入本地配置,选择节点并检查出口,然后启动环境。浏览器、终端、Claude Code 及其子进程共用 Cage 管理的出口;即使没有安装本机 Clash,仍能完成这一过程。
7新增:用户安装 Cage 后,在应用内添加代理订阅或导入本地配置,在节点页选择最终出口,按需添加中转并点击「应用代理」,检查出口后启动环境。浏览器、终端、Claude Code 及其子进程共用 Cage 管理的出口;即使没有安装本机 Clash,仍能完成这一过程。
88
99代理页提供已配置节点、最近检测出口、核心状态及连接反馈。用户更换节点后,旧连接结束,新节点通过检查才恢复对外联网;终端进程和项目文件保留。修改本地端口时需要重启环境,界面提前提示终端中断。代理不可用时明确显示离线原因和重试入口,不回退主机直连。
1010
@@ -14,16 +14,28 @@
1414|---|---|---|
1515| 订阅 | 添加多个订阅、修改名称、手动更新、设置定期更新、删除;有服务端数据时显示流量与到期信息 | 更新失败保留最后可用版本,展示失败原因和更新时间;删除当前来源时要求另选节点或保持离线 |
1616| 本地导入 | 导入 Clash/Mihomo YAML 完整配置或节点集合;手动添加 HTTP/SOCKS5 节点 | 显示格式及协议兼容性错误;不借助第三方在线转换服务上传订阅凭据 |
17删除:| 节点 | 按来源查看、搜索、选择、单节点或批量延迟检测,保存选择 | 延迟和真实出口连通性分别展示;不把延迟成功当作环境已放行 |
17新增:| 节点 | 按来源查看和搜索,选择单节点或组合中转与最终出口,预览后统一应用;支持单节点或批量延迟检测 | 草稿未应用时不改变当前网络;配置验证或核心启动失败保留草稿和原配置;出口检查失败保留新配置并关闭外网;离开设置前确认是否放弃;延迟成功不代表环境已放行 |
1818| 连接状态 | 查看核心是否就绪、当前实际节点、出口 IP/地区、实时速率和本次流量 | 区分核心未启动、节点连接失败、环境检查未通过及主动暂停 |
1919| 诊断 | 查看连接和状态摘要,停止或重启 Cage 自己的核心,配置独立端口 | 不操作本机其他代理实例;重启期间关闭 Cage 外网;核心原始日志保存在私有目录,不向页面公开 |
2020
21删除:订阅支持含 `proxies` 或 `payload` 的 Clash/Mihomo YAML,也接受含内联节点的完整配置。只含远程 provider 的配置、Base64 列表和各类分享链接暂不支持,需提供节点订阅地址或先导出 YAML。支持 HTTP、SOCKS5、SS、SSR、VMess、VLESS、Trojan、Hysteria、Hysteria2、TUIC、AnyTLS、Mieru;Mieru 可使用 TCP/UDP 传输、端口范围、复用、握手模式和流量模式参数,具体字段仍须由固定版本核心校验。代理链必须引用同一来源内的具体节点,选择分组和 DIRECT 链路会被拒绝。
21新增:订阅支持含 `proxies` 或 `payload` 的 Clash/Mihomo YAML,也接受含内联节点的完整配置。只含远程 provider 的配置、Base64 列表和各类分享链接暂不支持,需提供节点订阅地址或先导出 YAML。支持 HTTP、SOCKS5、SS、SSR、VMess、VLESS、Trojan、Hysteria、Hysteria2、TUIC、AnyTLS、Mieru;Mieru 可使用 TCP/UDP 传输、端口范围、复用、握手模式和流量模式参数,具体字段仍须由固定版本核心校验。导入内容里的代理链必须引用同一来源内的具体节点,选择分组和 DIRECT 链路会被拒绝。界面配置的代理链可以组合不同来源的节点。
22新增:
23新增:### 在界面中配置代理链
24新增:
25新增:住宅代理无法从国内直接连接时,在「节点」页选择「链式代理」,将国内可连接的代理设为中转,将住宅代理设为最终出口。列表按流量顺序展示,例如「Cage → 中转节点 → 住宅代理 → 目标网站」。最终出口决定目标网站看到的 IP;节点名称与协议不能证明其出口属于住宅网络。可继续添加中转,节点不得重复。下拉选项在容器内展开,撑开页面;支持键盘选择与收起。
26新增:
27新增:节点列表用于选择最终出口,修改后须点击「应用代理」生效。配置区、当前链路摘要分别显示草稿与已保存的配置,修改期间当前链路继续工作。应用前会验证整条链路的配置;生效时沿用关闭旧连接、更新配置版本与重新检查出口的流程。配置验证或核心启动失败时保留原有保存配置,核心启动失败后可能处于停止状态,需要重试。新配置启动后若出口检查失败,保留新配置并关闭业务外网,待修复后重新检测;不因此直连或绕过中转。订阅参数校验通过与核心启动成功均不代表远端链路连通,仍须检查实际出口。
28新增:
29新增:界面代理链以可选的 `chain` 节点 ID 列表独立保存,按入口到出口排序,`selected` 指向最后一跳。生成运行配置时,复制节点字段并按顺序覆盖每一跳的 `dialer-proxy`,第一跳清除原有前置代理;订阅原文和凭据保持不变。单节点模式显式保存一个节点并清除该节点原有前置代理。旧配置没有 `chain` 时继续遵循已导入的代理链,状态接口返回其实际顺序。
30新增:
31新增:订阅更新按稳定节点 ID 保留界面链路。如果更新移除了链路中的节点,拒绝该更新并保留最后可用来源;删除多节点链路正在使用的来源时,要求先应用其他配置。已明确选择单节点时可删除其来源,随后停止代理并保持离线。不会静默删掉中转或更换最终出口。
2232
2333每份导入内容最多 8 MiB,全部来源保存后的 JSON 总量最多 32 MiB。累计超限时拒绝保存并保留原文件,用户仍可查看或删除已有来源。
2434
2535默认手动选择固定节点,与现有出口 IP 变化规则协作。自动测速可以提供建议;自动切换和负载均衡涉及出口变化,需单独设计准入流程,首版不静默启用。
2636
37新增:节点列表和工作台状态栏共用 HTTPS `www.gstatic.com/generate_204` 延迟检测,核心固定开启 `unified-delay`。第二次 HEAD 请求成功时,显示已建立连接上的 HTTP 往返耗时;首次建连和握手仍会发生,但不计入该数值。核心在第二次请求失败时会回退首轮计时,因此界面说明为“通常不含建连开销”。延迟不代表带宽、网页首开耗时或环境已经放行。核心就绪检查同时核对这一设置,旧口径的运行实例需在应用代理时重新生成配置并启动。
38新增:
2739## 流量与模块职责
2840
2941```text
@@ -98,7 +110,7 @@ Cage 业务 DNS 继续通过选定节点发送,不回退主机解析器。订
98110
99111`internal/managedproxy` 维护来源、运行配置、下载与核心控制;`internal/cage/egress.go` 及网络准入负责业务出口;`internal/workbench/proxy.go` 承接经工作台认证的管理接口;`ui/src/proxy-settings.jsx` 提供节点、订阅、连接及诊断页面。`scripts/fetch-proxy-core.sh` 固定核心制品,`scripts/build-app.sh` 将其随 App 分发。节点管理器是唯一出口配置来源,网络设置仅提供加密 DNS,不接受手工指定本地出口地址。`proxy_url` 与 `proxy_revision` 是管理器生成的内部字段,通用设置和配置恢复无法覆盖它们。未选节点、未应用或配置版本不一致时,启动、探测和网络授权均拒绝放行。
100112
101删除:来源与核心操作使用工作台已有的串行任务机制。管理接口包括 `GET /api/proxy`、`POST /api/proxy/{import,refresh,edit,delete,select,restart,stop}`、`POST /api/proxy/delay` 及连接和诊断摘要的 GET 接口。前端不能传入任意核心控制路径。订阅 URL、认证和节点原始参数只存在私有来源文件中,GET 状态只返回来源主机名及节点显示信息。
113新增:来源与核心操作使用工作台已有的串行任务机制。管理接口包括 `GET /api/proxy`、`POST /api/proxy/{import,refresh,edit,delete,select,route,restart,stop}`、`POST /api/proxy/delay` 及连接和诊断摘要的 GET 接口。前端不能传入任意核心控制路径。订阅 URL、认证和节点原始参数只存在私有来源文件中,GET 状态只返回来源主机名、节点显示信息与脱敏的有序 `route` 节点 ID。`route` 操作以 `node_ids` 提交完整链路,统一校验并应用;不会逐个修改已在使用的节点。
102114
103115验收必须覆盖:未安装 Clash 时从导入到客机联网;与本机 Clash 系统代理/TUN 分别共存;订阅更新失败与选中节点被移除;真实节点切换后旧连接关闭、旧报告失效;核心崩溃后业务和 DNS 均无直连回退;App 停止、退出、保留运行和重新进入;凭据及管理接口未向 guest 暴露。模拟测试和核心延迟测试不能代替这些安装版路径。
104116
修改docs/getting-started.md+5 −1看文件
@@ -34,7 +34,11 @@
3434- **本地 YAML**:选择文件,或粘贴配置内容。适合已经导出节点配置的情况。
3535- **手动节点**:填写自己的 HTTP 或 SOCKS5 节点参数;用户名和密码在对应字段中填写。
3636
37删除:点击“导入并验证”,再进入“节点”,点击要使用的节点。顶部会显示当前节点和准确状态:核心运行但环境未启动时显示“待启动环境”,检查通过后显示“已联网”;核心停止或未应用节点时不会放行外网。
37新增:点击“导入并验证”,再进入“节点”,选择最终出口并点击“应用代理”。顶部会显示当前出口和准确状态:核心运行但环境未启动时显示“待启动环境”,检查通过后显示“已联网”;核心停止或未应用节点时不会放行外网。
38新增:
39新增:如果住宅代理无法从国内直接连接,在“节点”页切换到“链式代理”,选择国内可连接的中转节点,再将住宅代理选为“最终出口”。节点可以来自不同订阅;按页面从上到下的顺序连接,预览应显示“Cage → 中转节点 → 住宅代理 → 目标网站”。点击“应用代理”后生效,网站看到的是最终出口的 IP。若需要多次中转,可点击“添加中转”。
40新增:
41新增:代理组合会独立保存,订阅更新不会覆盖它;更新移除了正在使用的节点时,会保留原配置并显示错误。应用前的选择只是草稿,离开页面会提示是否放弃。“保存设置”用于 DNS、IP 变化规则等其他设置;代理使用配置区内的“应用代理”。
3842
3943订阅应包含 `proxies` 或 `payload` 节点内容。Base64 列表、单个分享链接以及仅含远程 provider 的配置暂不支持;请向服务提供方获取 Clash/Mihomo YAML 节点订阅,或导出本地 YAML。导入只采用节点与明确的代理链,配置中的系统代理、TUN、端口及直连规则不会应用到 Cage。
4044
新增docs/releases/0.1.5-alpha.2.md+23 −0看文件
@@ -0,0 +1,23 @@
1新增:# Cage v0.1.5-alpha.2
2新增:
3新增:代理设置可以直接组合中转与最终出口,无需编辑 YAML。选择链式代理后,节点按实际连接顺序排列,并显示目标网站看到的最终出口;支持跨订阅组合。配置完成后统一应用,订阅更新保留组合,失败时保留可重试的草稿。
4新增:
5新增:本版本还包含以下改进:
6新增:
7新增:- 将 IP 变化规则并入网络与代理页面,网络检查中的出口规则入口也指向同一位置;完善帮助、内嵌选择及未应用修改的离开提示。
8新增:- 代理与状态栏统一 HTTP 往返延迟口径,说明通常不含建连开销,与网页首开耗时区分。
9新增:- 调整代理连接与加密 DNS 的超时处理,在当前代理内重试,不回退主机直连。
10新增:- 环境准备失败后可以利用已有文件重试;镜像与工具下载支持经过摘要验证的缓存和续传,工具安装避免重复下载。
11新增:- 更新宣传片源码、横竖版界面素材与社交配图。
12新增:
13新增:## 安装与更新
14新增:
15新增:macOS 提供 Apple Silicon、macOS 14 或更新版本的 Developer ID 签名、公证 DMG。Windows 沿用 x64 未签名预览安装器,需要手动安装和更新,不进入签名自动更新通道。Linux 提供 Debian 12 / Ubuntu 24.04 x86_64 DEB,使用系统包管理器安装和更新。
16新增:
17新增:升级前保存文件、停止环境并退出 Cage。账户、订阅、收藏、项目和持久虚拟机数据保留。三平台附件共用 SHA256SUMS,同时提供 Mihomo 与 QEMU 主程序对应源码。
18新增:
19新增:## 验证范围
20新增:
21新增:本地通过完整 Go 测试、相关 race 检查、前端 lint / 50 项测试 / 构建、48 项发布流程测试。真实控制服务与随附 Mihomo 验证了本地双跳、单节点切换和出口故障时没有直连回退;界面验证跨来源选择、键盘操作、草稿保留、失败重试、离开确认和窄屏。macOS 更新器验证签名、失败回滚和数据保留,本机安装后原账户与关键数据保留。
22新增:
23新增:公开发行前,还须在对应提交完成三平台 CI、macOS 最终 DMG 的签名公证与匿名下载验证,并通过官网检查。实际完成情况与源码提交记录在本次 GitHub Release 中;未完成的项目不能据本说明视为通过。真实住宅节点、公网 Claude 请求、全新 Mac 首次启动、Windows 10/11 和 Linux/KVM 桌面仍需实机验收。
修改docs/troubleshooting.md+10 −0看文件
@@ -63,6 +63,16 @@ Cage 需要先选择自己的代理。首次首页点击“配置网络与代理
6363
6464第一次会下载 Linux 镜像并安装开发工具,速度取决于网络。点击“操作详情”查看当前阶段和错误;如果仍在下载或安装,保留窗口等待。失败后先检查代理节点和磁盘空间,再重新启动。
6565
66新增:固定摘要的 Linux 镜像,以及 code-server、mise、Claude Code 原生包,会保留未完成下载并有限重试。再次启动时会尝试续传;服务器不支持续传时重新下载该文件。完整校验通过后才使用文件。APT 使用自己的软件包缓存与下载重试机制。不要清空个人数据目录或重建账户来处理下载失败。
67新增:
68新增:| 操作详情中的错误 | 处理方式 |
69新增:| --- | --- |
70新增:| `Guest DNS could not resolve deb.debian.org` | 客机未能解析 Debian 下载地址。检查“网络与代理”的节点与 DNS 设置,应用后重试。宿主浏览器能上网不足以证明此通路可用;更换 DoH 地址后仍通过同一代理访问。 |
71新增:| `Download interrupted; partial data is saved` 或 `partial data retained` | 未完成文件已保留,网络恢复后重试。操作详情会显示重试次数或已保存的字节数。 |
72新增:| `checksum mismatch` | 文件未通过完整性校验,安装被拒绝,损坏的未完成文件会移除。重试会重新下载,不应跳过校验。 |
73新增:| NodeSource 公钥下载失败 | 下载会有限重试,成功前保留已有公钥。持续失败时检查节点到 `deb.nodesource.com` 的连接后重试。 |
74新增:| `APT failed`,后面有 `oom_kill before` / `after` | 安装器记录了失败前后的 OOM 计数、失败时的内存摘要与内核 OOM 日志。导出诊断包供维护者判断;计数增加表示该时段客机发生过 OOM,具体被终止的进程以内核日志为准。 |
75新增:
6676正在启动或检查时可以停止环境。网络设置需要重启时,先保存文件;不要同时运行多个安装副本或手动修改运行中的私有配置。
6777
6878## 节点已经应用,但外网仍然离线
修改internal/cage/egress.go+36 −7看文件
@@ -150,30 +150,59 @@ func (e *Egress) ExchangeDNS(ctx context.Context, q *dns.Msg) (*dns.Msg, error)
150150 if err != nil {
151151 return nil, err
152152 }
153新增: // Keep the original total deadline, but allow a fresh connection after an
154新增: // intermittent EOF or overloaded DoH server. Every attempt uses this same
155新增: // proxy-only transport and the configured endpoint.
156新增: ctx, cancel := context.WithTimeout(ctx, 20*time.Second)
157新增: defer cancel()
158新增: for attempt := 0; attempt < 3; attempt++ {
159新增: if ctx.Err() != nil {
160新增: return nil, ctx.Err()
161新增: }
162新增: attemptCtx, done := context.WithTimeout(ctx, 6*time.Second)
163新增: var answer *dns.Msg
164新增: var retry bool
165新增: answer, retry, err = e.exchangeDNSOnce(attemptCtx, q, wire)
166新增: done()
167新增: if err == nil || !retry {
168新增: return answer, err
169新增: }
170新增: if attempt < 2 {
171新增: select {
172新增: case <-ctx.Done():
173新增: return nil, ctx.Err()
174新增: case <-time.After(time.Duration(attempt+1) * 150 * time.Millisecond):
175新增: }
176新增: }
177新增: }
178新增: return nil, err
179新增:}
180新增:
181新增:func (e *Egress) exchangeDNSOnce(ctx context.Context, q *dns.Msg, wire []byte) (*dns.Msg, bool, error) {
153182 req, err := http.NewRequestWithContext(ctx, http.MethodPost, e.dnsURL, bytes.NewReader(wire))
154183 if err != nil {
155删除: return nil, errors.New("invalid DNS request")
184新增: return nil, false, errors.New("invalid DNS request")
156185 }
157186 req.Header.Set("Content-Type", "application/dns-message")
158187 req.Header.Set("Accept", "application/dns-message")
159188 resp, err := e.client.Do(req)
160189 if err != nil {
161删除: return nil, errors.New("cage DNS upstream unavailable")
190新增: return nil, true, errors.New("cage DNS upstream unavailable; check the configured DoH endpoint through the selected proxy")
162191 }
163192 defer resp.Body.Close()
164193 if resp.StatusCode != 200 {
165删除: return nil, fmt.Errorf("cage DNS upstream returned HTTP %d", resp.StatusCode)
194新增: return nil, resp.StatusCode == 429 || resp.StatusCode >= 500, fmt.Errorf("cage DNS upstream returned HTTP %d", resp.StatusCode)
166195 }
167196 body, err := io.ReadAll(io.LimitReader(resp.Body, 65536))
168197 if err != nil {
169删除: return nil, err
198新增: return nil, true, errors.New("incomplete DNS upstream response")
170199 }
171200 r := new(dns.Msg)
172201 if err = r.Unpack(body); err != nil {
173删除: return nil, errors.New("invalid DNS upstream response")
202新增: return nil, false, errors.New("invalid DNS upstream response")
174203 }
175204 if !r.Response || r.Id != q.Id {
176删除: return nil, errors.New("mismatched DNS upstream response")
205新增: return nil, false, errors.New("mismatched DNS upstream response")
177206 }
178删除: return r, nil
207新增: return r, false, nil
179208}
修改internal/cage/egress_test.go+54 −0看文件
@@ -180,6 +180,60 @@ func TestDNSUsesProxyAndNoFallback(t *testing.T) {
180180 }
181181}
182182
183新增:func TestDNSRetriesOnlyTransientFailuresThroughSameProxy(t *testing.T) {
184新增: for _, status := range []int{503, 429, 400} {
185新增: t.Run(http.StatusText(status), func(t *testing.T) {
186新增: var requests atomic.Int32
187新增: doh := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
188新增: if requests.Add(1) <= 2 {
189新增: w.WriteHeader(status)
190新增: return
191新增: }
192新增: body, _ := io.ReadAll(r.Body)
193新增: q := new(dns.Msg)
194新增: if err := q.Unpack(body); err != nil {
195新增: t.Error(err)
196新增: return
197新增: }
198新增: answer := new(dns.Msg).SetReply(q)
199新增: body, _ = answer.Pack()
200新增: w.Write(body)
201新增: }))
202新增: defer doh.Close()
203新增: p, connects := testProxy(t)
204新增: defer p.Close()
205新增: c := DefaultConfig()
206新增: c.ProxyURL, c.DNSURL = p.URL, doh.URL
207新增: e, err := NewEgress(c)
208新增: if err != nil {
209新增: t.Fatal(err)
210新增: }
211新增: defer e.client.CloseIdleConnections()
212新增: e.client.Transport.(*http.Transport).TLSClientConfig = &tls.Config{RootCAs: doh.Client().Transport.(*http.Transport).TLSClientConfig.RootCAs}
213新增: _, err = e.ExchangeDNS(t.Context(), new(dns.Msg).SetQuestion("example.com.", dns.TypeA))
214新增: if status == 400 {
215新增: if err == nil || requests.Load() != 1 {
216新增: t.Fatalf("permanent failure retried: %v, %d", err, requests.Load())
217新增: }
218新增: } else if err != nil || requests.Load() != 3 {
219新增: t.Fatalf("transient failure not recovered: %v, %d", err, requests.Load())
220新增: }
221新增: if connects.Load() == 0 {
222新增: t.Fatal("DNS bypassed proxy")
223新增: }
224新增: ctx, cancel := context.WithCancel(t.Context())
225新增: cancel()
226新增: before := requests.Load()
227新增: if _, err := e.ExchangeDNS(ctx, new(dns.Msg).SetQuestion("example.com.", dns.TypeA)); err == nil {
228新增: t.Fatal("cancel ignored")
229新增: }
230新增: if requests.Load() != before {
231新增: t.Fatal("cancelled lookup sent request")
232新增: }
233新增: })
234新增: }
235新增:}
236新增:
183237func TestRejectHostLANAndUDP(t *testing.T) {
184238 e, _ := NewEgress(DefaultConfig())
185239 for _, addr := range []string{"127.0.0.1:80", "10.0.0.1:80", "192.168.1.1:80", "169.254.169.254:80", "[::1]:80", "[::ffff:127.0.0.1]:80", "100.64.0.1:80"} {
修改internal/cage/guest-tools.sh+81 −8看文件
@@ -1,5 +1,72 @@
1新增:# shellcheck shell=bash
12# Functions are shared by first installation and an explicit in-place upgrade.
23# Each invocation owns its staging files and leaves caller traps unchanged.
4新增:# Keep only version-shaped tokens; first-run notices can precede --version.
5新增:# Read all output so pipefail cannot turn an early reader exit into SIGPIPE.
6新增:cage_tool_version() {
7新增: awk '$1 ~ /^v?[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$/ && !found { print $1; found=1 }'
8新增:}
9新增:
10新增:# The caller holds the checksum directory lock. Partial files survive a failed
11新增:# attempt; only a complete checksum-verified artifact is eligible for install.
12新增:cage_download_tool() (
13新增: set -euo pipefail
14新增: local url="$1" checksum="$2" artifact="$3" hash="${4:-sha256sum}" attempt status http
15新增: if [ -f "$artifact" ]; then
16新增: if printf '%s %s\n' "$checksum" "$artifact" | "$hash" --check --status; then return 0; fi
17新增: rm -f "$artifact"
18新增: fi
19新增: for attempt in 1 2 3 4; do
20新增: printf 'Downloading %s (attempt %s/4; resume from %s bytes).\n' "${artifact##*/}" "$attempt" "$(if [ -f "$artifact.part" ]; then wc -c < "$artifact.part"; else echo 0; fi)"
21新增: if http="$(curl --proto '=https' --proto-redir '=https' --tlsv1.2 --fail --location \
22新增: --connect-timeout 15 --max-time 1800 --speed-limit 1024 --speed-time 60 \
23新增: --continue-at - --write-out '%{http_code}' "$url" -o "$artifact.part" </dev/null)"; then
24新增: status=0
25新增: else
26新增: status=$?
27新增: fi
28新增: # A previous attempt can have received the whole body before cancellation.
29新增: if [ "$status" = 0 ] || [ "$http" = 416 ]; then
30新增: if printf '%s %s\n' "$checksum" "$artifact.part" | "$hash" --check --status; then
31新增: mv -f "$artifact.part" "$artifact"
32新增: return 0
33新增: fi
34新增: rm -f "$artifact.part"
35新增: echo 'Tool checksum mismatch; installation refused. Retry downloads a fresh copy.' >&2
36新增: return 1
37新增: fi
38新增: case "$status" in
39新增: 33|36) rm -f "$artifact.part" ;; # Server cannot resume: next attempt starts at zero.
40新增: 5|6|7|18|28|35|52|55|56|92) ;; # Connection, partial body, TLS EOF or timeout.
41新增: 22) case "$http" in 408|429|500|502|503|504) ;; *) return "$status" ;; esac ;;
42新增: *) return "$status" ;;
43新增: esac
44新增: if [ "$attempt" != 4 ]; then sleep "$attempt"; fi
45新增: done
46新增: echo 'Download interrupted; partial data is saved. Retry setup to continue.' >&2
47新增: return "$status"
48新增:)
49新增:
50新增:# npm caches verified tarballs by their integrity. Populate it as the same
51新增:# guest user that installs Claude, so a setup retry does not fetch its large
52新增:# optional native package again. npm remains responsible for dependency setup.
53新增:cage_cache_claude() (
54新增: set -euo pipefail
55新增: local arch="$1" wanted="$2" package metadata integrity checksum url cache
56新增: case "$arch" in arm64) package=claude-code-linux-arm64 ;; amd64) package=claude-code-linux-x64 ;; esac
57新增: metadata="$(npm view --registry=https://registry.npmjs.org "@anthropic-ai/$package@$wanted" dist --json </dev/null)"
58新增: integrity="$(printf '%s' "$metadata" | jq -er '.integrity | select(startswith("sha512-"))')"
59新增: checksum="$(printf '%s' "${integrity#sha512-}" | base64 -d | od -An -v -tx1 | tr -d ' \n')"
60新增: [[ "$checksum" =~ ^[0-9a-f]{128}$ ]]
61新增: url="$(printf '%s' "$metadata" | jq -er '.tarball | select(startswith("https://registry.npmjs.org/"))')"
62新增: cache="$HOME/.cache/cage/downloads/$checksum"
63新增: mkdir -p "$cache"
64新增: exec 9>"$cache/lock"
65新增: flock -w 60 9
66新增: cage_download_tool "$url" "$checksum" "$cache/$package.tgz" sha512sum
67新增: npm cache add --offline --ignore-scripts "$cache/$package.tgz" </dev/null
68新增:)
69新增:
370cage_install_tool() (
471 set -euo pipefail
572 local tool="$1" arch current='' wanted url checksum artifact
@@ -8,21 +75,21 @@ cage_install_tool() (
875 case "$tool" in
976 code-server)
1077 wanted="$CAGE_CODE_SERVER_VERSION"
11删除: if command -v code-server >/dev/null; then current="$(code-server --version | head -n1 | cut -d' ' -f1)"; fi
78新增: if command -v code-server >/dev/null; then current="$(code-server --version | cage_tool_version)" || current=''; fi
1279 url="https://github.com/coder/code-server/releases/download/v$wanted/code-server_${wanted}_${arch}.deb"
1380 if [ "$arch" = arm64 ]; then checksum="$CAGE_CODE_SERVER_ARM64_SHA256"; else checksum="$CAGE_CODE_SERVER_AMD64_SHA256"; fi
1481 artifact=code-server.deb
1582 ;;
1683 mise)
1784 wanted="$CAGE_MISE_VERSION"
18删除: if [ -x "$HOME/.local/bin/mise" ]; then current="$("$HOME/.local/bin/mise" --version | head -n1 | cut -d' ' -f1)"; fi
85新增: if [ -x "$HOME/.local/bin/mise" ]; then current="$("$HOME/.local/bin/mise" --version | cage_tool_version)" || current=''; fi
1986 if [ "$arch" = arm64 ]; then checksum="$CAGE_MISE_ARM64_SHA256"; else checksum="$CAGE_MISE_AMD64_SHA256"; fi
2087 url="https://github.com/jdx/mise/releases/download/v$wanted/mise-v$wanted-linux-$(if [ "$arch" = arm64 ]; then echo arm64; else echo x64; fi).tar.gz"
2188 artifact=mise.tar.gz
2289 ;;
2390 claude)
2491 wanted="$CAGE_CLAUDE_VERSION"
25删除: if command -v claude >/dev/null; then current="$(DISABLE_AUTOUPDATER=1 claude --version | head -n1 | cut -d' ' -f1)"; fi
92新增: if command -v claude >/dev/null; then current="$(DISABLE_AUTOUPDATER=1 claude --version | cage_tool_version)" || current=''; fi
2693 ;;
2794 *) echo 'Unknown Cage tool.' >&2; exit 2 ;;
2895 esac
@@ -31,17 +98,23 @@ cage_install_tool() (
3198 exit 0
3299 fi
33100 if [ "$tool" = claude ]; then
34删除: npm install --prefix "$HOME/.local" --global "@anthropic-ai/claude-code@$wanted" </dev/null
101新增: export npm_config_fetch_retries=3 npm_config_fetch_timeout=120000
102新增: cage_cache_claude "$arch" "$wanted"
103新增: npm install --registry=https://registry.npmjs.org --prefix "$HOME/.local" --global "@anthropic-ai/claude-code@$wanted" </dev/null
35104 exit 0
36105 fi
106新增: local cache="$HOME/.cache/cage/downloads/$checksum" stage
107新增: mkdir -p "$cache"
108新增: # First setup and maintenance can both reach this helper in a Linux guest.
109新增: exec 9>"$cache/lock"
110新增: flock -w 60 9
111新增: cage_download_tool "$url" "$checksum" "$cache/$artifact"
37112 stage="$(mktemp -d)"
38113 trap 'rm -rf "$stage"' EXIT
39删除: curl --proto '=https' --tlsv1.2 --fail --location --retry 3 --connect-timeout 15 --max-time 600 "$url" -o "$stage/$artifact"
40删除: printf '%s %s\n' "$checksum" "$stage/$artifact" | sha256sum --check --status || { echo 'Tool checksum mismatch; installation refused.' >&2; exit 1; }
41114 if [ "$tool" = code-server ]; then
42删除: sudo env DEBIAN_FRONTEND=noninteractive APT_CONFIG="${CAGE_APT_CONFIG:-/dev/null}" apt-get install -y --no-install-recommends "$stage/$artifact" </dev/null
115新增: sudo env DEBIAN_FRONTEND=noninteractive APT_CONFIG="${CAGE_APT_CONFIG:-/dev/null}" apt-get -o Acquire::Retries=3 install -y --no-install-recommends "$cache/$artifact" </dev/null
43116 else
44删除: tar -xzf "$stage/$artifact" -C "$stage"
117新增: tar -xzf "$cache/$artifact" -C "$stage"
45118 mkdir -p "$HOME/.local/bin"
46119 install -m 0755 "$stage/mise/bin/mise" "$HOME/.local/bin/.mise-new"
47120 mv -f "$HOME/.local/bin/.mise-new" "$HOME/.local/bin/mise"
修改internal/cage/guest_versions_test.go+186 −1看文件
@@ -1,10 +1,19 @@
11package cage
22
33import (
4新增: "crypto/sha256"
5新增: "crypto/sha512"
6新增: "encoding/base64"
7新增: "encoding/pem"
8新增: "fmt"
9新增: "net/http"
10新增: "net/http/httptest"
411 "os"
512 "os/exec"
613 "path/filepath"
14新增: "runtime"
715 "strings"
16新增: "sync/atomic"
817 "testing"
918)
1019
@@ -42,6 +51,108 @@ esac
4251 }
4352}
4453
54新增:func TestToolDownloadWithRealCurlAndTLS(t *testing.T) {
55新增: if _, err := exec.LookPath("curl"); err != nil {
56新增: t.Skip("curl unavailable")
57新增: }
58新增: dir := t.TempDir()
59新增: if _, err := exec.LookPath("sha256sum"); err != nil || runtime.GOOS == "darwin" {
60新增: if _, err := exec.LookPath("shasum"); err != nil {
61新增: t.Skip("SHA-256 tool unavailable")
62新增: }
63新增: if err := os.WriteFile(filepath.Join(dir, "sha256sum"), []byte("#!/bin/sh\nexec shasum -a 256 \"$@\"\n"), 0755); err != nil {
64新增: t.Fatal(err)
65新增: }
66新增: }
67新增: data := "complete download bytes"
68新增: var calls atomic.Int32
69新增: s := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
70新增: if calls.Add(1) == 1 {
71新增: w.Header().Set("Content-Length", fmt.Sprint(len(data)))
72新增: fmt.Fprint(w, data[:5])
73新增: return
74新增: }
75新增: if r.Header.Get("Range") != "bytes=5-" {
76新增: t.Errorf("range: %q", r.Header.Get("Range"))
77新增: }
78新增: w.Header().Set("Content-Range", fmt.Sprintf("bytes 5-%d/%d", len(data)-1, len(data)))
79新增: w.WriteHeader(206)
80新增: fmt.Fprint(w, data[5:])
81新增: }))
82新增: defer s.Close()
83新增: ca := filepath.Join(dir, "ca.pem")
84新增: if err := os.WriteFile(ca, pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: s.Certificate().Raw}), 0600); err != nil {
85新增: t.Fatal(err)
86新增: }
87新增: hash := sha256.Sum256([]byte(data))
88新增: cmd := exec.Command("bash", "-c", "set -euo pipefail\n"+ToolInstallPrelude()+`cage_download_tool "$DOWNLOAD_URL" "$DOWNLOAD_HASH" "$HOME/package"
89新增:cage_download_tool "$DOWNLOAD_URL" "$DOWNLOAD_HASH" "$HOME/package"`)
90新增: cmd.Env = append(os.Environ(), "HOME="+dir, "PATH="+dir+":"+os.Getenv("PATH"), "CURL_CA_BUNDLE="+ca, "DOWNLOAD_URL="+s.URL, fmt.Sprintf("DOWNLOAD_HASH=%x", hash), "NO_PROXY=127.0.0.1", "no_proxy=127.0.0.1")
91新增: if out, err := cmd.CombinedOutput(); err != nil {
92新增: t.Fatalf("%v %s", err, out)
93新增: }
94新增: got, err := os.ReadFile(filepath.Join(dir, "package"))
95新增: if err != nil || string(got) != data || calls.Load() != 2 {
96新增: t.Fatalf("%q %v calls=%d", got, err, calls.Load())
97新增: }
98新增:}
99新增:
100新增:func TestClaudeNativeCacheUsesGuestArchitectureAndIntegrity(t *testing.T) {
101新增: if _, err := exec.LookPath("jq"); err != nil {
102新增: t.Skip("jq unavailable")
103新增: }
104新增: for _, arch := range []string{"arm64", "amd64"} {
105新增: t.Run(arch, func(t *testing.T) {
106新增: dir := t.TempDir()
107新增: hash := sha512.Sum512([]byte("native-package"))
108新增: packageName := "claude-code-linux-arm64"
109新增: if arch == "amd64" {
110新增: packageName = "claude-code-linux-x64"
111新增: }
112新增: commands := map[string]string{
113新增: "dpkg": "#!/bin/sh\nif [ \"$1\" = --print-architecture ]; then echo \"$TEST_ARCH\"; else exit 1; fi\n",
114新增: "claude": "#!/bin/sh\necho 1.0.0\n",
115新增: "flock": "#!/bin/sh\nexit 0\n",
116新增: "curl": "#!/bin/sh\nwhile [ \"$#\" -gt 0 ]; do if [ \"$1\" = -o ]; then shift; printf native-package > \"$1\"; printf 200; exit; fi; shift; done\nexit 1\n",
117新增: "npm": `#!/bin/sh
118新增:case "$1" in
119新增:view)
120新增: test "$3" = "@anthropic-ai/[email protected]" || exit 91
121新增: printf '{"integrity":"sha512-%s","tarball":"https://registry.npmjs.org/%s.tgz"}' "$TEST_INTEGRITY" "$TEST_PACKAGE";;
122新增:cache)
123新增: test "$2 $3 $4" = 'add --offline --ignore-scripts' || exit 92
124新增: test "$(cat "$5")" = native-package || exit 93
125新增: printf cached > "$HOME/cached";;
126新增:install)
127新增: test -f "$HOME/cached" || exit 94
128新增: printf installed > "$HOME/installed";;
129新增:*) exit 95;;
130新增:esac
131新增:`,
132新增: }
133新增: if _, err := exec.LookPath("sha512sum"); err != nil || runtime.GOOS == "darwin" {
134新增: if _, err := exec.LookPath("shasum"); err != nil {
135新增: t.Skip("SHA-512 tool unavailable")
136新增: }
137新增: commands["sha512sum"] = "#!/bin/sh\nexec shasum -a 512 \"$@\"\n"
138新增: }
139新增: for name, body := range commands {
140新增: if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0755); err != nil {
141新增: t.Fatal(err)
142新增: }
143新增: }
144新增: cmd := exec.Command("bash", "-c", ToolInstallPrelude()+"cage_install_tool claude")
145新增: cmd.Env = append(os.Environ(), "HOME="+dir, "PATH="+dir+":"+os.Getenv("PATH"), "TEST_ARCH="+arch, "TEST_PACKAGE="+packageName, "TEST_INTEGRITY="+base64.StdEncoding.EncodeToString(hash[:]))
146新增: if out, err := cmd.CombinedOutput(); err != nil {
147新增: t.Fatalf("%v %s", err, out)
148新增: }
149新增: if _, err := os.Stat(filepath.Join(dir, "installed")); err != nil {
150新增: t.Fatal(err)
151新增: }
152新增: })
153新增: }
154新增:}
155新增:
45156func TestGeneratedGuestScriptsParseAsBash(t *testing.T) {
46157 for name, script := range map[string]string{"start": DefaultConfig().StartScript(), "tools": ToolsUpdateScript(), "first-install-functions": ToolInstallPrelude()} {
47158 t.Run(name, func(t *testing.T) {
@@ -57,6 +168,7 @@ func TestGeneratedGuestScriptsParseAsBash(t *testing.T) {
57168func TestPinnedToolInstallerRejectsWrongHashBeforeInstalling(t *testing.T) {
58169 dir := t.TempDir()
59170 commands := map[string]string{
171新增: "flock": "#!/bin/sh\nexit 0\n",
60172 "dpkg": "#!/bin/sh\nif [ \"$1\" = --print-architecture ]; then echo arm64; else exit 1; fi\n",
61173 "code-server": "#!/bin/sh\necho 1.0.0\n",
62174 "curl": "#!/bin/sh\nwhile [ \"$#\" -gt 0 ]; do if [ \"$1\" = -o ]; then shift; printf altered-package > \"$1\"; exit; fi; shift; done\nexit 1\n",
@@ -70,7 +182,7 @@ func TestPinnedToolInstallerRejectsWrongHashBeforeInstalling(t *testing.T) {
70182 }
71183 installed := filepath.Join(dir, "installed")
72184 cmd := exec.Command("bash", "-c", ToolInstallPrelude()+"\ncage_install_tool code-server")
73删除: cmd.Env = append(os.Environ(), "PATH="+dir+":"+os.Getenv("PATH"), "AUDIT_INSTALL="+installed)
185新增: cmd.Env = append(os.Environ(), "HOME="+dir, "PATH="+dir+":"+os.Getenv("PATH"), "AUDIT_INSTALL="+installed)
74186 out, err := cmd.CombinedOutput()
75187 if err == nil || !strings.Contains(string(out), "checksum mismatch") {
76188 t.Fatalf("changed download accepted: %v %s", err, out)
@@ -79,3 +191,76 @@ func TestPinnedToolInstallerRejectsWrongHashBeforeInstalling(t *testing.T) {
79191 t.Fatal("installer ran before verifying the artifact")
80192 }
81193}
194新增:
195新增:func TestPinnedToolVersionIgnoresFirstRunNotices(t *testing.T) {
196新增: for _, version := range []string{"4.144.0", "v4.144.1", "4.144.0-rc.1"} {
197新增: t.Run(version, func(t *testing.T) {
198新增: dir := t.TempDir()
199新增: commands := map[string]string{
200新增: "code-server": "#!/bin/sh\nprintf '%s\\n' '[2026-11-05T14:58:49.600Z] info Wrote default config file' '" + version + " commit with Code 1.144.0'\n",
201新增: "dpkg": "#!/bin/sh\nif [ \"$1\" = --print-architecture ]; then echo arm64; else test \"$2\" = \"${EXPECTED_VERSION#v}\"; fi\n",
202新增: "curl": "#!/bin/sh\necho unexpected-download >&2\nexit 90\n",
203新增: }
204新增: for name, body := range commands {
205新增: if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0755); err != nil {
206新增: t.Fatal(err)
207新增: }
208新增: }
209新增: cmd := exec.Command("bash", "-c", ToolInstallPrelude()+"\ncage_install_tool code-server")
210新增: cmd.Env = append(os.Environ(), "HOME="+dir, "PATH="+dir+":"+os.Getenv("PATH"), "EXPECTED_VERSION="+version)
211新增: out, err := cmd.CombinedOutput()
212新增: if err != nil || !strings.Contains(string(out), "already meets") {
213新增: t.Fatalf("%v: %s", err, out)
214新增: }
215新增: })
216新增: }
217新增:}
218新增:
219新增:func TestToolDownloadKeepsPartialAndResumes(t *testing.T) {
220新增: dir := t.TempDir()
221新增: commands := map[string]string{
222新增: "sleep": "#!/bin/sh\nexit 0\n",
223新增: "curl": `#!/bin/sh
224新增:while [ "$#" -gt 0 ]; do
225新增: case "$1" in -o) shift; artifact="$1";; --continue-at) shift; test "$1" = - || exit 99;; esac
226新增: shift
227新增:done
228新增:if [ ! -f "$HOME/recover" ]; then
229新增: printf partial > "$artifact"
230新增: exit 56
231新增:fi
232新增:test "$(cat "$artifact")" = partial || exit 98
233新增:printf complete > "$artifact"
234新增:printf 206
235新增:`,
236新增: "sha256sum": "#!/bin/sh\nread checksum artifact\ntest \"$(cat \"$artifact\")\" = complete\n",
237新增: }
238新增: for name, body := range commands {
239新增: if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0755); err != nil {
240新增: t.Fatal(err)
241新增: }
242新增: }
243新增: run := func() ([]byte, error) {
244新增: cmd := exec.Command("bash", "-c", ToolInstallPrelude()+`cage_download_tool https://example.invalid/tool pinned "$HOME/package"`)
245新增: cmd.Env = append(os.Environ(), "HOME="+dir, "PATH="+dir+":"+os.Getenv("PATH"))
246新增: return cmd.CombinedOutput()
247新增: }
248新增: if out, err := run(); err == nil || !strings.Contains(string(out), "partial data is saved") {
249新增: t.Fatalf("%v %s", err, out)
250新增: }
251新增: if data, err := os.ReadFile(filepath.Join(dir, "package.part")); err != nil || string(data) != "partial" {
252新增: t.Fatal("partial lost", err)
253新增: }
254新增: if err := os.WriteFile(filepath.Join(dir, "recover"), nil, 0600); err != nil {
255新增: t.Fatal(err)
256新增: }
257新增: if out, err := run(); err != nil {
258新增: t.Fatalf("%v %s", err, out)
259新增: }
260新增: if data, err := os.ReadFile(filepath.Join(dir, "package")); err != nil || string(data) != "complete" {
261新增: t.Fatal("not published", err)
262新增: }
263新增: if _, err := os.Stat(filepath.Join(dir, "package.part")); !os.IsNotExist(err) {
264新增: t.Fatal("partial left after success")
265新增: }
266新增:}
修改internal/managedproxy/applied.go+3 −0看文件
@@ -14,5 +14,8 @@ func Applied(profile, endpoint, revision string) (Store, error) {
1414 if revision == "" || p.Revision == "" || revision != p.Revision || endpoint != p.Endpoint() {
1515 return p, errors.New("代理节点尚未应用或配置不一致,请重新应用节点;外网保持关闭")
1616 }
17新增: if _, err := p.Route(); err != nil {
18新增: return p, err
19新增: }
1720 return p, nil
1821}
修改internal/managedproxy/core.go+4 −3看文件
@@ -114,14 +114,15 @@ func API(ctx context.Context, profile, method, path string, body any, reply any)
114114}
115115func Running(ctx context.Context, profile string, s Store) bool {
116116 var cfg struct {
117删除: Port int `json:"mixed-port"`
118删除: Interface string `json:"interface-name"`
117新增: Port int `json:"mixed-port"`
118新增: Interface string `json:"interface-name"`
119新增: UnifiedDelay bool `json:"unified-delay"`
119120 }
120121 var group struct {
121122 Now string `json:"now"`
122123 }
123124 bound, err := BoundInterface(filepath.Join(Dir(profile), "config.yaml"))
124删除: return err == nil && bound != "" && API(ctx, profile, "GET", "/configs", nil, &cfg) == nil && cfg.Port == s.Port && cfg.Interface == bound && API(ctx, profile, "GET", "/proxies/"+Group, nil, &group) == nil && group.Now == s.Selected
125新增: return err == nil && bound != "" && API(ctx, profile, "GET", "/configs", nil, &cfg) == nil && cfg.Port == s.Port && cfg.Interface == bound && cfg.UnifiedDelay && API(ctx, profile, "GET", "/proxies/"+Group, nil, &group) == nil && group.Now == s.Selected
125126}
126127func label(profile string) string {
127128 h := sha256.Sum256([]byte(profile))
新增internal/managedproxy/latency_test.go+156 −0看文件
@@ -0,0 +1,156 @@
1新增:package managedproxy
2新增:
3新增:import (
4新增: "context"
5新增: "io"
6新增: "net"
7新增: "net/http"
8新增: "net/http/httptest"
9新增: "net/url"
10新增: "os"
11新增: "os/exec"
12新增: "path/filepath"
13新增: "strings"
14新增: "sync/atomic"
15新增: "testing"
16新增: "time"
17新增:
18新增: "go.yaml.in/yaml/v3"
19新增:)
20新增:
21新增:// This runs the bundled core against local servers. A slow CONNECT handshake
22新增:// must affect elapsed time without inflating the displayed request latency.
23新增:func TestCoreLatencyExcludesProxyHandshake(t *testing.T) {
24新增: if os.Getenv("CAGE_PROXY_INTEGRATION") != "1" {
25新增: t.Skip("requires a test binary beside the bundled Mihomo")
26新增: }
27新增: var requests, connections atomic.Int32
28新增: target := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
29新增: if r.Method != http.MethodHead {
30新增: t.Error("latency probe must use HEAD")
31新增: }
32新增: requests.Add(1)
33新增: w.WriteHeader(http.StatusNoContent)
34新增: }))
35新增: t.Cleanup(target.Close)
36新增: const handshake = 500 * time.Millisecond
37新增: upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
38新增: if r.Method != http.MethodConnect {
39新增: t.Error("expected proxy CONNECT")
40新增: w.WriteHeader(http.StatusMethodNotAllowed)
41新增: return
42新增: }
43新增: remote, err := net.Dial("tcp", strings.TrimPrefix(target.URL, "http://"))
44新增: if err != nil {
45新增: t.Error(err)
46新增: return
47新增: }
48新增: defer remote.Close()
49新增: client, buffered, err := w.(http.Hijacker).Hijack()
50新增: if err != nil {
51新增: t.Error(err)
52新增: return
53新增: }
54新增: defer client.Close()
55新增: connections.Add(1)
56新增: time.Sleep(handshake)
57新增: if _, err := io.WriteString(client, "HTTP/1.1 200 Connection Established\r\n\r\n"); err != nil {
58新增: return
59新增: }
60新增: go func() { _, _ = io.Copy(remote, buffered) }()
61新增: _, _ = io.Copy(client, remote)
62新增: }))
63新增: t.Cleanup(upstream.Close)
64新增:
65新增: profile := t.TempDir()
66新增: s, err := Load(profile)
67新增: if err != nil {
68新增: t.Fatal(err)
69新增: }
70新增: address := strings.TrimPrefix(upstream.URL, "http://")
71新增: _, port, _ := net.SplitHostPort(address)
72新增: if err := s.Import("local", "", []byte("proxies: [{name: local, type: http, server: 127.0.0.1, port: "+port+"}]"), "local", 0, ""); err != nil {
73新增: t.Fatal(err)
74新增: }
75新增: s.Selected, s.Port = s.Sources[0].Nodes[0].ID, 0
76新增: data, err := s.Runtime(profile)
77新增: if err != nil {
78新增: t.Fatal(err)
79新增: }
80新增: interfaces, err := net.Interfaces()
81新增: if err != nil {
82新增: t.Fatal(err)
83新增: }
84新增: loopback := ""
85新增: for _, iface := range interfaces {
86新增: if iface.Flags&net.FlagLoopback != 0 {
87新增: loopback = iface.Name
88新增: break
89新增: }
90新增: }
91新增: data, err = BindInterface(data, loopback)
92新增: if err != nil {
93新增: t.Fatal(err)
94新增: }
95新增: config := filepath.Join(Dir(profile), "config.yaml")
96新增: if err := Write(config, data); err != nil {
97新增: t.Fatal(err)
98新增: }
99新增: if err := os.MkdirAll(filepath.Dir(Socket(profile)), 0700); err != nil {
100新增: t.Fatal(err)
101新增: }
102新增: t.Cleanup(func() { _ = os.RemoveAll(filepath.Dir(Socket(profile))) })
103新增: core, err := CorePath()
104新增: if err != nil {
105新增: t.Fatal(err)
106新增: }
107新增: log, err := os.Create(filepath.Join(profile, "core.log"))
108新增: if err != nil {
109新增: t.Fatal(err)
110新增: }
111新增: cmd := exec.Command(core, "-d", Dir(profile), "-f", config)
112新增: cmd.Env, cmd.Stdout, cmd.Stderr = coreEnvironment(Dir(profile)), log, log
113新增: if err := cmd.Start(); err != nil {
114新增: log.Close()
115新增: t.Fatal(err)
116新增: }
117新增: t.Cleanup(func() { _ = cmd.Process.Kill(); _ = cmd.Wait(); _ = log.Close() })
118新增: ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
119新增: defer cancel()
120新增: ticker := time.NewTicker(20 * time.Millisecond)
121新增: defer ticker.Stop()
122新增: for !Running(ctx, profile, s) {
123新增: select {
124新增: case <-ctx.Done():
125新增: t.Fatal("generated configuration did not become ready")
126新增: case <-ticker.C:
127新增: }
128新增: }
129新增: var result struct {
130新增: Delay int `json:"delay"`
131新增: }
132新增: start := time.Now()
133新增: if err := API(ctx, profile, "GET", "/proxies/"+s.Selected+"/delay?timeout=5000&url="+url.QueryEscape(target.URL), nil, &result); err != nil {
134新增: t.Fatal(err)
135新增: }
136新增: elapsed := time.Since(start)
137新增: if result.Delay <= 0 || elapsed-time.Duration(result.Delay)*time.Millisecond < handshake-100*time.Millisecond || requests.Load() != 2 || connections.Load() != 1 {
138新增: t.Fatalf("delay=%dms elapsed=%s HEADs=%d connections=%d; expected two requests on one connection with handshake excluded", result.Delay, elapsed, requests.Load(), connections.Load())
139新增: }
140新增: t.Logf("reported=%dms elapsed=%s HEADs=%d CONNECTs=%d", result.Delay, elapsed, requests.Load(), connections.Load())
141新增: var legacy map[string]any
142新增: if err := yaml.Unmarshal(data, &legacy); err != nil {
143新增: t.Fatal(err)
144新增: }
145新增: legacy["unified-delay"] = false
146新增: legacyData, err := yaml.Marshal(legacy)
147新增: if err != nil {
148新增: t.Fatal(err)
149新增: }
150新增: if err := API(ctx, profile, "PUT", "/configs", map[string]string{"payload": string(legacyData)}, nil); err != nil {
151新增: t.Fatal(err)
152新增: }
153新增: if Running(ctx, profile, s) {
154新增: t.Fatal("core using the old latency metric was accepted for reuse")
155新增: }
156新增:}
新增internal/managedproxy/route_test.go+85 −0看文件
@@ -0,0 +1,85 @@
1新增:package managedproxy
2新增:
3新增:import (
4新增: "reflect"
5新增: "testing"
6新增:
7新增: "go.yaml.in/yaml/v3"
8新增:)
9新增:
10新增:func TestRouteOverridesAcrossSourcesWithoutRewritingSubscription(t *testing.T) {
11新增: profile := t.TempDir()
12新增: s, _ := Load(profile)
13新增: if err := s.Import("airport", "", []byte(testNodes), "airport", 0, ""); err != nil {
14新增: t.Fatal(err)
15新增: }
16新增: if err := s.Import("home", "", []byte(`proxies: [{name: home, type: socks5, server: 127.0.0.1, port: 1081, password: private-home}]`), "home", 0, ""); err != nil {
17新增: t.Fatal(err)
18新增: }
19新增: entry := s.Sources[0].Nodes[1] // Already has an imported dialer, which the explicit entry must override.
20新增: exit := s.Sources[1].Nodes[0]
21新增: s.Selected = exit.ID
22新增: s.Chain = []string{entry.ID, exit.ID}
23新增: data, err := s.Runtime(profile)
24新增: if err != nil {
25新增: t.Fatal(err)
26新增: }
27新增: var runtime struct {
28新增: Proxies []map[string]any `yaml:"proxies"`
29新增: }
30新增: if err := yaml.Unmarshal(data, &runtime); err != nil {
31新增: t.Fatal(err)
32新增: }
33新增: if runtime.Proxies[1]["dialer-proxy"] != nil || runtime.Proxies[2]["dialer-proxy"] != entry.ID {
34新增: t.Fatal("wrong entry/exit order", runtime.Proxies)
35新增: }
36新增: if s.Sources[0].Nodes[1].Config["dialer-proxy"] == nil || s.Sources[1].Nodes[0].Config["dialer-proxy"] != nil {
37新增: t.Fatal("runtime changed subscription nodes")
38新增: }
39新增: if err := s.Save(profile); err != nil {
40新增: t.Fatal(err)
41新增: }
42新增: loaded, err := Load(profile)
43新增: if err != nil {
44新增: t.Fatal(err)
45新增: }
46新增: if route, err := loaded.Route(); err != nil || !reflect.DeepEqual(route, s.Chain) {
47新增: t.Fatal("chain was not durable", route, err)
48新增: }
49新增: if err := loaded.Import("home", "", []byte(`proxies: [{name: home, type: socks5, server: 127.0.0.1, port: 2081, password: refreshed-home}]`), "home", 0, ""); err != nil {
50新增: t.Fatal(err)
51新增: }
52新增: if route, err := loaded.Route(); err != nil || !reflect.DeepEqual(route, s.Chain) {
53新增: t.Fatal("refresh lost the explicit chain", route, err)
54新增: }
55新增: loaded.Chain = []string{entry.ID}
56新增: loaded.Selected = entry.ID
57新增: data, err = loaded.Runtime(profile)
58新增: if err != nil {
59新增: t.Fatal(err)
60新增: }
61新增: if err := yaml.Unmarshal(data, &runtime); err != nil {
62新增: t.Fatal(err)
63新增: }
64新增: if runtime.Proxies[1]["dialer-proxy"] != nil {
65新增: t.Fatal("single-node mode retained imported transit")
66新增: }
67新增:}
68新增:
69新增:func TestRouteReadsLegacyImportedChainsAndRejectsBrokenExplicitChains(t *testing.T) {
70新增: s, _ := Load(t.TempDir())
71新增: if err := s.Import("legacy", "", []byte(testNodes), "legacy", 0, ""); err != nil {
72新增: t.Fatal(err)
73新增: }
74新增: entry, exit := s.Sources[0].Nodes[0].ID, s.Sources[0].Nodes[1].ID
75新增: s.Selected = exit
76新增: if route, err := s.Route(); err != nil || !reflect.DeepEqual(route, []string{entry, exit}) {
77新增: t.Fatal("legacy chain changed", route, err)
78新增: }
79新增: for _, chain := range [][]string{{entry, entry, exit}, {"missing", exit}, {entry}} {
80新增: s.Chain = chain
81新增: if _, err := s.Runtime(t.TempDir()); err == nil {
82新增: t.Fatal("invalid chain accepted", chain)
83新增: }
84新增: }
85新增:}
修改internal/managedproxy/store.go+63 −3看文件
@@ -46,6 +46,7 @@ type Store struct {
4646 Auth string `json:"auth"`
4747 Revision string `json:"revision"`
4848 Selected string `json:"selected"`
49新增: Chain []string `json:"chain,omitempty"`
4950 Sources []Source `json:"sources"`
5051}
5152
@@ -263,19 +264,78 @@ func unsafeOption(v any) bool {
263264 return false
264265}
265266
266删除:func (s Store) Runtime(profile string) ([]byte, error) {
267新增:// Route returns the actual hops from entry to exit. Explicit UI chains override
268新增:// dialers at runtime without modifying subscription nodes or their credentials.
269新增:func (s Store) Route() ([]string, error) {
267270 if _, ok := s.Find(s.Selected); !ok {
268删除: return nil, errors.New("请先选择有效节点")
271新增: return nil, errors.New("请先选择有效的最终出口")
272新增: }
273新增: if len(s.Chain) > 0 {
274新增: if s.Chain[len(s.Chain)-1] != s.Selected {
275新增: return nil, errors.New("代理链与最终出口不一致,请重新配置代理")
276新增: }
277新增: seen := map[string]bool{}
278新增: for _, id := range s.Chain {
279新增: if _, ok := s.Find(id); !ok {
280新增: return nil, errors.New("代理链中的节点已被移除,请重新选择;原配置已保留")
281新增: }
282新增: if seen[id] {
283新增: return nil, errors.New("代理链不能重复使用同一个节点")
284新增: }
285新增: seen[id] = true
286新增: }
287新增: return append([]string(nil), s.Chain...), nil
288新增: }
289新增: var reversed []string
290新增: seen := map[string]bool{}
291新增: for id := s.Selected; id != ""; {
292新增: n, ok := s.Find(id)
293新增: if !ok || seen[id] {
294新增: return nil, errors.New("导入的代理链存在循环或缺失节点,请检查来源配置")
295新增: }
296新增: seen[id] = true
297新增: reversed = append(reversed, id)
298新增: id, _ = n.Config["dialer-proxy"].(string)
299新增: }
300新增: for i, j := 0, len(reversed)-1; i < j; i, j = i+1, j-1 {
301新增: reversed[i], reversed[j] = reversed[j], reversed[i]
302新增: }
303新增: return reversed, nil
304新增:}
305新增:
306新增:func (s Store) Runtime(profile string) ([]byte, error) {
307新增: if _, err := s.Route(); err != nil {
308新增: return nil, err
309新增: }
310新增: dialers := map[string]string{}
311新增: for i, id := range s.Chain {
312新增: dialers[id] = ""
313新增: if i > 0 {
314新增: dialers[id] = s.Chain[i-1]
315新增: }
269316 }
270317 proxies := []map[string]any{}
271318 for _, src := range s.Sources {
272319 for _, n := range src.Nodes {
273删除: proxies = append(proxies, n.Config)
320新增: config := make(map[string]any, len(n.Config))
321新增: for key, value := range n.Config {
322新增: config[key] = value
323新增: }
324新增: if via, overridden := dialers[n.ID]; overridden {
325新增: delete(config, "dialer-proxy")
326新增: if via != "" {
327新增: config["dialer-proxy"] = via
328新增: }
329新增: }
330新增: proxies = append(proxies, config)
274331 }
275332 }
276333 // Infrastructure DNS bootstraps only the core's server domains. Guest DNS
277334 // remains behind Cage Egress, and there is no host-system resolver fallback.
278335 dns := map[string]any{"enable": true, "ipv6": false, "use-hosts": false, "use-system-hosts": false, "default-nameserver": BootstrapDNSURLs(), "proxy-server-nameserver": BootstrapDNSURLs(), "nameserver": []string{"https://1.1.1.1/dns-query#" + Group}}
279336 config := map[string]any{"mixed-port": s.Port, "bind-address": "127.0.0.1", "allow-lan": false, "authentication": []string{"cage:" + s.Auth}, "skip-auth-prefixes": []string{}, "mode": "rule", "ipv6": false, "log-level": "warning", "find-process-mode": "off", "external-controller-unix": Socket(profile), "tun": map[string]any{"enable": false}, "dns": dns, "geo-auto-update": false, "profile": map[string]any{"store-selected": false}, "proxies": proxies, "proxy-groups": []any{map[string]any{"name": Group, "type": "select", "proxies": []string{s.Selected}}}, "rules": []string{"MATCH," + Group}}
337新增: // Measure a request on the established connection rather than folding
338新增: // protocol and TLS setup into the node's displayed HTTP latency.
339新增: config["unified-delay"] = true
280340 return yaml.Marshal(config)
281341}
修改internal/managedproxy/store_test.go+3 −0看文件
@@ -134,6 +134,9 @@ func TestImportCompilesOnlyOwnedNetworkBoundary(t *testing.T) {
134134 if config["tun"].(map[string]any)["enable"] != false {
135135 t.Fatal("TUN enabled")
136136 }
137新增: if config["unified-delay"] != true {
138新增: t.Fatal("node latency includes connection setup instead of an established-connection request")
139新增: }
137140 if s.Sources[0].Nodes[1].Config["dialer-proxy"] != s.Sources[0].Nodes[0].ID {
138141 t.Fatal("chain not namespaced")
139142 }
修改internal/workbench/proxy.go+43 −11看文件
@@ -19,14 +19,15 @@ var (
1919)
2020
2121type proxyInput struct {
22删除: ID string `json:"id"`
23删除: Name string `json:"name"`
24删除: URL string `json:"url"`
25删除: Content string `json:"content"`
26删除: Interval int `json:"interval_hours"`
27删除: HostDownload bool `json:"host_download"`
28删除: NodeID string `json:"node_id"`
29删除: Port int `json:"port"`
22新增: ID string `json:"id"`
23新增: Name string `json:"name"`
24新增: URL string `json:"url"`
25新增: Content string `json:"content"`
26新增: Interval int `json:"interval_hours"`
27新增: HostDownload bool `json:"host_download"`
28新增: NodeID string `json:"node_id"`
29新增: NodeIDs []string `json:"node_ids"`
30新增: Port int `json:"port"`
3031}
3132
3233func (s *Server) proxyStatus(w http.ResponseWriter, r *http.Request) {
@@ -87,7 +88,15 @@ func (s *Server) proxyStatus(w http.ResponseWriter, r *http.Request) {
8788 _ = managedproxy.API(ctx, s.profile, "GET", "/version", nil, &version)
8889 }
8990 _, coreErr := managedproxy.CorePath()
90删除: jsonReply(w, map[string]any{"sources": sources, "selected": p.Selected, "port": p.Port, "running": running, "active": active, "state": state, "state_label": label, "network_open": state == "ready", "core_available": coreErr == nil, "version": version.Version, "revision": p.Revision, "bootstrap_dns": strings.Join(managedproxy.BootstrapDNSURLs(), "、"), "udp_blocked": true, "ipv6_blocked": true})
91新增: route, routeErr := p.Route()
92新增: if route == nil {
93新增: route = append([]string{}, p.Chain...)
94新增: }
95新增: routeError := ""
96新增: if routeErr != nil && selected {
97新增: routeError = routeErr.Error()
98新增: }
99新增: jsonReply(w, map[string]any{"route": route, "route_error": routeError, "sources": sources, "selected": p.Selected, "port": p.Port, "running": running, "active": active, "state": state, "state_label": label, "network_open": state == "ready", "core_available": coreErr == nil, "version": version.Version, "revision": p.Revision, "bootstrap_dns": strings.Join(managedproxy.BootstrapDNSURLs(), "、"), "udp_blocked": true, "ipv6_blocked": true})
91100}
92101func (s *Server) proxyMutation(w http.ResponseWriter, r *http.Request) {
93102 var input proxyInput
@@ -95,7 +104,7 @@ func (s *Server) proxyMutation(w http.ResponseWriter, r *http.Request) {
95104 return
96105 }
97106 action := r.PathValue("action")
98删除: allowed := map[string]bool{"import": true, "refresh": true, "edit": true, "delete": true, "select": true, "restart": true, "stop": true}
107新增: allowed := map[string]bool{"import": true, "refresh": true, "edit": true, "delete": true, "select": true, "restart": true, "stop": true, "route": true}
99108 if !allowed[action] {
100109 http.NotFound(w, r)
101110 return
@@ -143,12 +152,25 @@ func (s *Server) changeProxy(action string, in proxyInput, resumeVersion *uint64
143152 }
144153 return managedproxy.Stop(s.profile)
145154 }
146删除: if action == "select" || action == "restart" {
155新增: if action == "select" || action == "restart" || action == "route" {
156新增: if action == "route" {
157新增: if len(in.NodeIDs) == 0 {
158新增: return errors.New("请至少选择一个最终出口")
159新增: }
160新增: p.Chain = append([]string(nil), in.NodeIDs...)
161新增: p.Selected = p.Chain[len(p.Chain)-1]
162新增: if _, err := p.Route(); err != nil {
163新增: return err
164新增: }
165新增: }
147166 if action == "select" {
148167 if _, ok := p.Find(in.NodeID); !ok {
149168 return errors.New("所选节点已不存在,请刷新列表")
150169 }
151170 p.Selected = in.NodeID
171新增: if len(p.Chain) > 0 {
172新增: p.Chain[len(p.Chain)-1] = in.NodeID
173新增: }
152174 }
153175 if in.Port != 0 {
154176 if in.Port < 1024 || in.Port > 65535 {
@@ -169,9 +191,19 @@ func (s *Server) changeProxy(action string, in proxyInput, resumeVersion *uint64
169191 if index < 0 {
170192 return errors.New("订阅来源不存在")
171193 }
194新增: if len(p.Chain) > 1 {
195新增: for _, id := range p.Chain {
196新增: for _, n := range p.Sources[index].Nodes {
197新增: if n.ID == id {
198新增: return errors.New("该来源包含当前代理链中的节点,请先选择并应用其他来源的节点")
199新增: }
200新增: }
201新增: }
202新增: }
172203 p.Sources = append(p.Sources[:index], p.Sources[index+1:]...)
173204 if _, ok := p.Find(p.Selected); !ok {
174205 p.Selected = ""
206新增: p.Chain = nil
175207 }
176208 } else if action == "edit" {
177209 if index < 0 {
新增internal/workbench/proxy_route_test.go+127 −0看文件
@@ -0,0 +1,127 @@
1新增:package workbench
2新增:
3新增:import (
4新增: "context"
5新增: "encoding/json"
6新增: "errors"
7新增: "net/http"
8新增: "reflect"
9新增: "strings"
10新增: "testing"
11新增: "time"
12新增:
13新增: "github.com/sylvinus/agent-vm/internal/managedproxy"
14新增:)
15新增:
16新增:func TestProxyRouteAPIIsAtomicAndSurvivesRefresh(t *testing.T) {
17新增: s := testServer(t)
18新增: p, _ := managedproxy.Load(s.profile)
19新增: entry := p.Selected
20新增: if err := p.Import("home", "https://example.com/home?token=private-token", []byte(`proxies: [{name: home, type: http, server: 127.0.0.1, port: 1080, password: private-password}]`), "home", 0, ""); err != nil {
21新增: t.Fatal(err)
22新增: }
23新增: exit := p.Sources[1].Nodes[0].ID
24新增: if err := p.Save(s.profile); err != nil {
25新增: t.Fatal(err)
26新增: }
27新增: oldValidate, oldStart, oldFetch := validateProxyCore, startProxyCore, fetchProxySource
28新增: t.Cleanup(func() { validateProxyCore, startProxyCore, fetchProxySource = oldValidate, oldStart, oldFetch })
29新增: validateProxyCore = func(_ context.Context, profile string, p managedproxy.Store) error {
30新增: _, err := p.Runtime(profile)
31新增: return err
32新增: }
33新增: failStart := false
34新增: startProxyCore = func(context.Context, string, managedproxy.Store) error {
35新增: if failStart {
36新增: return errors.New("test core startup failed")
37新增: }
38新增: return nil
39新增: }
40新增: body, _ := json.Marshal(proxyInput{NodeIDs: []string{entry, exit}})
41新增: if w := request(s, "POST", "/api/proxy/route", s.origin, string(body), false); w.Code != http.StatusUnauthorized {
42新增: t.Fatal("unauthenticated chain accepted", w.Code)
43新增: }
44新增: if w := request(s, "POST", "/api/proxy/route", s.origin, string(body), true); w.Code != http.StatusOK {
45新增: t.Fatal(w.Code, w.Body.String())
46新增: }
47新增: deadline := time.Now().Add(3 * time.Second)
48新增: for {
49新增: s.mu.Lock()
50新增: job := s.jobs.snapshot()
51新增: s.mu.Unlock()
52新增: if !job.Running {
53新增: if job.Error != "" {
54新增: t.Fatal(job.Error)
55新增: }
56新增: break
57新增: }
58新增: if time.Now().After(deadline) {
59新增: t.Fatal("chain apply did not finish")
60新增: }
61新增: time.Sleep(10 * time.Millisecond)
62新增: }
63新增: applied, _ := managedproxy.Load(s.profile)
64新增: if !reflect.DeepEqual(applied.Chain, []string{entry, exit}) || applied.Selected != exit || applied.Revision == p.Revision {
65新增: t.Fatal("chain not applied atomically", applied.Chain)
66新增: }
67新增: w := request(s, "GET", "/api/proxy", s.origin, "", true)
68新增: var view struct {
69新增: Route []string `json:"route"`
70新增: }
71新增: if err := json.Unmarshal(w.Body.Bytes(), &view); err != nil || !reflect.DeepEqual(view.Route, applied.Chain) {
72新增: t.Fatal("chain status missing", err, w.Body.String())
73新增: }
74新增: for _, secret := range []string{"private-token", "private-password", p.Auth} {
75新增: if strings.Contains(w.Body.String(), secret) {
76新增: t.Fatal("chain status leaked credentials")
77新增: }
78新增: }
79新增: cfgBefore, _ := loadConfig(s.configPath)
80新增: failStart = true
81新增: if err := s.changeProxy("route", proxyInput{NodeIDs: []string{exit}}, nil); err == nil {
82新增: t.Fatal("startup failure accepted")
83新增: }
84新增: after, _ := managedproxy.Load(s.profile)
85新增: cfgAfter, _ := loadConfig(s.configPath)
86新增: if !reflect.DeepEqual(after, applied) || !reflect.DeepEqual(cfgAfter, cfgBefore) {
87新增: t.Fatal("failed chain application replaced last saved route")
88新增: }
89新增: failStart = false
90新增: if err := s.changeProxy("route", proxyInput{NodeIDs: []string{entry, entry}}, nil); err == nil {
91新增: t.Fatal("repeated node accepted")
92新增: }
93新增: if err := s.changeProxy("delete", proxyInput{ID: "source"}, nil); err == nil {
94新增: t.Fatal("active transit source removed")
95新增: }
96新增: fetchProxySource = func(context.Context, *http.Client, string) ([]byte, string, error) {
97新增: return []byte(`proxies: [{name: home, type: http, server: 127.0.0.1, port: 2080, password: updated}]`), "", nil
98新增: }
99新增: if err := s.changeProxy("refresh", proxyInput{ID: "home", HostDownload: true}, nil); err != nil {
100新增: t.Fatal(err)
101新增: }
102新增: refreshed, _ := managedproxy.Load(s.profile)
103新增: if !reflect.DeepEqual(refreshed.Chain, applied.Chain) || refreshed.Sources[1].Nodes[0].Config["password"] != "updated" {
104新增: t.Fatal("subscription refresh lost the chain")
105新增: }
106新增: fetchProxySource = func(context.Context, *http.Client, string) ([]byte, string, error) {
107新增: return []byte(`proxies: [{name: replacement, type: http, server: 127.0.0.1, port: 3080}]`), "", nil
108新增: }
109新增: if err := s.changeProxy("refresh", proxyInput{ID: "home", HostDownload: true}, nil); err == nil {
110新增: t.Fatal("missing exit silently replaced")
111新增: }
112新增: retained, _ := managedproxy.Load(s.profile)
113新增: if !reflect.DeepEqual(retained.Chain, applied.Chain) || retained.Sources[1].Nodes[0].ID != exit {
114新增: t.Fatal("missing node refresh discarded the working chain")
115新增: }
116新增: if err := s.changeProxy("route", proxyInput{NodeIDs: []string{exit}}, nil); err != nil {
117新增: t.Fatal(err)
118新增: }
119新增: if err := s.changeProxy("delete", proxyInput{ID: "home"}, nil); err != nil {
120新增: t.Fatal("single-node source could not be deleted", err)
121新增: }
122新增: deleted, _ := managedproxy.Load(s.profile)
123新增: if deleted.Selected != "" || len(deleted.Chain) != 0 {
124新增: t.Fatal("deleted single-node source retained an active route")
125新增: }
126新增:
127新增:}
修改patches/README.md+1 −0看文件
@@ -52,6 +52,7 @@ It runs inside the Lima hostagent, which with vz also runs the VM: a panic there
5252| `lima/0009-start-channels-buffered` | lima-vm/lima | not sent | `StartWithPaths` left the losing goroutine of its race blocked on an unbuffered send, for as long as the program lives. No test: it starts a hostagent. |
5353| `lima/0011-windows-native-usernet-socket` | lima-vm/lima | not sent | Opens the per-instance network control endpoint with its native filesystem path. Constructing `unix://C:\\...` fails URL parsing on Windows. `TestNetstackWindowsNativeSocketPaths` connects to both control and QEMU AF_UNIX listeners on Windows. |
5454| `lima/0012-dynamic-memory` | lima-vm/lima | not sent | Adds an optional hostagent resource controller with bounded private SSH observations, VZ memory targets and deadline-bound QEMU balloon commands. Stops the controller before the VM and suppresses probe consoles on Windows. VZ borrowed device wrappers retain VM ownership instead of releasing it from a temporary Go finalizer. Protocol, cancellation and capacity checks are covered in `TestMemoryTargetQMPProtocolAndCancellation`; Cage owns the adaptive policy and live acceptance. |
55新增:| `lima/0013-resumable-image-downloads` | lima-vm/lima | not sent | Resumes digest-pinned cached image downloads under the existing cache lock. Validates byte ranges and the complete digest before publication; retains partial data on interruption, handles servers that ignore or reject Range, and discards corrupted data. Local HTTP tests cover retries, cancellation and cache reuse. |
5556| `sshocker/0001-rooted-server-readonly-names` | lima-vm/sshocker | fork branch `readonly-names` | The builtin server serves only the mounted directory, and `ReadonlyNames`. |
5657| `sshocker/0002-expect-remove` | lima-vm/sshocker | fork branch `expect-remove` | `ExpectRemove`, for 0002 of Lima. |
5758| `sshocker/0003-append-fix` | lima-vm/sshocker | not sent | Bug 1. Tests `TestRootedOpenAppend`, `TestRootedOpenMode`. No pkg/sftp dependency: send first. |
新增patches/lima/0013-resumable-image-downloads.patch+435 −0看文件
@@ -0,0 +1,435 @@
1新增:Subject: [PATCH] Resume digest-pinned image downloads across setup retries
2新增:
3新增:Retain partial cache data under the existing directory lock. Validate ranges
4新增:and the full pinned digest before publishing; keep proxy routing unchanged.
5新增:
6新增:---
7新增:diff --git a/pkg/downloader/downloader.go b/pkg/downloader/downloader.go
8新增:--- a/pkg/downloader/downloader.go
9新增:+++ b/pkg/downloader/downloader.go
10新增:@@ -409,7 +409,13 @@
11新增: if err := os.WriteFile(shadURL, []byte(remote), 0o644); err != nil {
12新增: return nil, err
13新增: }
14新增:- if err := downloadHTTP(ctx, shadData, shadTime, shadType, remote, o.description, o.expectedDigest); err != nil {
15新增:+ // A cache entry is locked by Download. Only digest-pinned downloads may
16新增:+ // retain and resume partial bytes across processes and setup retries.
17新增:+ download := downloadHTTP
18新增:+ if o.expectedDigest != "" {
19新增:+ download = downloadHTTPResumable
20新增:+ }
21新增:+ if err := download(ctx, shadData, shadTime, shadType, remote, o.description, o.expectedDigest); err != nil {
22新增: return nil, err
23新增: }
24新增: if shadDigest != "" && o.expectedDigest != "" {
25新增:@@ -1056,6 +1062,7 @@
26新增: return lockutil.WithDirLock(dir, func() error {
27新增: patterns := []string{
28新增: filepath.Join(dir, "data.part"),
29新增:+ filepath.Join(dir, "data.part.digest"),
30新增: filepath.Join(dir, "data.tmp.*"),
31新增: }
32新增: for _, pattern := range patterns {
33新增:diff --git a/pkg/downloader/resume.go b/pkg/downloader/resume.go
34新增:new file mode 100644
35新增:--- /dev/null
36新增:+++ b/pkg/downloader/resume.go
37新增:@@ -0,0 +1,213 @@
38新增:+// SPDX-FileCopyrightText: Copyright The Lima Authors
39新增:+// SPDX-License-Identifier: Apache-2.0
40新增:+
41新增:+package downloader
42新增:+
43新增:+import (
44新增:+ "context"
45新增:+ "errors"
46新增:+ "fmt"
47新增:+ "io"
48新增:+ "net/http"
49新增:+ "os"
50新增:+ "strconv"
51新增:+ "strings"
52新增:+ "time"
53新增:+
54新增:+ "github.com/lima-vm/lima/v2/pkg/progressbar"
55新增:+ "github.com/opencontainers/go-digest"
56新增:+ "github.com/sirupsen/logrus"
57新增:+)
58新增:+
59新增:+// downloadHTTPResumable is called only while holding the cache directory lock
60新增:+// and with a pinned digest. A partial response is never published as cache data.
61新增:+func downloadHTTPResumable(ctx context.Context, local, modified, contentType, remote, description string, expected digest.Digest) error {
62新增:+ part := local + ".part"
63新增:+ identity := part + ".digest"
64新增:+ previous, err := os.ReadFile(identity)
65新增:+ if err != nil && !errors.Is(err, os.ErrNotExist) {
66新增:+ return err
67新增:+ }
68新增:+ if string(previous) != expected.String() {
69新增:+ if err := os.Remove(part); err != nil && !errors.Is(err, os.ErrNotExist) {
70新增:+ return err
71新增:+ }
72新增:+ if err := os.WriteFile(identity, []byte(expected.String()), 0600); err != nil {
73新增:+ return err
74新增:+ }
75新增:+ }
76新增:+ // Cancellation can arrive after all bytes were received but before rename.
77新增:+ if validateLocalFileDigest(part, expected) == nil {
78新增:+ return publishPartial(part, local, identity)
79新增:+ }
80新增:+ for attempt := 0; attempt < 4; attempt++ {
81新增:+ if ctx.Err() != nil {
82新增:+ return ctx.Err()
83新增:+ }
84新增:+ attemptCtx, cancel := context.WithTimeout(ctx, 30*time.Minute)
85新增:+ var retry bool
86新增:+ retry, err = resumeHTTPOnce(attemptCtx, local, modified, contentType, remote, description, expected)
87新增:+ cancel()
88新增:+ if err == nil {
89新增:+ return publishPartial(part, local, identity)
90新增:+ }
91新增:+ if !retry {
92新增:+ return err
93新增:+ }
94新增:+ if attempt < 3 {
95新增:+ logrus.Infof("Image download interrupted; retry %d/3 will reuse saved partial data", attempt+1)
96新增:+ select {
97新增:+ case <-ctx.Done():
98新增:+ return ctx.Err()
99新增:+ case <-time.After(time.Duration(attempt+1) * time.Second):
100新增:+ }
101新增:+ }
102新增:+ }
103新增:+ return fmt.Errorf("image download interrupted; partial data retained for setup retry: %w", err)
104新增:+}
105新增:+
106新增:+func publishPartial(part, local, identity string) error {
107新增:+ if err := os.Rename(part, local); err != nil {
108新增:+ return err
109新增:+ }
110新增:+ return os.Remove(identity)
111新增:+}
112新增:+
113新增:+func resumeHTTPOnce(ctx context.Context, local, modified, contentType, remote, description string, expected digest.Digest) (bool, error) {
114新增:+ part := local + ".part"
115新增:+ var offset int64
116新增:+ if st, err := os.Stat(part); err == nil {
117新增:+ offset = st.Size()
118新增:+ } else if !errors.Is(err, os.ErrNotExist) {
119新增:+ return false, err
120新增:+ }
121新增:+ ctx, cancel := context.WithCancel(ctx)
122新增:+ defer cancel()
123新增:+ // A slow but progressing transfer may run for 30 minutes. A stalled
124新增:+ // connection is interrupted after one minute so a fresh attempt can resume.
125新增:+ idle := time.AfterFunc(time.Minute, cancel)
126新增:+ defer idle.Stop()
127新增:+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, remote, nil)
128新增:+ if err != nil {
129新增:+ return false, err
130新增:+ }
131新增:+ req.Header.Set("Accept-Encoding", "identity")
132新增:+ if offset > 0 {
133新增:+ req.Header.Set("Range", fmt.Sprintf("bytes=%d-", offset))
134新增:+ }
135新增:+ resp, err := http.DefaultClient.Do(req)
136新增:+ if err != nil {
137新增:+ return true, err
138新增:+ }
139新增:+ defer resp.Body.Close()
140新增:+ var total int64
141新增:+ expectedBody := resp.ContentLength
142新增:+ switch resp.StatusCode {
143新增:+ case http.StatusOK:
144新增:+ // Servers may ignore Range. Replace the partial file instead of appending.
145新增:+ offset, total = 0, resp.ContentLength
146新增:+ case http.StatusPartialContent:
147新增:+ start, end, size, ok := parseDownloadRange(resp.Header.Get("Content-Range"))
148新增:+ if !ok || start != offset || (resp.ContentLength >= 0 && resp.ContentLength != end-start+1) {
149新增:+ return false, errors.New("invalid image Content-Range; partial data left unchanged")
150新增:+ }
151新增:+ total = size
152新增:+ expectedBody = end - start + 1
153新增:+ case http.StatusRequestedRangeNotSatisfiable:
154新增:+ // The digest above already ruled out a completed file. Reset only this
155新增:+ // incomplete artifact, for a server whose representation has changed.
156新增:+ if err := os.Remove(part); err != nil && !errors.Is(err, os.ErrNotExist) {
157新增:+ return false, err
158新增:+ }
159新增:+ return true, errors.New("image range rejected; restarting this artifact")
160新增:+ default:
161新增:+ return resp.StatusCode == 408 || resp.StatusCode == 429 || resp.StatusCode >= 500, fmt.Errorf("image download returned HTTP %d", resp.StatusCode)
162新增:+ }
163新增:+ for name, value := range map[string]string{modified: resp.Header.Get("Last-Modified"), contentType: resp.Header.Get("Content-Type")} {
164新增:+ if name != "" {
165新增:+ if err := os.WriteFile(name, []byte(value), 0600); err != nil {
166新增:+ return false, err
167新增:+ }
168新增:+ }
169新增:+ }
170新增:+ flags := os.O_CREATE | os.O_WRONLY
171新增:+ if offset == 0 {
172新增:+ flags |= os.O_TRUNC
173新增:+ }
174新增:+ out, err := os.OpenFile(part, flags, 0600)
175新增:+ if err != nil {
176新增:+ return false, err
177新增:+ }
178新增:+ defer out.Close()
179新增:+ if _, err := out.Seek(offset, io.SeekStart); err != nil {
180新增:+ return false, err
181新增:+ }
182新增:+ bar, err := progressbar.New(total)
183新增:+ if err != nil {
184新增:+ return false, err
185新增:+ }
186新增:+ if HideProgress {
187新增:+ hideBar(bar)
188新增:+ }
189新增:+ bar.SetCurrent(offset)
190新增:+ if description == "" {
191新增:+ description = "pinned image"
192新增:+ }
193新增:+ logrus.Infof("Downloading %s; continuing at %d bytes", description, offset)
194新增:+ bar.Start()
195新增:+ defer bar.Finish()
196新增:+ reader := &downloadActivityReader{reader: resp.Body, timer: idle}
197新增:+ n, err := io.Copy(out, bar.NewProxyReader(reader))
198新增:+ if err != nil {
199新增:+ return true, err
200新增:+ }
201新增:+ if expectedBody >= 0 && n != expectedBody {
202新增:+ if n > expectedBody {
203新增:+ _ = out.Close()
204新增:+ _ = os.Remove(part)
205新增:+ return false, errors.New("image response exceeded its declared range; partial data discarded")
206新增:+ }
207新增:+ return true, io.ErrUnexpectedEOF
208新增:+ }
209新增:+ if total >= 0 && n+offset != total {
210新增:+ return true, io.ErrUnexpectedEOF
211新增:+ }
212新增:+ if err := out.Sync(); err != nil {
213新增:+ return false, err
214新增:+ }
215新增:+ if err := out.Close(); err != nil {
216新增:+ return false, err
217新增:+ }
218新增:+ if err := validateLocalFileDigest(part, expected); err != nil {
219新增:+ _ = os.Remove(part)
220新增:+ return false, fmt.Errorf("image checksum mismatch; partial data discarded: %w", err)
221新增:+ }
222新增:+ return false, nil
223新增:+}
224新增:+
225新增:+type downloadActivityReader struct {
226新增:+ reader io.Reader
227新增:+ timer *time.Timer
228新增:+}
229新增:+
230新增:+func (r *downloadActivityReader) Read(p []byte) (int, error) {
231新增:+ n, err := r.reader.Read(p)
232新增:+ if n > 0 {
233新增:+ r.timer.Reset(time.Minute)
234新增:+ }
235新增:+ return n, err
236新增:+}
237新增:+
238新增:+func parseDownloadRange(value string) (start, end, total int64, ok bool) {
239新增:+ span, size, found := strings.Cut(strings.TrimPrefix(value, "bytes "), "/")
240新增:+ first, last, dash := strings.Cut(span, "-")
241新增:+ if !strings.HasPrefix(value, "bytes ") || !found || !dash {
242新增:+ return
243新增:+ }
244新增:+ var a, b, c error
245新增:+ start, a = strconv.ParseInt(first, 10, 64)
246新增:+ end, b = strconv.ParseInt(last, 10, 64)
247新增:+ total, c = strconv.ParseInt(size, 10, 64)
248新增:+ ok = a == nil && b == nil && c == nil && start >= 0 && end >= start && total > end
249新增:+ return
250新增:+}
251新增:diff --git a/pkg/downloader/resume_test.go b/pkg/downloader/resume_test.go
252新增:new file mode 100644
253新增:--- /dev/null
254新增:+++ b/pkg/downloader/resume_test.go
255新增:@@ -0,0 +1,180 @@
256新增:+// SPDX-FileCopyrightText: Copyright The Lima Authors
257新增:+// SPDX-License-Identifier: Apache-2.0
258新增:+
259新增:+package downloader
260新增:+
261新增:+import (
262新增:+ "context"
263新增:+ "errors"
264新增:+ "fmt"
265新增:+ "net/http"
266新增:+ "net/http/httptest"
267新增:+ "os"
268新增:+ "path/filepath"
269新增:+ "strings"
270新增:+ "sync/atomic"
271新增:+ "testing"
272新增:+ "time"
273新增:+
274新增:+ "github.com/opencontainers/go-digest"
275新增:+)
276新增:+
277新增:+func TestPinnedDownloadResumesInterruptedBody(t *testing.T) {
278新增:+ data := "0123456789abcdef"
279新增:+ var calls atomic.Int32
280新增:+ s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
281新增:+ if calls.Add(1) == 1 {
282新增:+ w.Header().Set("Content-Length", "16")
283新增:+ fmt.Fprint(w, data[:5])
284新增:+ return
285新增:+ }
286新增:+ if r.Header.Get("Range") != "bytes=5-" {
287新增:+ t.Errorf("did not resume: %q", r.Header.Get("Range"))
288新增:+ }
289新增:+ w.Header().Set("Content-Range", "bytes 5-15/16")
290新增:+ w.WriteHeader(http.StatusPartialContent)
291新增:+ fmt.Fprint(w, data[5:])
292新增:+ }))
293新增:+ defer s.Close()
294新增:+ cache := t.TempDir()
295新增:+ r, err := Download(t.Context(), "", s.URL, WithCacheDir(cache), WithExpectedDigest(digest.FromString(data)))
296新增:+ if err != nil {
297新增:+ t.Fatal(err)
298新增:+ }
299新增:+ got, err := os.ReadFile(r.CachePath)
300新增:+ if err != nil || string(got) != data || calls.Load() != 2 {
301新增:+ t.Fatalf("result %q, calls %d, error %v", got, calls.Load(), err)
302新增:+ }
303新增:+}
304新增:+
305新增:+func TestPinnedDownloadAcrossSetupRetries(t *testing.T) {
306新增:+ for _, mode := range []string{"range", "ignore-range", "bad-range", "wrong-hash", "changed-digest", "complete", "range-rejected"} {
307新增:+ t.Run(mode, func(t *testing.T) {
308新增:+ data := "0123456789abcdef"
309新增:+ var calls atomic.Int32
310新增:+ s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
311新增:+ calls.Add(1)
312新增:+ switch mode {
313新增:+ case "complete":
314新增:+ t.Error("complete partial was downloaded again")
315新增:+ case "changed-digest", "ignore-range":
316新增:+ if mode == "changed-digest" && r.Header.Get("Range") != "" {
317新增:+ t.Error("resumed a different digest")
318新增:+ }
319新增:+ fmt.Fprint(w, data)
320新增:+ case "range-rejected":
321新增:+ if calls.Load() == 1 {
322新增:+ w.WriteHeader(416)
323新增:+ } else {
324新增:+ if r.Header.Get("Range") != "" {
325新增:+ t.Error("rejected range was reused")
326新增:+ }
327新增:+ fmt.Fprint(w, data)
328新增:+ }
329新增:+ default:
330新增:+ if r.Header.Get("Range") != "bytes=5-" {
331新增:+ t.Error("partial not reused")
332新增:+ }
333新增:+ span := "bytes 5-15/16"
334新增:+ if mode == "bad-range" {
335新增:+ span = "bytes 4-14/16"
336新增:+ }
337新增:+ w.Header().Set("Content-Range", span)
338新增:+ w.WriteHeader(206)
339新增:+ if mode == "wrong-hash" {
340新增:+ fmt.Fprint(w, "xxxxxxxxxxx")
341新增:+ } else {
342新增:+ fmt.Fprint(w, data[5:])
343新增:+ }
344新增:+ }
345新增:+ }))
346新增:+ defer s.Close()
347新增:+ cache := t.TempDir()
348新增:+ dir := cacheDirectoryPath(cache, s.URL)
349新增:+ if err := os.MkdirAll(dir, 0700); err != nil {
350新增:+ t.Fatal(err)
351新增:+ }
352新增:+ part := filepath.Join(dir, "data.part")
353新增:+ body, expected := data[:5], digest.FromString(data)
354新增:+ identity := expected.String()
355新增:+ if mode == "changed-digest" {
356新增:+ identity = digest.FromString("old").String()
357新增:+ }
358新增:+ if mode == "complete" {
359新增:+ body = data
360新增:+ }
361新增:+ if err := os.WriteFile(part, []byte(body), 0600); err != nil {
362新增:+ t.Fatal(err)
363新增:+ }
364新增:+ if err := os.WriteFile(part+".digest", []byte(identity), 0600); err != nil {
365新增:+ t.Fatal(err)
366新增:+ }
367新增:+ r, err := Download(t.Context(), "", s.URL, WithCacheDir(cache), WithExpectedDigest(expected))
368新增:+ if mode == "bad-range" || mode == "wrong-hash" {
369新增:+ if err == nil {
370新增:+ t.Fatal("invalid data accepted")
371新增:+ }
372新增:+ if _, err := os.Stat(filepath.Join(dir, "data")); !os.IsNotExist(err) {
373新增:+ t.Fatal("invalid cache published")
374新增:+ }
375新增:+ if mode == "bad-range" {
376新增:+ got, _ := os.ReadFile(part)
377新增:+ if string(got) != body {
378新增:+ t.Fatal("bad range altered partial")
379新增:+ }
380新增:+ } else if _, err := os.Stat(part); !os.IsNotExist(err) {
381新增:+ t.Fatal("corrupt partial retained")
382新增:+ }
383新增:+ return
384新增:+ }
385新增:+ if err != nil {
386新增:+ t.Fatal(err)
387新增:+ }
388新增:+ got, err := os.ReadFile(r.CachePath)
389新增:+ if err != nil || string(got) != data {
390新增:+ t.Fatalf("got %q: %v", got, err)
391新增:+ }
392新增:+ })
393新增:+ }
394新增:+}
395新增:+
396新增:+func TestPinnedDownloadCancellationRetainsPartial(t *testing.T) {
397新增:+ ctx, cancel := context.WithCancel(context.Background())
398新增:+ defer cancel()
399新增:+ s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
400新增:+ w.Header().Set("Content-Length", "1000")
401新增:+ fmt.Fprint(w, "partial")
402新增:+ w.(http.Flusher).Flush()
403新增:+ <-r.Context().Done()
404新增:+ }))
405新增:+ defer s.Close()
406新增:+ dir := t.TempDir()
407新增:+ local := filepath.Join(dir, "data")
408新增:+ done := make(chan error, 1)
409新增:+ go func() {
410新增:+ done <- downloadHTTPResumable(ctx, local, "", "", s.URL, "test", digest.FromString(strings.Repeat("x", 1000)))
411新增:+ }()
412新增:+ // Wait for the client to persist data, not just for the server to send it.
413新增:+ for i := 0; i < 1000; i++ {
414新增:+ if st, err := os.Stat(local + ".part"); err == nil && st.Size() > 0 {
415新增:+ break
416新增:+ }
417新增:+ select {
418新增:+ case err := <-done:
419新增:+ t.Fatalf("ended early: %v", err)
420新增:+ default:
421新增:+ }
422新增:+ time.Sleep(time.Millisecond)
423新增:+ }
424新增:+ cancel()
425新增:+ if err := <-done; !errors.Is(err, context.Canceled) {
426新增:+ t.Fatalf("cancel: %v", err)
427新增:+ }
428新增:+ got, err := os.ReadFile(local + ".part")
429新增:+ if err != nil || string(got) != "partial" {
430新增:+ t.Fatalf("partial lost: %q %v", got, err)
431新增:+ }
432新增:+ if _, err := os.Stat(local); !os.IsNotExist(err) {
433新增:+ t.Fatal("cancelled data published")
434新增:+ }
435新增:+}
修改promo/README.md+17 −10看文件
@@ -1,25 +1,30 @@
11# Claude Cage 宣传片
22
3删除:一支 60 秒、1920×1080 / 60 fps 的宣传片,画面和配乐都由代码生成。
3新增:一支约 61 秒的宣传片,横屏 1920×1080 和竖屏 1080×1920 两个版本,60 fps,画面和配乐都由代码生成。
44
55| 时间 | 段落 | 内容 |
66|---|---|---|
7删除:| 0–14s | 痛点 | 四个硬切镜头:封号让钱和进度清零;VPS、指纹浏览器、远程 Mac mini 的月账单;全局代理把整台电脑拖下水;传统虚拟机又重又慢还得自己配。最后一句“就不能,简单一点吗?” |
8删除:| 14–20s | 方案 | 像素 Logo 落笼,定位语“为 Claude 量身定制的轻量虚拟机”,开箱即用,只需配置自己的代理。 |
9删除:| 19–44s | 三步上手 | 复刻应用界面:配置代理、时区跟随出口 → 11 项泄漏检查通过后才联网 → 在 Cage 里打开终端运行 `claude`,主机不开全局代理。 |
10删除:| 44–50s | 卖点汇总 | 轻量开箱即用 · 自带泄漏审查 · 与主机隔离 · 开源接受审查。 |
11删除:| 49–55s | 写给相遇 | 角色插画与“把 Claude 关起来,是为了更好地保护我们的相遇。” |
12删除:| 55–60s | 片尾 | Logo、平台、主页与 GitHub 地址、非隶属声明。 |
7新增:| 0–4s | 冷开场 | 还原 “Your account is on hold” 停用页,滚到 “Reviews take about 10 days.”,随后缩成证据卡,砸出损失:订阅打水漂、余额不能用、项目停摆。 |
8新增:| 4–15s | 痛点 | VPS、指纹浏览器、远程 Mac mini 的月账单;全局代理把整台电脑拖下水;传统虚拟机又重又慢还得自己配;“就不能,简单一点吗?” |
9新增:| 15–20s | 方案 | 像素 Logo 落笼,定位语“为 Claude 量身定制的轻量虚拟机”,开箱即用,只需配置自己的代理。 |
10新增:| 20–43s | 真实工作台 | 用当前版本工作台的真实截图做底:「网络与隔离检查」11 项逐个打勾、外网放行 → 状态栏的出口与时区 → 内置 Claude Desktop 对话 → 项目上新建「Claude 终端」进入 Claude Code → 授权页在 Cage 浏览器打开并完成登录 → 回到终端干活。 |
11新增:| 43–49s | 多账号调度 | “Claude 账号”面板:多个订阅的 5h / 7d 额度,新建终端按负载和余量自动分配,额度用尽的账号本轮跳过。 |
12新增:| 49–53s | 卖点汇总 | 轻量开箱即用 · 自带泄漏审查 · 与主机隔离 · 开源接受审查。 |
13新增:| 53–57s | 写给相遇 | 角色插画与“把 Claude 关起来,是为了更好地保护我们的相遇。” |
14新增:| 57–61s | 片尾 | Logo、平台、主页与 GitHub 地址、非隶属声明。 |
1315
14删除:痛点里的账单金额、节点名和终端对话都是示意内容,改文案直接编辑 `index.html`。
16新增:痛点里的账单金额、停用页日期、节点名、账号邮箱与额度、终端对话都是示意内容,改文案直接编辑 `index.html`。
1517
1618## 文件
1719
1820- `index.html`:舞台、各幕布局和样式。
1921- `promo.js`:每一帧都是时间的纯函数 `render(t)`,预览、拖动和导出看到的画面完全一致。
2022- `timeline.js`:画面与配乐共用的时间点,改节奏只改这里。
23新增:- `plates/`:第三幕的底图,是真实工作台界面的 2x 截图。横屏用 1440×860 的窗口,竖屏用 760×1100 的窄窗口(`plates/portrait/`,工作台自带的窄屏布局),竖屏因此能整宽展示、字号够大。`layout.js` 记录侧栏按钮、状态栏、检查弹窗每一行等位置;Claude Desktop、终端文字、浏览器页面和逐行打勾由 `promo.js` 叠加绘制。
24新增:- `capture-plates.mjs`:用模拟接口加载 `internal/workbench/web` 里构建好的工作台,按横竖两种窗口尺寸重新截取 `plates/` 并生成 `layout.js`。
2125- `soundtrack.mjs`:按时间轴合成配乐与音效,输出 `out/soundtrack.wav`。
22删除:- `render.mjs`:本地静态服务 + 无头 Chrome 逐帧截图 + ffmpeg 编码。
26新增:- `render.mjs`:本地静态服务 + 无头 Chrome 逐帧截图 + ffmpeg 编码;`--portrait` 输出竖屏。
27新增:- `chrome.mjs`:在 macOS、Windows、Linux 上查找 Chrome / Chromium / Edge。
2328
2429## 使用
2530
@@ -29,8 +34,10 @@
2934cd promo
3035npm install
3136npm run preview # 打开打印出的地址实时预览:空格播放/暂停,←/→ 跳转,?t=12.5 定位
32删除:npm run render # 合成配乐并导出 out/claude-cage-promo.mp4
37新增:npm run render # 合成配乐并导出横屏 out/claude-cage-promo.mp4
38新增:npm run render:vertical # 竖屏 9:16,导出 out/claude-cage-promo-vertical.mp4(预览加 ?portrait)
3339npm run render:draft # 960×540 / 30 fps 快速草稿
40新增:npm run plates # 工作台界面更新后,先构建 UI,再重截第三幕底图
3441node render.mjs --frames 8.6,24,33 # 只导出这些时间点的 PNG
3542```
3643
新增promo/capture-plates.mjs+158 −0看文件
@@ -0,0 +1,158 @@
1新增:// Capture the real workbench UI as the promo's Act 3 plates (plates/*.png, 2x).
2新增:// Serves the built UI from internal/workbench/web against a small mock API, so
3新增:// no VM is needed. Rebuild the UI first (make, or `npm run build` in ui/) when
4新增:// the workbench changes, then run `npm run plates`.
5新增://
6新增:// Remote panes (Claude Desktop, the browser page) and terminal text are hidden;
7新增:// promo.js draws them on top of the plates.
8新增:import { createReadStream, existsSync, mkdirSync, statSync, writeFileSync } from 'node:fs';
9新增:import { createServer } from 'node:http';
10新增:import { extname, join, resolve } from 'node:path';
11新增:import { fileURLToPath } from 'node:url';
12新增:import { findChrome } from './chrome.mjs';
13新增:
14新增:const here = fileURLToPath(new URL('.', import.meta.url));
15新增:const web = resolve(here, '..', 'internal', 'workbench', 'web');
16新增:const out = join(here, 'plates');
17新增:if (!existsSync(join(web, 'index.html'))) {
18新增: console.error(`No built workbench UI at ${web}. Build it first (make, or npm run build in ui/).`);
19新增: process.exit(1);
20新增:}
21新增:
22新增:// ---------- mock API ----------
23新增:let scene = 'home';
24新增:const until = new Date(Date.now() + 864e5).toISOString();
25新增:const WS = '/workspace/hello-cage';
26新增:const dev = { id: 't2', kind: 'shell', workspace: WS, title: '开发终端' };
27新增:const claude = { id: 't1', kind: 'claude', workspace: WS, title: 'Claude 终端', claude_account_id: 'a1' };
28新增:const authorize = { id: 'b1', kind: 'browser', title: 'Authorize · Claude', url: 'https://claude.ai/oauth/authorize?code=true&client_id=claude-code' };
29新增:// The eleven critical checks, as the safety dialog lists them.
30新增:const CHECKS = ['VM 外出站约束', '终端检测通道', 'DNS 与解析约束', '系统时区与语言', '浏览器时区与语言', '共享文件与宿主私有目录',
31新增: '宿主管理接口', '代理故障关闭', 'UDP 出站约束', 'IPv6 出站约束', '出口符合已保存规则'];
32新增:const created = '2026-11-05T06:30:12Z';
33新增:const report = state => ({
34新增: created_at: created,
35新增: checks: CHECKS.map((title, i) => ({ id: `c${i}`, title, critical: true, state, checked_at: created, evidence: '' })),
36新增:});
37新增:const safety = () => scene === 'safety-run'
38新增: ? { gate: { mode: 'checking', until }, exit_ip: '203.0.113.8', report: report('unknown') }
39新增: : { gate: { mode: 'open', until }, exit_ip: '203.0.113.8', ...(scene === 'safety-done' ? { report: report('passed') } : {}) };
40新增:const job = () => scene === 'safety-run'
41新增: ? { id: 'j1', running: true, kind: 'safety', message: '正在核对网络与隔离…', error: '' }
42新增: : { id: 'j0', running: false, kind: 'start', message: '', error: '' };
43新增:const routes = {
44新增: 'GET /api/settings': () => ({ timezone: 'America/Los_Angeles', auto_timezone: true, browser_home_url: 'https://claude.ai/' }),
45新增: 'GET /api/proxy': () => ({ active: true, selected: 'la-01', groups: [], sources: [] }),
46新增: 'GET /api/account': () => ({ exists: true, unlocked: true, username: 'lee', devices: {}, require_authentication: false }),
47新增: 'GET /api/status': () => ({
48新增: ready: true, vm_running: true, workspace: WS, environment_workspace: '/workspace', environment_directory: '/workspace',
49新增: projects: [WS, '/workspace/api-server'], project_errors: [], can_restore: false,
50新增: job: job(),
51新增: location: { ip: '203.0.113.8', country: 'US', city: 'Los Angeles' },
52新增: safety: safety(), keyboard: {},
53新增: }),
54新增: 'GET /api/browser/tabs': () => (scene === 'browser' ? { tabs: [authorize], active: 'b1' } : { tabs: [], active: '' }),
55新增: 'GET /api/terminals': () => (scene === 'term' || scene === 'browser' ? [dev, claude] : [dev]),
56新增: 'GET /api/claude-desktop': () => ({ installed: true, running: scene === 'desktop', version: '1.2.0', managed: true }),
57新增: 'GET /api/favorites': () => ({ items: [], folders: [] }),
58新增: 'GET /api/claude-accounts': () => ({ accounts: [{ id: 'a1', label: '工作', email: '[email protected]', enabled: true, status: 'ready', plan: 'Max', source: 'login' }] }),
59新增: 'GET /api/browser/files/saved': () => [],
60新增: 'GET /api/input/files/desktop/requests': () => ({ uploads: [] }),
61新增:};
62新增:const TYPES = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.png': 'image/png', '.svg': 'image/svg+xml' };
63新增:const server = createServer((req, res) => {
64新增: const url = new URL(req.url, 'http://x');
65新增: if (url.pathname.startsWith('/api/')) {
66新增: const route = routes[`${req.method} ${url.pathname}`];
67新增: res.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify(route ? route() : {}));
68新增: return;
69新增: }
70新增: let file = join(web, url.pathname === '/' ? 'index.html' : url.pathname);
71新增: if (!file.startsWith(web) || !existsSync(file) || !statSync(file).isFile()) file = join(web, 'index.html');
72新增: res.writeHead(200, { 'content-type': TYPES[extname(file)] || 'application/octet-stream' });
73新增: createReadStream(file).pipe(res);
74新增:});
75新增:await new Promise(ok => server.listen(0, '127.0.0.1', ok));
76新增:const origin = `http://127.0.0.1:${server.address().port}`;
77新增:
78新增:// ---------- scenes ----------
79新增:const hide = `.view-overlay,.terminal-note,.remote-canvas,.xterm{visibility:hidden!important}
80新增:*:focus,*:focus-visible{outline:none!important;box-shadow:none!important}`;
81新增:const press = label => `(() => {
82新增: const b = ${JSON.stringify(label)}.startsWith('.') ? document.querySelector(${JSON.stringify(label)})
83新增: : [...document.querySelectorAll('button')].find(b => b.getAttribute('aria-label') === ${JSON.stringify(label)} || b.textContent.trim().startsWith(${JSON.stringify(label)}));
84新增: if (!b) throw new Error('button not found: ' + ${JSON.stringify(label)});
85新增: b.click();
86新增:})()`;
87新增:const scenes = [
88新增: ['home', 'home', []],
89新增: ['desktop', 'desktop', ['Claude Desktop']],
90新增: ['menu', 'desktop', ['Claude Desktop', '在 hello-cage 新建终端']],
91新增: ['term', 'term', ['Claude 终端']],
92新增: ['browser', 'browser', ['打开浏览器']],
93新增: ['safety-run', 'safety-run', ['.sidebar-status']],
94新增: ['safety-done', 'safety-done', ['.sidebar-status']],
95新增:];
96新增:const wait = ms => new Promise(ok => setTimeout(ok, ms));
97新增:// Landscape matches the 16:9 cut; portrait is a tall window the vertical cut can show at full width.
98新增:const sizes = [
99新增: ['landscape', 1440, 860, out],
100新增: ['portrait', 760, 1100, join(out, 'portrait')],
101新增:];
102新增:// What promo.js needs to know about each plate, measured from the live DOM.
103新增:const measure = () => {
104新增: const box = el => { if (!el) return null; const r = el.getBoundingClientRect(); return [r.left, r.top, r.width, r.height].map(v => Math.round(v * 10) / 10); };
105新增: const button = text => [...document.querySelectorAll('button')].find(b => b.getAttribute('aria-label') === text || b.textContent.trim().startsWith(text));
106新增: const status = document.querySelector('.status-bar');
107新增: return {
108新增: sidebar: box(document.querySelector('.workspace-sidebar')),
109新增: header: box(document.querySelector('.content-heading, .claude-desktop-toolbar')),
110新增: status: box(status),
111新增: statusItems: [...status.querySelectorAll(':scope > button')].filter(b => b.offsetParent).slice(0, 3).map(box),
112新增: shield: box(document.querySelector('.sidebar-status')),
113新增: desktopNav: box(button('Claude Desktop')),
114新增: termIcon: box(button('在 hello-cage 新建终端')),
115新增: claudeItem: box(document.querySelector('.terminal-create-menu button:nth-child(2)')),
116新增: navigation: box(document.querySelector('.navigation-row')),
117新增: dialog: box(document.querySelector('[role="dialog"]')),
118新增: summary: box(document.querySelector('.safety-summary')),
119新增: count: box(document.querySelector('.safety-section-heading > span')),
120新增: rows: [...document.querySelectorAll('.safety-check > summary')].map(box),
121新增: };
122新增:};
123新增:
124新增:const { default: puppeteer } = await import('puppeteer-core');
125新增:const browser = await puppeteer.launch({ executablePath: findChrome(), headless: true, args: ['--hide-scrollbars', '--force-color-profile=srgb'] });
126新增:const layout = {};
127新增:try {
128新增: for (const [orientation, width, height, dir] of sizes) {
129新增: mkdirSync(dir, { recursive: true });
130新增: layout[orientation] = { width, height };
131新增: for (const [name, state, steps] of scenes) {
132新增: scene = state;
133新增: const page = await browser.newPage();
134新增: await page.setViewport({ width, height, deviceScaleFactor: 2 });
135新增: await page.emulateTimezone('Asia/Shanghai');
136新增: await page.goto(origin + '/', { waitUntil: 'networkidle0' });
137新增: await page.addStyleTag({ content: hide });
138新增: await wait(1500);
139新增: for (const label of steps) { await page.evaluate(press(label)); await wait(900); }
140新增: if (name === 'menu') {
141新增: // Hover the Claude terminal item, as the cursor is about to click it.
142新增: await page.evaluate(() => {
143新增: document.querySelector('.terminal-create-menu button:nth-child(2)').style.background = 'var(--hover)';
144新增: document.activeElement?.blur();
145新增: });
146新增: }
147新增: await wait(400);
148新增: await page.screenshot({ path: join(dir, `${name}.png`) });
149新增: layout[orientation][name] = await page.evaluate(measure);
150新增: console.log(join(dir, `${name}.png`));
151新增: await page.close();
152新增: }
153新增: }
154新增: writeFileSync(join(out, 'layout.js'), `// Generated by capture-plates.mjs: where things sit on each plate, in workbench pixels.\nwindow.PLATE_LAYOUT = ${JSON.stringify(layout)};\n`);
155新增:} finally {
156新增: await browser.close();
157新增: server.close();
158新增:}
新增promo/chrome.mjs+28 −0看文件
@@ -0,0 +1,28 @@
1新增:// Locate a Chrome, Chromium or Edge executable on macOS, Windows or Linux.
2新增:import { existsSync } from 'node:fs';
3新增:import { join } from 'node:path';
4新增:
5新增:export function findChrome() {
6新增: if (process.env.CHROME_PATH) return process.env.CHROME_PATH;
7新增: const pf = process.env.PROGRAMFILES || 'C:\\Program Files';
8新增: const pf86 = process.env['PROGRAMFILES(X86)'] || 'C:\\Program Files (x86)';
9新增: const local = process.env.LOCALAPPDATA || '';
10新增: const candidates = {
11新增: darwin: [
12新增: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
13新增: '/Applications/Chromium.app/Contents/MacOS/Chromium',
14新增: '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
15新增: ],
16新增: win32: [
17新增: join(pf, 'Google\\Chrome\\Application\\chrome.exe'),
18新增: join(pf86, 'Google\\Chrome\\Application\\chrome.exe'),
19新增: join(local, 'Google\\Chrome\\Application\\chrome.exe'),
20新增: join(pf86, 'Microsoft\\Edge\\Application\\msedge.exe'),
21新增: join(pf, 'Microsoft\\Edge\\Application\\msedge.exe'),
22新增: ],
23新增: linux: ['/usr/bin/google-chrome', '/usr/bin/google-chrome-stable', '/usr/bin/chromium', '/usr/bin/chromium-browser', '/snap/bin/chromium'],
24新增: }[process.platform] || [];
25新增: const found = candidates.find(p => existsSync(p));
26新增: if (!found) throw new Error('Chrome not found. Set CHROME_PATH to a Chrome, Chromium or Edge executable.');
27新增: return found;
28新增:}
修改promo/index.html+345 −262看文件
@@ -6,7 +6,7 @@
66<title>Claude Cage · 宣传片</title>
77<link rel="preconnect" href="https://fonts.googleapis.com" />
88<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9删除:<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Noto+Sans+SC:wght@400;500;600;700&family=Noto+Serif+SC:wght@500;600;700&display=block" />
9新增:<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Noto+Sans+SC:wght@400;500;600;700&family=Noto+Serif+SC:wght@500;600;700&family=Source+Serif+4:opsz,[email protected],500;8..60,600&display=block" />
1010<style>
1111:root {
1212 --paper: #faf8f4;
@@ -57,14 +57,19 @@ body { font-family: var(--sans); -webkit-font-smoothing: antialiased; font-synth
5757 box-shadow: 0 40px 90px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06); border-radius: 22px; color: #f4ece4; }
5858
5959/* beat 1 */
60删除:#alarm { position: absolute; left: 50%; top: 404px; width: 900px; margin-left: -450px; padding: 30px 32px; display: grid; grid-template-columns: 76px 1fr auto; gap: 24px; align-items: center;
61删除: background: linear-gradient(180deg, #6b2a1d, #3d1912); border-color: rgba(255,140,100,.35); }
62删除:#alarm .ico { width: 76px; height: 76px; border-radius: 18px; background: rgba(255,120,80,.22); color: #ffb391; display: grid; place-items: center; }
63删除:#alarm .ico svg { width: 40px; height: 40px; }
64删除:#alarm h4 { margin: 0 0 8px; font: 700 36px/1.2 var(--sans); }
65删除:#alarm p { margin: 0; font: 400 21px/1.4 var(--sans); color: rgba(255,230,220,.66); }
66删除:#alarm time { align-self: start; font: 400 17px/1 var(--sans); color: rgba(255,230,220,.5); padding-top: 8px; }
67删除:#losses { position: absolute; left: 0; right: 0; top: 652px; display: flex; justify-content: center; gap: 24px; }
60新增:#hold { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; overflow: hidden; background: #f8f7f3; transform-origin: 50% 50%; z-index: 2; }
61新增:#holdScroll { position: absolute; left: 50%; top: 0; width: 900px; margin-left: -450px; text-align: center; color: #2b2a27; font-family: "Inter", sans-serif; will-change: transform; }
62新增:#holdScroll h1 { margin: 112px 0 0; font: 500 118px/1.04 "Source Serif 4", Georgia, serif; letter-spacing: -.028em; color: #1c1b19; }
63新增:#holdScroll .lock { display: block; width: 132px; height: 165px; margin: 52px auto 44px; }
64新增:#holdScroll p { margin: 0 0 30px; font: 400 33px/1.45 "Inter", sans-serif; color: #3b3a36; }
65新增:#holdScroll p b { font-weight: 600; color: #1c1b19; }
66新增:#holdScroll .next { text-align: left; margin: 46px 0 24px; color: #57554f; }
67新增:#holdScroll .hcard { text-align: left; background: #fff; border: 1.5px solid #dcd9d2; border-radius: 40px; padding: 40px 48px 14px; }
68新增:#holdScroll .step { display: grid; grid-template-columns: 46px 1fr; margin-bottom: 30px; font: 400 35px/1.3 "Inter", sans-serif; color: #2b2a27; }
69新增:#holdScroll .step p { margin: 6px 0 0; font-size: 29px; line-height: 1.4; color: #8a877f; }
70新增:#holdMark { background: linear-gradient(transparent 58%, rgba(226,92,58,.30) 58%) no-repeat 0 0 / 0% 100%; color: #8a877f; }
71新增:#holdTint { position: absolute; inset: 0; background: #2a0d06; opacity: 0; pointer-events: none; }
72新增:#losses { position: absolute; left: 0; right: 0; top: 722px; display: flex; justify-content: center; gap: 24px; }
6873.loss { width: 284px; padding: 26px 28px; border-radius: 18px; text-align: left; }
6974.loss span { display: block; font: 500 19px/1 var(--sans); color: rgba(244,236,228,.5); text-decoration: line-through; text-decoration-color: rgba(255,106,69,.7); }
7075.loss b { display: block; margin-top: 14px; font: 700 34px/1.1 var(--sans); color: #ff6a45; }
@@ -146,152 +151,140 @@ body { font-family: var(--sans); -webkit-font-smoothing: antialiased; font-synth
146151#progressDots i b { position: absolute; inset: 0; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
147152
148153#cam { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
149删除:#win {
150删除: position: relative; width: 1280px; height: 760px; border-radius: 14px; overflow: hidden; background: #fff;
151删除: box-shadow: 0 0 0 1px rgba(40,25,10,.09), 0 50px 120px -20px rgba(70,40,15,.28), 0 18px 40px -12px rgba(70,40,15,.18);
152删除: font-size: 14px; color: #1f1d1b;
153删除:}
154删除:#win svg.i { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
155删除:.side { position: absolute; left: 0; top: 0; bottom: 0; width: 248px; background: #f7f6f4; border-right: 1px solid #ebe8e4; }
156删除:.lights { position: absolute; left: 18px; top: 17px; display: flex; gap: 8px; }
157删除:.lights i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.15); }
158删除:.lights i:nth-child(2) { background: #febc2e; } .lights i:nth-child(3) { background: #28c840; }
159删除:.brand { position: absolute; left: 18px; top: 46px; right: 16px; display: flex; align-items: center; gap: 10px; font: 650 18px/1 var(--sans); }
160删除:.brand .mark { width: 22px; height: 22px; }
161删除:.brand .collapse { margin-left: auto; color: #6c6763; }
162删除:.nav { position: absolute; left: 12px; right: 12px; top: 88px; display: grid; gap: 2px; }
163删除:.nav div, .proj div { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border-radius: 9px; color: #2a2724; }
164删除:.nav .dim { color: #b4aea8; }
165删除:.nav .on { background: #ebe9e6; }
166删除:.nav kbd { margin-left: auto; font: 400 12px var(--sans); color: #9a948e; }
167删除:.sec { position: absolute; left: 24px; right: 24px; top: 262px; display: flex; justify-content: space-between; color: #6c6763; font-size: 13px; }
168删除:.proj { position: absolute; left: 12px; right: 12px; top: 292px; display: grid; gap: 2px; }
169删除:.proj .child { padding-left: 34px; font-size: 13px; color: #8b8580; position: relative; }
170删除:.proj .child .alt { position: absolute; left: 0; top: 0; height: 38px; width: 100%; padding-left: 12px; display: flex; align-items: center; gap: 9px;
171删除: border-radius: 9px; color: #2a2724; background: #ebe9e6; font-size: 14px; }
172删除:.side-foot { position: absolute; left: 12px; right: 12px; bottom: 12px; border-top: 1px solid #e6e2dd; padding-top: 10px; display: grid; gap: 2px; }
173删除:.side-foot div { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; font-size: 13.5px; color: #2a2724; }
174删除:.side-foot .dot { width: 7px; height: 7px; border-radius: 50%; background: #b7b1ab; margin: 0 4px 0 2px; }
175删除:.side-foot kbd { margin-left: auto; font: 400 12px var(--sans); color: #9a948e; }
176删除:.side-foot .shield { margin-left: auto; color: #6c6763; }
177删除:.main { position: absolute; left: 248px; right: 0; top: 0; bottom: 0; }
178删除:.topbar { position: absolute; left: 0; right: 0; top: 0; height: 58px; display: flex; align-items: center; padding: 0 22px; gap: 10px; }
179删除:.crumb { display: flex; align-items: center; gap: 10px; font-weight: 500; }
180删除:.crumb .sep, .crumb .leaf { color: #2a2724; }
181删除:.top-actions { margin-left: auto; display: flex; gap: 12px; align-items: center; color: #3c3936; }
182删除:.pill { display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border: 1px solid #e3dfda; border-radius: 9px; font-size: 13px; background: #fff; }
183删除:.status { position: absolute; left: 0; right: 0; bottom: 0; height: 32px; border-top: 1px solid #ece9e5; display: flex; align-items: center;
184删除: padding: 0 18px; gap: 0; font-size: 12px; color: #4a4642; background: #fff; }
185删除:.status .it { display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 16px; border-left: 1px solid #e3dfda; position: relative; }
186删除:.status .it:first-child { border-left: 0; padding-left: 2px; }
187删除:.status svg.i { width: 13px !important; height: 13px !important; }
188删除:.status .right { margin-left: auto; display: flex; }
189删除:.flip { position: relative; display: inline-block; overflow: hidden; height: 16px; line-height: 16px; vertical-align: top; }
190删除:.flip span { display: block; white-space: nowrap; }
191删除:.flip span + span { position: absolute; left: 0; top: 0; }
192删除:.hl { position: absolute; inset: -6px -4px; border-radius: 7px; background: rgba(185,80,50,.10); box-shadow: 0 0 0 1.5px rgba(185,80,50,.45); opacity: 0; }
193删除:
194删除:/* hero (first run) */
195删除:.view { position: absolute; left: 0; right: 0; top: 58px; bottom: 32px; }
196删除:.hero { text-align: center; }
197删除:.hero .shield-big { width: 44px; height: 44px; margin: 74px auto 0; color: #232120; }
198删除:#win .hero .shield-big svg.i { width: 44px; height: 44px; stroke-width: 1.5; }
199删除:.hero h2 { margin: 18px 0 0; font: 700 34px/1.2 var(--sans); letter-spacing: -.01em; }
200删除:.hero .lead { margin-top: 18px; color: #3c3936; font-size: 14.5px; }
201删除:.steps { margin: 24px auto 0; display: flex; justify-content: center; gap: 26px; font-size: 13.5px; color: #3c3936; }
202删除:.steps span { display: flex; align-items: center; gap: 8px; }
203删除:.steps b { width: 22px; height: 22px; border-radius: 50%; border: 1px solid #cfcac4; display: grid; place-items: center; font: 500 12px var(--sans); position: relative; background: #fff; }
204删除:.steps b.on { background: #1d1b1a; color: #fff; border-color: #1d1b1a; }
205删除:.steps b.done { background: var(--ok); border-color: var(--ok); color: #fff; }
206删除:.steps b svg.i { width: 13px !important; height: 13px !important; stroke-width: 2.4 !important; }
207删除:.steps .strong { font-weight: 600; color: #1d1b1a; }
208删除:.card { position: relative; width: 500px; margin: 26px auto 0; border: 1px solid #e3dfda; border-radius: 16px; padding: 22px 22px 18px; text-align: left; background: #fff; }
209删除:.card .head { display: flex; gap: 14px; align-items: flex-start; }
210删除:#win .card .head svg.i { width: 24px; height: 24px; margin-top: 4px; }
211删除:.card .t { font: 600 15px/1.4 var(--sans); }
212删除:.card .d { font-size: 12.5px; color: #6c6763; margin-top: 4px; }
213删除:.card .row { margin-top: 22px; display: flex; align-items: center; justify-content: space-between; height: 38px; }
214删除:.card .state { position: relative; font-size: 12.5px; color: #6c6763; height: 20px; width: 260px; }
215删除:.card .state > div { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
216删除:.card .state i { width: 6px; height: 6px; border-radius: 50%; background: #b7b1ab; display: block; }
217删除:.card .state .ready i { background: var(--ok); box-shadow: 0 0 0 3px rgba(47,138,76,.15); }
218删除:.card .state .ready b { color: #1d1b1a; font-weight: 600; }
219删除:.btn { position: relative; height: 38px; padding: 0 16px; border-radius: 9px; background: #1d1b1a; color: #fff; display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; }
220删除:.btn-swap { position: relative; width: 150px; height: 38px; }
221删除:.btn-swap .btn { position: absolute; right: 0; top: 0; white-space: nowrap; }
222删除:.hero .foot { margin-top: 26px; font-size: 12.5px; color: #3c3936; }
223删除:
224删除:/* proxy modal */
225删除:#modalShade { position: absolute; inset: 0; background: rgba(30,24,20,.18); }
226删除:#modal { position: absolute; left: 50%; top: 92px; width: 560px; margin-left: -280px; background: #fff; border-radius: 16px;
227删除: box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 40px 80px -10px rgba(40,25,10,.32); overflow: hidden; }
228删除:#modal .mh { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 16px; border-bottom: 1px solid #efebe6; font: 650 18px var(--sans); }
229删除:#modal .src { margin: 16px 22px 10px; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 11px; background: #f7f5f2; font-size: 13px; }
230删除:#modal .src .tag { margin-left: auto; color: var(--ok); font-size: 12.5px; display: flex; align-items: center; gap: 5px; }
231删除:#modal .lbl { margin: 14px 22px 6px; font-size: 12px; color: #8b8580; letter-spacing: .04em; }
232删除:#modal .nodes { margin: 0 14px; display: grid; gap: 2px; }
233删除:#modal .node { position: relative; display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
234删除:#modal .node .sel { position: absolute; inset: 0; border-radius: 10px; background: #f3f0ec; box-shadow: inset 0 0 0 1.5px #1d1b1a; opacity: 0; }
235删除:#modal .node .radio { position: relative; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #c9c3bc; display: grid; place-items: center; }
236删除:#modal .node .radio i { width: 8px; height: 8px; border-radius: 50%; background: #1d1b1a; transform: scale(0); }
237删除:#modal .node .ms { margin-left: auto; position: relative; font: 500 12.5px var(--mono); color: #6c6763; display: flex; align-items: center; gap: 8px; }
238删除:#modal .node .ms em { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); display: block; }
239删除:#modal .node .ms em.warn { background: #d29a2e; }
240删除:#modal .node > span { position: relative; }
241删除:#modal .mf { margin-top: 14px; padding: 14px 22px; border-top: 1px solid #efebe6; display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: #6c6763; }
242删除:
243删除:/* launch panel */
244删除:.launch { padding-top: 34px; }
245删除:.panel { width: 820px; margin: 0 auto; border: 1px solid #e3dfda; border-radius: 16px; overflow: hidden; background: #fff; }
246删除:.ph { display: flex; gap: 14px; align-items: center; padding: 20px 24px; border-bottom: 1px solid #efebe6; position: relative; }
247删除:.ph .badge { position: relative; width: 44px; height: 44px; border-radius: 12px; background: #f4f1ed; display: grid; place-items: center; }
248删除:#win .ph .badge svg.i { width: 24px; height: 24px; }
249删除:.ph .badge .okb { position: absolute; inset: 0; border-radius: 12px; background: #e9f4ec; color: var(--ok); display: grid; place-items: center; opacity: 0; }
250删除:.ph .tt { position: relative; height: 46px; flex: 1; }
251删除:.ph .tt > div { position: absolute; left: 0; top: 0; }
252删除:.ph .tt .a { font: 650 17px/1.4 var(--sans); }
253删除:.ph .tt .b { font-size: 13px; color: #6c6763; margin-top: 3px; }
254删除:.ph .count { font: 500 13px var(--mono); color: #6c6763; }
255删除:.prog { padding: 14px 24px 6px; display: grid; gap: 10px; }
256删除:.prog .p { display: grid; grid-template-columns: 20px 150px 1fr 54px; align-items: center; gap: 12px; font-size: 13px; height: 22px; }
257删除:.prog .bar { height: 5px; border-radius: 5px; background: #efebe6; overflow: hidden; }
258删除:.prog .bar i { display: block; height: 100%; background: #1d1b1a; transform-origin: 0 50%; transform: scaleX(0); }
259删除:.prog .pct { font: 500 12px var(--mono); color: #8b8580; text-align: right; }
260删除:.st { position: relative; width: 18px; height: 18px; }
261删除:.st > * { position: absolute; inset: 0; }
262删除:.st .spin { border-radius: 50%; border: 2px solid #e2ddd7; border-top-color: #1d1b1a; }
263删除:.st .ok { border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; transform: scale(0); }
264删除:.st .ok svg.i { width: 11px !important; height: 11px !important; stroke-width: 3 !important; }
265删除:.st .wait { border-radius: 50%; border: 2px solid #e8e4df; }
266删除:.checks-h { padding: 14px 24px 8px; display: flex; justify-content: space-between; font-size: 12.5px; color: #8b8580; border-top: 1px solid #f2efeb; margin-top: 10px; }
267删除:.checks { padding: 0 16px 16px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; row-gap: 2px; }
268删除:.ck { display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 10px; border-radius: 9px; font-size: 13.5px; position: relative; }
269删除:.ck .res { margin-left: auto; position: relative; width: 60px; height: 16px; font-size: 12.5px; text-align: right; }
270删除:.ck .res span { position: absolute; right: 0; top: 0; white-space: nowrap; }
271删除:.ck .res .y { color: var(--ok); font-weight: 500; }
272删除:.ck .res .n { color: #a39d97; }
273删除:.ck .flash { position: absolute; inset: 0; border-radius: 9px; background: rgba(47,138,76,.08); opacity: 0; }
274删除:
275删除:/* terminal */
276删除:.term-bar { position: absolute; left: 0; right: 0; top: 0; height: 46px; border-top: 1px solid #efebe6; border-bottom: 1px solid #efebe6; display: flex; align-items: center; padding: 0 18px; gap: 10px; font: 400 13px var(--mono); color: #3c3936; }
277删除:.term-bar .r { margin-left: auto; display: flex; align-items: center; gap: 14px; font: 400 12.5px var(--sans); }
278删除:.term { position: absolute; left: 36px; right: 36px; top: 76px; bottom: 0; font: 400 14.5px/1.72 var(--mono); color: #23201e; }
279删除:.term .ln, .cc { white-space: pre; }
280删除:.term .acc { color: #9a4a2c; font-weight: 600; }
281删除:.term .g { color: #6f8f3a; }
282删除:.term .m { color: #8b8580; }
283删除:.term .ln { height: 25px; }
284删除:.caret { display: inline-block; width: 9px; height: 19px; background: #23201e; vertical-align: -4px; margin-left: 1px; }
285删除:.cc { margin: 6px 0 8px; width: 560px; border: 1.5px solid #d97757; border-radius: 10px; padding: 10px 18px; line-height: 1.7; }
286删除:.cc .w { color: #c25f3c; font-weight: 600; }
287删除:.reply .dot { color: #23201e; }
288删除:.reply .tool { font-weight: 600; }
154新增:#win { position: relative; width: 1440px; height: 860px; border-radius: 14px; overflow: hidden; background: #fff;
155新增: box-shadow: 0 0 0 1px rgba(40,25,10,.10), 0 50px 120px -20px rgba(70,40,15,.30), 0 18px 40px -12px rgba(70,40,15,.18); }
156新增:#win .plate { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
157新增:.pane { position: absolute; left: 249px; right: 0; bottom: 32px; overflow: hidden; }
158新增:.ring2 { position: absolute; border-radius: 8px; box-shadow: 0 0 0 2px rgba(185,80,50,.8); background: rgba(185,80,50,.07); opacity: 0; }
159新增:
160新增:/* safety dialog: rows flip from pending to passed one at a time */
161新增:#checkFx { position: absolute; inset: 0; pointer-events: none; }
162新增:#checkFx .row { position: absolute; background-repeat: no-repeat; opacity: 0; }
163新增:#checkFx .flash { position: absolute; inset: 0; background: rgba(39,131,92,.10); opacity: 0; }
164新增:#checkFx .spin { position: absolute; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px; border-radius: 50%; background: #fff;
165新增: box-shadow: 0 0 0 3px #fff; border: 2px solid #cfe0f6; border-top-color: #2f7fe0; opacity: 0; }
166新增:#checkCount { position: absolute; height: 17px; padding-right: 6px; background: #fff; font: 400 14px/17px "Noto Sans SC", "PingFang SC", sans-serif; color: #363636; white-space: nowrap; opacity: 0; }
167新增:
168新增:/* Claude Desktop, running inside the VM display */
169新增:#paneDesktop { top: 42px; background: #faf9f5; }
170新增:.cd { position: absolute; inset: 0; display: flex; font-family: "Inter", "Noto Sans SC", sans-serif; color: #3d3929; }
171新增:.cd-side { width: 236px; flex: none; background: #f3f1ea; border-right: 1px solid #e6e2d8; padding: 18px 14px; }
172新增:.cd-logo { font: 600 22px/1 "Source Serif 4", Georgia, serif; letter-spacing: -.01em; padding: 6px 8px 20px; color: #3d3929; }
173新增:.cd-new { display: flex; align-items: center; gap: 10px; padding: 8px; font: 500 15px/1 "Inter", sans-serif; color: #b6593a; }
174新增:.cd-new i { width: 24px; height: 24px; border-radius: 50%; background: #d97757; color: #fff; display: grid; place-items: center; font: 500 17px/1 "Inter", sans-serif; font-style: normal; }
175新增:.cd-nav { margin-top: 6px; }
176新增:.cd-nav div { padding: 9px 8px; border-radius: 9px; font: 400 15px/1 "Inter", sans-serif; color: #4a463d; }
177新增:.cd-nav div.on { background: #e8e4d9; }
178新增:.cd-rec { margin: 24px 8px 8px; font: 500 12.5px/1 "Inter", sans-serif; color: #8d8778; }
179新增:.cd-side .it { padding: 8px; font: 400 14px/1.2 "Inter", "Noto Sans SC", sans-serif; color: #57534a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 8px; }
180新增:.cd-side .it.on { background: #e8e4d9; color: #2f2c26; }
181新增:.cd-main { position: relative; flex: 1; }
182新增:.cd-hello { position: absolute; left: 0; right: 0; top: 214px; text-align: center; font: 400 42px/1.2 "Source Serif 4", Georgia, serif; color: #3d3929; letter-spacing: -.01em; }
183新增:.cd-hello span { color: #d97757; margin-right: 14px; font-family: "Inter", sans-serif; }
184新增:.cd-input { position: absolute; left: 50%; width: 680px; margin-left: -340px; top: 300px; background: #fff; border: 1px solid #e3dfd5; border-radius: 20px;
185新增: box-shadow: 0 4px 22px rgba(60,50,30,.07); padding: 18px 20px 14px; }
186新增:.cd-input .tx { min-height: 26px; font: 400 17px/1.5 "Inter", "Noto Sans SC", sans-serif; color: #2f2c26; }
187新增:.cd-input .ph { color: #9b968a; }
188新增:.cd-input .row { display: flex; align-items: center; gap: 10px; margin-top: 26px; font: 400 14px/1 "Inter", sans-serif; color: #6f6a5f; }
189新增:.cd-input .row .pl { width: 32px; height: 32px; border: 1px solid #e3dfd5; border-radius: 10px; display: grid; place-items: center; font-size: 18px; }
190新增:.cd-input .row .md { margin-left: auto; }
191新增:.cd-input .row .send { width: 34px; height: 34px; border-radius: 10px; background: #e8b8a5; color: #fff; display: grid; place-items: center; font: 600 18px/1 "Inter", sans-serif; }
192新增:.cd-chat { position: absolute; left: 50%; width: 720px; margin-left: -360px; top: 46px; }
193新增:.cd-user { margin-left: auto; width: fit-content; max-width: 540px; background: #efece3; border-radius: 16px; padding: 12px 18px; font: 400 16.5px/1.6 "Inter", "Noto Sans SC", sans-serif; color: #2f2c26; }
194新增:.cd-reply { margin-top: 26px; font: 400 19px/1.8 "Source Serif 4", "Noto Serif SC", Georgia, serif; color: #2f2c26; }
195新增:.cd-reply p { margin: 0 0 8px; }
196新增:.cd-reply .li { padding-left: 4px; }
197新增:
198新增:/* Claude Code in the Claude terminal */
199新增:#paneTerm { top: 41px; background: #fff; padding: 24px 30px; font: 400 15px/1.75 "JetBrains Mono", "Noto Sans Mono CJK SC", monospace; color: #2b2b2b; }
200新增:#paneTerm .tl { position: absolute; left: 30px; right: 30px; top: 22px; }
201新增:#paneTerm .ln { white-space: pre; min-height: 26px; }
202新增:#paneTerm .acc { color: #c15f3c; }
203新增:#paneTerm .dim { color: #8a8a8a; }
204新增:#paneTerm .g { color: #3f8f4f; }
205新增:#paneTerm b { font-weight: 600; }
206新增:#paneTerm .box { width: 640px; margin: 2px 0 12px; padding: 10px 18px; border: 1.5px solid #d97757; border-radius: 8px; white-space: pre; line-height: 1.75; }
207新增:.tcaret { display: inline-block; width: 9px; height: 19px; background: #2b2b2b; vertical-align: -4px; margin-left: 1px; }
208新增:
209新增:/* claude.ai authorisation, inside the Cage browser */
210新增:#paneBrowser { top: 114px; background: #faf9f5; }
211新增:.auth { position: absolute; inset: 0; display: grid; place-items: center; font-family: "Inter", "Noto Sans SC", sans-serif; }
212新增:.auth-card { width: 500px; text-align: center; }
213新增:.auth-word { font: 600 32px/1 "Source Serif 4", Georgia, serif; color: #3d3929; margin-bottom: 26px; letter-spacing: -.01em; }
214新增:.auth h3 { margin: 0 0 10px; font: 600 25px/1.35 "Inter", sans-serif; color: #262420; }
215新增:.auth .who { margin-bottom: 22px; font: 400 15px/1.5 "Inter", sans-serif; color: #7b766b; }
216新增:.auth ul { list-style: none; margin: 0 0 22px; padding: 14px 20px; text-align: left; background: #fff; border: 1px solid #e6e2d8; border-radius: 14px; }
217新增:.auth li { display: flex; gap: 12px; padding: 7px 0; font: 400 15.5px/1.45 "Inter", sans-serif; color: #3d3929; }
218新增:.auth li i { font-style: normal; color: #3f8f4f; font-weight: 700; }
219新增:.auth .go { height: 48px; border-radius: 12px; background: #1f1e1d; color: #fff; font: 600 16px/48px "Inter", sans-serif; }
220新增:.auth .no { margin-top: 10px; height: 44px; border-radius: 12px; border: 1px solid #e0dcd2; font: 500 15px/44px "Inter", sans-serif; color: #57534a; }
221新增:.auth-done { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font-family: "Inter", sans-serif; }
222新增:.auth-done .ok { width: 64px; height: 64px; margin: 0 auto 22px; border-radius: 50%; background: #e7f2ea; color: #2f8a4c; display: grid; place-items: center; font: 700 30px/1 "Inter", sans-serif; }
223新增:.auth-done h3 { margin: 0 0 10px; font: 600 26px/1.3 "Inter", sans-serif; color: #262420; }
224新增:.auth-done p { margin: 0; font: 400 16px/1.5 "Inter", sans-serif; color: #7b766b; }
289225
290226/* cursor */
291227#cursor { position: absolute; left: 0; top: 0; width: 26px; height: 26px; z-index: 30; pointer-events: none; will-change: transform; }
292228#cursor svg { width: 26px; height: 26px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
293229#ripple { position: absolute; left: 0; top: 0; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; border: 2px solid rgba(185,80,50,.55); z-index: 29; opacity: 0; }
294230
231新增:/* ---------- act 3b · accounts ---------- */
232新增:#accts { background: radial-gradient(ellipse 70% 60% at 50% 40%, #fffdfa, var(--paper) 70%), var(--paper); }
233新增:#accts .cap { position: absolute; left: 112px; top: 54px; display: flex; gap: 26px; align-items: baseline; }
234新增:#accts .cap .num { font: 600 22px/1 var(--mono); color: var(--accent); letter-spacing: .08em; position: relative; top: -6px; }
235新增:#accts .cap .txt { display: grid; gap: 10px; }
236新增:#accts .cap .title { font: 650 40px/1.1 var(--sans); color: var(--ink); letter-spacing: -.01em; }
237新增:#accts .cap .sub { font: 400 22px/1.3 var(--sans); color: var(--muted); }
238新增:#accts .dots { position: absolute; right: 112px; top: 68px; display: flex; gap: 10px; }
239新增:#accts .dots i { display: block; width: 34px; height: 4px; border-radius: 4px; background: #e4ddd4; overflow: hidden; position: relative; }
240新增:#accts .dots b { position: absolute; inset: 0; background: var(--accent); transform-origin: 0 50%; }
241新增:#acctPanel { position: absolute; left: 150px; top: 214px; width: 960px; padding: 34px 36px 26px; background: #fff; border-radius: 22px;
242新增: box-shadow: 0 0 0 1px rgba(40,25,10,.08), 0 50px 110px -30px rgba(70,40,15,.28); }
243新增:.ap-head { display: flex; justify-content: space-between; align-items: flex-start; }
244新增:.ap-head h3 { margin: 0; font: 700 30px/1.2 var(--sans); color: #1f1d1b; }
245新增:.ap-head p { margin: 8px 0 0; font: 400 18px/1.4 var(--sans); color: #7a736c; }
246新增:.ap-btn { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: 11px; background: #1d1b1a; color: #fff; font: 500 18px/1 var(--sans); }
247新增:.ap-sub { margin: 26px 0 14px; display: flex; align-items: baseline; gap: 10px; font: 600 18px/1 var(--sans); color: #3c3936; }
248新增:.ap-sub span { color: #8b8580; font-weight: 500; }
249新增:.ap-sub small { margin-left: auto; font: 400 16px/1 var(--sans); color: #8b8580; }
250新增:.acct { position: relative; margin-top: 14px; padding: 20px 22px 18px; border: 1px solid #e7e2db; border-radius: 16px; background: #fffdfb; }
251新增:.acct .ring { position: absolute; inset: -2px; border-radius: 17px; box-shadow: 0 0 0 3px rgba(81,148,137,.55), 0 0 30px rgba(81,148,137,.25); opacity: 0; }
252新增:.acct .row1 { display: flex; align-items: center; gap: 16px; }
253新增:.acct .av { width: 54px; height: 54px; border-radius: 15px; background: #f9e6de; display: grid; place-items: center; flex: none; }
254新增:.acct .av svg { width: 36px; height: 24px; }
255新增:.acct .nm { display: flex; align-items: center; gap: 10px; font: 650 22px/1.2 var(--sans); color: #1f1d1b; }
256新增:.acct .plan { padding: 3px 8px; border-radius: 6px; background: #f1eeea; font: 600 14px/1.2 var(--sans); color: #3c3936; }
257新增:.acct .meta { margin-top: 6px; display: flex; gap: 12px; align-items: center; font: 400 16px/1 var(--sans); color: #8b8580; }
258新增:.acct .meta .ok { display: flex; align-items: center; gap: 6px; color: #3c3936; }
259新增:.acct .meta .ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #2f8a4c; }
260新增:.acct .load { margin-left: auto; position: relative; height: 34px; min-width: 120px; padding: 0 14px; border-radius: 10px; background: #f4f1ed; display: flex; align-items: center; gap: 8px; font: 500 16px/1 var(--sans); color: #4a4642; }
261新增:.acct .load em { font: 600 17px/1 var(--mono); font-style: normal; color: #1f1d1b; }
262新增:.acct .skip { margin-left: auto; height: 34px; padding: 0 14px; border-radius: 10px; background: rgba(217,87,58,.10); color: #b5452a; display: flex; align-items: center; font: 600 16px/1 var(--sans); }
263新增:.acct .tog { display: flex; align-items: center; gap: 10px; font: 500 16px/1 var(--sans); color: #4a4642; }
264新增:.acct .tog i { width: 40px; height: 23px; border-radius: 12px; background: #519489; position: relative; display: block; }
265新增:.acct .tog i::after { content: ""; position: absolute; right: 3px; top: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; }
266新增:.acct .quota { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
267新增:.acct .qr { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; font: 400 15px/1 var(--sans); color: #8b8580; }
268新增:.acct .qr b { font: 600 16px/1 var(--mono); color: #1f1d1b; }
269新增:.acct .qr .bar { height: 9px; border-radius: 6px; background: #eeeae4; overflow: hidden; }
270新增:.acct .qr .bar i { display: block; height: 100%; border-radius: 6px; transform-origin: 0 50%; }
271新增:.acct .qr .five i { background: #d06e4f; }
272新增:.acct .qr .seven i { background: #4f8e83; }
273新增:.acct .qr strong { font: 600 16px/1 var(--mono); color: #1f1d1b; }
274新增:.acct .qr small { grid-column: 2 / -1; font: 400 14px/1 var(--sans); color: #8b8580; }
275新增:.acct.done .qr .five i { background: #c94a2c; }
276新增:#termCol { position: absolute; left: 1330px; top: 330px; width: 440px; }
277新增:.tlabel { font: 600 17px/1 var(--mono); letter-spacing: .2em; color: #a39b92; margin-bottom: 22px; }
278新增:.tpill { position: absolute; left: 0; width: 440px; height: 92px; padding: 0 22px; display: flex; align-items: center; gap: 16px; background: #1f1c1a; color: #f3ece4; border-radius: 16px;
279新增: box-shadow: 0 30px 60px -20px rgba(40,20,10,.45); font: 500 20px/1.2 var(--mono); }
280新增:.tpill .ti { width: 44px; height: 44px; border-radius: 11px; background: rgba(255,255,255,.08); display: grid; place-items: center; color: #e9a487; flex: none; }
281新增:.tpill .ti svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
282新增:.tpill b { display: block; font: 600 21px/1.2 var(--sans); }
283新增:.tpill small { display: block; margin-top: 6px; font: 400 15px/1 var(--sans); color: rgba(243,236,228,.55); }
284新增:.tpill .to { margin-left: auto; padding: 8px 12px; border-radius: 9px; background: rgba(81,148,137,.25); color: #9fd6cb; font: 600 16px/1 var(--sans); white-space: nowrap; }
285新增:#acctWires { position: absolute; inset: 0; width: 1920px; height: 1080px; overflow: visible; pointer-events: none; }
286新增:#acctWires path { fill: none; stroke: #519489; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 2 9; }
287新增:
295288/* ---------- act 4 · perks ---------- */
296289#perks { background: radial-gradient(ellipse 70% 60% at 50% 40%, #fffdfa, var(--paper) 70%), var(--paper); }
297290#perksHead { top: 196px; font: 700 66px/1.2 var(--sans); color: var(--ink); }
@@ -326,6 +319,100 @@ body { font-family: var(--sans); -webkit-font-smoothing: antialiased; font-synth
326319#endUrl { top: 786px; font: 500 24px/1 var(--mono); color: var(--accent); letter-spacing: .02em; }
327320#endNote { top: 978px; font: 400 15px/1.5 var(--sans); color: #a39b92; letter-spacing: .04em; }
328321
322新增:/* ---------- portrait 9:16 ---------- */
323新增:body.portrait #stage { width: 1080px; height: 1920px; }
324新增:/* act 1 */
325新增:body.portrait .kick { top: 230px; }
326新增:body.portrait .head { top: 290px; font-size: 76px; line-height: 1.3; }
327新增:body.portrait .head > span, body.portrait .head > em { display: block; }
328新增:body.portrait #hold { width: 1080px; height: 1920px; }
329新增:body.portrait #holdScroll { top: 250px; }
330新增:body.portrait #losses { top: 1430px; }
331新增:body.portrait .loss { width: 300px; }
332新增:body.portrait #receipt { top: 640px; }
333新增:body.portrait #pcLabel { left: 410px; top: 590px; font-size: 21px; }
334新增:body.portrait .app-chip { left: 410px; }
335新增:body.portrait .warn { right: 690px; font-size: 23px; height: 54px; }
336新增:body.portrait #proxyNode { left: 420px; top: 1330px; }
337新增:body.portrait #vmWin { top: 640px; width: 980px; margin-left: -490px; }
338新增:body.portrait .q { top: 760px; font-size: 128px; line-height: 1.35; }
339新增:body.portrait .q > span, body.portrait .q > em { display: block; }
340新增:/* act 2 */
341新增:body.portrait #logoWrap { top: 560px; }
342新增:body.portrait #wordmark { top: 880px; }
343新增:body.portrait #roomPos { top: 990px; font-size: 56px; }
344新增:body.portrait #roomSub { top: 1092px; font-size: 32px; }
345新增:/* act 3: the real workbench in a tall window, shown at full width */
346新增:body.portrait #capShade { height: 380px; background: linear-gradient(180deg, var(--paper) 0%, rgba(250,248,244,.96) 70%, rgba(250,248,244,0) 100%); }
347新增:body.portrait #caption { left: 64px; top: 104px; }
348新增:body.portrait #caption .slot { width: 952px; height: 190px; }
349新增:body.portrait #caption .cap, body.portrait #accts .cap { gap: 20px; }
350新增:body.portrait #caption .title, body.portrait #accts .cap .title { font-size: 54px; }
351新增:body.portrait #caption .sub, body.portrait #accts .cap .sub { font-size: 29px; line-height: 1.42; max-width: 880px; }
352新增:body.portrait #progressDots { right: auto; left: 64px; top: 60px; }
353新增:body.portrait #appFloor { top: 1720px; width: 1100px; margin-left: -550px; }
354新增:body.portrait .cd-side { display: none; }
355新增:body.portrait .cd-hello { top: 300px; font-size: 36px; }
356新增:body.portrait .cd-input { width: 480px; margin-left: -240px; top: 380px; }
357新增:body.portrait .cd-input .tx { font-size: 16.5px; }
358新增:body.portrait .cd-chat { width: 484px; margin-left: -242px; top: 34px; }
359新增:body.portrait .cd-user { font-size: 15.5px; max-width: 440px; }
360新增:body.portrait .cd-reply { font-size: 17.5px; line-height: 1.75; }
361新增:body.portrait #paneTerm { font-size: 14.5px; }
362新增:body.portrait #paneTerm .tl { left: 22px; right: 16px; top: 18px; }
363新增:body.portrait #paneTerm .box { width: 480px; }
364新增:body.portrait #paneTerm .sfx { display: none; }
365新增:body.portrait .auth-card { width: 450px; }
366新增:body.portrait .auth h3 { font-size: 23px; }
367新增:/* act 3b */
368新增:body.portrait #accts .cap { left: 64px; top: 104px; }
369新增:body.portrait #accts .dots { right: auto; left: 64px; top: 60px; }
370新增:body.portrait #acctPanel { left: 60px; top: 330px; padding: 38px 36px 30px; }
371新增:body.portrait .ap-head h3 { font-size: 38px; }
372新增:body.portrait .ap-head p { font-size: 21px; max-width: 560px; line-height: 1.45; }
373新增:body.portrait .ap-btn { font-size: 21px; height: 54px; padding: 0 20px; }
374新增:body.portrait .ap-sub { font-size: 21px; }
375新增:body.portrait .ap-sub small { font-size: 19px; }
376新增:body.portrait .acct { padding: 22px 24px 20px; }
377新增:body.portrait .acct .av { width: 60px; height: 60px; }
378新增:body.portrait .acct .nm { font-size: 27px; }
379新增:body.portrait .acct .plan { font-size: 16px; }
380新增:body.portrait .acct .meta { font-size: 18px; }
381新增:body.portrait .acct .tog, body.portrait .acct .load, body.portrait .acct .skip { font-size: 19px; }
382新增:body.portrait .acct .load { height: 40px; min-width: 116px; }
383新增:body.portrait .acct .skip { height: 40px; }
384新增:body.portrait .acct .quota { grid-template-columns: 1fr; gap: 14px; margin-top: 18px; }
385新增:body.portrait .acct .qr { grid-template-columns: 40px 1fr auto auto; font-size: 17px; }
386新增:body.portrait .acct .qr b, body.portrait .acct .qr strong { font-size: 19px; }
387新增:body.portrait .acct .qr .bar { height: 11px; }
388新增:body.portrait .acct .qr small { grid-column: auto; font-size: 16px; min-width: 170px; text-align: right; }
389新增:body.portrait #termCol { left: 280px; top: 1290px; }
390新增:body.portrait .tlabel { font-size: 20px; }
391新增:body.portrait .tpill { width: 520px; height: 104px; }
392新增:body.portrait .tpill b { font-size: 24px; }
393新增:body.portrait .tpill small { font-size: 18px; }
394新增:body.portrait .tpill .to { font-size: 19px; }
395新增:/* act 4 */
396新增:body.portrait #perksHead { top: 380px; font-size: 68px; }
397新增:body.portrait #perkRow { top: 560px; flex-wrap: wrap; width: 980px; left: 50px; gap: 26px 26px; }
398新增:body.portrait .perk { width: 477px; height: 440px; }
399新增:body.portrait .perk h3 { font-size: 40px; }
400新增:body.portrait .perk p { font-size: 25px; }
401新增:/* act 5 */
402新增:body.portrait #art { left: 90px; top: 220px; width: 900px; height: 900px; }
403新增:body.portrait #letterKicker { left: 120px; top: 1240px; }
404新增:body.portrait #letterText { left: 116px; top: 1290px; }
405新增:body.portrait #letterText .l { font-size: 66px; }
406新增:/* act 6 */
407新增:body.portrait #endLogo { top: 500px; width: 230px; height: 230px; margin-left: -115px; }
408新增:body.portrait #endWord { top: 790px; font-size: 104px; }
409新增:body.portrait #endSub { top: 925px; font-size: 38px; }
410新增:body.portrait #endPlat { top: 1020px; font-size: 27px; }
411新增:body.portrait #endPlat span { padding: 13px 24px; }
412新增:body.portrait #endUrl { top: 1140px; font-size: 33px; }
413新增:body.portrait #endGit { top: 1200px; font-size: 25px; }
414新增:body.portrait #endNote { top: 1740px; font-size: 21px; }
415新增:
329416/* ---------- preview controls ---------- */
330417#controls { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 20px; display: flex; align-items: center; gap: 14px;
331418 background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #eee; font: 500 13px var(--mono); z-index: 100; opacity: 0; transition: opacity .25s; }
@@ -346,7 +433,21 @@ body.render #controls { display: none; }
346433 <div class="beat" id="b1">
347434 <div class="kick"><i></i>痛点 01 · 封号</div>
348435 <div class="head"><span data-split>一次封号,</span><em data-split>钱和进度一起清零。</em></div>
349删除: <div id="alarm" class="dark-card"><div class="ico"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><circle cx="12" cy="12" r="8.5"/><path d="M6 6l12 12"/></svg></div><div><h4>你的 Claude 账户已被停用</h4><p>检测到异常活动,账户已暂停使用。</p></div><time>刚刚</time></div>
436新增: <div id="hold">
437新增: <div id="holdScroll">
438新增: <h1>Your account is<br />on hold</h1>
439新增: <svg class="lock" viewBox="0 0 120 150" fill="none" stroke="#1c1b19" stroke-width="3.4" stroke-linecap="round" stroke-linejoin="round"><path d="M33.5 66C32.5 41 34.5 19.5 60 18.5c25.5-1 28 21.5 27 47.5"/><path d="M45.5 66c-.5-19 1-33.5 14.5-34.5 14-1 15.5 15 15 34.5"/><path d="M14.5 67.5c30-2 61-1.5 92 0 1 26 .5 52 1 78.5-31 1.5-61 1-92 .5-.5-26.5-1-52.5-1-79z" fill="#fff"/><path d="M60 91c-8.5.5-11.5 10-5.5 15l-4.5 16.5h20.5L66 106c5.5-5.5 2.5-15.5-6-15z"/></svg>
440新增: <p>We put your account on hold on <b>Nov 3, 2026 at 02:47</b> because of unusual activity. Your chats and data are safe.</p>
441新增: <p>If you think this hold is an error, you can request an account review.</p>
442新增: <p class="next">What happens next:</p>
443新增: <div class="hcard">
444新增: <div class="step"><span>1</span><div>Request a review<p>Tell us more about what happened.</p></div></div>
445新增: <div class="step"><span>2</span><div>We’ll review your account<p>A team member will review your request and account activity together.</p></div></div>
446新增: <div class="step"><span>3</span><div>We’ll email you the outcome<p><span id="holdMark">Reviews take about 10 days.</span></p></div></div>
447新增: </div>
448新增: </div>
449新增: <div id="holdTint"></div>
450新增: </div>
350451 <div id="losses">
351452 <div class="loss dark-card"><span>Max 订阅</span><b>$200 打水漂</b></div>
352453 <div class="loss dark-card"><span>API 余额</span><b>无法再用</b></div>
@@ -412,137 +513,118 @@ body.render #controls { display: none; }
412513 <div id="capShade"></div>
413514 <div id="caption">
414515 <div class="slot">
415删除: <div class="cap" data-cap="0"><span class="num">01</span><div class="txt"><div class="title">你只需要:配置自己的代理</div><div class="sub">导入订阅,选个节点。时区和语言自动跟随出口 IP。</div></div></div>
416删除: <div class="cap" data-cap="1"><span class="num">02</span><div class="txt"><div class="title">自带泄漏审查</div><div class="sub">11 项关键检查,有一项没过,环境就不连外网。</div></div></div>
417删除: <div class="cap" data-cap="2"><span class="num">03</span><div class="txt"><div class="title">与主机隔离,日常照常用</div><div class="sub">终端、浏览器、编辑器都在 Cage 里。你的电脑不用开全局代理。</div></div></div>
516新增: <div class="cap" data-cap="0"><span class="num">01</span><div class="txt"><div class="title">配好代理,环境即刻就绪</div><div class="sub">11 项泄漏检查通过才放行外网;出口、时区和语言始终一致。</div></div></div>
517新增: <div class="cap" data-cap="1"><span class="num">02</span><div class="txt"><div class="title">内置 Claude Desktop</div><div class="sub">官方桌面应用直接跑在 Cage 里,Chat 和 Code 都能用。</div></div></div>
518新增: <div class="cap" data-cap="2"><span class="num">03</span><div class="txt"><div class="title">一键打开 Claude Code 终端</div><div class="sub">在项目上新建「Claude 终端」,自动分配账号,直接进入 Claude Code。</div></div></div>
519新增: <div class="cap" data-cap="3"><span class="num">04</span><div class="txt"><div class="title">浏览器登录,也在笼子里</div><div class="sub">授权页在 Cage 浏览器里打开,出口一致;登录完回到终端就能干活。</div></div></div>
418520 </div>
419521 </div>
420删除: <div id="progressDots"><i><b></b></i><i><b></b></i><i><b></b></i></div>
421删除:
522新增: <div id="progressDots"><i><b></b></i><i><b></b></i><i><b></b></i><i><b></b></i><i><b></b></i></div>
422523 <div id="cam">
423524 <div id="win">
424删除: <aside class="side">
425删除: <div class="lights"><i></i><i></i><i></i></div>
426删除: <div class="brand"><svg class="mark logo-svg" viewBox="0 0 926 926" id="miniLogo"></svg>Cage<svg class="i collapse" viewBox="0 0 24 24"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><path d="M9 4.5v15M15 10l-2 2 2 2"/></svg></div>
427删除: <div class="nav">
428删除: <div class="on" id="navHome"><svg class="i" viewBox="0 0 24 24"><path d="M3.5 10.5 12 3.5l8.5 7V20a1 1 0 0 1-1 1H15v-6H9v6H4.5a1 1 0 0 1-1-1z"/></svg>工作台</div>
429删除: <div class="dim" data-enable><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8.5"/><path d="M3.5 12h17M12 3.5c2.6 2.6 3.6 5.3 3.6 8.5s-1 5.9-3.6 8.5c-2.6-2.6-3.6-5.3-3.6-8.5s1-5.9 3.6-8.5z"/></svg>浏览器</div>
430删除: <div class="dim" data-enable><svg class="i" viewBox="0 0 24 24"><path d="M3.5 7A1.5 1.5 0 0 1 5 5.5h4l2 2.5h8a1.5 1.5 0 0 1 1.5 1.5v9A1.5 1.5 0 0 1 19 20H5a1.5 1.5 0 0 1-1.5-1.5z"/></svg>打开项目<kbd>⌘O</kbd></div>
431删除: <div class="dim" data-enable><svg class="i" viewBox="0 0 24 24"><path d="M14 3.5H6.5a1 1 0 0 0-1 1v15a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1V8z"/><path d="M14 3.5V8h4.5M10.5 12l-2 2 2 2M13.5 12l2 2-2 2"/></svg>项目文件<span style="color:#6c6763">↗</span></div>
432删除: </div>
433删除: <div class="sec"><span>项目</span><span>+</span></div>
434删除: <div class="proj">
435删除: <div><svg class="i" viewBox="0 0 24 24" style="width:13px;height:13px"><path d="M6 9l6 6 6-6"/></svg><svg class="i" viewBox="0 0 24 24"><path d="M3.5 7A1.5 1.5 0 0 1 5 5.5h4l2 2.5h8a1.5 1.5 0 0 1 1.5 1.5v9A1.5 1.5 0 0 1 19 20H5a1.5 1.5 0 0 1-1.5-1.5z"/></svg><b style="font-weight:600">hello-cage</b><span style="margin-left:auto;color:#6c6763" id="projPlus">+</span></div>
436删除: <div class="child"><span id="childHint">启动后可新建终端</span><div class="alt" id="childTerm"><svg class="i" viewBox="0 0 24 24"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><path d="M7.5 9.5l3 2.5-3 2.5M12.5 15h4"/></svg>开发终端<span style="margin-left:auto;color:#6c6763;letter-spacing:1px">···</span></div></div>
437删除: </div>
438删除: <div class="side-foot">
439删除: <div><i class="dot" id="envDot"></i><span class="flip" id="envFlip" style="width:120px"><span>已停止</span><span>启动中…</span><span>环境运行正常</span></span><svg class="i shield" viewBox="0 0 24 24"><path d="M12 3.5l7.5 2.8v5.6c0 4.3-3.2 7.6-7.5 8.6-4.3-1-7.5-4.3-7.5-8.6V6.3z"/></svg></div>
440删除: <div><svg class="i" viewBox="0 0 24 24"><path d="M4 7.5h9M17 7.5h3M4 16.5h3M11 16.5h9"/><circle cx="15" cy="7.5" r="2"/><circle cx="9" cy="16.5" r="2"/></svg>设置<kbd>⌘,</kbd></div>
441删除: </div>
442删除: </aside>
443删除:
444删除: <div class="main">
445删除: <div class="topbar">
446删除: <div class="crumb"><svg class="i" viewBox="0 0 24 24"><path d="M3.5 7A1.5 1.5 0 0 1 5 5.5h4l2 2.5h8a1.5 1.5 0 0 1 1.5 1.5v9A1.5 1.5 0 0 1 19 20H5a1.5 1.5 0 0 1-1.5-1.5z"/></svg>hello-cage<span id="crumbLeaf" style="display:flex;gap:10px;align-items:center"><svg class="i" viewBox="0 0 24 24" style="width:14px;height:14px"><path d="M9 6l6 6-6 6"/></svg>开发终端</span></div>
447删除: <div class="top-actions"><div class="pill"><svg class="i" viewBox="0 0 24 24" style="width:15px;height:15px"><path d="M14 3.5H6.5a1 1 0 0 0-1 1v15a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1V8z"/><path d="M14 3.5V8h4.5M10.5 12l-2 2 2 2M13.5 12l2 2-2 2"/></svg>打开文件</div><svg class="i" viewBox="0 0 24 24"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><path d="M7.5 9.5l3 2.5-3 2.5M12.5 15h4"/></svg><svg class="i" viewBox="0 0 24 24" id="topX"><path d="M6.5 6.5l11 11M17.5 6.5l-11 11"/></svg></div>
448删除: </div>
449删除:
450删除: <!-- first run -->
451删除: <div class="view hero" id="viewHero">
452删除: <div class="shield-big"><svg class="i" viewBox="0 0 24 24"><path d="M12 3.5l7.5 2.8v5.6c0 4.3-3.2 7.6-7.5 8.6-4.3-1-7.5-4.3-7.5-8.6V6.3z"/></svg></div>
453删除: <h2>为 Claude 准备独立工作区</h2>
454删除: <div class="lead">先连接你的代理,再启动浏览器、终端和编辑器。无需安装额外的代理软件。</div>
455删除: <div class="steps">
456删除: <span id="st1"><b class="on"><span class="n">1</span></b><span class="strong">配置代理</span></span>
457删除: <span id="st2"><b><span class="n">2</span></b><span>启动环境</span></span>
458删除: <span><b>3</b><span>开始工作</span></span>
525新增: <img class="plate" data-plate="home" src="plates/home.png" alt="" />
526新增: <img class="plate" data-plate="desktop" src="plates/desktop.png" alt="" />
527新增: <img class="plate" data-plate="menu" src="plates/menu.png" alt="" />
528新增: <img class="plate" data-plate="term" src="plates/term.png" alt="" />
529新增: <img class="plate" data-plate="browser" src="plates/browser.png" alt="" />
530新增: <img class="plate" data-plate="safety-run" src="plates/safety-run.png" alt="" />
531新增: <img class="plate" data-plate="safety-done" src="plates/safety-done.png" alt="" />
532新增: <div id="checkFx"><div id="checkCount"></div></div>
533新增:
534新增: <div class="pane" id="paneDesktop">
535新增: <div class="cd">
536新增: <div class="cd-side">
537新增: <div class="cd-logo">Claude</div>
538新增: <div class="cd-new"><i>+</i>New chat</div>
539新增: <div class="cd-nav"><div class="on">Chats</div><div>Projects</div><div>Code</div></div>
540新增: <div class="cd-rec">Recents</div>
541新增: <div class="it on" id="cdRecent">README 改写</div>
542新增: <div class="it">API 设计评审</div>
543新增: <div class="it">周报草稿</div>
544新增: <div class="it">hello-cage 架构梳理</div>
459545 </div>
460删除: <div class="card">
461删除: <div class="head"><svg class="i" viewBox="0 0 24 24"><path d="M12 3.5l7.5 2.8v5.6c0 4.3-3.2 7.6-7.5 8.6-4.3-1-7.5-4.3-7.5-8.6V6.3z"/></svg><div><div class="t">Cage 隔离环境</div><div class="d">自备代理订阅、YAML 配置或节点</div></div></div>
462删除: <div class="row">
463删除: <div class="state"><div class="wait" id="stateWait"><i></i>等待配置代理</div><div class="ready" id="stateReady"><i></i>代理已就绪 · <b>美国 · 洛杉矶 01</b></div></div>
464删除: <div class="btn-swap">
465删除: <div class="btn" id="btnProxy"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8.5"/><path d="M3.5 12h17M12 3.5c2.6 2.6 3.6 5.3 3.6 8.5s-1 5.9-3.6 8.5c-2.6-2.6-3.6-5.3-3.6-8.5s1-5.9 3.6-8.5z"/></svg>配置网络与代理</div>
466删除: <div class="btn" id="btnLaunch"><svg class="i" viewBox="0 0 24 24"><path d="M8 5.5v13l10.5-6.5z"/></svg>启动 Cage 环境</div>
546新增: <div class="cd-main">
547新增: <div class="cd-hello" id="cdHello"><span>✻</span>Good evening, Lee</div>
548新增: <div class="cd-chat" id="cdChat">
549新增: <div class="cd-user" id="cdUser"></div>
550新增: <div class="cd-reply" id="cdReply">
551新增: <p>好的。我先读了 README 和 package.json,建议这样改:</p>
552新增: <p class="li">1. 开头一句话讲清 hello-cage 是什么、给谁用;</p>
553新增: <p class="li">2. 安装、配置、运行合成三步,每步一条命令;</p>
554新增: <p class="li">3. 末尾补上常见问题和许可说明。</p>
467555 </div>
468556 </div>
557新增: <div class="cd-input" id="cdInput"><div class="tx"><span class="ph" id="cdPh">How can I help you today?</span><span id="cdTx"></span><i class="tcaret" id="cdCaret"></i></div>
558新增: <div class="row"><span class="pl">+</span><span class="md">Claude ⌄</span><span class="send" id="cdSend">↑</span></div></div>
469559 </div>
470删除: <div class="foot">Cage 不提供代理或 Claude 账户。连接后,在 Cage 内完成 Claude 登录。</div>
471560 </div>
561新增: </div>
472562
473删除: <!-- launch -->
474删除: <div class="view launch" id="viewLaunch">
475删除: <div class="panel">
476删除: <div class="ph">
477删除: <div class="badge"><svg class="i" viewBox="0 0 24 24"><path d="M12 3.5l7.5 2.8v5.6c0 4.3-3.2 7.6-7.5 8.6-4.3-1-7.5-4.3-7.5-8.6V6.3z"/></svg><div class="okb"><svg class="i" viewBox="0 0 24 24"><path d="M12 3.5l7.5 2.8v5.6c0 4.3-3.2 7.6-7.5 8.6-4.3-1-7.5-4.3-7.5-8.6V6.3z"/><path d="M8.8 12.2l2.2 2.2 4.3-4.6"/></svg></div></div>
478删除: <div class="tt">
479删除: <div id="phBusy"><div class="a">正在启动 Cage 环境</div><div class="b">准备镜像与工具,然后核对网络和隔离。</div></div>
480删除: <div id="phDone"><div class="a" style="color:#1f5f35">外网已放行</div><div class="b">关键检查已通过,后台继续核对出口规则与环境配置。</div></div>
481删除: </div>
482删除: <div class="count" id="ckCount">0 / 11</div>
483删除: </div>
484删除: <div class="prog">
485删除: <div class="p" data-p="0"><div class="st"><div class="wait"></div><div class="spin"></div><div class="ok"><svg class="i" viewBox="0 0 24 24"><path d="M5.5 12.5l4 4 9-9"/></svg></div></div><span>下载 Linux 镜像</span><div class="bar"><i></i></div><span class="pct">0%</span></div>
486删除: <div class="p" data-p="1"><div class="st"><div class="wait"></div><div class="spin"></div><div class="ok"><svg class="i" viewBox="0 0 24 24"><path d="M5.5 12.5l4 4 9-9"/></svg></div></div><span>安装开发工具</span><div class="bar"><i></i></div><span class="pct">0%</span></div>
487删除: </div>
488删除: <div class="checks-h"><span>网络与隔离检查 · 关键项</span><span>失败时保持离线</span></div>
489删除: <div class="checks" id="checks"></div>
490删除: </div>
563新增: <div class="pane" id="paneTerm">
564新增: <div class="tl" id="termA">
565新增: <div class="ln"><span class="dim">/workspace/hello-cage $</span> claude</div>
566新增: <div class="box"><span class="acc">✻</span> Welcome to <b>Claude Code</b></div>
567新增: <div class="ln">Select login method:</div>
568新增: <div class="ln"> </div>
569新增: <div class="ln"><span class="acc">❯ 1. Claude account with subscription</span><span class="dim sfx"> · Pro, Max, Team, or Enterprise</span></div>
570新增: <div class="ln"> 2. Anthropic Console account<span class="dim sfx"> · API usage billing</span></div>
571新增: <div class="ln"> </div>
572新增: <div class="ln acc" id="termOpening">Opening browser to sign in…</div>
491573 </div>
574新增: <div class="tl" id="termB">
575新增: <div class="ln"><span class="g">✓</span> Login successful. Press <b>Enter</b> to continue…</div>
576新增: <div class="box"><span class="acc">✻</span> Welcome to <b>Claude Code</b>!<br /><span class="dim"> cwd: /workspace/hello-cage</span></div>
577新增: <div class="ln"><span class="dim">&gt;</span> <span id="termPrompt"></span><i class="tcaret" id="termCaret"></i></div>
578新增: <div class="ln" data-r="0">● 我先看一下路由结构。</div>
579新增: <div class="ln" data-r="1"><span class="g">●</span> <b>Read</b>(src/server.js)<span class="dim"> ⎿ Read 64 lines</span></div>
580新增: <div class="ln" data-r="2"><span class="g">●</span> <b>Update</b>(src/server.js)<span class="dim"> ⎿ Added GET /healthz</span></div>
581新增: <div class="ln" data-r="3">● <span id="termFinal"></span></div>
582新增: </div>
583新增: </div>
492584
493删除: <!-- terminal -->
494删除: <div class="view" id="viewTerm">
495删除: <div class="term-bar"><svg class="i" viewBox="0 0 24 24" style="width:15px;height:15px"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><path d="M7.5 9.5l3 2.5-3 2.5M12.5 15h4"/></svg>/workspace/hello-cage<div class="r"><span>Linux · bash</span><span>+ 新建终端</span></div></div>
496删除: <div class="term" id="term">
497删除: <div class="ln"><span class="acc">Claude Cage</span> · hello-cage</div>
498删除: <div class="ln"></div>
499删除: <div class="ln">A separate Linux workspace. Your project, your tools.</div>
500删除: <div class="ln"></div>
501删除: <div class="ln"><span class="g">✓</span> Project folder shared: /workspace/hello-cage</div>
502删除: <div class="ln"><span class="g">✓</span> Terminal ready</div>
503删除: <div class="ln"></div>
504删除: <div class="ln" id="cmdLine">$ <span id="cmdText"></span><i class="caret" id="caret1"></i></div>
505删除: <div id="ccBlock">
506删除: <div class="cc"><span class="w">✻</span> Welcome to <b>Claude Code</b>!<br><span class="m"> cwd: /workspace/hello-cage</span></div>
507删除: <div class="ln" id="promptLine"><span class="m">&gt;</span> <span id="promptText"></span><i class="caret" id="caret2"></i></div>
508删除: <div class="reply" id="reply">
509删除: <div class="ln" data-r="0"><span class="dot">●</span> 我先看一下项目结构。</div>
510删除: <div class="ln" data-r="1"><span class="g">●</span> <span class="tool">Read</span>(package.json)<span class="m"> ⎿ Read 18 lines</span></div>
511删除: <div class="ln" data-r="2"><span class="g">●</span> <span class="tool">Write</span>(README.md)<span class="m"> ⎿ Wrote 42 lines</span></div>
512删除: <div class="ln" data-r="3"><span class="dot">●</span> README 写好了:简介、安装方式和本地运行步骤都在里面。</div>
513删除: </div>
514删除: </div>
585新增: <div class="pane" id="paneBrowser">
586新增: <div class="auth" id="authAsk">
587新增: <div class="auth-card">
588新增: <div class="auth-word">Claude</div>
589新增: <h3>Claude Code would like to connect to your Claude account</h3>
590新增: <div class="who">Signed in as [email protected]</div>
591新增: <ul><li><i>✓</i>Use your Claude subscription in Claude Code</li><li><i>✓</i>Read your profile and organization</li><li><i>✓</i>Show your usage limits</li></ul>
592新增: <div class="go" id="authGo">Authorize</div>
593新增: <div class="no">Cancel</div>
515594 </div>
516595 </div>
596新增: <div class="auth-done" id="authDone"><div class="ok">✓</div><h3>You’re all set up for Claude Code.</h3><p>You can close this window and return to your terminal.</p></div>
597新增: </div>
517598
518删除: <div class="status">
519删除: <div class="it" style="position:relative"><svg class="i" viewBox="0 0 24 24" id="netIco"><path d="M12 3.5l7.5 2.8v5.6c0 4.3-3.2 7.6-7.5 8.6-4.3-1-7.5-4.3-7.5-8.6V6.3z"/><path d="M8.8 12.2l2.2 2.2 4.3-4.6" id="netTick"/></svg><span class="flip" id="netFlip" style="width:56px"><span>网络检查</span><span style="color:#1f5f35">外网已放行</span></span></div>
520删除: <div class="it"><div class="hl" id="hlProxy"></div><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8.5"/><path d="M3.5 12h17M12 3.5c2.6 2.6 3.6 5.3 3.6 8.5s-1 5.9-3.6 8.5c-2.6-2.6-3.6-5.3-3.6-8.5s1-5.9 3.6-8.5z"/></svg><span class="flip" id="proxyFlip" style="width:150px"><span>未选择代理</span><span>指定代理出口 · 洛杉矶 01</span></span></div>
521删除: <div class="it"><div class="hl" id="hlTz"></div><span class="flip" id="tzFlip" style="width:172px"><span>Asia/Shanghai · 主机</span><span>America/Los_Angeles · 自动</span></span></div>
522删除: <div class="it"><svg class="i" viewBox="0 0 24 24"><path d="M3 12h4l3-7 4 14 3-7h4"/></svg><span class="flip" id="latFlip" style="width:50px"><span>延迟 —</span><span>128 ms</span></span></div>
523删除: <div class="right"><div class="it" id="syncIt">文件与本机同步</div><div class="it" id="stopIt"><svg class="i" viewBox="0 0 24 24"><path d="M12 3.5v8"/><path d="M6.6 6.8a7.5 7.5 0 1 0 10.8 0"/></svg>停止环境</div></div>
524删除: </div>
525599
526删除: <div id="modalShade"></div>
527删除: <div id="modal">
528删除: <div class="mh">网络与代理<svg class="i" viewBox="0 0 24 24"><path d="M6.5 6.5l11 11M17.5 6.5l-11 11"/></svg></div>
529删除: <div class="src"><svg class="i" viewBox="0 0 24 24"><path d="M14 3.5H6.5a1 1 0 0 0-1 1v15a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1V8z"/><path d="M14 3.5V8h4.5"/></svg><span><b style="font-weight:600">my-nodes.yaml</b> · Clash / Mihomo 订阅</span><span class="tag"><svg class="i" viewBox="0 0 24 24" style="width:14px;height:14px"><path d="M5.5 12.5l4 4 9-9"/></svg>已导入 24 个节点</span></div>
530删除: <div class="lbl">节点</div>
531删除: <div class="nodes" id="nodes">
532删除: <div class="node" id="nodeLA"><div class="sel"></div><div class="radio"><i></i></div><span>美国 · 洛杉矶 01</span><span class="ms"><em></em>128 ms</span></div>
533删除: <div class="node"><div class="sel"></div><div class="radio"><i></i></div><span>美国 · 圣何塞 02</span><span class="ms"><em></em>141 ms</span></div>
534删除: <div class="node"><div class="sel"></div><div class="radio"><i></i></div><span>日本 · 东京 03</span><span class="ms"><em></em>96 ms</span></div>
535删除: <div class="node"><div class="sel"></div><div class="radio"><i></i></div><span>新加坡 04</span><span class="ms"><em></em>112 ms</span></div>
536删除: <div class="node"><div class="sel"></div><div class="radio"><i></i></div><span>英国 · 伦敦 05</span><span class="ms"><em class="warn"></em>214 ms</span></div>
537删除: </div>
538删除: <div class="mf"><span>代理不可用时没有直连回退。</span><div class="btn" id="btnUse">使用此节点</div></div>
539删除: </div>
600新增: <div id="ripple"></div>
601新增: <div id="cursor"><svg viewBox="0 0 26 26"><path d="M5 2.8v18.6l4.6-4.4 3 6.6 3.1-1.4-3-6.4h6.5z" fill="#111" stroke="#fff" stroke-width="1.6" stroke-linejoin="round"/></svg></div>
602新增: </div>
603新增: </div>
604新增: </section>
540605
541删除: <div id="ripple"></div>
542删除: <div id="cursor"><svg viewBox="0 0 26 26"><path d="M5 2.8v18.6l4.6-4.4 3 6.6 3.1-1.4-3-6.4h6.5z" fill="#111" stroke="#fff" stroke-width="1.6" stroke-linejoin="round"/></svg></div>
606新增: <!-- ============ ACT 3b · ACCOUNTS ============ -->
607新增: <section class="layer" id="accts">
608新增: <div class="cap"><span class="num">05</span><div class="txt"><div class="title">多账号,自动调度</div><div class="sub">登录你自己的多个订阅。每开一个新终端,自动分给更空闲的账号。</div></div></div>
609新增: <div class="dots"><i><b></b></i><i><b></b></i><i><b></b></i><i><b></b></i><i><b></b></i></div>
610新增: <svg id="acctWires" viewBox="0 0 1920 1080"></svg>
611新增: <div id="acctPanel">
612新增: <div class="ap-head"><div><h3>Claude 账号</h3><p>登录新账号,或把已登录的订阅加入调度。新建 Claude 终端时自动分配。</p></div><div class="ap-btn">+ 登录新账号</div></div>
613新增: <div class="ap-sub">账号列表 <span>3</span><small>3 个启用调度</small></div>
614新增: <div class="acct"><div class="ring"></div>
615新增: <div class="row1"><div class="av"><svg viewBox="0 0 16 10" fill="#D97757" shape-rendering="crispEdges"><path fill-rule="evenodd" d="M2 0h12v4h2v2h-2v2H2V6H0V4h2z M4 2v2h1V2z M11 2v2h1V2z"/><path d="M3 8h1v2H3z M5 8h1v2H5z M10 8h1v2h-1z M12 8h1v2h-1z"/></svg></div><div><div class="nm">工作<span class="plan">Max</span></div><div class="meta"><span class="ok">已登录</span><span>[email protected]</span></div></div><div class="load">终端 <em>0</em></div><div class="tog"><i></i><span>参与分配</span></div></div>
616新增: <div class="quota"><div class="qr"><b>5h</b><div class="bar five"><i style="transform:scaleX(0.32)"></i></div><strong>32%</strong><small>2 小时 14 分后重置</small></div><div class="qr"><b>7d</b><div class="bar seven"><i style="transform:scaleX(0.18)"></i></div><strong>18%</strong><small>4 天后重置</small></div></div>
617新增: </div>
618新增: <div class="acct"><div class="ring"></div>
619新增: <div class="row1"><div class="av"><svg viewBox="0 0 16 10" fill="#D97757" shape-rendering="crispEdges"><path fill-rule="evenodd" d="M2 0h12v4h2v2h-2v2H2V6H0V4h2z M4 2v2h1V2z M11 2v2h1V2z"/><path d="M3 8h1v2H3z M5 8h1v2H5z M10 8h1v2h-1z M12 8h1v2h-1z"/></svg></div><div><div class="nm">个人<span class="plan">Pro</span></div><div class="meta"><span class="ok">已登录</span><span>[email protected]</span></div></div><div class="load">终端 <em>0</em></div><div class="tog"><i></i><span>参与分配</span></div></div>
620新增: <div class="quota"><div class="qr"><b>5h</b><div class="bar five"><i style="transform:scaleX(0.58)"></i></div><strong>58%</strong><small>3 小时 40 分后重置</small></div><div class="qr"><b>7d</b><div class="bar seven"><i style="transform:scaleX(0.41)"></i></div><strong>41%</strong><small>5 天后重置</small></div></div>
621新增: </div>
622新增: <div class="acct"><div class="ring"></div>
623新增: <div class="row1"><div class="av"><svg viewBox="0 0 16 10" fill="#D97757" shape-rendering="crispEdges"><path fill-rule="evenodd" d="M2 0h12v4h2v2h-2v2H2V6H0V4h2z M4 2v2h1V2z M11 2v2h1V2z"/><path d="M3 8h1v2H3z M5 8h1v2H5z M10 8h1v2h-1z M12 8h1v2h-1z"/></svg></div><div><div class="nm">备用<span class="plan">Pro</span></div><div class="meta"><span class="ok">已登录</span><span>[email protected]</span></div></div><div class="skip">本轮跳过</div><div class="tog"><i></i><span>参与分配</span></div></div>
624新增: <div class="quota"><div class="qr"><b>5h</b><div class="bar five"><i style="transform:scaleX(1.0)"></i></div><strong>100%</strong><small>额度用尽 · 47 分后重置</small></div><div class="qr"><b>7d</b><div class="bar seven"><i style="transform:scaleX(0.63)"></i></div><strong>63%</strong><small>2 天后重置</small></div></div>
543625 </div>
544删除: </div>
545626 </div>
627新增: <div id="termCol"><div class="tlabel">新建终端</div><div class="tpill"><div class="ti"><svg viewBox="0 0 24 24"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><path d="M7.5 9.5l3 2.5-3 2.5M12.5 15h4"/></svg></div><div><b>新建 Claude 终端</b><small>~/hello-cage</small></div><span class="to">→ 工作</span></div><div class="tpill"><div class="ti"><svg viewBox="0 0 24 24"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><path d="M7.5 9.5l3 2.5-3 2.5M12.5 15h4"/></svg></div><div><b>新建 Claude 终端</b><small>~/api-server</small></div><span class="to">→ 个人</span></div><div class="tpill"><div class="ti"><svg viewBox="0 0 24 24"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><path d="M7.5 9.5l3 2.5-3 2.5M12.5 15h4"/></svg></div><div><b>新建 Claude 终端</b><small>~/blog</small></div><span class="to">→ 工作</span></div></div>
546628 </section>
547629
548630 <!-- ============ ACT 4 · PERKS ============ -->
@@ -586,6 +668,7 @@ body.render #controls { display: none; }
586668<div id="controls"><button id="play">播放</button><span id="tc">00.00</span><input id="scrub" type="range" min="0" step="0.01" /><button id="restart">重来</button></div>
587669
588670<script src="timeline.js"></script>
671新增:<script src="plates/layout.js"></script>
589672<script src="promo.js"></script>
590673</body>
591674</html>
修改promo/package.json+2 −0看文件
@@ -4,8 +4,10 @@
44 "description": "Claude Cage promo video, rendered from code.",
55 "scripts": {
66 "preview": "node render.mjs --preview",
7新增: "plates": "node capture-plates.mjs",
78 "soundtrack": "node soundtrack.mjs",
89 "render": "node soundtrack.mjs && node render.mjs",
10新增: "render:vertical": "node soundtrack.mjs && node render.mjs --portrait",
911 "render:draft": "node soundtrack.mjs && node render.mjs --fps 30 --scale 0.5"
1012 },
1113 "dependencies": {
新增promo/plates/browser.png看文件

二进制文件,不显示改动。

新增promo/plates/desktop.png看文件

二进制文件,不显示改动。

新增promo/plates/home.png看文件

二进制文件,不显示改动。

新增promo/plates/layout.js+2 −0看文件
@@ -0,0 +1,2 @@
1新增:// Generated by capture-plates.mjs: where things sit on each plate, in workbench pixels.
2新增:window.PLATE_LAYOUT = {"landscape":{"width":1440,"height":860,"home":{"sidebar":[0,0,248,860],"header":[248,0,1192,40],"status":[248,828,1192,32],"statusItems":[[268,833.5,73.9,22],[366.9,833.5,181,22],[573,833.5,164.7,22]],"shield":[12,761,223,33],"desktopNav":[12,156,223,36],"termIcon":[209,297.5,26,26],"claudeItem":null,"navigation":null,"dialog":null,"summary":null,"count":null,"rows":[]},"desktop":{"sidebar":[0,0,248,860],"header":[248,0,1192,43],"status":[248,828,1192,32],"statusItems":[[268,833.5,73.9,22],[366.9,833.5,181,22],[573,833.5,164.7,22]],"shield":[12,761,223,33],"desktopNav":[12,156,223,36],"termIcon":[209,297.5,26,26],"claudeItem":null,"navigation":null,"dialog":null,"summary":null,"count":null,"rows":[]},"menu":{"sidebar":[0,0,248,860],"header":[248,0,1192,43],"status":[248,828,1192,32],"statusItems":[[268,833.5,73.9,22],[366.9,833.5,181,22],[573,833.5,164.7,22]],"shield":[12,761,223,33],"desktopNav":[12,156,223,36],"termIcon":[209,297.5,26,26],"claudeItem":[58,377,170,39],"navigation":null,"dialog":null,"summary":null,"count":null,"rows":[]},"term":{"sidebar":[0,0,248,860],"header":[248,0,1192,40],"status":[248,828,1192,32],"statusItems":[[268,833.5,73.9,22],[366.9,833.5,181,22],[573,833.5,164.7,22]],"shield":[12,761,223,33],"desktopNav":[12,156,223,36],"termIcon":[209,297.5,26,26],"claudeItem":null,"navigation":null,"dialog":null,"summary":null,"count":null,"rows":[]},"browser":{"sidebar":[0,0,248,860],"header":null,"status":[248,828,1192,32],"statusItems":[[268,833.5,73.9,22],[366.9,833.5,181,22],[573,833.5,164.7,22]],"shield":[12,761,223,33],"desktopNav":[12,156,223,36],"termIcon":[209,297.5,26,26],"claudeItem":null,"navigation":[248,40,1192,40],"dialog":null,"summary":null,"count":null,"rows":[]},"safety-run":{"sidebar":[0,0,248,860],"header":[248,0,1192,40],"status":[248,828,1192,32],"statusItems":[[268,833.5,63,22],[356,833.5,181,22],[562,833.5,164.7,22]],"shield":[12,761,223,33],"desktopNav":[12,156,223,36],"termIcon":[209,297.5,26,26],"claudeItem":null,"navigation":null,"dialog":[340,20,760,820],"summary":[363,105,714,83.8],"count":[427,211.3,561,17],"rows":[[364,280.4,712,41],[364,322.4,712,41],[364,364.4,712,41],[364,406.4,712,41],[364,448.4,712,41],[364,490.4,712,41],[364,532.4,712,41],[364,574.4,712,41],[364,616.4,712,41],[364,658.4,712,41],[364,700.4,712,41]]},"safety-done":{"sidebar":[0,0,248,860],"header":[248,0,1192,40],"status":[248,828,1192,32],"statusItems":[[268,833.5,73.9,22],[366.9,833.5,181,22],[573,833.5,164.7,22]],"shield":[12,761,223,33],"desktopNav":[12,156,223,36],"termIcon":[209,297.5,26,26],"claudeItem":null,"navigation":null,"dialog":[340,20,760,820],"summary":[363,105,714,83.8],"count":[427,211.3,561,17],"rows":[[364,280.4,712,41],[364,322.4,712,41],[364,364.4,712,41],[364,406.4,712,41],[364,448.4,712,41],[364,490.4,712,41],[364,532.4,712,41],[364,574.4,712,41],[364,616.4,712,41],[364,658.4,712,41],[364,700.4,712,41]]}},"portrait":{"width":760,"height":1100,"home":{"sidebar":[0,0,224,1100],"header":[224,0,536,40],"status":[224,1068,536,32],"statusItems":[[244,1073.5,73.9,22],[329.9,1073.5,181,22],[523,1073.5,52.4,22]],"shield":[12,1001,199,33],"desktopNav":[12,156,199,36],"termIcon":[185,297.5,26,26],"claudeItem":null,"navigation":null,"dialog":null,"summary":null,"count":null,"rows":[]},"desktop":{"sidebar":[0,0,224,1100],"header":[224,0,536,43],"status":[224,1068,536,32],"statusItems":[[244,1073.5,73.9,22],[329.9,1073.5,181,22],[523,1073.5,52.4,22]],"shield":[12,1001,199,33],"desktopNav":[12,156,199,36],"termIcon":[185,297.5,26,26],"claudeItem":null,"navigation":null,"dialog":null,"summary":null,"count":null,"rows":[]},"menu":{"sidebar":[0,0,224,1100],"header":[224,0,536,43],"status":[224,1068,536,32],"statusItems":[[244,1073.5,73.9,22],[329.9,1073.5,181,22],[523,1073.5,52.4,22]],"shield":[12,1001,199,33],"desktopNav":[12,156,199,36],"termIcon":[185,297.5,26,26],"claudeItem":[34,377,170,39],"navigation":null,"dialog":null,"summary":null,"count":null,"rows":[]},"term":{"sidebar":[0,0,224,1100],"header":[224,0,536,40],"status":[224,1068,536,32],"statusItems":[[244,1073.5,73.9,22],[329.9,1073.5,181,22],[523,1073.5,52.4,22]],"shield":[12,1001,199,33],"desktopNav":[12,156,199,36],"termIcon":[185,297.5,26,26],"claudeItem":null,"navigation":null,"dialog":null,"summary":null,"count":null,"rows":[]},"browser":{"sidebar":[0,0,224,1100],"header":null,"status":[224,1068,536,32],"statusItems":[[244,1073.5,73.9,22],[329.9,1073.5,181,22],[523,1073.5,52.4,22]],"shield":[12,1001,199,33],"desktopNav":[12,156,199,36],"termIcon":[185,297.5,26,26],"claudeItem":null,"navigation":[224,40,536,40],"dialog":null,"summary":null,"count":null,"rows":[]},"safety-run":{"sidebar":[0,0,224,1100],"header":[224,0,536,40],"status":[224,1068,536,32],"statusItems":[[244,1073.5,63,22],[319,1073.5,181,22],[512,1073.5,52.4,22]],"shield":[12,1001,199,33],"desktopNav":[12,156,199,36],"termIcon":[185,297.5,26,26],"claudeItem":null,"navigation":null,"dialog":[20,20,720,1060],"summary":[43,105,674,83.8],"count":[107,211.3,521,17],"rows":[[44,280.4,672,41],[44,322.4,672,41],[44,364.4,672,41],[44,406.4,672,41],[44,448.4,672,41],[44,490.4,672,41],[44,532.4,672,41],[44,574.4,672,41],[44,616.4,672,41],[44,658.4,672,41],[44,700.4,672,41]]},"safety-done":{"sidebar":[0,0,224,1100],"header":[224,0,536,40],"status":[224,1068,536,32],"statusItems":[[244,1073.5,73.9,22],[329.9,1073.5,181,22],[523,1073.5,52.4,22]],"shield":[12,1001,199,33],"desktopNav":[12,156,199,36],"termIcon":[185,297.5,26,26],"claudeItem":null,"navigation":null,"dialog":[20,20,720,1060],"summary":[43,105,674,83.8],"count":[107,211.3,521,17],"rows":[[44,280.4,672,41],[44,322.4,672,41],[44,364.4,672,41],[44,406.4,672,41],[44,448.4,672,41],[44,490.4,672,41],[44,532.4,672,41],[44,574.4,672,41],[44,616.4,672,41],[44,658.4,672,41],[44,700.4,672,41]]}}};
新增promo/plates/menu.png看文件

二进制文件,不显示改动。

新增promo/plates/portrait/browser.png看文件

二进制文件,不显示改动。

新增promo/plates/portrait/desktop.png看文件

二进制文件,不显示改动。

新增promo/plates/portrait/home.png看文件

二进制文件,不显示改动。

新增promo/plates/portrait/menu.png看文件

二进制文件,不显示改动。

新增promo/plates/portrait/safety-done.png看文件

二进制文件,不显示改动。

新增promo/plates/portrait/safety-run.png看文件

二进制文件,不显示改动。

新增promo/plates/portrait/term.png看文件

二进制文件,不显示改动。

新增promo/plates/safety-done.png看文件

二进制文件,不显示改动。

新增promo/plates/safety-run.png看文件

二进制文件,不显示改动。

新增promo/plates/term.png看文件

二进制文件,不显示改动。

修改promo/promo.js+294 −172看文件
@@ -4,6 +4,19 @@
44(() => {
55 'use strict';
66 const T = window.TL;
7新增: // ?portrait renders the 9:16 cut: same timeline, re-laid out for 1080 × 1920.
8新增: const PORTRAIT = new URLSearchParams(location.search).has('portrait');
9新增: if (PORTRAIT) { T.width = 1080; T.height = 1920; document.body.classList.add('portrait'); }
10新增: // Positions computed here rather than in CSS, per orientation.
11新增: const L = PORTRAIT
12新增: ? { chipY: 650, chipStep: 108, chipX: 680, node: [540, 1330], holdScale: 0.38, holdLift: -35, holdScroll: 0,
13新增: panelTop: 330, colLeft: 280, colTop: 1290, pillStep: 124, pillH: 104, inputDrop: 500, zBase: 1.32, shadeFrom: 1.45, rings: 2 }
14新增: : { chipY: 360, chipStep: 98, chipX: 972, node: [1330, 590], holdScale: 0.36, holdLift: -70, holdScroll: 430,
15新增: panelTop: 214, colLeft: 1330, colTop: 330, pillStep: 112, pillH: 92, inputDrop: 360, zBase: 1.0, shadeFrom: 1.15, rings: 3 };
16新增: // The real workbench, captured at a landscape or a tall window size (see capture-plates.mjs).
17新增: const PL = window.PLATE_LAYOUT[PORTRAIT ? 'portrait' : 'landscape'];
18新增: const PLATES = PORTRAIT ? 'plates/portrait/' : 'plates/';
19新增: const mid = ([x, y, w, h]) => [x + w / 2, y + h / 2];
720 const $ = (s, r = document) => r.querySelector(s);
821 const $$ = (s, r = document) => [...r.querySelectorAll(s)];
922
@@ -137,9 +150,6 @@
137150 { n: 'Claude', c: '#d97757', w: '时区与 IP 对不上' },
138151 ];
139152
140删除: const CHECKS = ['VM 外出站约束', '终端检测通道', 'DNS 与解析约束', '系统时区与语言', '浏览器时区与语言', '共享文件与宿主私有目录',
141删除: '宿主管理接口', '代理故障关闭', 'UDP 出站约束', 'IPv6 出站约束', '出口符合已保存规则'];
142删除:
143153 // ---------- build ----------
144154 const els = {};
145155 function build() {
@@ -147,7 +157,7 @@
147157
148158 const chips = $('#appChips'), wires = $('#wires');
149159 els.apps = APPS.map((a, i) => {
150删除: const y = 360 + i * 98;
160新增: const y = L.chipY + i * L.chipStep;
151161 const chip = document.createElement('div');
152162 chip.className = 'app-chip dark-card';
153163 chip.style.top = y + 'px';
@@ -159,7 +169,10 @@
159169 chips.append(chip, warn);
160170 const y0 = y + 39;
161171 const path = document.createElementNS(SVGNS, 'path');
162删除: path.setAttribute('d', `M972 ${y0} C 1150 ${y0}, 1170 590, 1330 590`);
172新增: const [nx, ny] = L.node;
173新增: path.setAttribute('d', PORTRAIT
174新增: ? `M${L.chipX} ${y0} C 900 ${y0}, ${nx + (i - 2) * 40} ${ny - 160}, ${nx + (i - 2) * 40} ${ny}`
175新增: : `M${L.chipX} ${y0} C 1150 ${y0}, 1170 ${ny}, ${nx} ${ny}`);
163176 const dot = document.createElementNS(SVGNS, 'circle');
164177 dot.setAttribute('r', 6);
165178 dot.setAttribute('fill', '#ffb08f');
@@ -177,29 +190,53 @@
177190 svgEnd.classList.add('logo-svg');
178191 $('#endLogo').appendChild(svgEnd);
179192 els.endLogo = buildLogo(svgEnd);
180删除: els.mini = buildLogo($('#miniLogo'));
181删除:
182删除: const box = $('#checks');
183删除: box.style.gridTemplateRows = 'repeat(6, 38px)';
184删除: box.style.gridAutoFlow = 'column';
185删除: els.checks = CHECKS.map(name => {
186删除: const d = document.createElement('div');
187删除: d.className = 'ck';
188删除: d.innerHTML = `<div class="flash"></div><div class="st"><div class="wait"></div><div class="spin"></div><div class="ok"><svg class="i" viewBox="0 0 24 24"><path d="M5.5 12.5l4 4 9-9"/></svg></div></div><span>${name}</span><span class="res"><span class="n">检查中…</span><span class="y">通过</span></span>`;
189删除: box.appendChild(d);
190删除: return d;
191删除: });
192193
193194 els.caps = $$('#caption .cap');
194195 els.dots = $$('#progressDots b');
195删除: els.prog = $$('.prog .p');
196删除: els.replies = $$('#reply [data-r]');
197删除: els.termLines = $$('#term > .ln');
198删除: els.navEnable = $$('[data-enable]');
199删除: els.nodes = $$('#modal .node');
200删除: const last = els.replies[3];
201删除: last.lastChild.textContent = '';
202删除: els.lastReply = last.lastChild;
196新增: els.plates = $$('#win .plate');
197新增: Object.assign($('#win').style, { width: PL.width + 'px', height: PL.height + 'px' });
198新增: els.plates.forEach(el => { el.src = PLATES + el.dataset.plate + '.png'; });
199新增: // Panes sit where the real UI leaves its remote views and terminal empty.
200新增: const side = PL.home.sidebar[2] + 1, foot = PL.home.status[3];
201新增: const place = (el, top) => Object.assign(el.style, { left: side + 'px', top: top + 'px', bottom: foot + 'px' });
202新增: place($('#paneDesktop'), PL.desktop.header[3]);
203新增: place($('#paneTerm'), PL.term.header[3]);
204新增: place($('#paneBrowser'), PL.browser.navigation[1] + PL.browser.navigation[3] + 34);
205新增: // One overlay per check row, cut from the "all passed" plate.
206新增: const S = PL['safety-done'], fx = $('#checkFx');
207新增: els.checkRows = S.rows.map(([x, y, w, h]) => {
208新增: const row = document.createElement('div');
209新增: row.className = 'row';
210新增: Object.assign(row.style, {
211新增: left: x + 'px', top: y + 'px', width: w + 'px', height: h + 'px',
212新增: backgroundImage: `url(${PLATES}safety-done.png)`, backgroundSize: `${PL.width}px ${PL.height}px`, backgroundPosition: `${-x}px ${-y}px`,
213新增: });
214新增: row.innerHTML = '<div class="flash"></div>';
215新增: const spin = document.createElement('div');
216新增: spin.className = 'spin';
217新增: Object.assign(spin.style, { left: (x + 20.5) + 'px', top: (y + h / 2) + 'px' });
218新增: fx.append(row, spin);
219新增: return { row, spin };
220新增: });
221新增: const [cx, cy, , ch] = S.count;
222新增: Object.assign($('#checkCount').style, { left: cx + 'px', top: cy + 'px', height: ch + 'px' });
223新增: // Status-bar highlights: exit, location and (when the window is wide enough to show it) timezone.
224新增: els.rings = PL.home.statusItems.slice(0, L.rings).map(([x, y, w, h]) => {
225新增: const ring = document.createElement('div');
226新增: ring.className = 'ring2';
227新增: Object.assign(ring.style, { left: (x - 5) + 'px', top: y + 'px', width: (w + 10) + 'px', height: h + 'px' });
228新增: $('#win').insertBefore(ring, $('#ripple'));
229新增: return ring;
230新增: });
231新增: els.cdReply = $$('#cdReply p');
232新增: els.termA = $$('#termA > *');
233新增: els.termB = $$('#termB > *');
234新增: els.reply2 = $$('#termB [data-r]');
235新增: els.acctBars = $$('#acctPanel .bar i').map(el => ({ el, v: parseFloat(el.style.transform.slice(7)) }));
236新增: els.accts = $$('#acctPanel .acct');
237新增: els.accts[2].classList.add('done');
238新增: els.pills = $$('#termCol .tpill');
239新增: els.pills.forEach((pl, j) => { pl.style.top = (40 + j * L.pillStep) + 'px'; });
203240 }
204241
205242 // Window-local position of an element's centre (offsets ignore transforms).
@@ -214,45 +251,79 @@
214251 let cursorKeys, clicks;
215252 function measure() {
216253 const A = T.app;
217删除: const proxy = center($('#btnProxy'), 10, 4);
218删除: const launch = center($('#btnLaunch'), 6, 4);
219删除: const node = center($('#nodeLA'), -120, 3);
220删除: const use = center($('#btnUse'), 8, 4);
221删除: const plus = center($('#projPlus'), 2, 3);
254新增: // Sidebar targets come from the captured layout; pane targets are measured.
255新增: const desk = mid(PL.home.desktopNav), icon = mid(PL.home.termIcon), claudeItem = mid(PL.menu.claudeItem);
256新增: const input = center($('#cdInput'), 0, -22);
257新增: const go = center($('#authGo'));
222258 // [time, x, y, opacity]
259新增: const shield = mid(PL.home.shield);
223260 cursorKeys = [
224删除: [20.6, 1120, 690, 0], [21.0, 1060, 620, 1], [21.55, ...proxy, 1], [21.9, ...proxy, 1],
225删除: [23.25, ...node, 1], [23.6, ...node, 1], [24.15, ...use, 1], [24.5, use[0] + 20, use[1] + 30, 1], [24.8, use[0] + 60, use[1] + 90, 0],
226删除: [27.3, 1060, 640, 0], [27.55, 1010, 600, 1], [27.98, ...launch, 1], [28.3, ...launch, 1], [28.7, launch[0] + 70, launch[1] + 80, 0],
227删除: [34.4, 520, 520, 0], [34.6, 420, 420, 1], [34.82, ...plus, 1], [35.15, ...plus, 1], [35.5, plus[0] + 60, plus[1] + 60, 0],
261新增: [A.step1 - 0.2, 620, 700, 0], [A.step1 + 0.1, 420, 740, 1], [A.safetyOpen - 0.05, ...shield, 1], [A.safetyOpen + 0.25, ...shield, 1],
262新增: [A.safetyOpen + 0.7, 260, 700, 0],
263新增: [A.step2 + 0.1, 760, 560, 0], [A.step2 + 0.3, 620, 420, 1], [A.clickDesktop - 0.05, ...desk, 1], [A.clickDesktop + 0.25, ...desk, 1],
264新增: [A.clickInput - 0.05, ...input, 1], [A.clickInput + 0.35, ...input, 1], [A.clickInput + 0.75, input[0] + 30, input[1] + 60, 0],
265新增: [A.step3, 620, 520, 0], [A.step3 + 0.25, 420, 430, 1], [A.clickTermIcon - 0.05, ...icon, 1], [A.clickTermIcon + 0.2, ...icon, 1],
266新增: [A.clickClaudeTerm - 0.05, ...claudeItem, 1], [A.clickClaudeTerm + 0.15, ...claudeItem, 1], [A.clickClaudeTerm + 0.55, 300, 520, 0],
267新增: [A.browserOpen + 0.2, go[0] + 160, go[1] + 140, 0], [A.browserOpen + 0.45, go[0] + 120, go[1] + 110, 1],
268新增: [A.clickAuthorize - 0.05, ...go, 1], [A.clickAuthorize + 0.25, ...go, 1], [A.clickAuthorize + 0.7, go[0] + 40, go[1] + 60, 0],
228269 ];
229删除: cursorKeys.forEach(k => { k[0] += O; });
230删除: clicks = [[A.clickProxy, proxy], [A.clickNode, node], [A.clickUse, use], [A.clickLaunch, launch], [A.clickTerminal, plus]];
270新增: // Wires from each new terminal to the account it lands on.
271新增: const wires = $('#acctWires');
272新增: wires.textContent = '';
273新增: els.acctWires = ACCT_ASSIGN.map((ai, j) => {
274新增: const acct = els.accts[ai];
275新增: const ay = L.panelTop + acct.offsetTop + acct.offsetHeight / 2;
276新增: const py = L.colTop + 40 + j * L.pillStep + L.pillH / 2;
277新增: const path = document.createElementNS(SVGNS, 'path');
278新增: path.setAttribute('d', PORTRAIT
279新增: ? `M${L.colLeft + 524} ${py} C 1062 ${py}, 1078 ${ay}, 1024 ${ay}`
280新增: : `M${L.colLeft - 4} ${py} C 1220 ${py}, 1225 ${ay}, 1114 ${ay}`);
281新增: const dot = document.createElementNS(SVGNS, 'circle');
282新增: dot.setAttribute('r', 8);
283新增: dot.setAttribute('fill', '#519489');
284新增: wires.append(path, dot);
285新增: return { path, dot, len: path.getTotalLength() };
286新增: });
287新增: clicks = [[A.safetyOpen, shield], [A.clickDesktop, desk], [A.clickInput, input], [A.clickTermIcon, icon], [A.clickClaudeTerm, claudeItem], [A.clickAuthorize, go]];
231288 }
232289
233290 // ---------- camera ----------
234291 // [time, zoom, focusX, focusY, anchorX, anchorY]
235删除: const O = T.app.rise - 19.0; // camera and cursor keys below are authored for a 19.0 s start
236删除: const BASE = [1.15, 640, 380, 960, 600];
292新增: const BASE = [1.0, 720, 430, 960, 612];
293新增: const A0 = T.app;
237294 const CAM = [
238删除: [19.0, ...BASE], [21.75, ...BASE],
239删除: [22.55, 1.42, 764, 322, 960, 616], [24.45, 1.42, 764, 322, 960, 616],
240删除: [25.25, 1.8, 620, 742, 960, 880], [26.65, 1.8, 620, 742, 960, 880],
241删除: [27.35, ...BASE], [30.15, ...BASE],
242删除: [30.9, 1.4, 764, 410, 960, 612], [33.25, 1.4, 764, 410, 960, 612],
243删除: [34.1, ...BASE], [36.4, ...BASE],
244删除: [42.6, 1.34, 700, 330, 960, 612],
245删除: ].map(([at, ...rest]) => [at + O, ...rest]);
295新增: [A0.rise, ...BASE], [A0.safetyOpen, ...BASE],
296新增: [A0.safetyOpen + 0.6, 1.18, 720, 520, 960, 760], [A0.allPass + 0.7, 1.18, 720, 520, 960, 760],
297新增: [A0.rings[0] - 0.2, 1.75, 505, 846, 960, 900], [A0.step2 - 0.7, 1.75, 505, 846, 960, 900],
298新增: [A0.step2, ...BASE], [A0.desktopBoot, ...BASE],
299新增: [A0.desktopBoot + 0.6, 1.1, 860, 440, 960, 630], [A0.step3, 1.1, 860, 440, 960, 630],
300新增: [A0.clickTermIcon - 0.1, 1.7, 170, 380, 720, 620], [A0.clickClaudeTerm + 0.1, 1.7, 170, 380, 720, 620],
301新增: [A0.termLines + 0.5, 1.08, 820, 430, 960, 630], [A0.browserOpen, 1.08, 820, 430, 960, 630],
302新增: [A0.browserOpen + 0.4, 1.12, 844, 450, 960, 630], [A0.backToTerm - 0.2, 1.12, 844, 450, 960, 630],
303新增: [A0.backToTerm + 0.3, 1.1, 820, 420, 960, 630], [A0.out, 1.22, 760, 330, 960, 620],
304新增: ];
305新增: // The tall cut shows the narrow window at full width, cutting in only where a detail matters.
306新增: const PB = [1.32, 380, 550, 540, 1026];
307新增: const CAM_P = [
308新增: [A0.rise, ...PB], [A0.safetyOpen, ...PB],
309新增: [A0.safetyOpen + 0.6, 1.42, 380, 470, 540, 1010], [A0.allPass + 0.7, 1.42, 380, 470, 540, 1010],
310新增: [A0.rings[0] - 0.2, 2.6, 380, 1084, 540, 1400], [A0.step2 - 0.7, 2.6, 380, 1084, 540, 1400],
311新增: [A0.step2, ...PB], [A0.clickTermIcon - 0.6, ...PB],
312新增: [A0.clickTermIcon - 0.1, 2.0, 230, 330, 490, 980], [A0.clickClaudeTerm + 0.1, 2.0, 230, 330, 490, 980],
313新增: [A0.termLines + 0.5, ...PB], [A0.backToTerm + 0.3, ...PB],
314新增: [A0.out, 1.42, 380, 420, 540, 1000],
315新增: ];
246316 function camAt(t) {
247删除: if (t <= CAM[0][0]) return CAM[0].slice(1);
248删除: for (let i = 0; i < CAM.length - 1; i++) {
249删除: const a = CAM[i], b = CAM[i + 1];
317新增: const K = PORTRAIT ? CAM_P : CAM;
318新增: if (t <= K[0][0]) return K[0].slice(1);
319新增: for (let i = 0; i < K.length - 1; i++) {
320新增: const a = K[i], b = K[i + 1];
250321 if (t <= b[0]) {
251322 const k = E.io(p(t, a[0], b[0]));
252323 return a.slice(1).map((v, j) => lerp(v, b[j + 1], k));
253324 }
254325 }
255删除: return CAM[CAM.length - 1].slice(1);
326新增: return K[K.length - 1].slice(1);
256327 }
257328 function cursorAt(t) {
258329 const K = cursorKeys;
@@ -283,7 +354,7 @@
283354 if (t >= P.end) return;
284355
285356 // Hard cuts: every hit shakes the frame and flashes it for a few frames.
286删除: const hits = [[P.slam, 1], [P.b2, 0.55], [P.b3, 0.55], [P.b4, 0.55], [P.vmMem, 0.45], ...P.losses.map(x => [x, 0.32]), [P.total, 0.3]];
357新增: const hits = [[P.slam, 0.5], [P.holdShrink, 0.8], [P.b2, 0.55], [P.b3, 0.55], [P.b4, 0.55], [P.vmMem, 0.45], ...P.losses.map(x => [x, 0.32]), [P.total, 0.3]];
287358 let shake = 0, flash = 0;
288359 hits.forEach(([h, k]) => {
289360 const q = p(t, h, h + 0.35), f = p(t, h, h + 0.13);
@@ -300,7 +371,8 @@
300371 const k = E.out5(p(t, a, a + 0.4));
301372 css(b, { o: t >= a && t < z ? 1 : 0, tf: `translate(${sx.toFixed(2)}px, ${sy.toFixed(2)}px) scale(${(lerp(1.05, 1, k) + Math.max(0, t - a) * 0.006).toFixed(4)})` });
302373 const kick = b.querySelector('.kick');
303删除: if (kick) css(kick, { o: E.out(p(t, a + 0.05, a + 0.3)) });
374新增: const ka = i === 0 ? P.holdShrink + 0.1 : a + 0.05;
375新增: if (kick) css(kick, { o: E.out(p(t, ka, ka + 0.25)) });
304376 const head = b.querySelector('.head');
305377 if (head) {
306378 const at = i === 0 ? P.losses[2] + 0.2 : a + 0.12;
@@ -309,8 +381,20 @@
309381 }
310382 });
311383
312删除: // 01 · banned
313删除: slam($('#alarm'), t, P.slam, { from: 1.5, dur: 0.42 });
384新增: // 01 · banned: the on-hold screen people recognise, then it shrinks into evidence.
385新增: const sc = E.io(p(t, P.holdScroll[0], P.holdScroll[1]));
386新增: const sk = E.io(p(t, P.holdShrink, P.holdShrink + 0.5));
387新增: const hs = lerp(1 + Math.min(t, P.holdShrink) * 0.014, L.holdScale, sk);
388新增: const hold = $('#hold');
389新增: css(hold, { tf: `translateY(${(L.holdLift * sk).toFixed(2)}px) scale(${hs.toFixed(4)}) rotate(${(-1.6 * sk).toFixed(3)}deg)` });
390新增: hold.style.borderRadius = sk > 0 ? `${(16 / hs).toFixed(1)}px` : '0';
391新增: hold.style.boxShadow = sk > 0 ? `0 0 0 ${(3 / hs).toFixed(1)}px rgba(255,106,69,${(0.7 * sk).toFixed(3)}), 0 ${(40 / hs).toFixed(0)}px ${(110 / hs).toFixed(0)}px rgba(0,0,0,${(0.6 * sk).toFixed(3)})` : 'none';
392新增: $('#holdScroll').style.transform = `translateY(${(-L.holdScroll * sc * (1 - sk)).toFixed(2)}px)`;
393新增: css($('#holdTint'), { o: 0.14 * sk });
394新增: const mk = E.out(p(t, P.holdMark, P.holdMark + 0.4));
395新增: const mark = $('#holdMark');
396新增: mark.style.backgroundSize = `${(mk * 100).toFixed(2)}% 100%`;
397新增: mark.style.color = mk > 0.2 ? '#b5452a' : '#8a877f';
314398 $$('#losses .loss').forEach((el, i) => slam(el, t, P.losses[i], { from: 1.4, rot: [-3, 2, -2][i], dur: 0.3 }));
315399
316400 // 02 · bills
@@ -387,22 +471,42 @@
387471 ['#wordmark', '#roomPos', '#roomSub'].forEach(id => css($(id), { o: 1 - gone, tf: `translateY(${(-lift * 40).toFixed(2)}px)` }));
388472 }
389473
474新增: // Which real-UI plate is on screen at time t.
475新增: function plateAt(t) {
476新增: const A = T.app;
477新增: if (t < A.safetyOpen + 0.05) return 'home';
478新增: if (t < A.allPass) return 'safety-run';
479新增: if (t < A.safetyClose) return 'safety-done';
480新增: if (t < A.clickDesktop + 0.05) return 'home';
481新增: if (t < A.clickTermIcon + 0.05) return 'desktop';
482新增: if (t < A.clickClaudeTerm + 0.05) return 'menu';
483新增: if (t < A.browserOpen) return 'term';
484新增: if (t < A.backToTerm) return 'browser';
485新增: return 'term';
486新增: }
487新增: const typed = (t, text, [a, b]) => {
488新增: const chars = [...text];
489新增: const n = t < a ? 0 : Math.min(chars.length, Math.floor(p(t, a, b) * chars.length) + 1);
490新增: return chars.slice(0, n).join('');
491新增: };
492新增: const DESK_MSG = '帮我把 hello-cage 的 README 改得更清楚';
493新增: const TERM_MSG = '给 hello-cage 加一个健康检查接口';
494新增: const TERM_FINAL = '已添加 GET /healthz,返回 200 和当前版本号。';
495新增:
390496 function app(t) {
391497 const A = T.app;
392删除: const layer = $('#app');
393498 const lo = E.out(p(t, A.rise - 0.3, A.rise + 0.4)) * (1 - E.io(p(t, A.out + 0.4, A.end)));
394删除: css(layer, { o: lo });
499新增: css($('#app'), { o: lo });
395500 if (lo <= 0) return;
396501
397502 // captions + progress
398删除: const capWin = [[A.step1, A.step2 - 0.2], [A.step2, A.step3 - 0.2], [A.step3, A.out]];
503新增: const capWin = [[A.step1, A.step2 - 0.2], [A.step2, A.step3 - 0.2], [A.step3, A.step4 - 0.2], [A.step4, A.out]];
399504 els.caps.forEach((c, i) => {
400505 const [a, b] = capWin[i];
401506 const kin = E.out(p(t, a, a + 0.7)), kout = E.io(p(t, b - 0.35, b));
402507 css(c, { o: kin * (1 - kout), tf: `translateY(${((1 - kin) * 22 - kout * 14).toFixed(2)}px)`, f: blur((1 - kin) * 8 + kout * 8) });
403删除: const [num, txt] = c.children;
404508 const k2 = E.out(p(t, a + 0.12, a + 0.9));
405删除: css(txt.lastChild, { o: k2, tf: `translateY(${((1 - k2) * 10).toFixed(2)}px)` });
509新增: css(c.children[1].lastChild, { o: k2, tf: `translateY(${((1 - k2) * 10).toFixed(2)}px)` });
406510 els.dots[i].style.transform = `scaleX(${E.io(p(t, a, b)).toFixed(4)})`;
407511 });
408512 css($('#progressDots'), { o: win(t, A.step1, A.out, 0.6, 0.4) });
@@ -414,135 +518,152 @@
414518 const zz = z * lerp(0.94, 1, rise) * lerp(1, 0.9, exit);
415519 const tx = ax - fx * zz, ty = ay - fy * zz + (1 - rise) * 160 - exit * 20;
416520 css($('#cam'), { o: clamp(rise * 1.6) * (1 - exit), tf: `translate(${tx.toFixed(2)}px, ${ty.toFixed(2)}px) scale(${zz.toFixed(5)})`, f: blur(exit * 10) });
417删除: css($('#appFloor'), { o: rise * (1 - exit) * clamp(1 - (z - 1.15) * 3) });
418删除: css($('#capShade'), { o: clamp((z - 1.15) * 4) });
419删除:
420删除: // --- step 1 · proxy ---
421删除: const shade = win(t, A.modalOpen, A.modalClose + 0.35, 0.35, 0.35);
422删除: css($('#modalShade'), { o: shade });
423删除: const mo = E.out(p(t, A.modalOpen, A.modalOpen + 0.45)), mc = E.io(p(t, A.modalClose, A.modalClose + 0.3));
424删除: css($('#modal'), { o: mo * (1 - mc), tf: `translateY(${((1 - mo) * 18 + mc * 10).toFixed(2)}px) scale(${(lerp(0.965, 1, mo) - mc * 0.02).toFixed(4)})` });
425删除: const sel = E.out(p(t, A.clickNode, A.clickNode + 0.25));
426删除: css(els.nodes[0].querySelector('.sel'), { o: sel });
427删除: els.nodes[0].querySelector('.radio').style.borderColor = sel > 0.5 ? '#1d1b1a' : '#c9c3bc';
428删除: els.nodes[0].querySelector('.radio i').style.transform = `scale(${Math.max(0, E.back(p(t, A.clickNode, A.clickNode + 0.3), 2)).toFixed(4)})`;
429删除: els.nodes.forEach((n, i) => { css(n, { o: E.out(p(t, A.modalOpen + 0.15 + i * 0.06, A.modalOpen + 0.55 + i * 0.06)) }); });
430删除:
431删除: const press = (at) => 1 - Math.sin(Math.PI * p(t, at - 0.02, at + 0.16)) * 0.05;
432删除: const ready = E.io(p(t, A.modalClose + 0.4, A.modalClose + 0.75));
433删除: const swap = E.io(p(t, A.modalClose + 0.6, A.modalClose + 0.95));
434删除: css($('#stateWait'), { o: 1 - ready, tf: `translateY(${(-ready * 8).toFixed(2)}px)` });
435删除: css($('#stateReady'), { o: ready, tf: `translateY(${((1 - ready) * 8).toFixed(2)}px)` });
436删除: css($('#btnProxy'), { o: 1 - swap, tf: `scale(${press(A.clickProxy).toFixed(4)})` });
437删除: css($('#btnLaunch'), { o: swap, tf: `scale(${press(A.clickLaunch).toFixed(4)})` });
438删除: const s1 = $('#st1 b'), s2 = $('#st2 b');
439删除: const done1 = t > A.modalClose + 0.5, on2 = t > A.modalClose + 0.7;
440删除: s1.className = done1 ? 'done' : 'on';
441删除: s1.innerHTML = done1 ? '<svg class="i" viewBox="0 0 24 24"><path d="M5.5 12.5l4 4 9-9"/></svg>' : '1';
442删除: s1.style.transform = `scale(${(1 + Math.sin(Math.PI * p(t, A.modalClose + 0.5, A.modalClose + 0.8)) * 0.18).toFixed(4)})`;
443删除: s2.className = on2 ? 'on' : '';
444删除: $('#st1 > span:last-child').className = done1 ? '' : 'strong';
445删除: $('#st2 > span:last-child').className = on2 ? 'strong' : '';
446删除:
447删除: flip($('#proxyFlip'), t, [A.tzFlip - 0.3], 16);
448删除: flip($('#tzFlip'), t, [A.tzFlip], 16);
449删除: css($('#hlProxy'), { o: win(t, A.tzFlip - 0.35, A.tzFlip + 0.75, 0.3, 0.5) });
450删除: css($('#hlTz'), { o: win(t, A.tzFlip - 0.05, A.tzFlip + 0.95, 0.3, 0.5) });
451删除:
452删除: // --- step 2 · launch ---
453删除: const toLaunch = E.io(p(t, A.launch + 0.12, A.launch + 0.55));
454删除: const heroOut = E.io(p(t, A.launch, A.launch + 0.25));
455删除: const toTerm = E.io(p(t, A.terminal, A.terminal + 0.4));
456删除: css($('#viewHero'), { o: 1 - heroOut, tf: `translateY(${(-heroOut * 14).toFixed(2)}px)` });
457删除: css($('#viewLaunch'), { o: toLaunch * (1 - toTerm), tf: `translateY(${((1 - toLaunch) * 16 - toTerm * 10).toFixed(2)}px)` });
458删除:
459删除: const spin = `rotate(${(t * 420) % 360}deg)`;
460删除: const stage = (row, start, end, label) => {
461删除: const [wait, sp, ok] = row.querySelector('.st').children;
462删除: const k = p(t, start, end);
463删除: css(wait, { o: t < start ? 1 : 0 });
464删除: css(sp, { o: t >= start && k < 1 ? 1 : 0, tf: spin });
465删除: css(ok, { o: k >= 1 ? 1 : 0, tf: `scale(${Math.max(0, E.back(p(t, end, end + 0.3), 2)).toFixed(4)})` });
466删除: return k;
521新增: css($('#appFloor'), { o: rise * (1 - exit) * clamp(1 - (z - L.zBase) * 3) });
522新增: css($('#capShade'), { o: clamp((z - L.shadeFrom) * 4) });
523新增:
524新增: const plate = plateAt(t);
525新增: // The safety dialog fades in, settles to "all passed", then fades away; other changes are cuts.
526新增: const fade = {
527新增: 'safety-run': t >= A.safetyOpen ? E.out(p(t, A.safetyOpen + 0.05, A.safetyOpen + 0.25)) : 0,
528新增: 'safety-done': t >= A.allPass && t < A.safetyClose + 0.3 ? E.io(p(t, A.allPass, A.allPass + 0.35)) * (1 - E.io(p(t, A.safetyClose, A.safetyClose + 0.25))) : 0,
467529 };
468删除: els.prog.forEach((row, i) => {
469删除: const [a, b] = i === 0 ? A.image : A.tools;
470删除: const k = stage(row, a, b);
471删除: const fill = i === 0 ? E.sine(k) : E.out(k);
472删除: row.querySelector('.bar i').style.transform = `scaleX(${fill.toFixed(4)})`;
473删除: row.querySelector('.pct').textContent = `${Math.round(fill * 100)}%`;
530新增: els.plates.forEach(el => {
531新增: const name = el.dataset.plate;
532新增: let o = name === plate ? 1 : 0;
533新增: if (name === 'home' && (plate === 'safety-run' || plate === 'safety-done')) o = 1;
534新增: if (name === 'safety-run') o = plate === 'safety-run' ? fade[name] : plate === 'safety-done' ? 1 : 0;
535新增: if (name === 'safety-done') o = fade[name];
536新增: css(el, { o });
474537 });
538新增:
539新增: // 01 · the eleven critical checks pass one by one
540新增: const inDialog = t >= A.safetyOpen && t < A.allPass + 0.4;
475541 let passed = 0;
476删除: els.checks.forEach((row, i) => {
542新增: els.checkRows.forEach(({ row, spin }, i) => {
477543 const at = A.checks + 0.15 + i * A.checkStep;
478删除: stage(row, A.checks, at);
479544 if (t >= at) passed++;
480删除: const [n, y] = row.querySelector('.res').children;
545新增: css(row, { o: inDialog ? E.out(p(t, at, at + 0.18)) * fade['safety-run'] : 0 });
546新增: css(row.firstChild, { o: Math.sin(Math.PI * p(t, at, at + 0.5)) });
547新增: css(spin, { o: inDialog && t >= A.checks && t < at ? fade['safety-run'] : 0, tf: `rotate(${((t * 420) % 360).toFixed(1)}deg)` });
548新增: });
549新增: $('#checkCount').textContent = `${passed} / 11 通过`;
550新增: css($('#checkCount'), { o: inDialog && t < A.allPass + 0.35 ? fade['safety-run'] : 0 });
551新增: const press = at => 1 - Math.sin(Math.PI * p(t, at - 0.02, at + 0.16)) * 0.05;
552新增:
553新增: // 01 · ready: the status bar tells you where you exit from
554新增: els.rings.forEach((r, i) => css(r, { o: win(t, A.rings[i], A.step2 - 0.4, 0.3, 0.4) }));
555新增:
556新增: // 02 · Claude Desktop running inside the VM display
557新增: const desk = plate === 'desktop' || plate === 'menu';
558新增: css($('#paneDesktop'), { o: desk ? E.out(p(t, A.desktopBoot, A.desktopBoot + 0.45)) : 0 });
559新增: if (desk) {
560新增: const sent = t >= A.send;
561新增: const draft = sent ? '' : typed(t, DESK_MSG, A.typeMsg);
562新增: $('#cdTx').textContent = draft;
563新增: $('#cdPh').style.display = draft ? 'none' : '';
564新增: const typing = t > A.typeMsg[0] && t < A.typeMsg[1] + 0.2;
565新增: css($('#cdCaret'), { o: t >= A.clickInput && (typing || Math.floor(t * 2.2) % 2 === 0) ? 1 : 0 });
566新增: $('#cdSend').style.background = draft ? '#d97757' : '#e8b8a5';
567新增: const mv = E.io(p(t, A.send, A.send + 0.45));
568新增: css($('#cdHello'), { o: E.out(p(t, A.desktopBoot + 0.3, A.desktopBoot + 0.8)) * (1 - mv), tf: `translateY(${(-mv * 30).toFixed(2)}px)` });
569新增: css($('#cdInput'), { tf: `translateY(${(mv * L.inputDrop).toFixed(2)}px)` });
570新增: $('#cdUser').textContent = DESK_MSG;
571新增: const ck = E.out(p(t, A.send + 0.15, A.send + 0.5));
572新增: css($('#cdChat'), { o: ck, tf: `translateY(${((1 - ck) * 12).toFixed(2)}px)` });
573新增: els.cdReply.forEach((el, i) => {
574新增: const at = lerp(A.reply[0], A.reply[1], i / els.cdReply.length);
575新增: const k = E.out(p(t, at, at + 0.35));
576新增: css(el, { o: k, tf: `translateY(${((1 - k) * 8).toFixed(2)}px)` });
577新增: });
578新增: }
579新增:
580新增: // 03 · Claude terminal: Claude Code starts and asks to sign in
581新增: css($('#paneTerm'), { o: plate === 'term' ? 1 : 0 });
582新增: const back = t >= A.backToTerm;
583新增: css($('#termA'), { o: back ? 0 : 1 });
584新增: css($('#termB'), { o: back ? 1 : 0 });
585新增: els.termA.forEach((ln, i) => {
586新增: const at = i === els.termA.length - 1 ? A.opening : A.termLines + i * 0.1;
481587 const k = E.out(p(t, at, at + 0.25));
482删除: css(n, { o: t < A.checks ? 0.5 : 1 - k });
483删除: css(y, { o: k, tf: `translateX(${((1 - k) * 6).toFixed(2)}px)` });
484删除: css(row.querySelector('.flash'), { o: Math.sin(Math.PI * p(t, at, at + 0.5)) });
588新增: css(ln, { o: k, tf: `translateY(${((1 - k) * 6).toFixed(2)}px)` });
485589 });
486删除: const rel = E.out(p(t, A.released, A.released + 0.45));
487删除: $('#ckCount').textContent = passed === 11 ? '11 / 11 通过' : `${passed} / 11`;
488删除: $('#ckCount').style.color = passed === 11 ? '#1f5f35' : '#6c6763';
489删除: css($('#phBusy'), { o: 1 - clamp(rel * 2.5), tf: `translateY(${(-rel * 16).toFixed(2)}px)`, f: blur(rel * 6) });
490删除: css($('#phDone'), { o: clamp(rel * 1.6 - 0.4), tf: `translateY(${((1 - rel) * 14).toFixed(2)}px)` });
491删除: css($('.ph .okb'), { o: rel, tf: `scale(${lerp(0.6, 1, Math.max(0, E.back(p(t, A.released, A.released + 0.45), 2))).toFixed(4)})` });
492删除: $('.ph').style.background = `rgba(47,138,76,${(0.07 * Math.sin(Math.PI * p(t, A.released, A.released + 1.2))).toFixed(4)})`;
493删除:
494删除: // sidebar + status bar follow the environment state
495删除: flip($('#envFlip'), t, [A.launch, A.released], 18);
496删除: $('#envDot').style.background = t > A.released ? '#2f8a4c' : t > A.launch ? '#d29a2e' : '#b7b1ab';
497删除: $('#envDot').style.boxShadow = t > A.released ? '0 0 0 3px rgba(47,138,76,.16)' : 'none';
498删除: flip($('#netFlip'), t, [A.released + 0.15], 16);
499删除: flip($('#latFlip'), t, [A.released + 0.35], 16);
500删除: const netOk = t > A.released + 0.15;
501删除: $('#netIco').style.color = netOk ? '#2f8a4c' : '#4a4642';
502删除: $('#netTick').style.opacity = netOk ? 1 : 0;
503删除: els.navEnable.forEach(n => { n.style.color = t > A.released ? '#2a2724' : '#b4aea8'; });
504删除: css($('#stopIt'), { o: t > A.launch ? 1 : 0.4 });
505删除:
506删除: // --- step 3 · terminal ---
507删除: css($('#viewTerm'), { o: toTerm });
508删除: const term = E.out(p(t, A.clickTerminal, A.clickTerminal + 0.3));
509删除: css($('#childHint'), { o: 1 - term });
510删除: css($('#childTerm'), { o: term });
511删除: $('#navHome').className = term > 0.5 ? '' : 'on';
512删除: css($('#crumbLeaf'), { o: toTerm });
513删除: css($('#syncIt'), { o: toTerm });
514删除: els.termLines.forEach((ln, i) => {
515删除: const k = E.out(p(t, A.terminal + 0.1 + i * 0.05, A.terminal + 0.45 + i * 0.05));
590新增: if (t >= A.opening) $('#termOpening').style.opacity = String(0.55 + 0.45 * Math.abs(Math.sin((t - A.opening) * 5)));
591新增:
592新增: // 04 · authorise in the Cage browser, then back to work
593新增: css($('#paneBrowser'), { o: plate === 'browser' ? E.out(p(t, A.browserOpen, A.browserOpen + 0.3)) : 0 });
594新增: const dn = E.out(p(t, A.authDone, A.authDone + 0.35));
595新增: css($('#authAsk'), { o: 1 - dn });
596新增: css($('#authDone'), { o: dn, tf: `scale(${lerp(0.96, 1, dn).toFixed(4)})` });
597新增: $('#authGo').style.transform = `scale(${press(A.clickAuthorize).toFixed(4)})`;
598新增: els.termB.forEach((ln, i) => {
599新增: if (ln.dataset.r !== undefined) return;
600新增: const at = A.backToTerm + 0.1 + i * 0.25;
601新增: const k = E.out(p(t, at, at + 0.3));
516602 css(ln, { o: k, tf: `translateY(${((1 - k) * 6).toFixed(2)}px)` });
517603 });
518删除: const typed = (s, at, per) => s.slice(0, Math.max(0, Math.floor((t - at) / per) + 1) * (t >= at ? 1 : 0));
519删除: $('#cmdText').textContent = typed('claude', A.typeClaude, 0.1);
604新增: $('#termPrompt').textContent = typed(t, TERM_MSG, A.typePrompt);
520605 const blinkOn = Math.floor(t * 2.2) % 2 === 0;
521删除: css($('#caret1'), { o: t < A.enterClaude ? (t > A.typeClaude && t < A.typeClaude + 0.7 ? 1 : blinkOn ? 1 : 0) : 0 });
522删除: const cc = E.out(p(t, A.welcome, A.welcome + 0.5));
523删除: css($('#ccBlock'), { o: cc, tf: `translateY(${((1 - cc) * 10).toFixed(2)}px)` });
524删除: const prompt = '帮我给 hello-cage 写一份 README';
525删除: $('#promptText').textContent = typed(prompt, A.typePrompt, (A.enterPrompt - 0.2 - A.typePrompt) / prompt.length);
526删除: css($('#caret2'), { o: t < A.enterPrompt ? (t > A.typePrompt ? 1 : blinkOn ? 1 : 0) : 0 });
527删除: els.replies.forEach((r, i) => {
528删除: const k = E.out(p(t, A.reply[i], A.reply[i] + 0.35));
606新增: css($('#termCaret'), { o: t < A.enterPrompt && (t > A.typePrompt[0] || blinkOn) ? 1 : 0 });
607新增: els.reply2.forEach((r, i) => {
608新增: const k = E.out(p(t, A.reply2[i], A.reply2[i] + 0.35));
529609 css(r, { o: k, tf: `translateY(${((1 - k) * 6).toFixed(2)}px)` });
530610 });
531删除: const final = 'README 写好了:简介、安装方式和本地运行步骤都在里面。';
532删除: els.lastReply.textContent = ' ' + final.slice(0, Math.floor(p(t, A.reply[3], A.reply[3] + 1.1) * final.length));
611新增: $('#termFinal').textContent = TERM_FINAL.slice(0, Math.floor(p(t, A.reply2[3], A.reply2[3] + 1.0) * TERM_FINAL.length));
533612
534613 // cursor + clicks
535614 const [cx, cy, co] = cursorAt(t);
536615 const pressK = clicks.reduce((m, [at]) => Math.max(m, Math.sin(Math.PI * p(t, at - 0.04, at + 0.14))), 0);
537删除: css($('#cursor'), { o: co, tf: `translate(${(cx - 248 - 5).toFixed(2)}px, ${(cy - 3).toFixed(2)}px) scale(${(1 - pressK * 0.16).toFixed(4)})` });
616新增: css($('#cursor'), { o: co, tf: `translate(${(cx - 5).toFixed(2)}px, ${(cy - 3).toFixed(2)}px) scale(${(1 - pressK * 0.16).toFixed(4)})` });
538617 let rip = null;
539618 clicks.forEach(([at, pos]) => { if (t >= at && t < at + 0.55) rip = [p(t, at, at + 0.55), pos]; });
540619 if (rip) {
541620 const [k, [x, y]] = rip;
542删除: css($('#ripple'), { o: (1 - k) * 0.9, tf: `translate(${(x - 248).toFixed(2)}px, ${y.toFixed(2)}px) scale(${lerp(0.3, 1.5, E.out(k)).toFixed(4)})` });
621新增: css($('#ripple'), { o: (1 - k) * 0.9, tf: `translate(${x.toFixed(2)}px, ${y.toFixed(2)}px) scale(${lerp(0.3, 1.5, E.out(k)).toFixed(4)})` });
543622 } else css($('#ripple'), { o: 0 });
544623 }
545624
625新增: // Terminal j goes to account ACCT_ASSIGN[j]: fewest terminals first, then the most quota left.
626新增: const ACCT_ASSIGN = [0, 1, 0];
627新增: function accounts(t) {
628新增: const C = T.accounts;
629新增: const o = E.io(p(t, C.start, C.start + 0.5)) * (1 - E.io(p(t, C.out, C.end)));
630新增: css($('#accts'), { o });
631新增: if (o <= 0) return;
632新增: const kc = E.out(p(t, C.start + 0.1, C.start + 0.8));
633新增: css($('#accts .cap'), { o: kc, tf: `translateY(${((1 - kc) * 22).toFixed(2)}px)`, f: blur((1 - kc) * 8) });
634新增: $$('#accts .dots b').forEach((b, i) => { b.style.transform = `scaleX(${i < 4 ? 1 : E.io(p(t, C.start, C.out)).toFixed(4)})`; });
635新增: const pk = E.out5(p(t, C.panel, C.panel + 0.6));
636新增: css($('#acctPanel'), { o: clamp(pk * 1.5), tf: `translateY(${((1 - pk) * 50).toFixed(2)}px)` });
637新增: els.accts.forEach((r, i) => {
638新增: const k = E.out5(p(t, C.rows[i], C.rows[i] + 0.5));
639新增: css(r, { o: k, tf: `translateY(${((1 - k) * 20).toFixed(2)}px)` });
640新增: const mine = ACCT_ASSIGN.map((a, j) => (a === i ? C.terms[j] + 0.45 : null)).filter(x => x !== null);
641新增: const em = r.querySelector('.load em');
642新增: if (em) em.textContent = String(mine.filter(x => t >= x).length);
643新增: css(r.querySelector('.ring'), { o: mine.reduce((m, x) => Math.max(m, Math.sin(Math.PI * p(t, x - 0.1, x + 0.7))), 0) });
644新增: const skip = r.querySelector('.skip');
645新增: if (skip) css(skip, { o: E.out(p(t, C.terms[0] + 0.2, C.terms[0] + 0.5)), tf: `translateX(${(Math.sin(t * 60) * 3 * Math.sin(Math.PI * p(t, C.terms[0] + 0.2, C.terms[0] + 0.6))).toFixed(2)}px)` });
646新增: });
647新增: els.acctBars.forEach(({ el, v }, n) => {
648新增: const row = Math.floor(n / 2);
649新增: el.style.transform = `scaleX(${(v * E.out(p(t, C.rows[row] + 0.25, C.rows[row] + 1.0))).toFixed(4)})`;
650新增: });
651新增: css($('#termCol .tlabel'), { o: E.out(p(t, C.terms[0] - 0.4, C.terms[0])) });
652新增: els.pills.forEach((pl, j) => {
653新增: const at = C.terms[j];
654新增: const k = E.out5(p(t, at, at + 0.45));
655新增: css(pl, { o: clamp(k * 2), tf: `translateX(${((1 - k) * 90).toFixed(2)}px)` });
656新增: css(pl.querySelector('.to'), { o: E.out(p(t, at + 0.5, at + 0.7)), tf: `scale(${Math.max(0, E.back(p(t, at + 0.5, at + 0.8), 2)).toFixed(4)})` });
657新增: const w = els.acctWires[j];
658新增: const d = E.io(p(t, at + 0.1, at + 0.5));
659新增: w.path.style.opacity = (d > 0 ? lerp(0.9, 0.35, p(t, at + 0.6, at + 1.4)) : 0).toFixed(3);
660新增: const pt = w.path.getPointAtLength(d * w.len);
661新增: w.dot.setAttribute('cx', pt.x.toFixed(2));
662新增: w.dot.setAttribute('cy', pt.y.toFixed(2));
663新增: w.dot.style.opacity = d > 0 && d < 1 ? 1 : 0;
664新增: });
665新增: }
666新增:
546667 function perks(t) {
547668 const P = T.perks;
548669 const o = E.io(p(t, P.start, P.start + 0.6)) * (1 - E.io(p(t, P.out, P.end)));
@@ -592,16 +713,16 @@
592713 css($('#endLogo'), { tf: `translateY(${(barImpact(t, [a + 0.85, a + 1.0]) * 4).toFixed(2)}px)` });
593714 const k = (d, dur = 0.8) => E.out(p(t, a + d, a + d + dur));
594715 const rise = (el, d) => { const v = k(d); css(el, { o: v, tf: `translateY(${((1 - v) * 16).toFixed(2)}px)`, f: blur((1 - v) * 6) }); };
595删除: rise($('#endWord'), 1.2);
596删除: rise($('#endSub'), 1.55);
597删除: $$('#endPlat span').forEach((s, i) => rise(s, 1.95 + i * 0.12));
598删除: rise($('#endUrl'), 2.5);
599删除: rise($('#endGit'), 2.75);
600删除: rise($('#endNote'), 3.1);
716新增: rise($('#endWord'), 0.9);
717新增: rise($('#endSub'), 1.15);
718新增: $$('#endPlat span').forEach((s, i) => rise(s, 1.45 + i * 0.1));
719新增: rise($('#endUrl'), 1.85);
720新增: rise($('#endGit'), 2.05);
721新增: rise($('#endNote'), 2.3);
601722 }
602723
603724 function chrome(t, frame) {
604删除: const dark = t < T.room.start + 0.4 || (t > T.letter.start + 0.4 && t < T.letter.out + 0.4);
725新增: const dark = (t > T.pain.holdShrink && t < T.room.start + 0.4) || (t > T.letter.start + 0.4 && t < T.letter.out + 0.4);
605726 const g = $('#grain');
606727 g.style.opacity = dark ? 0.55 : 0.3;
607728 g.style.transform = `translate(${Math.floor(hash(frame) * 200) - 100}px, ${Math.floor(hash(frame + 0.5) * 200) - 100}px)`;
@@ -613,6 +734,7 @@
613734 pain(t);
614735 room(t);
615736 app(t);
737新增: accounts(t);
616738 perks(t);
617739 letter(t);
618740 end(t);
修改promo/render.mjs+9 −30看文件
@@ -4,6 +4,7 @@
44// node render.mjs full 1920×1080 @ 60 fps → out/claude-cage-promo.mp4
55// node render.mjs --fps 30 --scale 0.5 quick draft
66// node render.mjs --frames 12,20.5,33 stills only → out/frame-*.png
7新增:// node render.mjs --portrait 9:16 cut → out/claude-cage-promo-vertical.mp4 (combines with the flags above)
78// node render.mjs --preview serve the page for live preview
89//
910// Chrome: set CHROME_PATH, otherwise the usual install locations on macOS,
@@ -14,6 +15,7 @@ import { createServer } from 'node:http';
1415import { createRequire } from 'node:module';
1516import { extname, join, normalize, resolve, sep } from 'node:path';
1617import { fileURLToPath } from 'node:url';
18新增:import { findChrome } from './chrome.mjs';
1719
1820const require = createRequire(import.meta.url);
1921const here = fileURLToPath(new URL('.', import.meta.url));
@@ -28,7 +30,9 @@ const opt = (name, fallback) => {
2830};
2931const fps = Number(opt('fps', TL.fps));
3032const scale = Number(opt('scale', 1));
31删除:const output = resolve(opt('out', join(outDir, 'claude-cage-promo.mp4')));
33新增:const portrait = args.includes('--portrait');
34新增:const [W, H] = portrait ? [1080, 1920] : [TL.width, TL.height];
35新增:const output = resolve(opt('out', join(outDir, portrait ? 'claude-cage-promo-vertical.mp4' : 'claude-cage-promo.mp4')));
3236const audio = resolve(opt('audio', join(outDir, 'soundtrack.wav')));
3337
3438const TYPES = {
@@ -51,31 +55,6 @@ function serve(port = 0) {
5155 return new Promise(ok => server.listen(port, '127.0.0.1', () => ok(server)));
5256}
5357
54删除:function findChrome() {
55删除: if (process.env.CHROME_PATH) return process.env.CHROME_PATH;
56删除: const pf = process.env.PROGRAMFILES || 'C:\\Program Files';
57删除: const pf86 = process.env['PROGRAMFILES(X86)'] || 'C:\\Program Files (x86)';
58删除: const local = process.env.LOCALAPPDATA || '';
59删除: const candidates = {
60删除: darwin: [
61删除: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
62删除: '/Applications/Chromium.app/Contents/MacOS/Chromium',
63删除: '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
64删除: ],
65删除: win32: [
66删除: join(pf, 'Google\\Chrome\\Application\\chrome.exe'),
67删除: join(pf86, 'Google\\Chrome\\Application\\chrome.exe'),
68删除: join(local, 'Google\\Chrome\\Application\\chrome.exe'),
69删除: join(pf86, 'Microsoft\\Edge\\Application\\msedge.exe'),
70删除: join(pf, 'Microsoft\\Edge\\Application\\msedge.exe'),
71删除: ],
72删除: linux: ['/usr/bin/google-chrome', '/usr/bin/google-chrome-stable', '/usr/bin/chromium', '/usr/bin/chromium-browser', '/snap/bin/chromium'],
73删除: }[process.platform] || [];
74删除: const found = candidates.find(p => existsSync(p));
75删除: if (!found) throw new Error('Chrome not found. Set CHROME_PATH to a Chrome, Chromium or Edge executable.');
76删除: return found;
77删除:}
78删除:
7958async function openPage(server) {
8059 const { default: puppeteer } = await import('puppeteer-core');
8160 const browser = await puppeteer.launch({
@@ -84,10 +63,10 @@ async function openPage(server) {
8463 args: ['--hide-scrollbars', '--force-color-profile=srgb', '--font-render-hinting=none', '--disable-lcd-text'],
8564 });
8665 const page = await browser.newPage();
87删除: await page.setViewport({ width: TL.width, height: TL.height, deviceScaleFactor: scale });
66新增: await page.setViewport({ width: W, height: H, deviceScaleFactor: scale });
8867 const { port } = server.address();
8968 page.on('pageerror', e => console.error('page error:', e.message));
90删除: await page.goto(`http://127.0.0.1:${port}/promo/index.html?render`, { waitUntil: 'networkidle0', timeout: 120000 });
69新增: await page.goto(`http://127.0.0.1:${port}/promo/index.html?render${portrait ? '&portrait' : ''}`, { waitUntil: 'networkidle0', timeout: 120000 });
9170 await page.evaluate(() => window.__promo.ready);
9271 // Touch every act once so lazily loaded font subsets are in before frame 0.
9372 for (let t = 0; t < TL.duration; t += 0.5) await page.evaluate(x => window.__promo.seek(x), t);
@@ -101,7 +80,7 @@ async function stills(times) {
10180 mkdirSync(outDir, { recursive: true });
10281 for (const t of times) {
10382 await page.evaluate(x => window.__promo.seek(x), t);
104删除: const path = join(outDir, `frame-${t.toFixed(2)}.png`);
83新增: const path = join(outDir, `frame-${portrait ? 'v-' : ''}${t.toFixed(2)}.png`);
10584 await page.screenshot({ path, type: 'png' });
10685 console.log(path);
10786 }
@@ -117,7 +96,7 @@ async function video() {
11796 const total = Math.round(TL.duration * fps);
11897 const hasAudio = existsSync(audio);
11998 if (!hasAudio) console.warn(`No soundtrack at ${audio}; run "node soundtrack.mjs" first. Rendering silent video.`);
120删除: const w = Math.round(TL.width * scale), h = Math.round(TL.height * scale);
99新增: const w = Math.round(W * scale), h = Math.round(H * scale);
121100 const ff = spawn(ffmpeg, [
122101 '-y', '-loglevel', 'error',
123102 '-f', 'image2pipe', '-c:v', 'mjpeg', '-framerate', String(fps), '-i', '-',
新增promo/social/README.md+5 −0看文件
@@ -0,0 +1,5 @@
1新增:# Cage 社交宣传素材
2新增:
3新增:本目录保存横版、竖版及社区风格的正式配图,以及对应的生成提示词。文件名含 `x` 的配图用于横版社交平台,含 `xiaohongshu` 的配图用于竖版发布;同名的 v2 为后续修订稿。图中文字与界面用于产品宣传,不表示用户账户或网络验收结果。
4新增:
5新增:宣传片源码位于上一级目录,导出成片位于 `promo/out/`,不纳入源码提交。生成服务的调用元数据、中间候选图与私有诊断输出不进入公开源码。
新增promo/social/cage-anime-cover-prompt.txt+11 −0看文件
@@ -0,0 +1,11 @@
1新增:Use case: ads-marketing, open-source community anime key visual.
2新增:Input image 1: the ACTUAL Claude Cage website cover art, the identity and narrative reference. Make a polished Chinese anime promotional poster based on it, portrait 1536x2048. Preserve the same recognizable orange long-haired adult anime heroine, amber eyes, orange flower hair ornament, black ribbon, modest cream high-neck blouse and dark clothing, warm bronze cage window, extended hand offering a cream envelope sealed with an orange flower wax seal. Preserve her gently aloof, slightly pouty gaze at viewer and warm golden-hour light. This is an affectionate fictional mascot scene, no menace. Render beautiful clean 2D anime linework and nuanced cel shading, luminous hair, delicate face, confident hands and perspective, with painterly warm background. Avoid photorealism, 3D plastic, chibi and extra characters.
3新增:Art direction: an elegant anime illustration artbook cover for a small developer-made open-source project, warm cream paper, burnt orange and dark charcoal typography. Illustration occupies most of the poster, a tall bronze window as natural frame, heroine's face prominent, envelope reaching toward viewer at lower center. Compose the full artwork and text together with excellent readability. Top title region in warm cream, transition naturally into rich illustration; small restrained footer. Strong negative space and generous margins. No dense sales brochure, no feature cards, no prices, no badges, no buttons, no QR, no legal small print, no official endorsement, no watermark. The visual should feel inviting and slightly playful, low commercial intensity.
4新增:Render ONLY this exact copy, correctly and clearly:
5新增:Small top brand: "Claude Cage"
6新增:Large main headline in two lines: "把 Claude 大小姐" / "关起来。"
7新增:One supporting line: "一个为 Claude 准备的开源小窝"
8新增:Near bottom, modest readable feature line: "代理隔离 · 环境自动配置 · 多账号调度"
9新增:Footer platform line: "macOS / Windows / Linux"
10新增:Footer repository: "github.com/Lee-xeo/Claude-Cage"
11新增:No extra text or tiny pseudo-writing. Do not put words on the envelope. Keep typography separate from the heroine's face and hands. Output a finished ready-to-share poster, not a mockup of a poster on a wall.
新增promo/social/cage-anime-cover-x-prompt.txt+9 −0看文件
@@ -0,0 +1,9 @@
1新增:Use case: ads-marketing, open-source community anime key visual. Adapt the supplied finished Claude Cage portrait poster into a beautifully composed landscape 2048x1152 X/Twitter image. Keep the same adult orange-haired anime heroine, amber eyes, orange flower ornaments, dark ribbon, modest cream blouse, bronze cage window, reaching hand and sealed envelope, warm golden evening lighting and cream paper artbook identity. Preserve face identity, nuanced 2D anime rendering and warm wistful expression. Recompose, do not stretch or crop the portrait. Left 47%: quiet cream negative space with generous typography. Right 53%: full-height anime illustration, face large and unobstructed inside bronze window, envelope reaching across lower center. Hair and golden light can softly bridge the two halves. Sophisticated illustrated cover, not sales campaign; no price, no buttons, no disclaimers, no cards, no added characters, no watermark.
2新增:Use ONLY the exact following text, all correctly spelled, readable and inside 72px safe margins:
3新增:Small brand at upper left: "Claude Cage"
4新增:Large headline on left in three lines: "把 Claude" / "大小姐" / "关起来。"
5新增:Subhead below: "一个为 Claude 准备的开源小窝"
6新增:Three compact separate readable lines lower left: "代理隔离" / "环境自动配置" / "多账号调度"
7新增:Footer left: "macOS / Windows / Linux"
8新增:Repository along bottom left: "github.com/Lee-xeo/Claude-Cage"
9新增:Keep text on calm light background, no text on heroine or envelope. Footer comfortably above lower edge. Retain original's artbook-like burnt-orange and charcoal typography, refined spacing and low commercial intensity.
新增promo/social/cage-anime-x.png看文件

二进制文件,不显示改动。

新增promo/social/cage-anime-xiaohongshu.png看文件

二进制文件,不显示改动。

新增promo/social/cage-x-2048x1152-v2-prompt.txt+2 −0看文件
@@ -0,0 +1,2 @@
1新增:Edit this existing Cage advertisement with a narrowly scoped design revision. Remove the entire oversized orange '0 元' price and '软件使用费' caption. Do NOT replace them with any oversized words. Rebalance the vacated space with generous intentional whitespace and the existing glass cage illustration. Keep '完全开源' only in the existing feature section, with the same modest prominence as the other features. The focus should now clearly be the main headline and protective glass-cube mascot. No price, zero-cost, or sale-like message. Change the bottom orange CTA from '免费获取' to '查看源码'; if it contains '参与共建', keep that phrase. Preserve all other existing Chinese text verbatim, including main title, subtitle, steps strip, feature descriptions, platform names, GitHub URL and fine print. Preserve logo, ivory background, black typography, orange and sage accents, mascot design, premium polished glass/metal rendering, overall visual identity. Maintain careful legibility and editorial alignment. Do not introduce new copy.
2新增:Landscape: keep the large headline at left and glass cage at right. Use the former price area below the subtitle as calm whitespace, subtly vertically balance the headline block if needed. Keep all four bottom feature columns.
新增promo/social/cage-x-2048x1152.png看文件

二进制文件,不显示改动。

新增promo/social/cage-x-v2.png看文件

二进制文件,不显示改动。

新增promo/social/cage-x-v3-prompt.txt+1 −0看文件
@@ -0,0 +1 @@
1新增:Perform a precise local text removal on the supplied finished poster. Remove ONLY the two small fine-print lines at the bottom right, to the right of the GitHub URL. The exact lines to completely erase are: "代理与 Claude 服务费用另计;首次启动需下载环境。" and "网络隔离不承诺免封号;Windows / Linux 为预览版。". Seamlessly reconstruct the existing warm ivory paper background underneath. Leave the area blank. Do not add replacement text. Keep the entire rest of the image unchanged: same dimensions, exact composition, all other Chinese wording and typography, logo, headline, glass cage and orange mascot, network lines, setup bar, four feature blocks, platform icons and names, orange source-code CTA, GitHub icon and URL. Do not recompose, recenter, crop, or resize any element. This is removal of the specified fine-print block only.
新增promo/social/cage-xiaohongshu-1536x2048-v2-prompt.txt+2 −0看文件
@@ -0,0 +1,2 @@
1新增:Edit this existing Cage advertisement with a narrowly scoped design revision. Remove the entire oversized orange '0 元' price and '软件使用费' caption. Do NOT replace them with any oversized words. Rebalance the vacated space with generous intentional whitespace and the existing glass cage illustration. Keep '完全开源' only in the existing feature section, with the same modest prominence as the other features. The focus should now clearly be the main headline and protective glass-cube mascot. No price, zero-cost, or sale-like message. Change the bottom orange CTA from '免费获取' to '查看源码'; if it contains '参与共建', keep that phrase. Preserve all other existing Chinese text verbatim, including main title, subtitle, steps strip, feature descriptions, platform names, GitHub URL and fine print. Preserve logo, ivory background, black typography, orange and sage accents, mascot design, premium polished glass/metal rendering, overall visual identity. Maintain careful legibility and editorial alignment. Do not introduce new copy.
2新增:Portrait: thoughtfully recenter the hero cube within its illustration area, retaining the surrounding network motif; leave breathing room where the price was. Preserve the lower feature grid layout.
新增promo/social/cage-xiaohongshu-1536x2048.png看文件

二进制文件,不显示改动。

新增promo/social/cage-xiaohongshu-v2.png看文件

二进制文件,不显示改动。

新增promo/social/cage-xiaohongshu-v3-prompt.txt+1 −0看文件
@@ -0,0 +1 @@
1新增:Perform a precise local text removal on the supplied finished poster. Remove ONLY the two small fine-print lines at the bottom left, below the platform and GitHub footer row. The exact lines to completely erase are: "代理与 Claude 服务费用另计;首次启动需下载环境。" and "网络隔离不承诺免封号;Windows / Linux 为预览版。". Seamlessly reconstruct the existing warm ivory paper background underneath. Leave the area blank. Do not add replacement text. Keep the entire rest of the image unchanged: same dimensions, exact composition, all other Chinese wording and typography, logo, headline, glass cage and orange mascot, network lines, setup bar, four feature blocks, platform icons and names, orange source-code CTA, GitHub icon and URL. Do not recompose, recenter, crop, or resize any element. This is removal of the specified fine-print block only.
新增promo/social/community-01-readme-prompt.txt+16 −0看文件
@@ -0,0 +1,16 @@
1新增:Use case: ads-marketing, specifically an independent OPEN SOURCE COMMUNITY PROJECT introduction, not a commercial advertisement.
2新增:Create a complete finished Chinese poster 1536x2048. Input image is ONLY the actual Cage logo reference: orange pixel creature behind black cage bars. Preserve recognizable logo identity but do not scale the reference to fill poster. This is a new art direction.
3新增:Audience: developers and Claude users sharing a useful open source tool on Xiaohongshu and X. Quiet, sincere, useful, inviting. Strong readable Chinese typography with generous margins, clear hierarchy. No price, no "0元", no sales pitch, no button CTA, no glossy glass/metal cube, no security shield, no exaggerated safety claims, no disclaimer/fine-print block at bottom, no QR, no official endorsement, no invented stats, no extra text.
4新增:Keep all body copy at genuinely phone-readable size; repository URL must be accurate.
5新增:
6新增:Direction A: minimal open-source README / beautifully typeset independent project release sheet. Almost white warm paper #FAF9F6, charcoal type, very small vermilion accents. Flat graphic design, no 3D. A clean small Cage logo at top beside an understated OPEN SOURCE label. Large but calm mixed Latin and Chinese title, left aligned. Middle features a small charming flat pixel Cage mascot with simple fine network lines inside a thin outline of a workspace; it should occupy at most one quarter of page and feel like a diagrammatic illustration, not a luxury product. Lots of calm whitespace. Below, three vertically stacked text sections, divided by thin horizontal lines, simple small index numbers. Plain footer invitation, not boxed. Aim for a GitHub project beautifully introduced by its maintainer.
7新增:Use EXACT copy:
8新增:Top: "Cage" and "OPEN SOURCE"
9新增:Headline: "给 Claude 一个" / "独立的工作环境。"
10新增:Introduction: "一个开源桌面工具,把环境搭建和网络检查放在一起。"
11新增:Section 01: "配置自己的代理,启动环境" / "环境自动准备,浏览器、终端、编辑器一处就绪。"
12新增:Section 02: "网络隔离,有据可查" / "内置泄漏检查,代理断开不回退直连。"
13新增:Section 03: "支持多账号调度" / "新建 Claude Code 终端时自动分配账号。"
14新增:Footer invitation: "代码公开,欢迎提 Issue、审查与贡献。"
15新增:Platforms: "macOS / Windows / Linux"
16新增:Repo: "github.com/Lee-xeo/Claude-Cage"
新增promo/social/community-01-readme-x-prompt.txt+5 −0看文件
@@ -0,0 +1,5 @@
1新增:Use case: ads-marketing, independent open source community introduction.
2新增:Adapt the supplied finished Cage portrait poster into a carefully recomposed 2048x1152 LANDSCAPE image for X/Twitter. Preserve this particular reference's distinctive visual style, palette, logo, illustration, and ALL Chinese and English copy VERBATIM. Do not merely crop or stretch. No new copy, no commercial CTA, no prices, no safety guarantees, no disclaimers, no extra labels. The reference is the complete source of copy and style.
3新增:Composition: compact logo/brand at top left, left-aligned main headline and short introduction in left 55 percent; move the main illustration to the upper right 40 percent; arrange the functional notes in a generous full-width lower section with clear hierarchy, and use a plain understated bottom contribution invitation, platform names, repository. Keep font sizes comfortably readable and avoid a dense brochure. Use 72px minimum margins. Preserve line weight and character design, no glossy 3D makeover. Rebalance so it feels designed for landscape, not squeezed.
4新增:Exact repository: github.com/Lee-xeo/Claude-Cage
5新增:Keep the white README-like editorial design. The three numbered sections may run across three columns below the main headline/illustration area.
新增promo/social/community-01-readme-x.png看文件

二进制文件,不显示改动。

新增promo/social/community-01-readme-xiaohongshu.png看文件

二进制文件,不显示改动。

新增promo/social/community-02-dev-notes-prompt.txt+18 −0看文件
@@ -0,0 +1,18 @@
1新增:Use case: ads-marketing, specifically an independent OPEN SOURCE COMMUNITY PROJECT introduction, not a commercial advertisement.
2新增:Create a complete finished Chinese poster 1536x2048. Input image is ONLY the actual Cage logo reference: orange pixel creature behind black cage bars. Preserve recognizable logo identity but do not scale the reference to fill poster. This is a new art direction.
3新增:Audience: developers and Claude users sharing a useful open source tool on Xiaohongshu and X. Quiet, sincere, useful, inviting. Strong readable Chinese typography with generous margins, clear hierarchy. No price, no "0元", no sales pitch, no button CTA, no glossy glass/metal cube, no security shield, no exaggerated safety claims, no disclaimer/fine-print block at bottom, no QR, no official endorsement, no invented stats, no extra text.
4新增:Keep all body copy at genuinely phone-readable size; repository URL must be accurate.
5新增:
6新增:Direction B: maintainer's personal developer notebook / open source field notes. Warm off-white faint square-grid paper. Deep ink navy typography, restrained burnt orange handwritten underlines. Editorial but friendly, human-made, very organized. Main headline typeset in readable Chinese sans, supporting annotation in neat handwritten Chinese, not sloppy. Centerpiece: hand-drawn 2D laptop/workbench with browser, terminal, editor as three simplified panes containing NO tiny pseudo text; small orange pixel mascot standing by it, drawn from logo. Light pencil arrows connect three real readable annotations "浏览器" "终端" "编辑器". The diagram should feel like someone explaining their small tool, not mock official UI. Beneath, 3 concise handwritten-note rows with simple checkboxes or dashes, no feature cards. Tiny Cage logo top. A few charming orange pencil marks, no unnecessary decoration. Calm, personal.
7新增:Use EXACT copy:
8新增:Top: "Cage / 开发者手记"
9新增:Headline: "只是想好好用 Claude," / "于是做了个开源工具。"
10新增:Subhead: "把反复折腾的环境配置,整理成一个桌面应用。"
11新增:Illustration labels only: "浏览器" / "终端" / "编辑器"
12新增:Notes:
13新增:"配置代理,环境自动准备"
14新增:"内置泄漏检查,代理断开不回退直连"
15新增:"多账号调度:新建 Claude Code 终端时分配"
16新增:Small invitation above footer: "还在持续打磨,欢迎一起提问题、改代码。"
17新增:Footer: "macOS / Windows / Linux"
18新增:Repo: "github.com/Lee-xeo/Claude-Cage"
新增promo/social/community-02-dev-notes-x-prompt.txt+5 −0看文件
@@ -0,0 +1,5 @@
1新增:Use case: ads-marketing, independent open source community introduction.
2新增:Adapt the supplied finished Cage portrait poster into a carefully recomposed 2048x1152 LANDSCAPE image for X/Twitter. Preserve this particular reference's distinctive visual style, palette, logo, illustration, and ALL Chinese and English copy VERBATIM. Do not merely crop or stretch. No new copy, no commercial CTA, no prices, no safety guarantees, no disclaimers, no extra labels. The reference is the complete source of copy and style.
3新增:Composition: compact logo/brand at top left, left-aligned main headline and short introduction in left 55 percent; move the main illustration to the upper right 40 percent; arrange the functional notes in a generous full-width lower section with clear hierarchy, and use a plain understated bottom contribution invitation, platform names, repository. Keep font sizes comfortably readable and avoid a dense brochure. Use 72px minimum margins. Preserve line weight and character design, no glossy 3D makeover. Rebalance so it feels designed for landscape, not squeezed.
4新增:Exact repository: github.com/Lee-xeo/Claude-Cage
5新增:Keep handwritten notebook style, the laptop labels 浏览器 / 终端 / 编辑器, and the personal maintainer tone. Headline can wrap in two lines, and the three check notes may sit in the lower third.
新增promo/social/community-02-dev-notes-x.png看文件

二进制文件,不显示改动。

新增promo/social/community-02-dev-notes-xiaohongshu.png看文件

二进制文件,不显示改动。

新增promo/social/community-03-pixel-club-prompt.txt+18 −0看文件
@@ -0,0 +1,18 @@
1新增:Use case: ads-marketing, specifically an independent OPEN SOURCE COMMUNITY PROJECT introduction, not a commercial advertisement.
2新增:Create a complete finished Chinese poster 1536x2048. Input image is ONLY the actual Cage logo reference: orange pixel creature behind black cage bars. Preserve recognizable logo identity but do not scale the reference to fill poster. This is a new art direction.
3新增:Audience: developers and Claude users sharing a useful open source tool on Xiaohongshu and X. Quiet, sincere, useful, inviting. Strong readable Chinese typography with generous margins, clear hierarchy. No price, no "0元", no sales pitch, no button CTA, no glossy glass/metal cube, no security shield, no exaggerated safety claims, no disclaimer/fine-print block at bottom, no QR, no official endorsement, no invented stats, no extra text.
4新增:Keep all body copy at genuinely phone-readable size; repository URL must be accurate.
5新增:
6新增:Direction C: playful indie open source pixel-art club poster. Pale soft mint background, dark forest green typography, orange pixel mascot, small cream accents. Strictly flat 2D pixel art with deliberately hard pixel edges for the illustration. Chinese TEXT must be clean readable modern sans, not garbled pixel font. Large centered typography with airy spacing. In the central third, a cozy tiny pixel-art workspace/garden: friendly orange mascot from logo inside a modest outlined workspace, one small terminal monitor, leafy pixels and a short orange network cable. No prison atmosphere, no glossy/glass rendering, no neon cyberpunk. The visual should feel like a community hobby project sticker / game jam poster, not enterprise software ad. Bottom half has plain aligned short functional notes, thin pixel divider, friendly understated contribution line. Avoid sales badges and call-to-action buttons.
7新增:Use EXACT copy:
8新增:Top: "Cage" and "一个开源小项目"
9新增:Headline: "少折腾环境," / "多做点有意思的事。"
10新增:Subheading: "为 Claude 准备的独立工作空间"
11新增:Functional notes:
12新增:"配置自己的代理 · 环境自动准备"
13新增:"内置泄漏检查 · 代理断开不回退直连"
14新增:"支持多账号调度"
15新增:Smaller but readable qualification directly below last note: "新建 Claude Code 终端时分配"
16新增:Community line: "欢迎围观、提 Issue,也欢迎一起写代码。"
17新增:Footer: "macOS / Windows / Linux"
18新增:Repo: "github.com/Lee-xeo/Claude-Cage"
新增promo/social/community-03-pixel-club-x-prompt.txt+5 −0看文件
@@ -0,0 +1,5 @@
1新增:Use case: ads-marketing, independent open source community introduction.
2新增:Adapt the supplied finished Cage portrait poster into a carefully recomposed 2048x1152 LANDSCAPE image for X/Twitter. Preserve this particular reference's distinctive visual style, palette, logo, illustration, and ALL Chinese and English copy VERBATIM. Do not merely crop or stretch. No new copy, no commercial CTA, no prices, no safety guarantees, no disclaimers, no extra labels. The reference is the complete source of copy and style.
3新增:Composition: compact logo/brand at top left, left-aligned main headline and short introduction in left 55 percent; move the main illustration to the upper right 40 percent; arrange the functional notes in a generous full-width lower section with clear hierarchy, and use a plain understated bottom contribution invitation, platform names, repository. Keep font sizes comfortably readable and avoid a dense brochure. Use 72px minimum margins. Preserve line weight and character design, no glossy 3D makeover. Rebalance so it feels designed for landscape, not squeezed.
4新增:Exact repository: github.com/Lee-xeo/Claude-Cage
5新增:Keep the mint background and flat green/orange pixel illustration. Keep the qualification 新建 Claude Code 终端时分配 immediately beside or below 支持多账号调度.
新增promo/social/community-03-pixel-club-x.png看文件

二进制文件,不显示改动。

新增promo/social/community-03-pixel-club-xiaohongshu.png看文件

二进制文件,不显示改动。

新增promo/social/landscape-prompt.txt+17 −0看文件
@@ -0,0 +1,17 @@
1新增:Use case: ads-marketing. Adapt the supplied finished Cage portrait advertisement into an independently composed landscape X/Twitter ad at 2048x1152 (16:9). Preserve the visual identity: warm ivory, oversized black Chinese sans typography, vivid orange, small sage green icons, beautiful glass-and-metal protective cube with orange voxel mascot. Preserve exact logo identity. Do not crop or stretch the portrait. Redesign into a balanced wide composition: compact top brand line; left half strong two-line headline and subtitle, big orange '0 元' with '软件使用费'; right half large crisp hero cube and orange protected network route, soft studio light. Below main hero a full-width slim orange three-step setup bar. Under it four neat horizontally arranged feature groups, typography led, divided by hairlines. Bottom platform and GitHub line with legible fine print. All text highly legible, careful alignment, generous 64px safe margins. Stylish premium editorial campaign, not cluttered.
2新增:Render only this exact Chinese copy, do not invent any text:
3新增:Brand: 'Cage' / '为 Claude 而造'
4新增:Main title: '用 Claude,' / '少一点折腾。'
5新增:Subtitle: '担心网络泄露?把隔离与检查交给 Cage。'
6新增:Price: '0 元' / '软件使用费'
7新增:Steps bar: '下载安装 → 配置代理 → 开始使用'
8新增:Steps note: '环境自动准备,省去手动搭建'
9新增:Features:
10新增:'代理隔离' with '代理断开不回退直连'
11新增:'多账号调度' with '新建 Claude Code 终端时分配'
12新增:'完全开源' with '欢迎审查与贡献'
13新增:'轻量跨平台' with '浏览器、终端、编辑器一体'
14新增:Footer: 'macOS / Windows / Linux' and '免费获取 ↗ github.com/Lee-xeo/Claude-Cage'
15新增:Fine print: '代理与 Claude 服务费用另计;首次启动需下载环境。'
16新增:'网络隔离不承诺免封号;Windows / Linux 为预览版。'
17新增:No QR code, no extra labels, no endorsement, no watermark. Finished ready-to-share professional artwork.
新增promo/social/portrait-prompt.txt+25 −0看文件
@@ -0,0 +1,25 @@
1新增:Use case: ads-marketing. Create a finished, beautiful Chinese software advertisement poster for Cage, portrait 3:4 1536x2048, ready to post on Xiaohongshu. Input reference is the actual Cage logo: preserve its recognizable orange pixel creature and dark cage bars in a small top-left brand icon. This is a new ad design, not an alteration of the logo file.
2新增:Art direction: high-end contemporary independent developer product campaign, warm ivory background #F7F3EB, nearly black expressive large Chinese sans typography, vivid vermilion orange #EF663A, tiny sage-green safety cues. Strong Swiss editorial alignment combined with playful collectible 3D product art. Crisp typography, confident asymmetry, ample space, phone-readable, no gratuitous gradients, no cyberpunk, no stock photo humans, no generic dashboard cards everywhere.
3新增:Composition: top slim brand line with logo and Cage on left, '为 Claude 而造' right. Huge flush-left two-line headline in upper quarter. Small supporting line below. Central hero: an exquisite isometric transparent glass protective cube/cage containing the friendly orange blocky pixel mascot from logo; softly glowing orange interior, subtle brushed-metal rails and studio shadows, abstract disconnected network line outside and protected single orange route to cube, conveys isolated environment and safety. No words on illustration, no fake UI. Integrate an oversized typographic '0 元' and caption '软件使用费' beside hero, like an editorial price statement, not a sale sticker.
4新增:Lower half: one prominent horizontal orange installation strip, then neat 2 by 2 typography-led feature blocks separated by delicate rules, simple line symbols. Bottom platform line and clear GitHub CTA. Fine print still readable.
5新增:Render ONLY the following exact copy, preserve all Chinese characters, no other invented text:
6新增:Brand: 'Cage' / '为 Claude 而造'
7新增:Headline: '用 Claude,' / '少一点折腾。'
8新增:Subtitle: '担心网络泄露?把隔离与检查交给 Cage。'
9新增:Price: '0 元' / '软件使用费'
10新增:Orange strip headline: '下载安装 → 配置代理 → 开始使用'
11新增:Orange strip smaller: '环境自动准备,省去手动搭建'
12新增:Feature 1 heading: '代理隔离,安心开工'
13新增:Feature 1 body: '代理断开不回退直连 · 内置泄漏检查'
14新增:Feature 2 heading: '多账号,自动分配'
15新增:Feature 2 body: '新建 Claude Code 终端时调度'
16新增:Feature 3 heading: '完全开源,欢迎审查'
17新增:Feature 3 body: '代码公开 · 欢迎贡献'
18新增:Feature 4 heading: '轻量环境,专为 Claude'
19新增:Feature 4 body: '浏览器、终端、编辑器,一处就绪'
20新增:Platform line: 'macOS / Windows / Linux'
21新增:CTA: '免费获取,参与共建 ↗'
22新增:Repository: 'github.com/Lee-xeo/Claude-Cage'
23新增:Fine print in two clean lines: '代理与 Claude 服务费用另计;首次启动需下载环境。'
24新增:'网络隔离不承诺免封号;Windows / Linux 为预览版。'
25新增:No version numbers, no unsupported 100% security, no official Anthropic endorsement, no QR code, no watermark. All content comfortably inside safe margins. Final must look like meticulously art-directed professional social ad with strong typography, not a dense brochure.
修改promo/soundtrack.mjs+48 −20看文件
@@ -131,7 +131,7 @@ const bell = (t, m, vol) => {
131131};
132132
133133// ---------- score ----------
134删除:const { pain: P, room: R, app: A, perks: K, letter: L, end: En } = TL;
134新增:const { pain: P, room: R, app: A, accounts: C, perks: K, letter: L, end: En } = TL;
135135
136136// Act 1 · the problem: a driving pulse, an impact on every cut, then silence.
137137const kick = (t, vol) => { sine(t, 95, vol, 9, { f1: 42, glide: 0.035, send: 0.08 }); noise(t, 0.012, vol * 0.25, { lo: 1500, hi: 4000, shape: x => 1 - x, send: 0.02 }); };
@@ -143,15 +143,20 @@ const boom = (t, k) => {
143143const stamp = (t, vol = 0.3) => { tock(t, vol); noise(t, 0.05, vol * 0.3, { lo: 800, hi: 5000, shape: x => 1 - x, send: 0.15 }); };
144144const bpm = 60 / 128;
145145pad(0, P.b5 + 0.04, [26, 38, 45, 51], 0.05, { fadeIn: 0.4, fadeOut: 0.04, cutoff: 650, send: 0.45 });
146删除:for (let t = P.slam, i = 0; t < P.b5 - 0.05; t += bpm, i++) {
146新增:for (let t = P.holdShrink, i = 0; t < P.b5 - 0.05; t += bpm, i++) {
147147 const build = 0.55 + 0.45 * (t / P.b5);
148148 kick(t, 0.22 * build);
149149 sine(t, mtof(i % 8 === 6 ? 39 : 38), 0.05 * build, 6, { send: 0.1 });
150150 noise(t + bpm / 2, 0.02, 0.035 * build, { lo: 5000, hi: 9000, shape: x => 1 - x, send: 0.05, pan: 0.3 });
151151}
152删除:boom(P.slam, 1);
153删除:sine(P.slam, mtof(69), 0.08, 1.6, { send: 0.5 });
154删除:sine(P.slam, mtof(70), 0.07, 1.6, { send: 0.5 });
152新增:// The on-hold screen lands like a thunderclap, then the ears ring.
153新增:boom(P.slam, 1.15);
154新增:noise(P.slam, 0.09, 0.3, { lo: 1500, hi: 12000, shape: x => 1 - x, send: 0.6 });
155新增:sine(P.slam, 3150, 0.022, 0.9, { send: 0.15 });
156新增:sine(P.slam, 3170, 0.016, 0.8, { send: 0.15, pan: 0.4 });
157新增:piano(P.holdMark, 38, 0.5, { len: 2, bright: 0.4, send: 0.5 });
158新增:piano(P.holdMark, 39, 0.3, { len: 2, bright: 0.4, send: 0.5 });
159新增:boom(P.holdShrink, 0.8);
155160[P.b2, P.b3, P.b4].forEach(t => boom(t, 0.7));
156161P.losses.forEach(t => stamp(t, 0.32));
157162P.rows.forEach(t => noise(t, 0.05, 0.06, { lo: 2500, hi: 6000, shape: x => 1 - x, send: 0.1 }));
@@ -185,33 +190,56 @@ const beat = 60 / 76, bar = beat * 4, arpStart = A.rise + 0.45;
185190const chords = [
186191 [38, [62, 66, 69]], [37, [61, 64, 69]], [35, [62, 66, 71]], [31, [62, 67, 71]],
187192 [42, [62, 66, 69]], [40, [62, 67, 71]], [33, [62, 64, 69]], [33, [61, 64, 69]],
193新增: [38, [62, 66, 69]],
188194];
189195chords.forEach(([bass, [a, b, c]], ci) => {
190196 const t0 = arpStart + ci * bar;
191删除: if (t0 > A.out) return;
197新增: if (t0 > C.out) return;
192198 piano(t0, bass, 0.42, { len: bar + 0.6, bright: 0.5, send: 0.35 });
193199 piano(t0 + beat * 2, bass + 7, 0.24, { len: bar, bright: 0.5, send: 0.35 });
194200 const pat = [a, b + 12, c, a + 12, b, c + 12, a + 12, b + 12];
195201 pat.forEach((m, k) => {
196202 const t = t0 + k * beat / 2;
197删除: if (t > A.out + 0.3) return;
203新增: if (t > C.out + 0.3) return;
198204 piano(t, m, (k % 2 ? 0.16 : 0.22) * (k === 0 ? 1.2 : 1), { len: 2.6, send: 0.42 });
199205 });
200206});
201删除:noise(A.modalOpen - 0.05, 0.35, 0.03, { lo: 500, hi: 3000, send: 0.3 });
202删除:noise(A.modalClose - 0.05, 0.3, 0.025, { lo: 500, hi: 2500, send: 0.3 });
203删除:[A.clickProxy, A.clickNode, A.clickUse, A.clickLaunch, A.clickTerminal].forEach(t => click(t));
204删除:pip(A.tzFlip - 0.3, 1600, 0.035); pip(A.tzFlip, 2000, 0.04);
205删除:const scale = [74, 76, 78, 79, 81, 83, 85, 86, 88, 90, 91];
206删除:scale.forEach((m, i) => sine(A.checks + 0.15 + i * A.checkStep, mtof(m), 0.05, 7, { send: 0.45, pan: i < 6 ? -0.25 : 0.25 }));
207删除:[74, 78, 81, 86].forEach((m, i) => bell(A.released + i * 0.05, m, 0.09));
208删除:for (let i = 0; i < 6; i++) key(A.typeClaude + i * 0.1, i);
209删除:click(A.enterClaude, 0.1, -0.1);
210删除:const promptLen = [...'帮我给 hello-cage 写一份 README'].length;
211删除:const per = (A.enterPrompt - 0.2 - A.typePrompt) / promptLen;
212删除:for (let i = 0; i < promptLen; i++) key(A.typePrompt + i * per, i);
207新增:// 01 · the safety dialog: one rising plink per passed check, a chime when all eleven pass.
208新增:noise(A.safetyOpen, 0.3, 0.03, { lo: 500, hi: 3000, send: 0.3 });
209新增:[74, 76, 78, 79, 81, 83, 85, 86, 88, 90, 91].forEach((m, i) =>
210新增: sine(A.checks + 0.15 + i * A.checkStep, mtof(m), 0.05, 7, { send: 0.45, pan: -0.3 + i * 0.06 }));
211新增:[74, 78, 81, 86].forEach((m, i) => bell(A.allPass + i * 0.05, m, 0.09));
212新增:noise(A.safetyClose, 0.3, 0.025, { lo: 500, hi: 2500, send: 0.3 });
213新增:// 01 · ready: one chime per highlighted status item.
214新增:A.rings.forEach((t, i) => sine(t, mtof([79, 83, 86][i]), 0.045, 7, { send: 0.45 }));
215新增:[A.safetyOpen, A.clickDesktop, A.clickInput, A.clickTermIcon, A.clickClaudeTerm, A.clickAuthorize].forEach(t => click(t));
216新增:// 02 · Claude Desktop boots, a message is typed and answered.
217新增:noise(A.desktopBoot - 0.05, 0.45, 0.03, { lo: 500, hi: 3500, send: 0.35 });
218新增:const typeKeys = (text, [a, b]) => { const n = [...text].length; for (let i = 0; i < n; i++) key(a + (i / n) * (b - a), i); };
219新增:typeKeys('帮我把 hello-cage 的 README 改得更清楚', A.typeMsg);
220新增:click(A.send, 0.09, -0.1);
221新增:for (let i = 0; i < 4; i++) pip(A.reply[0] + i * (A.reply[1] - A.reply[0]) / 4, 1250 + i * 80, 0.02);
222新增:// 03 · the Claude terminal starts and asks to sign in.
223新增:noise(A.clickTermIcon + 0.02, 0.2, 0.025, { lo: 900, hi: 4000, send: 0.2 });
224新增:for (let i = 0; i < 7; i++) noise(A.termLines + i * 0.1, 0.015, 0.03, { lo: 2500, hi: 6000, shape: x => 1 - x, send: 0.05 });
225新增:pip(A.opening, 1500, 0.03);
226新增:// 04 · authorise in the Cage browser, then back to the terminal.
227新增:noise(A.browserOpen - 0.05, 0.4, 0.035, { lo: 600, hi: 4000, send: 0.35 });
228新增:[74, 78, 81, 86].forEach((m, i) => bell(A.authDone + i * 0.05, m, 0.085));
229新增:noise(A.backToTerm - 0.05, 0.35, 0.03, { lo: 600, hi: 3500, send: 0.3 });
230新增:typeKeys('给 hello-cage 加一个健康检查接口', A.typePrompt);
213231click(A.enterPrompt, 0.1, -0.1);
214删除:A.reply.forEach(t => pip(t, 1250, 0.02));
232新增:A.reply2.forEach(t => pip(t, 1250, 0.02));
233新增:
234新增:// Act 3b · accounts: each new terminal clicks, travels and lands on its account.
235新增:noise(C.panel - 0.05, 0.4, 0.03, { lo: 500, hi: 3000, send: 0.3 });
236新增:C.rows.forEach(t => noise(t, 0.03, 0.035, { lo: 2500, hi: 6000, shape: x => 1 - x, send: 0.1 }));
237新增:C.terms.forEach((t, j) => {
238新增: click(t, 0.1);
239新增: noise(t + 0.1, 0.4, 0.02, { lo: 800, hi: 4000, send: 0.25, pan: 0.3 });
240新增: sine(t + 0.45, mtof([79, 83, 86][j]), 0.05, 6, { send: 0.45, pan: -0.2 });
241新增:});
242新增:sine(C.terms[0] + 0.22, mtof(55), 0.05, 7, { send: 0.3 }); sine(C.terms[0] + 0.3, mtof(52), 0.04, 7, { send: 0.3 }); // skipped account
215243
216244// Act 4 · perks: a lift to G, one chime per card.
217245piano(K.head, 31, 0.4, { len: 5, bright: 0.5, send: 0.45 });
修改promo/timeline.js+79 −63看文件
@@ -3,94 +3,110 @@
33// in the browser and through require() in Node.
44(function (root) {
55 const TL = {
6删除: duration: 60,
6新增: duration: 61.3,
77 fps: 60,
88 width: 1920,
99 height: 1080,
1010
11删除: // Act 1 · the problem, four hard-cut beats and a question.
11新增: // Act 1 · the problem: the real on-hold screen, then four hard-cut beats.
1212 pain: {
13删除: slam: 0.15,
14删除: losses: [0.85, 1.15, 1.45],
15删除: b2: 3.4,
16删除: rows: [3.75, 4.05, 4.35, 4.65],
17删除: total: 5.0,
18删除: b3: 6.4,
19删除: wires: 6.75,
20删除: tags: [7.25, 7.55, 7.85, 8.15, 8.45],
21删除: b4: 9.4,
22删除: vm: 9.55,
23删除: vmMem: 10.5,
24删除: vmTodo: [10.9, 11.15, 11.4, 11.65],
25删除: b5: 12.2,
26删除: end: 13.75,
13新增: slam: 0.12,
14新增: holdScroll: [0.75, 1.75],
15新增: holdMark: 1.55,
16新增: holdShrink: 2.1,
17新增: losses: [2.6, 2.9, 3.2],
18新增: b2: 4.3,
19新增: rows: [4.65, 4.95, 5.25, 5.55],
20新增: total: 5.9,
21新增: b3: 7.3,
22新增: wires: 7.65,
23新增: tags: [8.15, 8.45, 8.75, 9.05, 9.35],
24新增: b4: 10.3,
25新增: vm: 10.45,
26新增: vmMem: 11.4,
27新增: vmTodo: [11.8, 12.05, 12.3, 12.55],
28新增: b5: 13.1,
29新增: end: 14.65,
2730 },
2831
2932 // Act 2 · the answer.
3033 room: {
31删除: start: 13.75,
32删除: pixels: 14.0,
33删除: frame: 14.65,
34删除: bars: [15.0, 15.2],
35删除: blink: 16.0,
36删除: word: 15.55,
37删除: pos: 16.1,
38删除: sub: 16.75,
39删除: end: 19.7,
34新增: start: 14.65,
35新增: pixels: 14.9,
36新增: frame: 15.55,
37新增: bars: [15.9, 16.1],
38新增: blink: 16.9,
39新增: word: 16.45,
40新增: pos: 17.0,
41新增: sub: 17.65,
42新增: end: 20.3,
4043 },
4144
42删除: // Act 3 · three steps inside the app.
45新增: // Act 3 · the real workbench: ready → Claude Desktop → Claude terminal → browser login.
4346 app: {
44删除: rise: 19.4,
45删除: step1: 20.4,
46删除: clickProxy: 22.1,
47删除: modalOpen: 22.3,
48删除: clickNode: 23.8,
49删除: clickUse: 24.7,
50删除: modalClose: 24.8,
51删除: tzFlip: 26.15,
52删除: step2: 27.6,
53删除: clickLaunch: 28.5,
54删除: launch: 28.6,
55删除: image: [29.0, 30.0],
56删除: tools: [30.0, 30.8],
57删除: checks: 30.85,
47新增: rise: 20.0,
48新增: step1: 21.0,
49新增: safetyOpen: 21.5,
50新增: checks: 21.8,
5851 checkStep: 0.2,
59删除: released: 33.25,
60删除: step3: 34.8,
61删除: clickTerminal: 35.25,
62删除: terminal: 35.4,
63删除: typeClaude: 36.2,
64删除: enterClaude: 37.0,
65删除: welcome: 37.2,
66删除: typePrompt: 37.8,
67删除: enterPrompt: 39.4,
68删除: reply: [39.65, 40.3, 40.95, 41.7],
69删除: out: 43.0,
70删除: end: 44.0,
52新增: allPass: 24.0,
53新增: safetyClose: 24.8,
54新增: rings: [25.5, 25.8, 26.1],
55新增: step2: 26.6,
56新增: clickDesktop: 27.35,
57新增: desktopBoot: 27.5,
58新增: clickInput: 28.3,
59新增: typeMsg: [28.45, 29.65],
60新增: send: 29.8,
61新增: reply: [30.1, 31.4],
62新增: step3: 31.7,
63新增: clickTermIcon: 32.4,
64新增: clickClaudeTerm: 33.1,
65新增: termLines: 33.3,
66新增: opening: 34.25,
67新增: step4: 34.6,
68新增: browserOpen: 34.75,
69新增: clickAuthorize: 35.9,
70新增: authDone: 36.05,
71新增: backToTerm: 36.8,
72新增: typePrompt: [37.6, 38.7],
73新增: enterPrompt: 38.8,
74新增: reply2: [39.05, 39.55, 40.05, 40.65],
75新增: out: 42.6,
76新增: end: 43.6,
77新增: },
78新增:
79新增: // Act 3b · several accounts, assigned per terminal.
80新增: accounts: {
81新增: start: 43.2,
82新增: panel: 43.45,
83新增: rows: [43.65, 43.8, 43.95],
84新增: terms: [44.6, 45.45, 46.3],
85新增: out: 48.2,
86新增: end: 48.8,
7187 },
7288
7389 // Act 4 · everything that comes in the box.
7490 perks: {
75删除: start: 43.8,
76删除: head: 44.1,
77删除: tiles: [44.7, 44.95, 45.2, 45.45],
78删除: out: 48.9,
79删除: end: 49.5,
91新增: start: 48.6,
92新增: head: 48.9,
93新增: tiles: [49.4, 49.65, 49.9, 50.15],
94新增: out: 52.6,
95新增: end: 53.2,
8096 },
8197
8298 // Act 5 · why the cage exists.
8399 letter: {
84删除: start: 49.3,
85删除: lines: [50.1, 51.0, 51.9],
86删除: out: 54.0,
87删除: end: 54.7,
100新增: start: 53,
101新增: lines: [53.7, 54.5, 55.3],
102新增: out: 56.3,
103新增: end: 56.9,
88104 },
89105
90106 // Act 6 · end card.
91107 end: {
92删除: start: 54.85,
93删除: blink: 57.9,
108新增: start: 56.9,
109新增: blink: 59.9,
94110 },
95111 };
96112
新增setup_recovery_test.go+106 −0看文件
@@ -0,0 +1,106 @@
1新增:package agentvm
2新增:
3新增:import (
4新增: "os"
5新增: "os/exec"
6新增: "path/filepath"
7新增: "strings"
8新增: "testing"
9新增:)
10新增:
11新增:func setupFunction(t *testing.T, name string, end string) string {
12新增: t.Helper()
13新增: start := strings.Index(SetupScript, name+"() ")
14新增: if start < 0 {
15新增: t.Fatal("missing function", name)
16新增: }
17新增: body := SetupScript[start:]
18新增: last := strings.Index(body, "\n"+end+"\n")
19新增: if last < 0 {
20新增: t.Fatal("missing function end", name)
21新增: }
22新增: return body[:last+len(end)+2]
23新增:}
24新增:
25新增:func TestRepositoryKeyFailurePreservesTrustedFile(t *testing.T) {
26新增: for _, mode := range []string{"eof", "empty", "invalid", "success"} {
27新增: t.Run(mode, func(t *testing.T) {
28新增: dir := t.TempDir()
29新增: key := filepath.Join(dir, "nodesource.asc")
30新增: if err := os.WriteFile(key, []byte("trusted"), 0644); err != nil {
31新增: t.Fatal(err)
32新增: }
33新增: commands := map[string]string{
34新增: "curl": `#!/bin/sh
35新增:while [ "$#" -gt 0 ]; do
36新增: if [ "$1" = -o ]; then shift; target="$1"; fi
37新增: shift
38新增:done
39新增:case "$KEY_MODE" in
40新增: eof) printf partial > "$target"; exit 56;;
41新增: empty) : > "$target";;
42新增: invalid) printf '<html>bad gateway</html>' > "$target";;
43新增: success) printf '%s\n' '-----BEGIN PGP PUBLIC KEY BLOCK-----' new '-----END PGP PUBLIC KEY BLOCK-----' > "$target";;
44新增:esac
45新增:`,
46新增: // Exercise actual local filesystem operations without root.
47新增: "sudo": `#!/bin/sh
48新增:if [ "$1" = install ]; then
49新增: shift
50新增: while [ "$#" -gt 2 ]; do shift; done
51新增: cp "$1" "$2"
52新增:else
53新增: exec "$@"
54新增:fi
55新增:`,
56新增: }
57新增: for name, body := range commands {
58新增: if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0755); err != nil {
59新增: t.Fatal(err)
60新增: }
61新增: }
62新增: cmd := exec.Command("bash", "-c", setupFunction(t, "install_repository_key", ")")+`install_repository_key https://example.invalid/key "$KEY_TARGET"`)
63新增: cmd.Env = append(os.Environ(), "HOME="+dir, "PATH="+dir+":"+os.Getenv("PATH"), "KEY_MODE="+mode, "KEY_TARGET="+key)
64新增: out, err := cmd.CombinedOutput()
65新增: data, readErr := os.ReadFile(key)
66新增: if readErr != nil {
67新增: t.Fatal(readErr)
68新增: }
69新增: if mode == "success" {
70新增: if err != nil || !strings.Contains(string(data), "\nnew\n") {
71新增: t.Fatalf("%v %s %q", err, out, data)
72新增: }
73新增: } else if err == nil || string(data) != "trusted" {
74新增: t.Fatalf("failed download replaced key: %v %q", err, data)
75新增: }
76新增: left, _ := filepath.Glob(key + ".*")
77新增: if len(left) != 0 {
78新增: t.Fatal("staging key leaked", left)
79新增: }
80新增: })
81新增: }
82新增:}
83新增:
84新增:func TestAPTFailureRecordsOOMWithoutChangingExitCode(t *testing.T) {
85新增: dir := t.TempDir()
86新增: commands := map[string]string{
87新增: "sudo": `#!/bin/sh
88新增:if [ "$1" = env ]; then echo apt-failed; exit 137; fi
89新增:if [ "$1" = timeout ]; then echo 'Out of memory: Killed process 2926 (apt-get)'; exit 0; fi
90新增:exit 99
91新增:`,
92新增: "awk": "#!/bin/sh\necho 3\n",
93新增: "ps": "#!/bin/sh\necho 'PID RSS COMMAND'\n",
94新增: }
95新增: for name, body := range commands {
96新增: if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0755); err != nil {
97新增: t.Fatal(err)
98新增: }
99新增: }
100新增: cmd := exec.Command("bash", "-c", "set -euo pipefail\n"+setupFunction(t, "apt_get", "}")+"apt_get install package")
101新增: cmd.Env = append(os.Environ(), "HOME="+dir, "PATH="+dir+":"+os.Getenv("PATH"), "CLAUDE_CAGE=1")
102新增: out, err := cmd.CombinedOutput()
103新增: if err == nil || cmd.ProcessState.ExitCode() != 137 || !strings.Contains(string(out), "oom_kill before=3") || !strings.Contains(string(out), "Killed process") {
104新增: t.Fatalf("lost failure evidence: %v %s", err, out)
105新增: }
106新增:}
修改third_party/lima/pkg/downloader/downloader.go+8 −1看文件
@@ -409,7 +409,13 @@ func fetch(ctx context.Context, localPath, remote string, o options) (*Result, e
409409 if err := os.WriteFile(shadURL, []byte(remote), 0o644); err != nil {
410410 return nil, err
411411 }
412删除: if err := downloadHTTP(ctx, shadData, shadTime, shadType, remote, o.description, o.expectedDigest); err != nil {
412新增: // A cache entry is locked by Download. Only digest-pinned downloads may
413新增: // retain and resume partial bytes across processes and setup retries.
414新增: download := downloadHTTP
415新增: if o.expectedDigest != "" {
416新增: download = downloadHTTPResumable
417新增: }
418新增: if err := download(ctx, shadData, shadTime, shadType, remote, o.description, o.expectedDigest); err != nil {
413419 return nil, err
414420 }
415421 if shadDigest != "" && o.expectedDigest != "" {
@@ -1056,6 +1062,7 @@ func removeStaleTempFilesInDir(dir string) error {
10561062 return lockutil.WithDirLock(dir, func() error {
10571063 patterns := []string{
10581064 filepath.Join(dir, "data.part"),
1065新增: filepath.Join(dir, "data.part.digest"),
10591066 filepath.Join(dir, "data.tmp.*"),
10601067 }
10611068 for _, pattern := range patterns {
新增third_party/lima/pkg/downloader/resume.go+213 −0看文件
@@ -0,0 +1,213 @@
1新增:// SPDX-FileCopyrightText: Copyright The Lima Authors
2新增:// SPDX-License-Identifier: Apache-2.0
3新增:
4新增:package downloader
5新增:
6新增:import (
7新增: "context"
8新增: "errors"
9新增: "fmt"
10新增: "io"
11新增: "net/http"
12新增: "os"
13新增: "strconv"
14新增: "strings"
15新增: "time"
16新增:
17新增: "github.com/lima-vm/lima/v2/pkg/progressbar"
18新增: "github.com/opencontainers/go-digest"
19新增: "github.com/sirupsen/logrus"
20新增:)
21新增:
22新增:// downloadHTTPResumable is called only while holding the cache directory lock
23新增:// and with a pinned digest. A partial response is never published as cache data.
24新增:func downloadHTTPResumable(ctx context.Context, local, modified, contentType, remote, description string, expected digest.Digest) error {
25新增: part := local + ".part"
26新增: identity := part + ".digest"
27新增: previous, err := os.ReadFile(identity)
28新增: if err != nil && !errors.Is(err, os.ErrNotExist) {
29新增: return err
30新增: }
31新增: if string(previous) != expected.String() {
32新增: if err := os.Remove(part); err != nil && !errors.Is(err, os.ErrNotExist) {
33新增: return err
34新增: }
35新增: if err := os.WriteFile(identity, []byte(expected.String()), 0600); err != nil {
36新增: return err
37新增: }
38新增: }
39新增: // Cancellation can arrive after all bytes were received but before rename.
40新增: if validateLocalFileDigest(part, expected) == nil {
41新增: return publishPartial(part, local, identity)
42新增: }
43新增: for attempt := 0; attempt < 4; attempt++ {
44新增: if ctx.Err() != nil {
45新增: return ctx.Err()
46新增: }
47新增: attemptCtx, cancel := context.WithTimeout(ctx, 30*time.Minute)
48新增: var retry bool
49新增: retry, err = resumeHTTPOnce(attemptCtx, local, modified, contentType, remote, description, expected)
50新增: cancel()
51新增: if err == nil {
52新增: return publishPartial(part, local, identity)
53新增: }
54新增: if !retry {
55新增: return err
56新增: }
57新增: if attempt < 3 {
58新增: logrus.Infof("Image download interrupted; retry %d/3 will reuse saved partial data", attempt+1)
59新增: select {
60新增: case <-ctx.Done():
61新增: return ctx.Err()
62新增: case <-time.After(time.Duration(attempt+1) * time.Second):
63新增: }
64新增: }
65新增: }
66新增: return fmt.Errorf("image download interrupted; partial data retained for setup retry: %w", err)
67新增:}
68新增:
69新增:func publishPartial(part, local, identity string) error {
70新增: if err := os.Rename(part, local); err != nil {
71新增: return err
72新增: }
73新增: return os.Remove(identity)
74新增:}
75新增:
76新增:func resumeHTTPOnce(ctx context.Context, local, modified, contentType, remote, description string, expected digest.Digest) (bool, error) {
77新增: part := local + ".part"
78新增: var offset int64
79新增: if st, err := os.Stat(part); err == nil {
80新增: offset = st.Size()
81新增: } else if !errors.Is(err, os.ErrNotExist) {
82新增: return false, err
83新增: }
84新增: ctx, cancel := context.WithCancel(ctx)
85新增: defer cancel()
86新增: // A slow but progressing transfer may run for 30 minutes. A stalled
87新增: // connection is interrupted after one minute so a fresh attempt can resume.
88新增: idle := time.AfterFunc(time.Minute, cancel)
89新增: defer idle.Stop()
90新增: req, err := http.NewRequestWithContext(ctx, http.MethodGet, remote, nil)
91新增: if err != nil {
92新增: return false, err
93新增: }
94新增: req.Header.Set("Accept-Encoding", "identity")
95新增: if offset > 0 {
96新增: req.Header.Set("Range", fmt.Sprintf("bytes=%d-", offset))
97新增: }
98新增: resp, err := http.DefaultClient.Do(req)
99新增: if err != nil {
100新增: return true, err
101新增: }
102新增: defer resp.Body.Close()
103新增: var total int64
104新增: expectedBody := resp.ContentLength
105新增: switch resp.StatusCode {
106新增: case http.StatusOK:
107新增: // Servers may ignore Range. Replace the partial file instead of appending.
108新增: offset, total = 0, resp.ContentLength
109新增: case http.StatusPartialContent:
110新增: start, end, size, ok := parseDownloadRange(resp.Header.Get("Content-Range"))
111新增: if !ok || start != offset || (resp.ContentLength >= 0 && resp.ContentLength != end-start+1) {
112新增: return false, errors.New("invalid image Content-Range; partial data left unchanged")
113新增: }
114新增: total = size
115新增: expectedBody = end - start + 1
116新增: case http.StatusRequestedRangeNotSatisfiable:
117新增: // The digest above already ruled out a completed file. Reset only this
118新增: // incomplete artifact, for a server whose representation has changed.
119新增: if err := os.Remove(part); err != nil && !errors.Is(err, os.ErrNotExist) {
120新增: return false, err
121新增: }
122新增: return true, errors.New("image range rejected; restarting this artifact")
123新增: default:
124新增: return resp.StatusCode == 408 || resp.StatusCode == 429 || resp.StatusCode >= 500, fmt.Errorf("image download returned HTTP %d", resp.StatusCode)
125新增: }
126新增: for name, value := range map[string]string{modified: resp.Header.Get("Last-Modified"), contentType: resp.Header.Get("Content-Type")} {
127新增: if name != "" {
128新增: if err := os.WriteFile(name, []byte(value), 0600); err != nil {
129新增: return false, err
130新增: }
131新增: }
132新增: }
133新增: flags := os.O_CREATE | os.O_WRONLY
134新增: if offset == 0 {
135新增: flags |= os.O_TRUNC
136新增: }
137新增: out, err := os.OpenFile(part, flags, 0600)
138新增: if err != nil {
139新增: return false, err
140新增: }
141新增: defer out.Close()
142新增: if _, err := out.Seek(offset, io.SeekStart); err != nil {
143新增: return false, err
144新增: }
145新增: bar, err := progressbar.New(total)
146新增: if err != nil {
147新增: return false, err
148新增: }
149新增: if HideProgress {
150新增: hideBar(bar)
151新增: }
152新增: bar.SetCurrent(offset)
153新增: if description == "" {
154新增: description = "pinned image"
155新增: }
156新增: logrus.Infof("Downloading %s; continuing at %d bytes", description, offset)
157新增: bar.Start()
158新增: defer bar.Finish()
159新增: reader := &downloadActivityReader{reader: resp.Body, timer: idle}
160新增: n, err := io.Copy(out, bar.NewProxyReader(reader))
161新增: if err != nil {
162新增: return true, err
163新增: }
164新增: if expectedBody >= 0 && n != expectedBody {
165新增: if n > expectedBody {
166新增: _ = out.Close()
167新增: _ = os.Remove(part)
168新增: return false, errors.New("image response exceeded its declared range; partial data discarded")
169新增: }
170新增: return true, io.ErrUnexpectedEOF
171新增: }
172新增: if total >= 0 && n+offset != total {
173新增: return true, io.ErrUnexpectedEOF
174新增: }
175新增: if err := out.Sync(); err != nil {
176新增: return false, err
177新增: }
178新增: if err := out.Close(); err != nil {
179新增: return false, err
180新增: }
181新增: if err := validateLocalFileDigest(part, expected); err != nil {
182新增: _ = os.Remove(part)
183新增: return false, fmt.Errorf("image checksum mismatch; partial data discarded: %w", err)
184新增: }
185新增: return false, nil
186新增:}
187新增:
188新增:type downloadActivityReader struct {
189新增: reader io.Reader
190新增: timer *time.Timer
191新增:}
192新增:
193新增:func (r *downloadActivityReader) Read(p []byte) (int, error) {
194新增: n, err := r.reader.Read(p)
195新增: if n > 0 {
196新增: r.timer.Reset(time.Minute)
197新增: }
198新增: return n, err
199新增:}
200新增:
201新增:func parseDownloadRange(value string) (start, end, total int64, ok bool) {
202新增: span, size, found := strings.Cut(strings.TrimPrefix(value, "bytes "), "/")
203新增: first, last, dash := strings.Cut(span, "-")
204新增: if !strings.HasPrefix(value, "bytes ") || !found || !dash {
205新增: return
206新增: }
207新增: var a, b, c error
208新增: start, a = strconv.ParseInt(first, 10, 64)
209新增: end, b = strconv.ParseInt(last, 10, 64)
210新增: total, c = strconv.ParseInt(size, 10, 64)
211新增: ok = a == nil && b == nil && c == nil && start >= 0 && end >= start && total > end
212新增: return
213新增:}
新增third_party/lima/pkg/downloader/resume_test.go+180 −0看文件
@@ -0,0 +1,180 @@
1新增:// SPDX-FileCopyrightText: Copyright The Lima Authors
2新增:// SPDX-License-Identifier: Apache-2.0
3新增:
4新增:package downloader
5新增:
6新增:import (
7新增: "context"
8新增: "errors"
9新增: "fmt"
10新增: "net/http"
11新增: "net/http/httptest"
12新增: "os"
13新增: "path/filepath"
14新增: "strings"
15新增: "sync/atomic"
16新增: "testing"
17新增: "time"
18新增:
19新增: "github.com/opencontainers/go-digest"
20新增:)
21新增:
22新增:func TestPinnedDownloadResumesInterruptedBody(t *testing.T) {
23新增: data := "0123456789abcdef"
24新增: var calls atomic.Int32
25新增: s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
26新增: if calls.Add(1) == 1 {
27新增: w.Header().Set("Content-Length", "16")
28新增: fmt.Fprint(w, data[:5])
29新增: return
30新增: }
31新增: if r.Header.Get("Range") != "bytes=5-" {
32新增: t.Errorf("did not resume: %q", r.Header.Get("Range"))
33新增: }
34新增: w.Header().Set("Content-Range", "bytes 5-15/16")
35新增: w.WriteHeader(http.StatusPartialContent)
36新增: fmt.Fprint(w, data[5:])
37新增: }))
38新增: defer s.Close()
39新增: cache := t.TempDir()
40新增: r, err := Download(t.Context(), "", s.URL, WithCacheDir(cache), WithExpectedDigest(digest.FromString(data)))
41新增: if err != nil {
42新增: t.Fatal(err)
43新增: }
44新增: got, err := os.ReadFile(r.CachePath)
45新增: if err != nil || string(got) != data || calls.Load() != 2 {
46新增: t.Fatalf("result %q, calls %d, error %v", got, calls.Load(), err)
47新增: }
48新增:}
49新增:
50新增:func TestPinnedDownloadAcrossSetupRetries(t *testing.T) {
51新增: for _, mode := range []string{"range", "ignore-range", "bad-range", "wrong-hash", "changed-digest", "complete", "range-rejected"} {
52新增: t.Run(mode, func(t *testing.T) {
53新增: data := "0123456789abcdef"
54新增: var calls atomic.Int32
55新增: s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
56新增: calls.Add(1)
57新增: switch mode {
58新增: case "complete":
59新增: t.Error("complete partial was downloaded again")
60新增: case "changed-digest", "ignore-range":
61新增: if mode == "changed-digest" && r.Header.Get("Range") != "" {
62新增: t.Error("resumed a different digest")
63新增: }
64新增: fmt.Fprint(w, data)
65新增: case "range-rejected":
66新增: if calls.Load() == 1 {
67新增: w.WriteHeader(416)
68新增: } else {
69新增: if r.Header.Get("Range") != "" {
70新增: t.Error("rejected range was reused")
71新增: }
72新增: fmt.Fprint(w, data)
73新增: }
74新增: default:
75新增: if r.Header.Get("Range") != "bytes=5-" {
76新增: t.Error("partial not reused")
77新增: }
78新增: span := "bytes 5-15/16"
79新增: if mode == "bad-range" {
80新增: span = "bytes 4-14/16"
81新增: }
82新增: w.Header().Set("Content-Range", span)
83新增: w.WriteHeader(206)
84新增: if mode == "wrong-hash" {
85新增: fmt.Fprint(w, "xxxxxxxxxxx")
86新增: } else {
87新增: fmt.Fprint(w, data[5:])
88新增: }
89新增: }
90新增: }))
91新增: defer s.Close()
92新增: cache := t.TempDir()
93新增: dir := cacheDirectoryPath(cache, s.URL)
94新增: if err := os.MkdirAll(dir, 0700); err != nil {
95新增: t.Fatal(err)
96新增: }
97新增: part := filepath.Join(dir, "data.part")
98新增: body, expected := data[:5], digest.FromString(data)
99新增: identity := expected.String()
100新增: if mode == "changed-digest" {
101新增: identity = digest.FromString("old").String()
102新增: }
103新增: if mode == "complete" {
104新增: body = data
105新增: }
106新增: if err := os.WriteFile(part, []byte(body), 0600); err != nil {
107新增: t.Fatal(err)
108新增: }
109新增: if err := os.WriteFile(part+".digest", []byte(identity), 0600); err != nil {
110新增: t.Fatal(err)
111新增: }
112新增: r, err := Download(t.Context(), "", s.URL, WithCacheDir(cache), WithExpectedDigest(expected))
113新增: if mode == "bad-range" || mode == "wrong-hash" {
114新增: if err == nil {
115新增: t.Fatal("invalid data accepted")
116新增: }
117新增: if _, err := os.Stat(filepath.Join(dir, "data")); !os.IsNotExist(err) {
118新增: t.Fatal("invalid cache published")
119新增: }
120新增: if mode == "bad-range" {
121新增: got, _ := os.ReadFile(part)
122新增: if string(got) != body {
123新增: t.Fatal("bad range altered partial")
124新增: }
125新增: } else if _, err := os.Stat(part); !os.IsNotExist(err) {
126新增: t.Fatal("corrupt partial retained")
127新增: }
128新增: return
129新增: }
130新增: if err != nil {
131新增: t.Fatal(err)
132新增: }
133新增: got, err := os.ReadFile(r.CachePath)
134新增: if err != nil || string(got) != data {
135新增: t.Fatalf("got %q: %v", got, err)
136新增: }
137新增: })
138新增: }
139新增:}
140新增:
141新增:func TestPinnedDownloadCancellationRetainsPartial(t *testing.T) {
142新增: ctx, cancel := context.WithCancel(context.Background())
143新增: defer cancel()
144新增: s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
145新增: w.Header().Set("Content-Length", "1000")
146新增: fmt.Fprint(w, "partial")
147新增: w.(http.Flusher).Flush()
148新增: <-r.Context().Done()
149新增: }))
150新增: defer s.Close()
151新增: dir := t.TempDir()
152新增: local := filepath.Join(dir, "data")
153新增: done := make(chan error, 1)
154新增: go func() {
155新增: done <- downloadHTTPResumable(ctx, local, "", "", s.URL, "test", digest.FromString(strings.Repeat("x", 1000)))
156新增: }()
157新增: // Wait for the client to persist data, not just for the server to send it.
158新增: for i := 0; i < 1000; i++ {
159新增: if st, err := os.Stat(local + ".part"); err == nil && st.Size() > 0 {
160新增: break
161新增: }
162新增: select {
163新增: case err := <-done:
164新增: t.Fatalf("ended early: %v", err)
165新增: default:
166新增: }
167新增: time.Sleep(time.Millisecond)
168新增: }
169新增: cancel()
170新增: if err := <-done; !errors.Is(err, context.Canceled) {
171新增: t.Fatalf("cancel: %v", err)
172新增: }
173新增: got, err := os.ReadFile(local + ".part")
174新增: if err != nil || string(got) != "partial" {
175新增: t.Fatalf("partial lost: %q %v", got, err)
176新增: }
177新增: if _, err := os.Stat(local); !os.IsNotExist(err) {
178新增: t.Fatal("cancelled data published")
179新增: }
180新增:}
修改ui/package-lock.json+2 −2看文件
@@ -1,12 +1,12 @@
11{
22 "name": "cage-workbench",
3删除: "version": "0.1.5-alpha.1",
3新增: "version": "0.1.5-alpha.2",
44 "lockfileVersion": 3,
55 "requires": true,
66 "packages": {
77 "": {
88 "name": "cage-workbench",
9删除: "version": "0.1.5-alpha.1",
9新增: "version": "0.1.5-alpha.2",
1010 "dependencies": {
1111 "@xterm/addon-fit": "0.11.0",
1212 "@xterm/xterm": "6.0.0",
修改ui/package.json+1 −1看文件
@@ -1,7 +1,7 @@
11{
22 "name": "cage-workbench",
33 "private": true,
4删除: "version": "0.1.5-alpha.1",
4新增: "version": "0.1.5-alpha.2",
55 "type": "module",
66 "scripts": {
77 "prepare-vnc": "node scripts/prepare-vnc.mjs",
新增ui/scripts/proxy-chain-smoke.mjs+136 −0看文件
@@ -0,0 +1,136 @@
1新增:// Real authenticated workbench, bundled Mihomo and local HTTP CONNECT servers.
2新增:// Uses a new private profile. Never touches the user's Cage, VM or subscriptions.
3新增:import assert from 'node:assert/strict';
4新增:import fs from 'node:fs/promises';
5新增:import http from 'node:http';
6新增:import net from 'node:net';
7新增:import path from 'node:path';
8新增:import { spawn, execFile } from 'node:child_process';
9新增:import { promisify } from 'node:util';
10新增:import { createRequire } from 'node:module';
11新增:const require=createRequire(import.meta.url);
12新增:const {chromium}=require(process.env.CAGE_PLAYWRIGHT_MODULE || 'playwright');
13新增:const run=promisify(execFile);
14新增:const root=path.resolve(import.meta.dirname,'../..');
15新增:const executable=process.env.CAGE_CHAIN_QA_EXECUTABLE || path.join(root,'_output/proxy-chain-20261105/bin/cage');
16新增:const output=path.join(root,'docs/test-reports/2026-11-05-proxy-chain');
17新增:await fs.mkdir(output,{recursive:true});
18新增:const profile=await fs.mkdtemp('/private/tmp/cage-chain-qa-');
19新增:const env={...process.env,CLAUDE_CAGE_CONFIG:path.join(profile,'config.json')};
20新增:await run(executable,['init'],{env});
21新增:const sockets=new Set();
22新增:const listen=server=>new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));
23新增:async function upstream(){
24新增: const destinations=[];
25新增: const server=http.createServer();
26新增: server.on('connect',(req,client,head)=>{
27新增: destinations.push(req.url);
28新增: const destination=new URL(`http://${req.url}`);
29新增: const remote=net.connect(Number(destination.port),destination.hostname,()=>{
30新增: client.write('HTTP/1.1 200 Connection Established\r\n\r\n');
31新增: if(head.length)remote.write(head);
32新增: remote.pipe(client);client.pipe(remote);
33新增: });
34新增: for(const socket of [client,remote]){sockets.add(socket);socket.on('close',()=>sockets.delete(socket));socket.on('error',()=>{client.destroy();remote.destroy();});}
35新增: });
36新增: await listen(server);
37新增: return {server,port:server.address().port,destinations};
38新增:}
39新增:const entry=await upstream(),exit=await upstream();
40新增:let targetRequests=0;
41新增:const target=http.createServer((_req,res)=>{targetRequests++;res.end('residential-exit-verified');});
42新增:await listen(target);
43新增:const reserve=net.createServer();await listen(reserve);const port=reserve.address().port;await new Promise(r=>reserve.close(r));
44新增:const log=await fs.open(path.join(profile,'server.log'),'w',0o600);
45新增:const server=spawn(executable,['serve'],{env,stdio:['ignore',log.fd,log.fd]});
46新增:let browser;
47新增:const errors=[];
48新增:try{
49新增: let control;
50新增: for(let i=0;i<100;i++){try{control=JSON.parse(await fs.readFile(path.join(profile,'control.json')));break;}catch{await new Promise(r=>setTimeout(r,100));}}
51新增: assert.ok(control,'private service did not start');
52新增: const origin=`http://localhost:${control.port}`;
53新增: assert.equal((await fetch(origin+'/api/proxy')).status,401);
54新增: const launch=await fetch(origin+'/api/launch',{method:'POST',headers:{Origin:origin,'Content-Type':'application/json'},body:JSON.stringify({token:control.token})}).then(r=>r.json());
55新增: browser=await chromium.launch({headless:true,executablePath:process.env.CAGE_TEST_BROWSER_PATH});
56新增: const page=await browser.newPage({viewport:{width:1280,height:1000}});
57新增: page.on('pageerror',e=>errors.push(e.message));
58新增: await page.goto(launch.url);
59新增: await page.getByLabel('用户名',{exact:true}).fill('Proxy Chain QA');
60新增: await page.getByLabel('设置密码',{exact:true}).fill('isolated-chain-test-password');
61新增: await page.getByLabel('确认密码',{exact:true}).fill('isolated-chain-test-password');
62新增: await page.getByRole('button',{name:'创建本地账户',exact:true}).click();
63新增: const enter=async()=>{
64新增: await page.getByRole('button',{name:/^设置/}).click();
65新增: await page.getByRole('button',{name:'网络与代理',exact:true}).click();
66新增: await page.getByRole('heading',{name:'内置代理',exact:true}).waitFor();
67新增: };
68新增: await enter();
69新增: const idle=()=>page.waitForFunction(()=>!document.querySelector('.proxy-progress'));
70新增: for(const [name,node,upstreamPort] of [['中转来源','本地中转',entry.port],['住宅来源','住宅出口',exit.port]]){
71新增: await page.getByRole('tab',{name:'订阅',exact:true}).click();
72新增: await page.getByRole('button',{name:'添加来源',exact:true}).click();
73新增: await page.getByRole('button',{name:'本地 YAML',exact:true}).click();
74新增: await page.getByLabel('来源名称',{exact:true}).fill(name);
75新增: await page.getByLabel('节点 YAML',{exact:true}).fill(`proxies:\n - {name: ${node}, type: http, server: 127.0.0.1, port: ${upstreamPort}}\n`);
76新增: await page.getByRole('button',{name:'导入并验证',exact:true}).click();await idle();
77新增: await page.getByText(name,{exact:true}).waitFor();
78新增: }
79新增: await page.getByRole('tab',{name:'诊断',exact:true}).click();
80新增: await page.getByLabel('独立代理端口',{exact:true}).fill(String(port));
81新增: await page.getByRole('tab',{name:'节点',exact:true}).click();
82新增: await page.getByRole('button',{name:'链式代理',exact:true}).click();
83新增: const choose=async(label,name)=>{
84新增: await page.getByRole('combobox',{name:label,exact:true}).click();
85新增: await page.getByRole('option',{name,exact:true}).click();
86新增: };
87新增: await choose('最终出口','住宅出口');
88新增: await choose('中转节点','本地中转');
89新增: await page.getByRole('button',{name:'应用代理',exact:true}).click();await idle();
90新增: await page.getByText('当前配置已应用',{exact:true}).waitFor();
91新增: const state=()=>page.evaluate(()=>fetch('/api/proxy').then(r=>r.json()));
92新增: const applied=await state();assert.equal(applied.active,true);assert.equal(applied.running,true);assert.equal(applied.route.length,2);
93新增: const stored=JSON.parse(await fs.readFile(path.join(profile,'proxy/sources.json')));
94新增: const curlConfig=path.join(profile,'curl.conf');
95新增: await fs.writeFile(curlConfig,`proxy = "socks5h://cage:${stored.auth}@127.0.0.1:${stored.port}"\n`,{mode:0o600});
96新增: const through=()=>run('curl',['--config',curlConfig,'--noproxy','','--fail','--silent','--show-error','--max-time','6',`http://127.0.0.1:${target.address().port}/probe`]);
97新增: assert.equal((await through()).stdout,'residential-exit-verified');
98新增: assert.deepEqual(entry.destinations,[`127.0.0.1:${exit.port}`]);
99新增: assert.deepEqual(exit.destinations,[`127.0.0.1:${target.address().port}`]);
100新增: await page.reload();await enter();
101新增: assert.equal((await state()).route.join(','),applied.route.join(','));
102新增: assert.match(await page.getByRole('combobox',{name:'中转节点',exact:true}).innerText(),/本地中转/);
103新增: await page.locator('.settings-content').evaluate(el=>el.scrollTop=0);
104新增: await page.waitForFunction(()=>[...document.querySelectorAll('.proxy-route-hop')].every(el=>getComputedStyle(el).opacity==='1'));
105新增: await page.screenshot({path:path.join(output,'real-chain.png')});
106新增: // Single-node explicitly bypasses the intermediate, without editing its source.
107新增: const entryCount=entry.destinations.length;
108新增: await page.getByRole('button',{name:'单节点',exact:true}).click();
109新增: await page.getByRole('button',{name:'应用代理',exact:true}).click();await idle();
110新增: await page.getByText('当前配置已应用',{exact:true}).waitFor();
111新增: assert.equal((await through()).stdout,'residential-exit-verified');
112新增: assert.equal(entry.destinations.length,entryCount);
113新增: // Re-enable the chain, then break its exit: no direct target request may occur.
114新增: await page.getByRole('button',{name:'链式代理',exact:true}).click();await choose('中转节点','本地中转');
115新增: await page.getByRole('button',{name:'应用代理',exact:true}).click();await idle();
116新增: await page.getByText('当前配置已应用',{exact:true}).waitFor();
117新增: for(const socket of sockets)socket.destroy();
118新增: await new Promise(resolve=>exit.server.close(resolve));
119新增: const beforeFailure=targetRequests;
120新增: await assert.rejects(through());
121新增: assert.equal(targetRequests,beforeFailure,'broken chain fell back to target directly');
122新增: const final=await state();assert.deepEqual(final.route,applied.route);
123新增: assert.deepEqual(errors,[]);
124新增: const result={passed:true,realWorkbench:true,realMihomo:true,crossSourceChain:true,entryReachedExit:entry.destinations.length>0,exitReachedTarget:true,reloadPersistence:true,singleNodeBypassesTransit:true,brokenExitHasNoDirectFallback:true,targetRequests,browserErrors:errors,guestVMTested:false,platform:process.platform};
125新增: await fs.writeFile(path.join(output,'result.json'),JSON.stringify(result,null,2));
126新增: console.log(JSON.stringify(result));
127新增:}catch(e){await fs.writeFile(path.join(output,'failure.txt'),String(e));throw e;}
128新增:finally{
129新增: if(browser)await browser.close();
130新增: await run(executable,['proxy-stop'],{env}).catch(()=>{});
131新增: server.kill('SIGTERM');await log.close();
132新增: for(const socket of sockets)socket.destroy();
133新增: entry.server.closeAllConnections();exit.server.closeAllConnections();target.closeAllConnections();
134新增: entry.server.close();exit.server.close();target.close();
135新增: console.log('Private QA profile retained at '+profile);
136新增:}
新增ui/scripts/proxy-chain-ui-smoke.mjs+135 −0看文件
@@ -0,0 +1,135 @@
1新增:// Runs the actual workbench with isolated API fixtures. Real core forwarding is
2新增:// covered by proxy-chain-smoke.mjs; this script covers user input and recovery.
3新增:import assert from 'node:assert/strict';
4新增:import fs from 'node:fs/promises';
5新增:import path from 'node:path';
6新增:import { createWorkbench, chooseInline } from './workbench-fixture.mjs';
7新增:
8新增:const output = path.resolve(process.env.CAGE_CHAIN_QA_OUTPUT || 'ui/.oil-ui/proxy-chain-20261105/shots');
9新增:await fs.mkdir(output, { recursive: true });
10新增:const f = await createWorkbench();
11新增:const { page, state, browser, errors } = f;
12新增:const saved = {
13新增: sources: [
14新增: { id:'airport', name:'旅行订阅', nodes:[{id:'entry',name:'🇺🇸 USA Los Angeles 02',type:'anytls'}, {id:'extra',name:'Tokyo Transit',type:'trojan'}]},
15新增: { id:'home',name:'住宅代理',nodes:[{id:'exit',name:'LoopsForge · AI 住宅 IP · 节点001',type:'vless'}]},
16新增: ], selected:'entry',route:['entry'],active:true,running:true,core_available:true,port:17896,state_label:'待启动环境',route_error:'',
17新增:};
18新增:let failRoute = false, submissions = [];
19新增:await page.route('**/api/proxy', r=>r.fulfill({json:saved}));
20新增:await page.route('**/api/proxy/route', r=>{
21新增: const body=r.request().postDataJSON();
22新增: submissions.push(body);
23新增: const available=saved.sources.flatMap(s=>s.nodes.map(n=>n.id));
24新增: const valid=body.node_ids.length>0 && body.node_ids.every(id=>available.includes(id)) && new Set(body.node_ids).size===body.node_ids.length;
25新增: const error=failRoute ? '代理核心拒绝该配置;原配置已保留' : !valid ? '代理链节点无效' : '';
26新增: if (!error) { saved.route=[...body.node_ids];saved.selected=body.node_ids.at(-1); }
27新增: state.status.job={id:`route-${submissions.length}`,kind:'proxy',running:false,error,message:error?'':'节点已应用;启动 Cage 环境后完成联网检查'};
28新增: return r.fulfill({json:{id:state.status.job.id}});
29新增:});
30新增:const enter = async()=>{
31新增: await page.getByRole('button',{name:/^设置/}).click();
32新增: await page.getByRole('button',{name:'网络与代理',exact:true}).click();
33新增: await page.getByRole('heading',{name:'内置代理',exact:true}).waitFor();
34新增: await page.getByRole('combobox',{name:'最终出口',exact:true}).waitFor();
35新增:};
36新增:const idle = ()=>page.waitForFunction(()=>!document.querySelector('.proxy-progress'));
37新增:try {
38新增: await page.getByRole('button',{name:'Cage 环境 网络检查',exact:true}).click();
39新增: await page.getByRole('button',{name:'出口规则',exact:true}).click();
40新增: await page.getByRole('heading',{name:'内置代理',exact:true}).waitFor();
41新增: await page.getByRole('region',{name:'IP 变化规则',exact:true}).waitFor();
42新增: await page.getByRole('button',{name:'链式代理',exact:true}).click();
43新增: assert.equal(await page.getByRole('button',{name:'应用代理',exact:true}).isDisabled(),true);
44新增: await chooseInline(page.getByRole('combobox',{name:'最终出口',exact:true}),'exit');
45新增: const exit = page.getByRole('combobox',{name:'最终出口',exact:true});
46新增: const via = page.getByRole('combobox',{name:'中转节点',exact:true});
47新增: const relativeExit = async () => (await exit.boundingBox()).y - (await page.locator(".proxy-route").boundingBox()).y;
48新增: const before=await relativeExit();
49新增: await via.click();
50新增: const after=await relativeExit();
51新增: assert.ok(after-before>80,'dropdown must push the following exit down');
52新增: const list=await page.getByRole('listbox',{name:'中转节点选项'}).boundingBox();
53新增: const container=await page.locator('.proxy-route').boundingBox();
54新增: assert.ok(list.x>=container.x && list.x+list.width<=container.x+container.width,'dropdown escapes its container');
55新增: await page.screenshot({path:path.join(output,'inline-options.png')});
56新增: await via.press('Home'); await via.press('Enter');
57新增: assert.match(await via.innerText(), /Los Angeles/);
58新增: assert.equal(await via.getAttribute('aria-expanded'),'false');
59新增: assert.equal(await via.evaluate(el=>el===document.activeElement),true);
60新增: assert.ok(Math.abs((await relativeExit())-before)<2,'collapsed dropdown did not restore layout');
61新增: assert.equal(submissions.length,0,'editing a chain applied it early');
62新增: await page.getByText('代理修改待应用,请点击「应用代理」',{exact:true}).waitFor();
63新增: await page.getByRole('button',{name:'返回工作台',exact:true}).last().click();
64新增: await page.getByRole('dialog',{name:'放弃尚未保存的修改?',exact:true}).waitFor();
65新增: await page.getByRole('dialog').getByRole('button',{name:'取消',exact:true}).click();
66新增: assert.equal(await page.locator('.proxy-route-hop').count(),2);
67新增: await page.getByRole('button',{name:'通用',exact:true}).click();
68新增: await page.getByRole('dialog',{name:'放弃尚未应用的代理修改?',exact:true}).waitFor();
69新增: await page.getByRole('dialog').getByRole('button',{name:'取消',exact:true}).click();
70新增: assert.equal(await page.locator('.proxy-route-hop').count(),2);
71新增: assert.equal(await page.getByRole('button',{name:'选择节点 🇺🇸 USA Los Angeles 02',exact:true}).isDisabled(),true,'transit can also be selected as exit');
72新增: await page.getByLabel('加密 DNS',{exact:true}).fill('https://dns.google/dns-query');
73新增: await page.getByRole('button',{name:'保存设置',exact:true}).click();
74新增: await page.waitForFunction(()=>document.querySelector('.settings-footer button.primary')?.disabled===true);
75新增: assert.equal(await page.locator('.proxy-route-hop').count(),2,'saving other settings discarded the proxy draft');
76新增: assert.equal(submissions.length,0,'saving other settings implicitly applied the route');
77新增:
78新增: await page.locator('.settings-content').evaluate(el=>el.scrollTop=0);
79新增: await page.screenshot({path:path.join(output,'chain-draft.png')});
80新增: await page.getByRole('button',{name:'应用代理',exact:true}).click(); await idle();
81新增: await page.getByText('当前配置已应用',{exact:true}).waitFor();
82新增: await page.getByRole('button',{name:'重新应用',exact:true}).waitFor();
83新增: assert.deepEqual(saved.route,['entry','exit']);
84新增: assert.deepEqual(submissions[0],{node_ids:['entry','exit'],port:17896});
85新增: await page.reload();await enter();
86新增: assert.match(await page.getByRole('combobox',{name:'中转节点',exact:true}).innerText(),/Los Angeles/);
87新增: assert.match(await page.getByRole('combobox',{name:'最终出口',exact:true}).innerText(),/LoopsForge/);
88新增: await page.getByRole('button',{name:'添加中转',exact:true}).click();
89新增: const extra=page.getByRole('combobox',{name:'中转节点 2',exact:true});
90新增: await extra.focus();await extra.press('ArrowDown');await extra.press('End');await extra.press('Enter');
91新增: assert.match(await extra.innerText(),/Tokyo/);
92新增: failRoute=true;
93新增: await page.getByRole('button',{name:'应用代理',exact:true}).click(); await idle();
94新增: await page.getByRole('alert').filter({hasText:'代理核心拒绝该配置'}).waitFor();
95新增: assert.deepEqual(saved.route,['entry','exit'],'failed route replaced persisted selection');
96新增: assert.match(await extra.innerText(),/Tokyo/,'failed save lost the draft');
97新增: await page.screenshot({path:path.join(output,'failed-apply.png')});
98新增: failRoute=false;
99新增: await page.getByRole('button',{name:'应用代理',exact:true}).click(); await idle();
100新增: await page.getByText('当前配置已应用',{exact:true}).waitFor();
101新增: assert.deepEqual(saved.route,['entry','extra','exit']);
102新增: await page.getByRole('button',{name:'移除中转节点 2',exact:true}).click();
103新增: await page.getByRole('button',{name:'撤销修改',exact:true}).click();
104新增: assert.equal(await page.locator('.proxy-route-hop').count(),3);
105新增: await page.getByRole('button',{name:'单节点',exact:true}).click();
106新增: assert.equal(await page.locator('.proxy-route-hop').count(),1);
107新增: await page.getByRole('button',{name:'应用代理',exact:true}).click(); await idle();
108新增: await page.getByText('当前配置已应用',{exact:true}).waitFor();
109新增: assert.deepEqual(saved.route,['exit']);
110新增: // A changed backend list cannot silently shorten a pending route.
111新增: saved.sources[0].nodes=saved.sources[0].nodes.filter(n=>n.id!=='extra');
112新增: await page.getByRole('button',{name:'链式代理',exact:true}).click();
113新增: await chooseInline(page.getByRole('combobox',{name:'中转节点',exact:true}),'entry');
114新增: await page.getByRole('button',{name:'应用代理',exact:true}).click(); await idle();
115新增: await page.getByText('当前配置已应用',{exact:true}).waitFor();
116新增: await page.locator('.settings-content').evaluate(el=>el.scrollTop=0);
117新增: await page.waitForFunction(()=>[...document.querySelectorAll('.proxy-route-hop')].every(el=>getComputedStyle(el).opacity==='1'));
118新增: await page.screenshot({path:path.join(output,'chain-applied.png')});
119新增: await page.locator('.proxy-route').screenshot({path:path.join(output,'chain-panel.png'),animations:'disabled'});
120新增: await page.setViewportSize({width:760,height:900});
121新增: await page.locator('.settings-content').evaluate(el=>el.scrollTop=0);
122新增: const bounds=await page.locator('.proxy-route').boundingBox();
123新增: assert.ok(bounds.x>=0 && bounds.x+bounds.width<=760,'route panel overflows the narrow viewport');
124新增: await page.waitForFunction(()=>innerHeight===900 && innerWidth===760);
125新增: assert.equal(await page.getByRole('heading',{name:'内置代理',exact:true}).count(),1);
126新增: assert.equal(await page.locator('.settings-page').count(),1);
127新增: await page.evaluate(()=>new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve))));
128新增: await page.screenshot({path:path.join(output,'narrow.png'),animations:'disabled'});
129新增: await page.setViewportSize({width:1280,height:850});
130新增: await page.emulateMedia({colorScheme:'dark',reducedMotion:'reduce'});
131新增: await page.evaluate(()=>new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve))));
132新增: await page.screenshot({path:path.join(output,'dark.png'),animations:'disabled'});
133新增: assert.deepEqual(errors,[]);
134新增: console.log(JSON.stringify({passed:true,submissions:submissions.length,checks:['network-check exit-rules entry','cross-source route draft','inline layout reflow','keyboard selection and focus','explicit atomic apply','reload persistence','failed apply keeps draft','retry','multiple transit nodes','undo','leave and section-change confirmation','saving DNS preserves route draft','single-node mode','narrow viewport'],browserErrors:errors}));
135新增:} finally {await browser.close();}
修改ui/scripts/proxy-smoke.mjs+3 −0看文件
@@ -76,6 +76,7 @@ try {
7676 await page.getByLabel("独立代理端口", { exact: true }).fill(String(port));
7777 await page.getByRole("tab", { name: "节点", exact: true }).click();
7878 await page.getByRole("button", { name: "选择节点 QA A", exact: true }).click();
79新增: await page.getByRole("button", { name: "应用代理", exact: true }).click();
7980 await page.getByText("核心运行中", { exact: false }).waitFor();
8081 await page.waitForFunction(() => !document.querySelector(".proxy-progress"));
8182 await page.getByText("没有未保存的修改", { exact: true }).waitFor();
@@ -93,6 +94,7 @@ try {
9394 await page.getByLabel("搜索节点", { exact: true }).fill("");
9495 await page.screenshot({ path: path.join(output, "nodes.png") });
9596 await page.getByRole("button", { name: "选择节点 QA B", exact: true }).click();
97新增: await page.getByRole("button", { name: "应用代理", exact: true }).click();
9698 await page.waitForFunction(() => !document.querySelector(".proxy-progress"));
9799 p = await state(); assert.notEqual(p.revision, firstRevision);
98100 assert.equal(await through(), "via-B"); assert.ok(b.requests() > 0);
@@ -135,6 +137,7 @@ try {
135137 const imported = (await state()).sources.find((s) => s.name === "Real egress QA");
136138 await page.getByRole("tab", { name: "节点", exact: true }).click();
137139 await page.getByRole("button", { name: `选择节点 ${imported.nodes.at(-1).name}`, exact: true }).click();
140新增: await page.getByRole("button", { name: "应用代理", exact: true }).click();
138141 await page.waitForFunction(() => !document.querySelector(".proxy-progress"));
139142 const stored = JSON.parse(await fs.readFile(path.join(profile, "proxy/sources.json")));
140143 const file=path.join(profile,"curl.conf");await fs.writeFile(file,`proxy = "socks5h://cage:${stored.auth}@127.0.0.1:${stored.port}"\n`,{mode:0o600});
修改ui/src/network-latency.jsx+1 −1看文件
@@ -31,7 +31,7 @@ export function NetworkLatency({ enabled, revision, selected }) {
3131 setSample({
3232 label: `${Math.round(result.delay)} ms`,
3333 detail:
34删除: "当前节点到 www.gstatic.com 的 HTTP 延迟;每 30 秒更新,点击重新检测。节点连通性与环境外网放行分别检查。",
34新增: "当前节点到 www.gstatic.com 的 HTTP 往返延迟(统一延迟口径),通常不含建连开销,不代表网页首开耗时。每 30 秒更新,点击重新检测;环境联网状态单独检查。",
3535 });
3636 } else {
3737 setSample({
修改ui/src/proxy-settings.jsx+324 −14看文件
@@ -13,6 +13,10 @@ import {
1313 Pencil,
1414 LoaderCircle,
1515 Square,
16新增: CircleHelp,
17新增: ArrowRight,
18新增: X,
19新增: Route,
1620} from "lucide-react";
1721import { api } from "./api";
1822import "./proxy.css";
@@ -45,7 +49,7 @@ const emptyForm = {
4549 interval_hours: 24,
4650 host_download: false,
4751};
48删除:export function ProxySettings({ status, onApplied, onConfirm }) {
52新增:export function ProxySettings({ status, onApplied, onConfirm, onDirty }) {
4953 const [proxy, setProxy] = useState(null),
5054 [tab, setTab] = useState("nodes"),
5155 [search, setSearch] = useState(""),
@@ -68,7 +72,9 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
6872 username: "",
6973 password: "",
7074 });
75新增: const [routeDraft, setRouteDraft] = useState(null);
7176 const [hostRefresh, setHostRefresh] = useState(false);
77新增: const [helpOpen, setHelpOpen] = useState(false);
7278 const alive = useRef(true),
7379 loading = useRef(false),
7480 latest = useRef(null),
@@ -165,6 +171,7 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
165171 if (current.error) throw new Error(current.error);
166172 if (alive.current) {
167173 setForm(null);
174新增: if (action === "route" || action === "select") setRouteDraft(null);
168175 setNotice(current.message || "已完成");
169176 setDelays({});
170177 }
@@ -174,7 +181,7 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
174181 if (alive.current) setPending("");
175182 }
176183 };
177删除: const select = async (id) => {
184新增: const applyRoute = async (nodeIDs) => {
178185 if (
179186 !proxy.active &&
180187 status.vm_running &&
@@ -185,7 +192,7 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
185192 }))
186193 )
187194 return;
188删除: mutate("select", { node_id: id, port: Number(port) });
195新增: mutate("route", { node_ids: nodeIDs, port: Number(port) });
189196 };
190197 const measure = async (ids) => {
191198 if (measuring.current) return;
@@ -236,12 +243,29 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
236243 }
237244 mutate(form.id ? "edit" : "import", value);
238245 };
246新增: const savedRoute = proxy?.route?.length
247新增: ? proxy.route
248新增: : proxy?.selected
249新增: ? [proxy.selected]
250新增: : [""];
251新增: const route = routeDraft ?? savedRoute;
252新增: const routeChanged = JSON.stringify(route) !== JSON.stringify(savedRoute);
253新增: useEffect(() => {
254新增: onDirty?.(routeChanged);
255新增: return () => onDirty?.(false);
256新增: }, [onDirty, routeChanged]);
239257 if (!proxy)
240258 return <div className="proxy-loading">{error || "正在读取代理配置…"}</div>;
241259 const allNodes = proxy.sources.flatMap((s) =>
242260 s.nodes.map((n) => ({ ...n, source: s.name, sourceID: s.id })),
243261 );
244262 const selected = allNodes.find((n) => n.id === proxy.selected);
263新增: const routeValid =
264新增: route.every((id) => allNodes.some((n) => n.id === id)) &&
265新增: new Set(route).size === route.length;
266新增: const routeName = (id) => allNodes.find((n) => n.id === id)?.name || "待选择";
267新增: const updateHop = (index, id) =>
268新增: setRouteDraft(route.map((current, i) => (i === index ? id : current)));
245269 const nodes = allNodes.filter(
246270 (n) =>
247271 (!source || n.sourceID === source) &&
@@ -252,13 +276,93 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
252276 return (
253277 <div className="proxy-manager">
254278 <div className="section-title">
255删除: <h3>内置代理</h3>
256删除: <p>导入订阅、选择节点,供 Cage 内所有程序共用。</p>
279新增: <div className="proxy-heading">
280新增: <h3>内置代理</h3>
281新增: <button
282新增: type="button"
283新增: className="icon-button proxy-help-toggle"
284新增: aria-label="代理使用说明"
285新增: title={helpOpen ? "收起代理使用说明" : "查看代理使用说明"}
286新增: aria-expanded={helpOpen}
287新增: aria-controls="proxy-help"
288新增: onClick={() => setHelpOpen((open) => !open)}
289新增: >
290新增: <CircleHelp size={17} aria-hidden="true" />
291新增: </button>
292新增: </div>
293新增: <p>选择最终出口,按需添加中转,供 Cage 内所有程序共用。</p>
257294 </div>
295新增: {helpOpen && (
296新增: <section
297新增: id="proxy-help"
298新增: className="proxy-help"
299新增: aria-labelledby="proxy-help-title"
300新增: >
301新增: <h4 id="proxy-help-title">代理使用说明</h4>
302新增: <p className="proxy-help-intro">
303新增: Cage 自带代理核心,无需另外安装
304新增: Clash。请先准备你已有的代理订阅或节点信息,Cage 不提供代理节点。
305新增: </p>
306新增: <ol className="proxy-help-steps">
307新增: <li>
308新增: <strong>导入你的代理</strong>
309新增: <p>打开「订阅」→「添加来源」,填写来源名称,再选择一种方式:</p>
310新增: <ul>
311新增: <li>
312新增: <strong>订阅链接:</strong>从代理服务商处复制 Clash/Mihomo
313新增: 格式的 HTTPS
314新增: 订阅地址,粘贴后点击「导入并验证」。首次还没有可用节点时,勾选「通过主机网络下载这份订阅」;主机需要能访问该地址。
315新增: </li>
316新增: <li>
317新增: <strong>本地 YAML:</strong>选择配置文件,或粘贴含节点的 YAML
318新增: 配置,再点击「导入并验证」。可从已有代理客户端导出配置。
319新增: </li>
320新增: <li>
321新增: <strong>手动节点:</strong>适用于 HTTP CONNECT 或
322新增: SOCKS5。填写节点名称、服务器地址、端口,以及服务商提供的用户名和密码(如有),再点击「导入并验证」。
323新增: </li>
324新增: </ul>
325新增: </li>
326新增: <li>
327新增: <strong>选择节点并启用</strong>
328新增: <p>
329新增: 导入完成后切到「节点」,选择最终出口,再点击「应用代理」。住宅代理无法从国内连接时,选择「链式代理」,在它前面添加可连接的中转节点;节点可以来自不同订阅。首次启用时若环境正在运行,需要重启;后续切换只重建网络连接。
330新增: </p>
331新增: </li>
332新增: <li>
333新增: <strong>确认可以联网</strong>
334新增: <p>
335新增: 回到工作台启动环境,等待网络检查通过。以工作台的联网状态为准;「测速」只检测节点延迟。Cage
336新增: 内的浏览器、终端和开发工具会共用所选节点,无需分别配置代理。
337新增: </p>
338新增: </li>
339新增: </ol>
340新增: <div className="proxy-help-notes">
341新增: <strong>导入失败或无法联网?</strong>
342新增: <p>
343新增: 确认复制的是订阅地址,而非服务商登录页或管理页。暂不支持单条分享链接、Base64
344新增: 节点列表,以及只引用远程节点列表的配置;请向服务商获取含节点的
345新增: Clash/Mihomo YAML。
346新增: </p>
347新增: <p>
348新增: 订阅下载失败时,可检查主机是否能访问订阅地址,或改用本地
349新增: YAML。节点不可用时,换一个节点并查看「诊断」;更换节点后仍需通过出口
350新增: IP 和地区检查。
351新增: </p>
352新增: </div>
353新增: </section>
354新增: )}
258355 <div className="proxy-summary">
259356 <Server size={22} />
260357 <div>
261删除: <strong>{selected?.name || "尚未配置代理节点"}</strong>
358新增: <strong>
359新增: {selected ? `最终出口 · ${selected.name}` : "尚未配置代理节点"}
360新增: </strong>
361新增: {savedRoute.length > 1 && (
362新增: <span className="proxy-current-route">
363新增: 当前链路:{savedRoute.map(routeName).join(" → ")}
364新增: </span>
365新增: )}
262366 <span>
263367 {proxy.active
264368 ? proxy.running
@@ -306,6 +410,198 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
306410 </div>
307411 {tab === "nodes" && (
308412 <>
413新增: {allNodes.length > 0 && (
414新增: <section
415新增: className="proxy-route"
416新增: aria-labelledby="proxy-route-title"
417新增: >
418新增: <div className="proxy-route-heading">
419新增: <div>
420新增: <h4 id="proxy-route-title">配置连接方式</h4>
421新增: <p>直接使用一个出口,或经中转连接住宅代理。</p>
422新增: </div>
423新增: <div
424新增: className="proxy-route-mode"
425新增: role="group"
426新增: aria-label="连接方式"
427新增: >
428新增: <button
429新增: type="button"
430新增: aria-pressed={route.length === 1}
431新增: disabled={busy}
432新增: onClick={() => setRouteDraft([route.at(-1)])}
433新增: >
434新增: 单节点
435新增: </button>
436新增: <button
437新增: type="button"
438新增: aria-pressed={route.length > 1}
439新增: disabled={busy}
440新增: onClick={() => {
441新增: if (route.length === 1) setRouteDraft(["", route[0]]);
442新增: }}
443新增: >
444新增: 链式代理
445新增: </button>
446新增: </div>
447新增: </div>
448新增: <ol className="proxy-route-hops">
449新增: {route.map((id, index) => {
450新增: const final = index === route.length - 1;
451新增: const label = final
452新增: ? "最终出口"
453新增: : `中转节点${route.length > 2 ? ` ${index + 1}` : ""}`;
454新增: return (
455新增: <li
456新增: key={index}
457新增: className={`proxy-route-hop ${final ? "is-exit" : ""}`}
458新增: >
459新增: <span className="proxy-hop-number" aria-hidden="true">
460新增: {index + 1}
461新增: </span>
462新增: <div className="proxy-hop-control">
463新增: <label htmlFor={`proxy-hop-${index}`}>{label}</label>
464新增: <InlineSelect
465新增: id={`proxy-hop-${index}`}
466新增: aria-label={label}
467新增: value={id}
468新增: disabled={busy}
469新增: onValueChange={(next) => updateHop(index, next)}
470新增: >
471新增: <option value="" disabled>
472新增: 请选择{label}
473新增: </option>
474新增: {Boolean(id) &&
475新增: !allNodes.some((n) => n.id === id) && (
476新增: <option value={id} disabled>
477新增: 节点已被移除,请重新选择
478新增: </option>
479新增: )}
480新增: {proxy.sources.map((src) => (
481新增: <optgroup key={src.id} label={src.name}>
482新增: {src.nodes.map((n) => (
483新增: <option
484新增: key={n.id}
485新增: value={n.id}
486新增: disabled={route.some(
487新增: (hop, i) => i !== index && hop === n.id,
488新增: )}
489新增: >
490新增: {n.name}
491新增: </option>
492新增: ))}
493新增: </optgroup>
494新增: ))}
495新增: </InlineSelect>
496新增: {final && <small>目标网站看到此节点的出口 IP</small>}
497新增: </div>
498新增: {!final && (
499新增: <button
500新增: className="icon-button proxy-hop-remove"
501新增: type="button"
502新增: disabled={busy}
503新增: aria-label={`移除${label}`}
504新增: title={`移除${label}`}
505新增: onClick={() =>
506新增: setRouteDraft(route.filter((_, i) => i !== index))
507新增: }
508新增: >
509新增: <X size={15} />
510新增: </button>
511新增: )}
512新增: </li>
513新增: );
514新增: })}
515新增: </ol>
516新增: {route.length > 1 && route.length < allNodes.length && (
517新增: <button
518新增: type="button"
519新增: className="proxy-route-add"
520新增: disabled={busy || route.length >= allNodes.length}
521新增: onClick={() =>
522新增: setRouteDraft([...route.slice(0, -1), "", route.at(-1)])
523新增: }
524新增: >
525新增: <Plus size={14} />
526新增: 添加中转
527新增: </button>
528新增: )}
529新增: <div className="proxy-route-preview" aria-label="待应用链路">
530新增: <Route size={16} aria-hidden="true" />
531新增: <span>Cage</span>
532新增: {route.map((id, index) => (
533新增: <React.Fragment key={index}>
534新增: <ArrowRight size={13} aria-hidden="true" />
535新增: <strong>{routeName(id)}</strong>
536新增: </React.Fragment>
537新增: ))}
538新增: <ArrowRight size={13} aria-hidden="true" />
539新增: <span>目标网站</span>
540新增: </div>
541新增: <div className="proxy-route-actions">
542新增: <span aria-live="polite">
543新增: {routeChanged
544新增: ? "有未应用的代理修改"
545新增: : proxy.active
546新增: ? "当前配置已应用"
547新增: : "选择完成后应用代理"}
548新增: </span>
549新增: <div>
550新增: {routeDraft !== null && (
551新增: <button
552新增: type="button"
553新增: disabled={busy}
554新增: onClick={() => setRouteDraft(null)}
555新增: >
556新增: 撤销修改
557新增: </button>
558新增: )}
559新增: <button
560新增: type="button"
561新增: className={routeChanged || !proxy.active ? "primary" : ""}
562新增: disabled={busy || !proxy.core_available || !routeValid}
563新增: onClick={() => applyRoute(route)}
564新增: >
565新增: {pending === "route" ? (
566新增: <LoaderCircle size={14} className="spin" />
567新增: ) : !routeChanged && proxy.active ? (
568新增: <RefreshCw size={14} />
569新增: ) : (
570新增: <Check size={14} />
571新增: )}
572新增: {routeChanged || !proxy.active ? "应用代理" : "重新应用"}
573新增: </button>
574新增: </div>
575新增: </div>
576新增: {proxy.route_error && (
577新增: <p role="alert" className="proxy-source-error">
578新增: {proxy.route_error}
579新增: </p>
580新增: )}
581新增: {error && (
582新增: <div role="alert" className="error-message">
583新增: {error}
584新增: </div>
585新增: )}
586新增: </section>
587新增: )}
588新增: {allNodes.length > 0 && (
589新增: <div className="proxy-node-heading">
590新增: <h4>可用节点</h4>
591新增: <button
592新增: type="button"
593新增: disabled={busy}
594新增: onClick={() => {
595新增: setTab("sources");
596新增: setForm({ ...emptyForm });
597新增: setMode("url");
598新增: }}
599新增: >
600新增: <Plus size={14} />
601新增: 添加来源
602新增: </button>
603新增: </div>
604新增: )}
309605 <div className="proxy-toolbar">
310606 <label className="proxy-search">
311607 <Search size={15} />
@@ -330,6 +626,7 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
330626 </InlineSelect>
331627 <button
332628 disabled={busy || !proxy.running || !nodes.length}
629新增: title="检测 HTTP 往返延迟,通常不含建连开销,不代表网页首开耗时"
333630 onClick={() => measure(nodes.map((n) => n.id))}
334631 >
335632 <Activity size={14} />
@@ -356,19 +653,27 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
356653 <div className="proxy-node-list">
357654 {nodes.map((n) => (
358655 <div
359删除: className={`proxy-node ${n.id === proxy.selected && proxy.active ? "selected" : ""}`}
656新增: className={`proxy-node ${n.id === route.at(-1) ? "selected" : ""}`}
360657 key={n.id}
361658 >
362659 <button
363660 className="proxy-node-choice"
364删除: disabled={busy || !proxy.core_available}
365删除: onClick={() => select(n.id)}
661新增: disabled={
662新增: busy ||
663新增: !proxy.core_available ||
664新增: route.slice(0, -1).includes(n.id)
665新增: }
666新增: title={
667新增: route.slice(0, -1).includes(n.id)
668新增: ? "此节点已用作中转"
669新增: : "选为最终出口,点击应用代理后生效"
670新增: }
671新增: onClick={() => updateHop(route.length - 1, n.id)}
672新增: aria-pressed={n.id === route.at(-1)}
366673 aria-label={`选择节点 ${n.name}`}
367674 >
368675 <span className="proxy-radio">
369删除: {n.id === proxy.selected && proxy.active && (
370删除: <Check size={12} />
371删除: )}
676新增: {n.id === route.at(-1) && <Check size={12} />}
372677 </span>
373678 <span>
374679 <strong>{n.name}</strong>
@@ -377,12 +682,17 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
377682 </small>
378683 </span>
379684 </button>
685新增: {savedRoute.includes(n.id) && (
686新增: <span className="proxy-node-role">
687新增: {n.id === proxy.selected ? "当前出口" : "当前中转"}
688新增: </span>
689新增: )}
380690 <span className="proxy-delay">
381691 {delays[n.id] || "未测速"}
382692 </span>
383693 <button
384694 aria-label={`测速 ${n.name}`}
385删除: title="测试此节点延迟"
695新增: title="检测此节点到 www.gstatic.com 的 HTTP 往返延迟,通常不含建连开销,不代表网页首开耗时"
386696 disabled={busy || !proxy.running}
387697 onClick={() => measure([n.id])}
388698 >
@@ -832,7 +1142,7 @@ export function ProxySettings({ status, onApplied, onConfirm }) {
8321142 : status.job?.message || "正在处理…"}
8331143 </p>
8341144 )}
835删除: {error && (
1145新增: {error && !(tab === "nodes" && allNodes.length > 0) && (
8361146 <div role="alert" className="error-message">
8371147 {error}
8381148 </div>
修改ui/src/proxy.css+286 −2看文件
@@ -1,6 +1,69 @@
11.proxy-manager {
22 margin-bottom: 28px;
33}
4新增:.proxy-heading {
5新增: display: flex;
6新增: align-items: center;
7新增: gap: 8px;
8新增:}
9新增:.settings-content .proxy-heading h3 {
10新增: margin: 0;
11新增:}
12新增:.proxy-heading + p {
13新增: margin-top: 10px;
14新增:}
15新增:.proxy-heading .proxy-help-toggle {
16新增: width: 28px;
17新增: height: 28px;
18新增: flex: none;
19新增: color: var(--muted);
20新增:}
21新增:.proxy-help-toggle[aria-expanded="true"] {
22新增: color: var(--strong);
23新增: background: color-mix(in srgb, currentColor 8%, transparent);
24新增:}
25新增:.proxy-help-toggle:focus-visible {
26新增: outline: 2px solid var(--accent);
27新增: outline-offset: 2px;
28新增:}
29新增:.proxy-help {
30新增: margin: 16px 0;
31新增: padding: 18px;
32新增: border: 1px solid var(--line);
33新增: border-radius: 12px;
34新增: font-size: 13px;
35新增: line-height: 1.75;
36新增: overflow-wrap: anywhere;
37新增:}
38新增:.settings-content .proxy-help h4 {
39新增: margin: 0 0 8px;
40新增: font-size: 14px;
41新增:}
42新增:.proxy-help p {
43新增: margin: 6px 0 0;
44新增:}
45新增:.proxy-help-intro,
46新增:.proxy-help-notes {
47新增: color: var(--muted);
48新增:}
49新增:.proxy-help-steps {
50新增: margin: 16px 0;
51新增: padding-left: 22px;
52新增:}
53新增:.proxy-help-steps > li + li {
54新增: margin-top: 14px;
55新增:}
56新增:.proxy-help-steps ul {
57新增: padding-left: 18px;
58新增: margin-top: 8px;
59新增:}
60新增:.proxy-help-steps ul > li + li {
61新增: margin-top: 8px;
62新增:}
63新增:.proxy-help-notes {
64新增: border-top: 1px solid var(--line);
65新增: padding-top: 14px;
66新增:}
467.proxy-summary {
568 display: flex;
669 align-items: center;
@@ -73,7 +136,10 @@
73136.proxy-toolbar .inline-select {
74137 max-width: 150px;
75138}
76删除:.settings-content label.proxy-search {
139新增:.settings-content
140新增: .proxy-manager
141新增: .proxy-toolbar
142新增: label.proxy-search:not(.check-line) {
77143 display: flex;
78144 flex-direction: row;
79145 flex: 1;
@@ -82,7 +148,11 @@
82148 gap: 6px;
83149 margin: 0;
84150}
85删除:.settings-content label.proxy-search input {
151新增:.settings-content
152新增: .proxy-manager
153新增: .proxy-toolbar
154新增: label.proxy-search:not(.check-line)
155新增: input {
86156 margin: 0;
87157}
88158.proxy-node-list {
@@ -249,6 +319,9 @@
249319.proxy-metrics small {
250320 opacity: 0.6;
251321}
322新增:.proxy-metrics + .field-help {
323新增: margin-top: 10px;
324新增:}
252325.proxy-connection {
253326 display: flex;
254327 align-items: center;
@@ -305,3 +378,214 @@
305378 max-width: 120px;
306379 }
307380}
381新增:
382新增:.proxy-route {
383新增: border: 1px solid var(--line);
384新增: border-radius: 12px;
385新增: padding: 18px;
386新增: margin-bottom: 24px;
387新增:}
388新增:.proxy-route-heading,
389新增:.proxy-route-actions,
390新增:.proxy-node-heading {
391新增: display: flex;
392新增: justify-content: space-between;
393新增: align-items: center;
394新增: gap: 12px;
395新增:}
396新增:.settings-content .proxy-route h4,
397新增:.settings-content .proxy-node-heading h4 {
398新增: margin: 0;
399新增: font-size: 14px;
400新增:}
401新增:.proxy-route-heading p {
402新增: margin: 6px 0 0;
403新增: font-size: 13px;
404新增: color: var(--muted);
405新增:}
406新增:.proxy-route-mode {
407新增: display: flex;
408新增: flex-shrink: 0;
409新增: gap: 3px;
410新增: padding: 3px;
411新增: background: color-mix(in srgb, currentColor 5%, transparent);
412新增: border-radius: 8px;
413新增:}
414新增:.proxy-route-mode button {
415新增: border: 0;
416新增: background: transparent;
417新增: padding: 7px 12px;
418新增: color: var(--muted);
419新增: transition:
420新增: background 140ms,
421新增: color 140ms;
422新增:}
423新增:.proxy-route-mode button[aria-pressed="true"] {
424新增: background: var(--paper);
425新增: color: var(--strong);
426新增: box-shadow: 0 1px 3px #00000012;
427新增:}
428新增:.proxy-route-hops {
429新增: list-style: none;
430新增: padding: 0;
431新增: margin: 18px 0 14px;
432新增:}
433新增:.proxy-route-hop {
434新增: display: flex;
435新增: align-items: flex-start;
436新增: gap: 12px;
437新增: position: relative;
438新增: padding-bottom: 16px;
439新增: animation: proxy-hop-in 160ms ease-out;
440新增:}
441新增:.proxy-route-hop:last-child {
442新增: padding-bottom: 0;
443新增:}
444新增:.proxy-route-hop:not(:last-child)::after {
445新增: content: "";
446新增: position: absolute;
447新增: top: 29px;
448新增: bottom: 5px;
449新增: left: 12px;
450新增: width: 1px;
451新增: background: var(--line);
452新增:}
453新增:.proxy-hop-number {
454新增: display: grid;
455新增: place-items: center;
456新增: width: 25px;
457新增: height: 25px;
458新增: margin-top: 2px;
459新增: flex: none;
460新增: border: 1px solid var(--line);
461新增: border-radius: 50%;
462新增: font-size: 12px;
463新增: color: var(--muted);
464新增:}
465新增:.is-exit .proxy-hop-number {
466新增: background: var(--strong);
467新增: border-color: var(--strong);
468新增: color: var(--paper);
469新增:}
470新增:.proxy-hop-control {
471新增: flex: 1;
472新增: min-width: 0;
473新增:}
474新增:.settings-content
475新增: .proxy-manager
476新增: .proxy-hop-control
477新增: label:not(.check-line):not(.choice):not(.toggle-row) {
478新增: margin: 3px 0 7px;
479新增: font-size: 13px;
480新增: font-weight: 600;
481新增:}
482新增:.proxy-hop-control .inline-select {
483新增: display: block;
484新增: width: 100%;
485新增:}
486新增:.proxy-hop-control .inline-select-trigger {
487新增: width: 100%;
488新增: text-align: left;
489新增:}
490新增:.proxy-hop-control small {
491新增: display: block;
492新增: font-size: 12px;
493新增: color: var(--muted);
494新增: margin-top: 7px;
495新增:}
496新增:.proxy-hop-remove {
497新增: flex: none;
498新增: margin-top: 28px;
499新增:}
500新增:.proxy-route-add {
501新增: margin-left: 37px;
502新增: margin-bottom: 16px;
503新增:}
504新增:.proxy-route-preview {
505新增: display: flex;
506新增: align-items: center;
507新增: flex-wrap: wrap;
508新增: gap: 7px;
509新增: border-top: 1px solid var(--line);
510新增: padding-top: 15px;
511新增: font-size: 12px;
512新增: line-height: 1.7;
513新增: color: var(--muted);
514新增: overflow-wrap: anywhere;
515新增:}
516新增:.proxy-route-preview svg {
517新增: flex: none;
518新增:}
519新增:.proxy-route-preview strong {
520新增: color: var(--strong);
521新增: font-weight: 500;
522新增:}
523新增:.proxy-route-actions {
524新增: margin-top: 18px;
525新增:}
526新增:.proxy-route-actions > span {
527新增: color: var(--muted);
528新增: font-size: 12px;
529新增:}
530新增:.proxy-route-actions > div {
531新增: display: flex;
532新增: gap: 8px;
533新增: flex-shrink: 0;
534新增:}
535新增:.proxy-route-actions .primary {
536新增: transition: background 140ms;
537新增:}
538新增:.proxy-node-role {
539新增: color: var(--muted);
540新增: font-size: 11px;
541新增: white-space: nowrap;
542新增:}
543新增:.proxy-summary .proxy-current-route {
544新增: font-size: 12px;
545新增: line-height: 1.6;
546新增: opacity: 1;
547新增: color: var(--muted);
548新增:}
549新增:@keyframes proxy-hop-in {
550新增: from {
551新增: opacity: 0;
552新增: transform: translateY(-4px);
553新增: }
554新增: to {
555新增: opacity: 1;
556新增: transform: translateY(0);
557新增: }
558新增:}
559新增:@media (max-width: 700px) {
560新增: .proxy-route {
561新增: padding: 14px;
562新增: }
563新增: .proxy-route-heading,
564新增: .proxy-route-actions {
565新增: align-items: flex-start;
566新增: flex-direction: column;
567新增: }
568新增: .proxy-route-mode,
569新增: .proxy-route-actions > div {
570新增: width: 100%;
571新增: }
572新增: .proxy-route-mode button,
573新增: .proxy-route-actions > div button {
574新增: flex: 1;
575新增: }
576新增: .proxy-node-role {
577新增: display: none;
578新增: }
579新增: .proxy-route-preview {
580新增: gap: 5px;
581新增: }
582新增:}
583新增:@media (prefers-reduced-motion: reduce) {
584新增: .proxy-route-hop {
585新增: animation: none;
586新增: }
587新增: .proxy-route-mode button,
588新增: .proxy-route-actions .primary {
589新增: transition: none;
590新增: }
591新增:}
修改ui/src/safety.jsx+1 −1看文件
@@ -140,7 +140,7 @@ export function SafetyPanel({
140140 "完成关键检查后,才允许连接外部网站。"}
141141 </p>
142142 </div>
143删除: <button className="text-button" onClick={() => onSettings("exit")}>
143新增: <button className="text-button" onClick={() => onSettings("network")}>
144144 <Settings2 size={15} />
145145 出口规则
146146 </button>
修改ui/src/settings.jsx+18 −15看文件
@@ -9,7 +9,6 @@ import {
99 FolderOpen,
1010 Check,
1111 LoaderCircle,
12删除: ShieldCheck,
1312 RotateCcw,
1413 ArrowLeft,
1514 SlidersHorizontal,
@@ -34,7 +33,6 @@ const sections = [
3433 ["keyboard", "通用", SlidersHorizontal],
3534 ["appearance", "外观", Palette],
3635 ["network", "网络与代理", Globe2],
37删除: ["exit", "IP 变化规则", ShieldCheck],
3836 ["region", "时区与语言", Clock3],
3937 ["project", "环境与恢复", RotateCcw],
4038];
@@ -50,6 +48,7 @@ export function SettingsPanel({
5048 initialSection = "keyboard",
5149}) {
5250 const [accountDirty, setAccountDirty] = useState(false);
51新增: const [proxyDirty, setProxyDirty] = useState(false);
5352 const [draft, setDraft] = useState({ ...current }),
5453 [section, setSection] = useState(initialSection),
5554 [probe, setProbe] = useState(null),
@@ -95,7 +94,7 @@ export function SettingsPanel({
9594 return;
9695 }
9796 if (
98删除: (!changed && !accountDirty) ||
97新增: (!changed && !accountDirty && !proxyDirty) ||
9998 (await onConfirm({
10099 title: "放弃尚未保存的修改?",
101100 body: "当前环境不会改变。关闭后会丢弃这次表单修改。",
@@ -110,7 +109,7 @@ export function SettingsPanel({
110109 if (status.job.error) setError(status.job.error);
111110 else {
112111 onSaved();
113删除: onClose();
112新增: if (!proxyDirty) onClose();
114113 }
115114 }
116115 }, [status.job]);
@@ -214,6 +213,7 @@ export function SettingsPanel({
214213 aria-current={section === id ? "page" : undefined}
215214 onClick={async () => {
216215 if (id !== section && accountDirty && !(await onConfirm({ title: "放弃尚未保存的修改?", body: "已保存的资料和密码保持不变。", confirm: "放弃修改" }))) return;
216新增: if (id !== section && proxyDirty && !(await onConfirm({ title: "放弃尚未应用的代理修改?", body: "当前代理仍按已应用的链路运行。离开会丢弃这次节点选择。", confirm: "放弃修改" }))) return;
217217 setSection(id);
218218 }}
219219 >
@@ -239,6 +239,7 @@ export function SettingsPanel({
239239 {section === "network" && (
240240 <>
241241 <ProxySettings
242新增: onDirty={setProxyDirty}
242243 status={status}
243244 onConfirm={onConfirm}
244245 onApplied={async () => {
@@ -290,18 +291,18 @@ export function SettingsPanel({
290291 <p className="footnote">
291292 代理不可用时,Cage 会停止对外联网。修改表单后需要重新验证。
292293 </p>
294新增: <section className="network-exit-policy" aria-label="IP 变化规则">
295新增: <ExitPolicyFields
296新增: value={draft.exit_policy}
297新增: onChange={(value) => update("exit_policy", value)}
298新增: observation={probe}
299新增: onProbe={check}
300新增: busy={busy}
301新增: probing={probing}
302新增: />
303新增: </section>
293304 </>
294305 )}
295删除: {section === "exit" && (
296删除: <ExitPolicyFields
297删除: value={draft.exit_policy}
298删除: onChange={(value) => update("exit_policy", value)}
299删除: observation={probe}
300删除: onProbe={check}
301删除: busy={busy}
302删除: probing={probing}
303删除: />
304删除: )}
305306 {section === "region" && (
306307 <>
307308 <div className="section-title">
@@ -642,7 +643,9 @@ export function SettingsPanel({
642643 <span className="save-note">
643644 {status.job?.running
644645 ? status.job.message
645删除: : changed
646新增: : proxyDirty
647新增: ? "代理修改待应用,请点击「应用代理」"
648新增: : changed
646649 ? environmentChanged && status.vm_running
647650 ? "网络和系统设置需要重启"
648651 : "有尚未保存的修改"
修改ui/src/style.css+5 −1看文件
@@ -764,6 +764,9 @@ button.large {
764764.section-title {
765765 margin-bottom: 23px;
766766}
767新增:.network-exit-policy {
768新增: margin-top: 28px;
769新增:}
767770.section-title h3 {
768771 font-size: 1.1429rem;
769772 font-weight: 620;
@@ -1067,7 +1070,8 @@ button.large {
10671070 border-radius: 7px;
10681071 padding: 15px;
10691072 margin: 15px 0 0;
1070删除: max-height: 50vh;
1073新增: height: 60dvh;
1074新增: max-height: 640px;
10711075 overflow: auto;
10721076 white-space: pre-wrap;
10731077 overflow-wrap: anywhere;
修改www/package-lock.json+2 −2看文件
@@ -1,12 +1,12 @@
11{
22 "name": "claude-cage-website",
3删除: "version": "0.1.5-alpha.1",
3新增: "version": "0.1.5-alpha.2",
44 "lockfileVersion": 3,
55 "requires": true,
66 "packages": {
77 "": {
88 "name": "claude-cage-website",
9删除: "version": "0.1.5-alpha.1",
9新增: "version": "0.1.5-alpha.2",
1010 "license": "MIT",
1111 "dependencies": {
1212 "@fontsource-variable/inter": "^5.3.0",
修改www/package.json+1 −1看文件
@@ -1,7 +1,7 @@
11{
22 "name": "claude-cage-website",
33 "type": "module",
4删除: "version": "0.1.5-alpha.1",
4新增: "version": "0.1.5-alpha.2",
55 "private": true,
66 "description": "Claude Cage project website and macOS, Windows and Linux downloads",
77 "license": "MIT",