huskies: merge 769
This commit is contained in:
@@ -19,6 +19,7 @@ const GATEWAY_TOOLS: &[&str] = &[
|
||||
"gateway_health",
|
||||
"init_project",
|
||||
"aggregate_pipeline_status",
|
||||
"agents.list",
|
||||
];
|
||||
|
||||
/// Gateway tool definitions.
|
||||
@@ -84,6 +85,14 @@ pub(crate) fn gateway_tool_definitions() -> Vec<Value> {
|
||||
"properties": {}
|
||||
}
|
||||
}),
|
||||
json!({
|
||||
"name": "agents.list",
|
||||
"description": "List all alive build agents currently registered with this gateway. Returns an array of agent objects with id, label, address, registered_at, last_seen, and assigned_project fields.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -245,6 +254,7 @@ async fn handle_gateway_tool(
|
||||
"gateway_health" => handle_gateway_health_tool(state, id).await,
|
||||
"init_project" => handle_init_project_tool(params, state, id).await,
|
||||
"aggregate_pipeline_status" => handle_aggregate_pipeline_status_tool(state, id).await,
|
||||
"agents.list" => handle_agents_list_tool(id),
|
||||
_ => JsonRpcResponse::error(id, -32601, format!("Unknown gateway tool: {tool_name}")),
|
||||
}
|
||||
}
|
||||
@@ -426,6 +436,22 @@ async fn handle_aggregate_pipeline_status_tool(
|
||||
)
|
||||
}
|
||||
|
||||
/// Handle the `agents.list` gateway tool — returns all alive build agents from the CRDT.
|
||||
fn handle_agents_list_tool(id: Option<Value>) -> JsonRpcResponse {
|
||||
let agents = gateway::list_agents();
|
||||
let agents_json = serde_json::to_value(&agents).unwrap_or(json!([]));
|
||||
JsonRpcResponse::success(
|
||||
id,
|
||||
json!({
|
||||
"content": [{
|
||||
"type": "text",
|
||||
"text": serde_json::to_string_pretty(&agents).unwrap_or_default()
|
||||
}],
|
||||
"agents": agents_json,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
|
||||
@@ -18,7 +18,7 @@ pub use mcp::{gateway_mcp_get_handler, gateway_mcp_post_handler};
|
||||
pub use rest::{
|
||||
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_bot_config_save_handler, gateway_generate_token_handler, gateway_mode_handler,
|
||||
gateway_remove_project_handler,
|
||||
};
|
||||
pub use websocket::{gateway_crdt_sync_handler, gateway_event_push_handler};
|
||||
|
||||
@@ -33,17 +33,6 @@ pub async fn gateway_generate_token_handler(state: Data<&Arc<GatewayState>>) ->
|
||||
.body(Body::from(serde_json::to_vec(&body).unwrap_or_default()))
|
||||
}
|
||||
|
||||
/// `GET /gateway/agents` — list all alive build agents registered in the CRDT.
|
||||
#[handler]
|
||||
pub async fn gateway_list_agents_handler(_state: Data<&Arc<GatewayState>>) -> Response {
|
||||
let agents = gateway::list_agents();
|
||||
let body = serde_json::to_vec(&agents).unwrap_or_default();
|
||||
Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.header("Content-Type", "application/json")
|
||||
.body(Body::from(body))
|
||||
}
|
||||
|
||||
/// Request body for assigning an agent to a project.
|
||||
#[derive(Deserialize)]
|
||||
struct AssignAgentRequest {
|
||||
|
||||
Reference in New Issue
Block a user