use serde_json::{Value, json};
use super::Verb;
use crate::envelope;
pub const ROLES: Verb = Verb {
word: "roles",
params: &["workspace"],
flags: &[],
summary: "what this workspace's roles are set to, and how each is tuned",
detail: "One row per role the workspace's config declares: the provider \
row and model id bound to it, the effort level it asks for, and \
whether it asks for the priority lane. It reads back from the \
same assignment `model`, `effort` and `priority` write, so a \
control opens showing what is in force rather than blank. Under \
follow-the-tip these are the settings every conversation here \
resolves at its next step, not only the next one started. A \
workspace whose config declares no role answers an empty list \
rather than refusing — nothing set is a state a fresh workspace \
is really in.",
};
pub const MODEL: Verb = Verb {
word: "model",
params: &["workspace", "role", "provider", "model"],
flags: &[],
summary: "give a role this model, on the workspace's config lineage",
detail: "One write into `providers.yaml` on the workspace's default \
config lineage, through `litany config`. It reaches the \
conversations already running: each follows its lineage's head at \
every step boundary, so this governs the next step of every \
conversation on the wall and not only the next one started. A \
provider row the engine does not have, and a row whose dialect \
cannot carry a turn, are each refused before anything is written.",
};
pub const EFFORT: &str = "effort";
pub const PRIORITY: &str = "priority";
const LEVEL: &str = "level";
const ON: &str = "on";
const ROLE: &str = "role";
pub fn roles(workspace: String) -> Value {
ROLES.built(vec![workspace], &[])
}
pub fn model(workspace: String, role: String, provider: String, model: String) -> Value {
MODEL.built(vec![workspace, role, provider, model], &[])
}
pub fn effort(workspace: String, role: String, level: Option<String>) -> Value {
json!({
envelope::OP: EFFORT,
envelope::WORKSPACE: workspace,
ROLE: role,
LEVEL: level,
})
}
pub fn priority(workspace: String, role: String, on: bool) -> Value {
json!({
envelope::OP: PRIORITY,
envelope::WORKSPACE: workspace,
ROLE: role,
ON: on,
})
}
pub fn levels() -> Vec<Option<String>> {
vec![
Some("low".to_owned()),
Some("medium".to_owned()),
Some("high".to_owned()),
None,
]
}
pub const OFF: &str = "off";
pub fn word(level: Option<&String>) -> String {
level.map_or_else(|| OFF.to_owned(), Clone::clone)
}
#[cfg(test)]
mod tests;