feat: auto-sync Antigravity OAuth auth to ephemeral Sprites
- Add server/antigravity-auth.ts to resolve Antigravity OAuth credentials from OpenBao (ANTIGRAVITY_OAUTH_TOKEN / AGY_OAUTH_TOKEN), env, local OS keyring (secret-tool / macOS security), or local token file and stream them over stdin (umask 077, mode 0600, atomic replace) into ~/.gemini/antigravity-cli/antigravity-oauth-token on Sprites - Cache full OpenBao KV secret map in OpenBaoClient and add getOptionalSecretKey for zero-extra-request lookup - Wire sync into SpritesManager.ensureSprite and restart Sprite Paseo daemon worker in ensureSpriteHost when credentials change - Add syncAntigravityAuth setting (default true) with Settings UI toggle - Add Antigravity to PROVIDER_CHOICES and prioritize it in PREFERRED_PROVIDERS
This commit is contained in:
1 parent
0b923ff019
commit
53f3e1b621
8 files changed
+404
-42
No files matched your search
+28
-3
@@ -5,11 +5,11 @@ import type { SpriteAgentSummary, SpriteHostSummary } from "../shared/contracts"
|
||||
import { shellQuote, type SpritesManager } from "./sprites-manager";
|
||||
|
||||
const PREFERRED_PROVIDERS = [
|
||||
"antigravity",
|
||||
"claude",
|
||||
"codex",
|
||||
"opencode",
|
||||
"pi",
|
||||
"antigravity",
|
||||
"omp",
|
||||
"muse",
|
||||
];
|
||||
@@ -236,6 +236,17 @@ async function isSpriteDaemonReachable(sprite: Sprite): Promise<boolean> {
|
||||
return parsed?.connectedDaemon === "reachable";
|
||||
}
|
||||
|
||||
async function restartSpriteDaemonWorker(sprite: Sprite): Promise<void> {
|
||||
await execSpriteBash(sprite, "paseo restart 2>/dev/null || true", { timeoutMs: 25_000 }).catch(
|
||||
() => undefined,
|
||||
);
|
||||
const deadline = Date.now() + 15_000;
|
||||
while (Date.now() < deadline) {
|
||||
if (await isSpriteDaemonReachable(sprite)) return;
|
||||
await new Promise((r) => setTimeout(r, 600));
|
||||
}
|
||||
}
|
||||
|
||||
async function drainServiceStream(
|
||||
stream: Awaited<ReturnType<Sprite["createService"]>>,
|
||||
timeoutMs = 6_000,
|
||||
@@ -269,9 +280,16 @@ async function ensureSpriteDaemonRunning(
|
||||
sprite: Sprite,
|
||||
paseoBin: string,
|
||||
onProgress?: (phase: string) => void,
|
||||
options?: { restartIfRunning?: boolean },
|
||||
): Promise<void> {
|
||||
onProgress?.("Checking Paseo daemon in Sprite…");
|
||||
if (await isSpriteDaemonReachable(sprite)) return;
|
||||
if (await isSpriteDaemonReachable(sprite)) {
|
||||
if (options?.restartIfRunning) {
|
||||
onProgress?.("Refreshing Paseo providers in Sprite…");
|
||||
await restartSpriteDaemonWorker(sprite);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
onProgress?.("Starting Paseo daemon in Sprite…");
|
||||
const lastSlash = paseoBin.lastIndexOf("/");
|
||||
@@ -379,6 +397,11 @@ export async function ensureSpriteHost(options: {
|
||||
const dir = await options.paseo.hosts.list();
|
||||
const existing = dir.hosts.find((h) => h.source.key === sourceKey);
|
||||
if (existing && existing.enabled && existing.status === "online" && existing.serverId) {
|
||||
if (ensured.antigravityAuthChanged) {
|
||||
progress("Refreshing Paseo providers in Sprite…");
|
||||
await restartSpriteDaemonWorker(sprite);
|
||||
await waitForHostOnline(options.paseo, existing.registrationId, 20_000).catch(() => existing);
|
||||
}
|
||||
options.onHostReady?.(sprite.name);
|
||||
return {
|
||||
spriteName: sprite.name,
|
||||
@@ -392,7 +415,9 @@ export async function ensureSpriteHost(options: {
|
||||
const paseoBin = await ensurePaseoCliInSprite(sprite, progress);
|
||||
progress("Reading relay pairing offer from Sprite…");
|
||||
const connection = await readPairingConnectionInSprite(sprite);
|
||||
await ensureSpriteDaemonRunning(sprite, paseoBin, progress);
|
||||
await ensureSpriteDaemonRunning(sprite, paseoBin, progress, {
|
||||
restartIfRunning: ensured.antigravityAuthChanged,
|
||||
});
|
||||
|
||||
progress("Registering Sprite host with Paseo…");
|
||||
let registration: HostSummary;
|
||||
|
||||
Reference in new issue
Block a user