objectiveai_sdk/agent/
upstream.rs1use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6#[derive(
8 Debug,
9 Clone,
10 Copy,
11 PartialEq,
12 Eq,
13 Hash,
14 Serialize,
15 Deserialize,
16 Default,
17 JsonSchema,
18 arbitrary::Arbitrary,
19)]
20#[serde(rename_all = "snake_case")]
21#[schemars(rename = "agent.Upstream")]
22pub enum Upstream {
23 #[schemars(title = "Unknown")]
25 #[default]
26 Unknown,
27 #[schemars(title = "Openrouter")]
29 Openrouter,
30 #[schemars(title = "ClaudeAgentSdk")]
32 ClaudeAgentSdk,
33 #[schemars(title = "CodexSdk")]
35 CodexSdk,
36 #[schemars(title = "Mock")]
38 Mock,
39}
40
41pub mod validate {
42 use super::Upstream;
43
44 pub fn validate(upstreams: &[Upstream]) -> Result<(), String> {
45 let mut seen = std::collections::HashSet::new();
47 for upstream in upstreams {
48 if !seen.insert(upstream) {
49 return Err(
50 "`upstreams` contains duplicate entries".to_string()
51 );
52 }
53 }
54
55 if seen.contains(&Upstream::Unknown) {
57 return Err("`upstreams` contains unknown upstream".to_string());
58 }
59
60 Ok(())
61 }
62}