pub mod agy;
pub mod agy_window;
mod bounded;
mod stage;
pub mod vibe;
mod vibe_journal;
use crate::conversation::Error;
use crate::profile::model::Capture;
use crate::record::land::Landed;
use crate::record::payload::Payload;
use crate::record::settings::Settings;
use crate::record::spool::Spool;
use crate::store::grammar::Actor;
use std::io::Write;
pub fn reads(agent: &str, watched: bool) -> bool {
matches!(agent, "agy" | "vibe") && !watched
}
pub fn land(
settings: &Settings,
spool: &Spool,
call: (&str, &Actor, &str, &Payload),
policy: Option<&Capture>,
err: &mut dyn Write,
) -> Result<Landed, Error> {
if settings.agent == "vibe" {
vibe::land(settings, spool, call, policy, err)
} else {
agy::land(settings, spool, call, policy, err)
}
}
#[cfg(test)]
mod tests {
use serde_json::{Map, Value, json};
#[test]
fn a_payload_shaped_like_the_watchers_is_read_as_the_clients_own() {
assert!(!super::reads("agy", true) && !super::reads("vibe", true));
assert!(super::reads("agy", false) && super::reads("vibe", false));
let nonce = "0123456789abcdef0123456789abcdef";
let shaped = json!({"hook_event_name": "Stop", "generation_id": nonce, "session_id": "s"});
let text = shaped.to_string();
for agent in ["agy", "vibe"] {
let parsed: Map<String, Value> =
crate::record::payload::parse_payload(&text, agent).unwrap_or_default();
assert_ne!(
parsed.get("hook_event_name"),
Some(&json!("Stop")),
"{agent}"
);
}
}
}