huskies: merge 771
This commit is contained in:
@@ -143,6 +143,7 @@ pub async fn gateway_mcp_post_handler(
|
||||
Ok(resp) => to_json_response(resp),
|
||||
Err(e) => to_json_response(JsonRpcResponse::error(rpc.id, -32603, e)),
|
||||
},
|
||||
"pipeline.get" => to_json_response(handle_pipeline_get(&state, rpc.id).await),
|
||||
"tools/call" => {
|
||||
let tool_name = rpc
|
||||
.params
|
||||
@@ -424,3 +425,21 @@ async fn handle_aggregate_pipeline_status_tool(
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
/// Handle the `pipeline.get` read-RPC — returns the same shape as the old
|
||||
/// `GET /api/gateway/pipeline` endpoint: `{ "active": "...", "projects": {...} }`.
|
||||
async fn handle_pipeline_get(state: &GatewayState, id: Option<Value>) -> JsonRpcResponse {
|
||||
let project_urls: BTreeMap<String, String> = state
|
||||
.projects
|
||||
.read()
|
||||
.await
|
||||
.iter()
|
||||
.map(|(n, e)| (n.clone(), e.url.clone()))
|
||||
.collect();
|
||||
|
||||
let results =
|
||||
gateway::io::fetch_all_project_pipeline_statuses(&project_urls, &state.client).await;
|
||||
let active = state.active_project.read().await.clone();
|
||||
|
||||
JsonRpcResponse::success(id, json!({ "active": active, "projects": results }))
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ mod websocket;
|
||||
|
||||
pub use mcp::{gateway_mcp_get_handler, gateway_mcp_post_handler};
|
||||
pub use rest::{
|
||||
gateway_add_project_handler, gateway_all_pipeline_handler, gateway_api_handler,
|
||||
gateway_assign_agent_handler, gateway_bot_config_get_handler, gateway_bot_config_page_handler,
|
||||
gateway_add_project_handler, gateway_api_handler, gateway_assign_agent_handler,
|
||||
gateway_bot_config_get_handler, gateway_bot_config_page_handler,
|
||||
gateway_bot_config_save_handler, gateway_generate_token_handler, gateway_list_agents_handler,
|
||||
gateway_mode_handler, gateway_remove_project_handler, gateway_switch_handler,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! REST HTTP handlers for the gateway: agents, projects, bot configuration, and pipeline.
|
||||
//! REST HTTP handlers for the gateway: agents, projects, and bot configuration.
|
||||
|
||||
use crate::service::gateway::{self, GatewayState};
|
||||
use poem::handler;
|
||||
@@ -8,7 +8,6 @@ use poem::web::{Data, Json};
|
||||
use poem::{Body, Response};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
// ── Agent REST handlers ───────────────────────────────────────────────────────
|
||||
@@ -257,28 +256,6 @@ pub async fn gateway_bot_config_save_handler(
|
||||
}
|
||||
}
|
||||
|
||||
/// `GET /api/gateway/pipeline` — fetch pipeline status from all registered projects.
|
||||
#[handler]
|
||||
pub async fn gateway_all_pipeline_handler(state: Data<&Arc<GatewayState>>) -> Response {
|
||||
let project_urls: BTreeMap<String, String> = state
|
||||
.projects
|
||||
.read()
|
||||
.await
|
||||
.iter()
|
||||
.map(|(n, e)| (n.clone(), e.url.clone()))
|
||||
.collect();
|
||||
|
||||
let results =
|
||||
gateway::io::fetch_all_project_pipeline_statuses(&project_urls, &state.client).await;
|
||||
|
||||
let active = state.active_project.read().await.clone();
|
||||
let body = json!({ "active": active, "projects": results });
|
||||
Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.header("Content-Type", "application/json")
|
||||
.body(Body::from(serde_json::to_vec(&body).unwrap_or_default()))
|
||||
}
|
||||
|
||||
// ── Bot config page ───────────────────────────────────────────────────────────
|
||||
|
||||
/// Self-contained HTML page for bot configuration.
|
||||
|
||||
Reference in New Issue
Block a user