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 #[schemars(title = "Script")]
41 Script,
42}
43
44pub mod validate {
45 use super::Upstream;
46
47 pub fn validate(upstreams: &[Upstream]) -> Result<(), String> {
48 let mut seen = std::collections::HashSet::new();
50 for upstream in upstreams {
51 if !seen.insert(upstream) {
52 return Err(
53 "`upstreams` contains duplicate entries".to_string()
54 );
55 }
56 }
57
58 if seen.contains(&Upstream::Unknown) {
60 return Err("`upstreams` contains unknown upstream".to_string());
61 }
62
63 Ok(())
64 }
65}