#![allow(dead_code)]
use openquiver_compile::CompiledPlan;
use openquiver_nodes::Registry;
use openquiver_store::{Event, RunId, Store};
pub fn plan(source: &str) -> CompiledPlan {
plan_with(source, Registry::builtin())
}
pub fn plan_with(source: &str, registry: Registry) -> CompiledPlan {
let parsed = openquiver_syntax::parse(source);
assert!(
parsed.diagnostics.is_empty(),
"fixture does not parse: {:#?}",
parsed.diagnostics
);
let file = parsed.file.expect("a file with no diagnostics");
openquiver_compile::compile(&file.document, ®istry)
.unwrap_or_else(|findings| panic!("fixture does not compile: {findings:#?}"))
}
pub async fn printed(store: &Store, run: &RunId) -> Vec<String> {
events(store, run)
.await
.iter()
.filter(|e| e.kind == "print")
.map(|e| e.payload["text"].as_str().expect("print text").to_owned())
.collect()
}
pub async fn events(store: &Store, run: &RunId) -> Vec<Event> {
store.events(run).await.expect("read journal")
}
pub async fn kinds(store: &Store, run: &RunId) -> Vec<String> {
events(store, run)
.await
.into_iter()
.map(|e| e.kind)
.collect()
}
pub const HELLO: &str = r#"
schema 1
graph "hello" {
node start = event.manual
node agent = acp.connect_agent { agent = "mock" }
node sess = acp.new_session
node ask = acp.prompt { text = "Say hello." }
node out = io.print
start.out -> agent.in
agent.out -> sess.in
sess.out -> ask.in
ask.end_turn -> out.in
agent.agent => sess.agent
ask.text => out.value
sess.session => ask.session
}
"#;