Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions crates/axe-core/src/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,42 @@ impl Forms {
open_prompts_in(&forms, at)
}

/// Closes the open forms other than `keep` that ask for the same
/// runtime login (runtime and provider) as `keep`: a new login attempt
/// replaces the form an earlier one left open, so the owner never holds
/// two. A replaced form prompted by `bot` is closed without a message
/// (the new prompt's keyboard, sent there next, drops its button);
/// elsewhere the server closes its prompt as for any finished form.
/// Returns the replaced forms' ids.
pub fn supersede(&self, keep: &str, bot: &str, now: i64) -> Vec<String> {
let mut forms = self.lock();
let Some(sealed::Target::Runtime {
runtime, provider, ..
}) = forms.get(keep).map(|f| f.spec.target.clone())
else {
return vec![];
};
let mut out = vec![];
for f in forms.values_mut() {
let same = matches!(&f.spec.target, sealed::Target::Runtime {
runtime: r, provider: p, ..
} if *r == runtime && *p == provider);
if f.spec.form == keep || f.state != OPEN || !same {
continue;
}
f.state = EXPIRED;
f.error = Some("replaced by a newer login form".into());
f.finished = Some(now);
f.closed = f.prompt.as_ref().is_none_or(|p| p.bot == bot);
out.push(f.spec.form.clone());
}
if !out.is_empty() {
self.save(&forms);
self.cv.notify_all();
}
out
}

/// Forgets a prompt that could not be sent.
pub fn clear_prompt(&self, form: &str) {
let mut forms = self.lock();
Expand Down Expand Up @@ -846,4 +882,68 @@ mod tests {
assert!(t.contains("\nFor willy · closes in 1h\n"), "{t}");
assert!(!t.contains("Sealed form"), "{t}");
}

#[test]
fn a_new_login_form_replaces_the_open_one_for_that_runtime() {
let forms = Forms::default();
let key = crate::sealed::Key::random();
let login = |runtime: &str, login: &str, provider: Option<&str>| Request {
purpose: "Log in".into(),
target: Target::Runtime {
runtime: runtime.into(),
login: login.into(),
provider: provider.map(String::from),
},
fields: vec![Field::parse("secret:secret:required").unwrap()],
ttl: Some(900),
from: "/runtimes".into(),
};
let add = |r: &Request| {
let (_, s) = key.sign("d", r, 0).unwrap();
forms.add(r, s, 0).unwrap().spec.form
};
let at = |bot: &str| Prompt {
bot: bot.into(),
chat: 7,
};
let first = add(&login("agy-1", "code", None));
forms.prompt_at(&first, &at("aux"));
let elsewhere = add(&login("agy-1", "token", None));
forms.prompt_at(&elsewhere, &at("grp"));
let other_runtime = add(&login("agy-2", "code", None));
let other_provider = add(&login("agy-1", "api_key", Some("deepseek")));
let task = add(&req());
let second = add(&login("agy-1", "code", None));

let mut replaced = forms.supersede(&second, "aux", 5);
replaced.sort();
let mut want = vec![first.clone(), elsewhere.clone()];
want.sort();
assert_eq!(replaced, want);
for f in [&first, &elsewhere] {
let f = forms.get(f, 5).unwrap();
assert_eq!(f.state, EXPIRED);
assert_eq!(f.error.as_deref(), Some("replaced by a newer login form"));
}
for f in [&second, &other_runtime, &other_provider, &task] {
assert_eq!(forms.get(f, 5).unwrap().state, OPEN, "{f}");
}
// The new prompt in aux's chat holds only the new form's button.
let open: Vec<String> = forms
.prompt_at(&second, &at("aux"))
.into_iter()
.map(|f| f.spec.form)
.collect();
assert_eq!(open, std::slice::from_ref(&second));
// The one prompted by another bot is closed there by the server;
// the one in aux's chat needs no message.
let closing: Vec<String> = forms
.take_closing(10)
.into_iter()
.map(|(f, _)| f.spec.form)
.collect();
assert_eq!(closing, [elsewhere]);
// A replaced form takes no reply; nothing to replace twice.
assert!(forms.supersede(&second, "aux", 11).is_empty());
}
}
158 changes: 79 additions & 79 deletions crates/axe-core/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,85 @@ pub const HARNESSES: &[Harness] = &[
home_own: &[],
bot_agent_file: None,
},
// Antigravity CLI (`agy`), verified on 1.5.22 (installed from Google's
// manifest, https://antigravity.google/docs/getting-started?tab=cli; not
// on npm) in a scratch home against a local Gemini API mock (store doc
// harvis/research/20261202-antigravity-harness.md, section 8). Flags:
// https://antigravity.google/docs/cli/reference/ and
// https://antigravity.google/docs/cli/headless/ (`-p`/`--print` takes the
// prompt as its value; `--conversation` resumes; without
// `--dangerously-skip-permissions` a blocked tool is soft-denied and the
// run still exits 0). The CLI picks the conversation id (`init`), and
// keeps everything under `$HOME/.gemini` and `$HOME/.config/antigravity`:
// no variable moves it, so a runtime's login directory is its HOME.
Harness {
name: "antigravity",
display: "Antigravity",
bin: "agy",
name_prefix: "antigravity",
agent: "antigravity",
launch: &[
"agy",
"--output-format",
"stream-json",
"--dangerously-skip-permissions",
"--print={prompt}",
],
resume: &[
"agy",
"--output-format",
"stream-json",
"--dangerously-skip-permissions",
"--conversation",
"{session_id}",
"--print={prompt}",
],
session: "jsonl:conversation_id",
login_env: &[("HOME", "")],
default_login: "~",
// Google by the owner's own Google account (AI Pro / Ultra quota);
// no API key login (owner msg #6704).
providers: Providers::Fixed("google", None),
quota: QuotaSource::None,
meter: Meter::None,
// `agy usage` ("Show account quota usage", `agy help usage` on
// 1.5.22) exits 1 at once when signed out ("Please sign in to view
// account usage").
probe: &["agy", "usage", "--json"],
// `agy acp --login`: "Log in with Google interactively, then exit
// (ACP terminal auth)" (`agy help acp`; https://antigravity.google/docs/cli/acp/).
// It prints an accounts.google.com URL and reads the code, or the
// URL the page lands on, from stdin.
logins: &[("device", None, "Google sign-in")],
login_checks: &[],
stdin_login: &[],
device_login: (&["acp", "--login"], true),
shared: &[],
// The bot's system prompt as a custom agent
// (https://antigravity.google/docs/cli/commands/agents/: "Global:
// ~/.gemini/config/agents/{agent_name}/agent.md", YAML `name` and
// `description`, then the prompt), selected with `--agent`.
bot_args: &["--agent", "{bot_agent}"],
bot_env: &[],
model_args: &["--model", "{model}"],
effort_args: &["--effort", "{effort}"],
model_effort_args: &[],
log: LogFormat::Antigravity,
inbox_hook: false,
config: ConfigFile::None,
package: None,
// `AGY_CLI_DISABLE_AUTO_UPDATE`: https://antigravity.google/docs/cli/troubleshooting/.
// `AGY_CLI_FORCE_FILE_TOKEN_STORAGE` is undocumented (seen in 1.5.21
// and 1.5.22 logs: "Using file-based token storage because
// AGY_CLI_FORCE_FILE_TOKEN_STORAGE is set"): the login stays a file
// in the runtime's home, never the user's shared desktop keyring.
cli_env: &[
("AGY_CLI_DISABLE_AUTO_UPDATE", "true"),
("AGY_CLI_FORCE_FILE_TOKEN_STORAGE", "true"),
],
home_own: &[".gemini", ".config/antigravity"],
bot_agent_file: Some(".gemini/config/agents/{bot_agent}/agent.md"),
},
// OpenCode 2.x (`@opencode/cli`), verified on 2.4.3 in a scratch home
// against a local provider mock (store doc
// harvis/research/20261201-open-harness-runtimes.md, sections 3 and 6):
Expand Down Expand Up @@ -623,85 +702,6 @@ pub const HARNESSES: &[Harness] = &[
home_own: &[],
bot_agent_file: None,
},
// Antigravity CLI (`agy`), verified on 1.5.22 (installed from Google's
// manifest, https://antigravity.google/docs/getting-started?tab=cli; not
// on npm) in a scratch home against a local Gemini API mock (store doc
// harvis/research/20261202-antigravity-harness.md, section 8). Flags:
// https://antigravity.google/docs/cli/reference/ and
// https://antigravity.google/docs/cli/headless/ (`-p`/`--print` takes the
// prompt as its value; `--conversation` resumes; without
// `--dangerously-skip-permissions` a blocked tool is soft-denied and the
// run still exits 0). The CLI picks the conversation id (`init`), and
// keeps everything under `$HOME/.gemini` and `$HOME/.config/antigravity`:
// no variable moves it, so a runtime's login directory is its HOME.
Harness {
name: "antigravity",
display: "Antigravity",
bin: "agy",
name_prefix: "antigravity",
agent: "antigravity",
launch: &[
"agy",
"--output-format",
"stream-json",
"--dangerously-skip-permissions",
"--print={prompt}",
],
resume: &[
"agy",
"--output-format",
"stream-json",
"--dangerously-skip-permissions",
"--conversation",
"{session_id}",
"--print={prompt}",
],
session: "jsonl:conversation_id",
login_env: &[("HOME", "")],
default_login: "~",
// Google by the owner's own Google account (AI Pro / Ultra quota);
// no API key login (owner msg #6704).
providers: Providers::Fixed("google", None),
quota: QuotaSource::None,
meter: Meter::None,
// `agy usage` ("Show account quota usage", `agy help usage` on
// 1.5.22) exits 1 at once when signed out ("Please sign in to view
// account usage").
probe: &["agy", "usage", "--json"],
// `agy acp --login`: "Log in with Google interactively, then exit
// (ACP terminal auth)" (`agy help acp`; https://antigravity.google/docs/cli/acp/).
// It prints an accounts.google.com URL and reads the code, or the
// URL the page lands on, from stdin.
logins: &[("device", None, "Google sign-in")],
login_checks: &[],
stdin_login: &[],
device_login: (&["acp", "--login"], true),
shared: &[],
// The bot's system prompt as a custom agent
// (https://antigravity.google/docs/cli/commands/agents/: "Global:
// ~/.gemini/config/agents/{agent_name}/agent.md", YAML `name` and
// `description`, then the prompt), selected with `--agent`.
bot_args: &["--agent", "{bot_agent}"],
bot_env: &[],
model_args: &["--model", "{model}"],
effort_args: &["--effort", "{effort}"],
model_effort_args: &[],
log: LogFormat::Antigravity,
inbox_hook: false,
config: ConfigFile::None,
package: None,
// `AGY_CLI_DISABLE_AUTO_UPDATE`: https://antigravity.google/docs/cli/troubleshooting/.
// `AGY_CLI_FORCE_FILE_TOKEN_STORAGE` is undocumented (seen in 1.5.21
// and 1.5.22 logs: "Using file-based token storage because
// AGY_CLI_FORCE_FILE_TOKEN_STORAGE is set"): the login stays a file
// in the runtime's home, never the user's shared desktop keyring.
cli_env: &[
("AGY_CLI_DISABLE_AUTO_UPDATE", "true"),
("AGY_CLI_FORCE_FILE_TOKEN_STORAGE", "true"),
],
home_own: &[".gemini", ".config/antigravity"],
bot_agent_file: Some(".gemini/config/agents/{bot_agent}/agent.md"),
},
];

impl Harness {
Expand Down
2 changes: 1 addition & 1 deletion crates/axe-core/src/runtime_views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ mod tests {
fn nouns_come_from_the_rows() {
// The empty state and A3 name tools from the harness rows; runtime
// is the noun, never "account".
assert_eq!(tools(), "Claude, Codex, OpenCode, Pi or Antigravity");
assert_eq!(tools(), "Claude, Codex, Antigravity, OpenCode or Pi");
assert_eq!(add_text(), "Add a runtime\nWhich one?");
// Claude takes the Anthropic-shaped provider rows: one step for them.
assert_eq!(other_provider("claude-code"), Some("Other provider…"));
Expand Down
Loading
Loading