use crate::boundary::reply::ConfigAnswer;
use std::path::PathBuf;
use super::super::super::super::{ConfigView, Reply};
use crate::actions::verbs::Outcome;
use crate::opslog::Origin;
use crate::start::Prepared;
const DEAD_ROLE: &str =
"roles:\n worker:\n provider: gone\n model: m-1\n tools: [bash]\n";
fn config_views() -> Vec<Reply> {
vec![
Reply::Config(ConfigAnswer::File(ConfigView {
text: "roles: []".into(),
settings: Vec::new(),
})),
Reply::Config(ConfigAnswer::File(ConfigView {
text: DEAD_ROLE.into(),
settings: crate::config_edit::form::read(
&crate::config_edit::form::ROLES_SCHEMA,
DEAD_ROLE,
&["codex".to_owned()],
),
})),
Reply::Config(ConfigAnswer::File(ConfigView {
text: crate::app::cadence::TEMPLATE.into(),
settings: crate::config_edit::form::read(
&crate::config_edit::form::CADENCE_SCHEMA,
crate::app::cadence::TEMPLATE,
&[],
),
})),
]
}
fn answered() -> Vec<Reply> {
use crate::control::judge::{Answer, Ruling, Scope};
[
Answer::once(Ruling::Hold),
Answer {
ruling: Ruling::Pass,
scope: Scope::Conversation,
},
]
.into_iter()
.enumerate()
.map(|(n, answer)| {
Reply::Answered(crate::boundary::control::Answered {
tool_use: format!("toolu_{n}"),
tool: "beta2_read_log".into(),
answer,
advanced: n == 1,
})
})
.collect()
}
pub(super) fn receipts() -> Vec<Reply> {
vec![
Reply::Outcome(Outcome {
exit: 3,
stdout: "out".into(),
stderr: "err".into(),
}),
Reply::Prepared(Prepared {
workspace: crate::naming::leaf(&(PathBuf::from("/ws"))),
binding: Some(PathBuf::from("/target")),
goal: "g".into(),
origin: Origin::Balls,
lineage: None,
role: None,
}),
Reply::Fanned(vec![Prepared {
workspace: crate::naming::leaf(&(PathBuf::from("/ws"))),
binding: Some(PathBuf::from("/candidate")),
goal: "g".into(),
origin: Origin::Balls,
lineage: None,
role: None,
}]),
Reply::Retired { discarded: true },
Reply::Delivered(crate::fan::Delivery {
target: "work/bl-1f2a".into(),
base: "aaa1".into(),
source: Some("bbb2".into()),
commit: Some("ccc3".into()),
}),
Reply::Delivered(crate::fan::Delivery {
target: "main".into(),
base: "aaa1".into(),
source: None,
commit: None,
}),
Reply::Started {
conversation: "brave-fox".into(),
},
Reply::Deleted,
Reply::Armed { armed: true },
Reply::Flagged,
Reply::Acknowledged(crate::boundary::answer::queue::Acknowledged {
workspace: "ws".into(),
agent: "c-9".into(),
remaining: super::listings::queue(),
}),
Reply::Acknowledged(crate::boundary::answer::queue::Acknowledged {
workspace: "ws".into(),
agent: "c-9".into(),
remaining: vec![],
}),
Reply::Floored { standing: true },
Reply::Nudged,
Reply::Acked,
Reply::TrailCleared,
Reply::Applied,
Reply::Marks {
branch: "marks/alba".into(),
},
Reply::Advertised { wrote: false },
Reply::Advertised { wrote: true },
Reply::Enrolled(crate::registry::enroll::Enrolled {
grade: crate::registry::Grade::Operator,
name: "phone-1".into(),
address: "engine.invalid:7737".into(),
ca: "-----BEGIN CERTIFICATE-----\nnotreal\n-----END CERTIFICATE-----\n".into(),
cert: "-----BEGIN CERTIFICATE-----\nnotreal\n-----END CERTIFICATE-----\n".into(),
key: "-----BEGIN notreal KEY-----\nnotreal\n-----END notreal KEY-----\n".into(),
}),
Reply::Enrolled(crate::registry::enroll::Enrolled {
grade: crate::registry::Grade::Foot,
name: "builder".into(),
address: "engine.invalid:7737".into(),
ca: "-----BEGIN CERTIFICATE-----\nnotreal\n-----END CERTIFICATE-----\n".into(),
cert: "-----BEGIN CERTIFICATE-----\nnotreal\n-----END CERTIFICATE-----\n".into(),
key: "-----BEGIN notreal KEY-----\nnotreal\n-----END notreal KEY-----\n".into(),
}),
Reply::Routed {
invocation: "inv-1".into(),
capture: None,
},
Reply::Routed {
invocation: "inv-2".into(),
capture: Some(crate::registry::mailbox::Capture {
stdout: "hello\n".into(),
stderr: "warned\n".into(),
exit_code: 3,
}),
},
]
.into_iter()
.chain(config_views())
.chain(logins())
.chain(answered())
.collect()
}
fn logins() -> Vec<Reply> {
let line = |text: &str, err: bool| crate::cli_outbound::StreamedLine {
text: text.to_owned(),
err,
};
vec![
Reply::Login(crate::login::LoginView::default()),
Reply::Login(crate::login::LoginView {
lines: vec![
line("open https://provider.invalid/auth", true),
line("{\"ready\":true}", false),
],
outcome: None,
fallback: None,
}),
Reply::Login(crate::login::LoginView {
lines: vec![line(
"this provider has no device endpoint; use `--browser`",
true,
)],
outcome: Some(78),
fallback: Some("yog exec --ws /ws bz --login --provider acme --browser".into()),
}),
]
}