Repository navigation
feat(auth): support agy acp --login flow for Antigravity accounts - #10103
Conversation
571fe17 to
77cc817
Compare
统一后台进程与 Windows 隔离策略 — agy_config.rsbackground_command 默认注入 AGY_CLI_DISABLE_AUTO_UPDATE=true,防止 agy 在后台触发自更新子进程。 额度查询防弹窗加固 — subscription_agy.rs提取 build_usage_command 与 wrap_background_command(保留 CREATE_NO_WINDOW + JobObject + KillOnDrop,并应用禁用自更新、中性工作目录和 Windows .exe 隔离)。 模型列表与协议兜底命令加固model_fetch.rs:在 get_agy_models 中应用 isolate_windows_background_exe 与中性工作目录。 sync_protocol.rs:为 Windows 下的 Command::new("hostname") 补充 creation_flags(0x0800_0000)。 ACP 登录探测与生命周期对齐 acp_login.rs:复用 agy_config 的工作目录与 Windows 隔离函数;将 HELP_TIMEOUT 提升至 15s(防止 Windows Defender 冷扫描大型 agy.exe 导致误回退到终端登录);增加基于二进制修改时间和文件大小的 ACP_LOGIN_SUPPORT_CACHE;修正 is_windows_native_exe 重导出为 #[cfg(test)]。 mod.rs:提取 stash_live_before_acp_login,确保 start_login_acp 在开始登录前正确暂存未收集的登录态并在完成时清除。 AgyOAuthSection.tsx 与 8 个语言文件(zh.json、en.json 等):更新 authCenter.group.agyHelp 提示文案。 回归测试补充tests.rs 与 subscription_agy.rs:新增测试覆盖 CREATE_NO_WINDOW + JobObject 包装、supports_acp_login 元数据缓存、ACP 登录前后 stash 状态流转以及额度命令隔离。 |
YUZHEthefool
left a comment
There was a problem hiding this comment.
复核了最新的 d60934f;之前测试初始化的问题已修复,下面三个生命周期问题仍能复现。
三个问题的本地修复及 6 项回归测试已完成,目前尚未推送。验证通过:Antigravity 定向测试 91 passed / 1 ignored,Rust 全量单元测试 5288 passed / 12 ignored、集成测试 236 passed,前端 4800 passed,以及 typecheck、format、renderer build 和 Clippy。
|
感谢 @jimpablo 的贡献!从 #10100 的方案到这个实现都考虑得很周全:全程交给官方 也谢谢 @funkpopo 和 @YUZHEthefool 补上的 Windows 后台加固和登录进程生命周期修复。这个改动会随下一个版本发布。 |
Human Note / 本人说明
按 #10100 的方案保留为 Draft PR:接入官方
agy acp --login在应用内完成打开/复制登录链接与粘贴授权码/回调地址,支持桌面登录面保持原样、旧版agy自动回退到终端登录流程。目前已基于最新main(含 #9999、#10102、#10122、#10124)完成 rebase 与加固,仍保持 Draft 等待维护者确认方向后再决定是否推进。Summary / 概述
Proposes in-app Antigravity sign-in via the official
agy acp --logincommand (mirroringt3code's compliant pattern andcc-switch'sClaudeOfficialSectionpaste box), while preserving desktop sign-in (#10122) and terminal login fallback for olderagybinaries. Kept as Draft until maintainers confirm the approach.agy acp --login子进程完成 OAuth 授权与钥匙串写入;CC Switch 不持有/使用agy的 OAuth client ID/secret,不直接请求 Google,也不伪造 User-Agent。main完成 Rebase 与对齐:LoginSurface::Desktop流程不动,仅在LoginSurface::Terminal(bin)下通过supports_acp_login(&bin)探测成功后分派至start_login_acp(&bin),失败则回退原终端流程。process-wrap10.x 与后台执行):将acp_login.rs与进程清理逻辑升级到process-wrap 10.0.2(ChildWrapper/CommandWrap,直接child.wait()),并在 ACP 登录完成时对齐 Desktopsync_fallback+finish_switch行为。AgyOAuthSection.tsx直接复用main已合入的completedLogin/reauthOtherAdded/reauthOtherUpdated逻辑,不额外改动useManagedAuth.ts或ManagedAccountsGroup.tsx。src-tauri/src/services/agy_account/acp_login.rs):0700私有临时目录放置拦截版open/xdg-openshim,并通过libc::access(..., X_OK)检测noexec挂载;若临时目录不可执行,自动回退为过滤PATH(移除系统open/xdg-open所在系统目录,仅保留二进制本身目录),避免用户关闭「登录时自动打开浏览器」时仍被agy弹窗。.exe设置NoDefaultCurrentDirectoryInExePath=1且PATH="",屏蔽SSH_*与AGY_CLI_FORCE_FILE_TOKEN_STORAGE环境变量。AgyOAuthSection.tsx、auth.ts、8 语种 locale):acpLinkNote);开启AgyPasteBox支持粘贴授权码或完整回调 URL 提交,保留原终端与桌面登录测试。pnpm typecheck、pnpm format:check、pnpm knip、pnpm test:unit tests/components/AgyOAuthSection.test.tsx tests/hooks/useManagedAuth.test.tsx(2 files, 51 passed)cargo fmt --check、cargo clippy --all-targets -- -D warnings、cargo test --lib agy_account(80 passed, 0 failed, 1 ignored)、cargo test --test integration(231 passed, 0 failed)Related Issue / 关联 Issue
Refs #10100
Screenshots / 截图
agy,无法复用「登录时自动打开浏览器」偏好Terminal(bin)路径探测支持agy acp --login时,直接应用内展示复制链接 + 粘贴框(关闭自动开浏览器时不弹终端),旧版自动回退终端,Desktop 登录流程保持不变Checklist / 检查清单
pnpm typecheckpasses / 通过 TypeScript 类型检查pnpm format:checkpasses / 通过代码格式检查cargo clippypasses (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)