chore: cargo fmt --all — clean up a2a merge's fmt violations
The a2a merge (d0d8e7f) landed with a handful of pre-existing rustfmt
diffs that were failing `cargo fmt --all --check` in CI. Pure whitespace
reformatting from `cargo fmt --all`; no semantic changes. Files touched:
mcp_door.rs, quota.rs, routes/a2a.rs, routes/world.rs, runtime_provision.rs,
chat_repos.rs test, and tools/chat.rs.
This commit is contained in:
@@ -23,8 +23,12 @@ use crate::{ApiError, AppState, Authed};
|
||||
/// The internal daemon base URL + bearer (single daemon today; a per-workspace
|
||||
/// resolver slots in here when multi-daemon lands).
|
||||
fn daemon(_workspace: Uuid) -> Option<(String, String)> {
|
||||
let url = std::env::var("ZEROCLAW_GATEWAY_URL").ok().filter(|u| !u.is_empty())?;
|
||||
let token = std::env::var("ZEROCLAW_TOKEN").ok().filter(|t| !t.is_empty())?;
|
||||
let url = std::env::var("ZEROCLAW_GATEWAY_URL")
|
||||
.ok()
|
||||
.filter(|u| !u.is_empty())?;
|
||||
let token = std::env::var("ZEROCLAW_TOKEN")
|
||||
.ok()
|
||||
.filter(|t| !t.is_empty())?;
|
||||
Some((url, token))
|
||||
}
|
||||
|
||||
@@ -78,7 +82,9 @@ pub async fn settings(
|
||||
// runtime is momentarily unreachable).
|
||||
if body.enabled {
|
||||
if let Some(p) = RuntimeProvisioner::from_env() {
|
||||
p.enable_a2a_server(&base).await.map_err(|_| ApiError::Internal)?;
|
||||
p.enable_a2a_server(&base)
|
||||
.await
|
||||
.map_err(|_| ApiError::Internal)?;
|
||||
for entry in &body.publish {
|
||||
// Scope: each claw must be in the caller's workspace.
|
||||
let agent = cm_db::repo::agents::get(&state.pool, entry.claw_id.into())
|
||||
@@ -93,7 +99,9 @@ pub async fn settings(
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Json(json!({ "enabled": body.enabled, "publicBaseUrl": base })))
|
||||
Ok(Json(
|
||||
json!({ "enabled": body.enabled, "publicBaseUrl": base }),
|
||||
))
|
||||
}
|
||||
|
||||
/// GET /api/a2a/settings — current A2A opt-in state for the workspace.
|
||||
@@ -157,7 +165,16 @@ pub async fn list_tokens(
|
||||
State(state): State<AppState>,
|
||||
Authed(user): Authed,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let rows = sqlx::query_as::<_, (Uuid, Option<String>, bool, Option<String>, Option<time::OffsetDateTime>)>(
|
||||
let rows = sqlx::query_as::<
|
||||
_,
|
||||
(
|
||||
Uuid,
|
||||
Option<String>,
|
||||
bool,
|
||||
Option<String>,
|
||||
Option<time::OffsetDateTime>,
|
||||
),
|
||||
>(
|
||||
"SELECT id, alias, enabled, label, last_used_at FROM a2a_tokens
|
||||
WHERE workspace_id = $1 ORDER BY created_at DESC",
|
||||
)
|
||||
@@ -186,14 +203,13 @@ pub async fn revoke_token(
|
||||
Authed(user): Authed,
|
||||
Path(id): Path<Uuid>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let res = sqlx::query(
|
||||
"UPDATE a2a_tokens SET enabled = false WHERE id = $1 AND workspace_id = $2",
|
||||
)
|
||||
.bind(id)
|
||||
.bind(user.workspace_id.as_uuid())
|
||||
.execute(&state.pool)
|
||||
.await
|
||||
.map_err(|_| ApiError::Internal)?;
|
||||
let res =
|
||||
sqlx::query("UPDATE a2a_tokens SET enabled = false WHERE id = $1 AND workspace_id = $2")
|
||||
.bind(id)
|
||||
.bind(user.workspace_id.as_uuid())
|
||||
.execute(&state.pool)
|
||||
.await
|
||||
.map_err(|_| ApiError::Internal)?;
|
||||
if res.rows_affected() == 0 {
|
||||
return Err(ApiError::NotFound);
|
||||
}
|
||||
@@ -220,7 +236,11 @@ fn rewrite_card(card: &str, daemon_base: &str, edge_base: &str) -> String {
|
||||
card.replace(daemon_base, edge_base.trim_end_matches('/'))
|
||||
}
|
||||
|
||||
async fn proxy_card(state: &AppState, workspace: Uuid, path: &str) -> Result<Json<Value>, StatusCode> {
|
||||
async fn proxy_card(
|
||||
state: &AppState,
|
||||
workspace: Uuid,
|
||||
path: &str,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
if !workspace_enabled(state, workspace).await {
|
||||
return Err(StatusCode::NOT_FOUND);
|
||||
}
|
||||
@@ -253,7 +273,12 @@ pub async fn discovery_card(
|
||||
State(state): State<AppState>,
|
||||
Path((workspace, alias)): Path<(Uuid, String)>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
proxy_card(&state, workspace, &format!("/a2a/{alias}/.well-known/agent-card.json")).await
|
||||
proxy_card(
|
||||
&state,
|
||||
workspace,
|
||||
&format!("/a2a/{alias}/.well-known/agent-card.json"),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// POST /api/a2a/{workspace}/{alias} — authenticated task invocation. Verifies
|
||||
@@ -372,7 +397,14 @@ async fn synthesize_run(
|
||||
let run_id = cm_db::repo::runs::create(&state.pool, session.id)
|
||||
.await
|
||||
.map_err(|_| ())?;
|
||||
let _ = cm_db::repo::run_events::append(&state.pool, run_id, 1, "run_started", json!({ "run_id": run_id })).await;
|
||||
let _ = cm_db::repo::run_events::append(
|
||||
&state.pool,
|
||||
run_id,
|
||||
1,
|
||||
"run_started",
|
||||
json!({ "run_id": run_id }),
|
||||
)
|
||||
.await;
|
||||
let _ = cm_db::repo::run_events::append(
|
||||
&state.pool,
|
||||
run_id,
|
||||
@@ -381,7 +413,15 @@ async fn synthesize_run(
|
||||
json!({ "alias": alias }),
|
||||
)
|
||||
.await;
|
||||
let _ = cm_db::repo::run_events::append(&state.pool, run_id, 3, "run_completed", json!({ "message_id": "" })).await;
|
||||
let _ = cm_db::repo::runs::set_state(&state.pool, run_id, cm_domain::RunState::Completed, None).await;
|
||||
let _ = cm_db::repo::run_events::append(
|
||||
&state.pool,
|
||||
run_id,
|
||||
3,
|
||||
"run_completed",
|
||||
json!({ "message_id": "" }),
|
||||
)
|
||||
.await;
|
||||
let _ = cm_db::repo::runs::set_state(&state.pool, run_id, cm_domain::RunState::Completed, None)
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user