swarmctl shares the create-agent, inference and permissions shapes with the controller
This commit is contained in:
parent
249aab6642
commit
0831b85b73
26 changed files with 675 additions and 434 deletions
28
swarm-wire/src/agent_archetype.rs
Normal file
28
swarm-wire/src/agent_archetype.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//! Which archetype an agent was created from.
|
||||
|
||||
/// Which archetype an agent was created from: the value under
|
||||
/// `swarm_queue_client::agent_archetype::BUCKET`/`<agent>`, and the
|
||||
/// `archetype` of `POST /api/agents`. `source` is a key of
|
||||
/// `swarm_queue_client::archetypes::BUCKET` and `name` an archetype in that
|
||||
/// source's record.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ArchetypeRef {
|
||||
pub source: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ArchetypeRef;
|
||||
|
||||
#[test]
|
||||
fn a_ref_round_trips() {
|
||||
let wire = r#"{"source":"hyperhive","name":"reviewer"}"#;
|
||||
let value = ArchetypeRef {
|
||||
source: "hyperhive".to_owned(),
|
||||
name: "reviewer".to_owned(),
|
||||
};
|
||||
assert_eq!(serde_json::to_string(&value).unwrap(), wire);
|
||||
assert_eq!(serde_json::from_str::<ArchetypeRef>(wire).unwrap(), value);
|
||||
}
|
||||
}
|
||||
|
|
@ -92,6 +92,19 @@ pub enum Source {
|
|||
Default,
|
||||
}
|
||||
|
||||
impl Source {
|
||||
/// The name as it is stored and served.
|
||||
#[must_use]
|
||||
pub const fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::Swarm => "swarm",
|
||||
Self::AgentNix => "agent_nix",
|
||||
Self::LocalFile => "local_file",
|
||||
Self::Default => "default",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The model and effort an agent runs on now, and where each comes from.
|
||||
///
|
||||
/// Part of the turn-state header the agent publishes on
|
||||
|
|
@ -184,6 +197,20 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_source_is_stored_as_its_name() {
|
||||
for source in [
|
||||
Source::Swarm,
|
||||
Source::AgentNix,
|
||||
Source::LocalFile,
|
||||
Source::Default,
|
||||
] {
|
||||
assert_eq!(
|
||||
serde_json::to_string(&source).unwrap(),
|
||||
format!("\"{}\"", source.as_str())
|
||||
);
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn an_unknown_effort_is_refused() {
|
||||
for doc in [
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
//! names a contract (the sender, the answerer, the auth-callout responder that
|
||||
//! grants the subject) depends on this one without linking either.
|
||||
|
||||
pub mod agent_archetype;
|
||||
pub mod agent_icon;
|
||||
pub mod agent_inference;
|
||||
pub mod agent_limits;
|
||||
|
|
|
|||
Loading…
Reference in a new issue