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 {
|
||||
|
||||
Reference in New Issue
Block a user