Skip to content
Clone

feat(sagent): expose agent routes through webapi

ZhenYi committed
parent 0079d8d commit 96c6018 Browse files

10 files changed

+25 −4

This change is very large, so some diffs are not shown. Clone the repository to see the full change.

File tree 10
Modified app/apihost/src/main.rs View app/apihost/src/main.rs
@@ -36,6 +36,13 @@
3636 tokio::spawn(chat::worker::run_background_tasks(state.clone()));
3737 tokio::spawn(auth::worker::run_deletion_executor(state.clone()));
3838
39 if cfg.sagent.is_on() {
40 tokio::spawn(
41 sagent::services::service::SagentService::new(state.clone()).run_reconcile_loop(),
42 );
43 info!("sagent reconcile loop started");
44 }
45
3946 // Web Push 消费者:与其它后台任务一起挂在 apihost 上,不为它单开进程。
4047 // 配置非法(密钥缺失或公私钥不成对)时直接报错退出——静默不投递比启动
4148 // 失败更难被发现。
Modified app/apihost/Cargo.toml View app/apihost/Cargo.toml
@@ -9,6 +9,7 @@
99auth = { workspace = true }
1010chat = { workspace = true }
1111push = { workspace = true }
12sagent = { workspace = true }
1213export = { workspace = true }
1314session = { workspace = true }
1415config = { workspace = true }
Modified lib/config/src/sagent.rs View lib/config/src/sagent.rs
@@ -72,7 +72,9 @@
7272 return Err("sagent.admin_key must not be empty when sagent is enabled".to_string());
7373 }
7474 if self.issuer_secret.trim().is_empty() {
75 return Err("sagent.issuer_secret must not be empty when sagent is enabled".to_string());
75 return Err(
76 "sagent.issuer_secret must not be empty when sagent is enabled".to_string(),
77 );
7678 }
7779 if self.issuer.trim().is_empty() || self.audience.trim().is_empty() {
7880 return Err("sagent issuer and audience must not be empty".to_string());
@@ -100,4 +102,4 @@
100102
101103fn is_blank(value: &str) -> bool {
102104 value.trim().is_empty()
103}
No newline at end of file
105}
Modified lib/config/src/scoped.rs View lib/config/src/scoped.rs
@@ -25,6 +25,7 @@
2525use crate::quota::QuotaConfig;
2626use crate::redis::RedisConfig;
2727use crate::s3::S3Config;
28use crate::sagent::SagentConfig;
2829use crate::search::SearchConfig;
2930use crate::session::SessionConfig;
3031use crate::space::SpaceConfig;
@@ -215,6 +216,7 @@
215216 pub ai: AiConfig,
216217 pub livekit: LiveKitConfig,
217218 pub push: PushConfig,
219 pub sagent: SagentConfig,
218220}
219221
220222impl ApihostConfig {
@@ -242,6 +244,7 @@
242244 ai: self.ai,
243245 livekit: self.livekit,
244246 push: self.push,
247 sagent: self.sagent,
245248 ..Default::default()
246249 }
247250 }
@@ -263,7 +266,8 @@
263266 self.apihost.is_valid()?;
264267 self.ai.validate()?;
265268 self.livekit.is_valid()?;
266 self.push.is_valid()
269 self.push.is_valid()?;
270 self.sagent.validate()
267271 }
268272}
269273
Modified lib/webapi/src/lib.rs View lib/webapi/src/lib.rs
@@ -60,6 +60,7 @@
6060 ::search::SearchService::from_parts(state.database.clone(), state.config.search.clone())
6161 .expect("validated search client configuration");
6262 let import = ::import::ImportService::new(state.clone());
63 let sagent = sagent::services::service::SagentService::new(state.clone());
6364 let health_state = state;
6465
6566 let public: Router = Router::new()
@@ -72,7 +73,8 @@
7273 .merge(pulls::routes::router().with_state(pulls))
7374 .merge(crate::search::router().with_state(search.clone()))
7475 .merge(::import::routes::router(import.clone()).with_state(import.clone()))
75 .merge(ci::routes::router().with_state(ci.clone()));
76 .merge(ci::routes::router().with_state(ci.clone()))
77 .merge(sagent::routes::router(sagent.clone()).with_state(sagent));
7678 let internal: Router = Router::new()
7779 .merge(git::routes::internal_router(git.clone()).with_state(git))
7880 .merge(crate::search::internal_router().with_state(search))
Modified lib/webapi/src/openapi.rs View lib/webapi/src/openapi.rs
@@ -114,6 +114,7 @@
114114 m!("search", crate::search::SearchApiDoc::openapi());
115115 m!("import", import::openapi::ImportApiDoc::openapi());
116116 m!("ci", ci::openapi::PipelinesApiDoc::openapi());
117 m!("sagent", sagent::openapi::SagentsApiDoc::openapi());
117118 doc.servers = Some(vec![utoipa::openapi::Server::new("/api/v1")]);
118119 doc.info.description = Some(CONVENTIONS.to_string());
119120 doc.info.license = None;
Modified lib/webapi/Cargo.toml View lib/webapi/Cargo.toml
@@ -8,6 +8,7 @@
88auth = { workspace = true }
99chat = { workspace = true }
1010issues = { workspace = true }
11sagent = { workspace = true }
1112pulls = { workspace = true }
1213space = { workspace = true }
1314user = { workspace = true }
Modified Cargo.lock View Cargo.lock
@@ -310,6 +310,7 @@
310310 "config",
311311 "export",
312312 "push",
313 "sagent",
313314 "session",
314315 "tokio",
315316 "tokio-util",
@@ -10892,6 +10893,7 @@
1089210893 "opentelemetry-otlp",
1089310894 "opentelemetry_sdk",
1089410895 "pulls",
10896 "sagent",
1089510897 "search",
1089610898 "serde",
1089710899 "session",
Modified Cargo.toml View Cargo.toml
@@ -43,6 +43,7 @@
4343import = { path = "lib/import" }
4444webapi = { path = "lib/webapi" }
4545pulls = { path = "lib/pulls" }
46sagent = { path = "lib/sagent" }
4647search = { path = "lib/search" }
4748social = { path = "lib/social" }
4849web = { path = "web" }
Modified openapi.json View openapi.json

Diff too large to display.