Skip to content

Commit 7185ea8

Browse files
committed
cargo fmt
1 parent 4aa1508 commit 7185ea8

19 files changed

Lines changed: 416 additions & 274 deletions

File tree

crates/openfang-api/src/routes.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,7 +3856,10 @@ pub async fn audit_append(
38563856
};
38573857
let outcome = req.outcome.clone().unwrap_or_else(|| "ok".to_string());
38583858

3859-
let hash = state.kernel.audit_log.record(agent_id, action, detail, outcome);
3859+
let hash = state
3860+
.kernel
3861+
.audit_log
3862+
.record(agent_id, action, detail, outcome);
38603863
let seq = state.kernel.audit_log.len().saturating_sub(1) as u64;
38613864

38623865
(
@@ -10063,7 +10066,9 @@ pub async fn clone_agent(
1006310066
Err(e) => {
1006410067
return (
1006510068
StatusCode::INTERNAL_SERVER_ERROR,
10066-
Json(serde_json::json!({"error": format!("Failed to serialize manifest: {e}")})),
10069+
Json(
10070+
serde_json::json!({"error": format!("Failed to serialize manifest: {e}")}),
10071+
),
1006710072
);
1006810073
}
1006910074
};
@@ -10240,7 +10245,12 @@ pub async fn list_agent_files(
1024010245
// Identity files live in the agent's private state directory (see #1097).
1024110246
// Fall back to the legacy workspace location for agents created before the
1024210247
// split so existing on-disk files remain reachable.
10243-
let workspace = match entry.manifest.state_dir.as_ref().or(entry.manifest.workspace.as_ref()) {
10248+
let workspace = match entry
10249+
.manifest
10250+
.state_dir
10251+
.as_ref()
10252+
.or(entry.manifest.workspace.as_ref())
10253+
{
1024410254
Some(ws) => ws.clone(),
1024510255
None => {
1024610256
return (

crates/openfang-api/src/types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ mod tests {
167167
fn skill_install_request_defaults_back_compat() {
168168
// Existing callers send `{"name": "..."}` only. New optional fields
169169
// must default cleanly (issue #1170).
170-
let req: SkillInstallRequest =
171-
serde_json::from_str(r#"{"name":"github-helper"}"#).unwrap();
170+
let req: SkillInstallRequest = serde_json::from_str(r#"{"name":"github-helper"}"#).unwrap();
172171
assert_eq!(req.name, "github-helper");
173172
assert!(!req.require_signed);
174173
assert!(req.allowed_signer_keys.is_empty());

crates/openfang-api/src/ws.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,9 @@ async fn handle_command(
10481048
"command": cmd,
10491049
"message": format!("Hand '{}' deactivated.", instance.hand_id),
10501050
}),
1051-
Err(e) => serde_json::json!({"type": "error", "content": format!("Stop failed: {e}")}),
1051+
Err(e) => {
1052+
serde_json::json!({"type": "error", "content": format!("Stop failed: {e}")})
1053+
}
10521054
}
10531055
} else {
10541056
match state.kernel.stop_agent_run(agent_id) {
@@ -1058,7 +1060,9 @@ async fn handle_command(
10581060
Ok(false) => {
10591061
serde_json::json!({"type": "command_result", "command": cmd, "message": "No active run to cancel."})
10601062
}
1061-
Err(e) => serde_json::json!({"type": "error", "content": format!("Stop failed: {e}")}),
1063+
Err(e) => {
1064+
serde_json::json!({"type": "error", "content": format!("Stop failed: {e}")})
1065+
}
10621066
}
10631067
}
10641068
}
@@ -1812,10 +1816,7 @@ mod tests {
18121816
// Cookie signed with the wrong secret must fail.
18131817
let bad = crate::session_auth::create_session_token("alice", "other-secret", 1);
18141818
let mut headers = axum::http::HeaderMap::new();
1815-
headers.insert(
1816-
"cookie",
1817-
format!("openfang_session={bad}").parse().unwrap(),
1818-
);
1819+
headers.insert("cookie", format!("openfang_session={bad}").parse().unwrap());
18191820
let uri = empty_uri();
18201821
let ctx = WsAuthCtx {
18211822
api_key: "secret",

crates/openfang-api/tests/api_integration_test.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,10 +1660,7 @@ async fn test_clone_agent_happy_path() {
16601660
assert_eq!(manifest["description"], "Cloned for user 1");
16611661
assert_eq!(
16621662
manifest["tags"].as_array().unwrap(),
1663-
&vec![
1664-
serde_json::json!("clone"),
1665-
serde_json::json!("user-1"),
1666-
]
1663+
&vec![serde_json::json!("clone"), serde_json::json!("user-1"),]
16671664
);
16681665
// Inherited from template — the system_prompt should match.
16691666
assert_eq!(
@@ -1678,10 +1675,7 @@ async fn test_clone_agent_happy_path() {
16781675
.await
16791676
.unwrap();
16801677
let agents: Vec<serde_json::Value> = resp.json().await.unwrap();
1681-
let names: Vec<&str> = agents
1682-
.iter()
1683-
.map(|a| a["name"].as_str().unwrap())
1684-
.collect();
1678+
let names: Vec<&str> = agents.iter().map(|a| a["name"].as_str().unwrap()).collect();
16851679
assert!(names.contains(&"test-agent"));
16861680
assert!(names.contains(&"cloned-user-1"));
16871681
}
@@ -1731,10 +1725,7 @@ async fn test_clone_agent_name_collision() {
17311725
"duplicate name must return 409 Conflict"
17321726
);
17331727
let body: serde_json::Value = resp.json().await.unwrap();
1734-
assert!(body["error"]
1735-
.as_str()
1736-
.unwrap()
1737-
.contains("already exists"));
1728+
assert!(body["error"].as_str().unwrap().contains("already exists"));
17381729

17391730
// Cloning into the template's own name must also be rejected.
17401731
let resp = client

crates/openfang-channels/src/matrix.rs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ impl MatrixAdapter {
144144
&& status == reqwest::StatusCode::UNAUTHORIZED
145145
&& is_unknown_token_body(&body_text)
146146
{
147-
match try_refresh_tokens(&self.client, &self.homeserver_url, &self.tokens)
148-
.await
147+
match try_refresh_tokens(&self.client, &self.homeserver_url, &self.tokens).await
149148
{
150149
Ok(()) => {
151150
info!("Matrix: access token refreshed via MSC2918, retrying send");
@@ -717,7 +716,8 @@ mod tests {
717716
#[test]
718717
fn test_is_unknown_token_body() {
719718
// Real matrix.org body for M_UNKNOWN_TOKEN under MAS.
720-
let body = r#"{"errcode":"M_UNKNOWN_TOKEN","error":"Token is not active","soft_logout":true}"#;
719+
let body =
720+
r#"{"errcode":"M_UNKNOWN_TOKEN","error":"Token is not active","soft_logout":true}"#;
721721
assert!(is_unknown_token_body(body));
722722
assert!(!is_hard_logout(body));
723723

@@ -740,19 +740,17 @@ mod tests {
740740
// access and refresh tokens and returns the new pair.
741741
use axum::{routing::post, Json, Router};
742742

743-
async fn refresh_handler(
744-
Json(body): Json<serde_json::Value>,
745-
) -> Json<serde_json::Value> {
746-
let incoming = body
747-
.get("refresh_token")
748-
.and_then(|v| v.as_str())
749-
.unwrap_or("");
750-
assert_eq!(incoming, "old_refresh");
751-
Json(serde_json::json!({
752-
"access_token": "new_access",
753-
"refresh_token": "new_refresh",
754-
"expires_in_ms": 3_600_000u64,
755-
}))
743+
async fn refresh_handler(Json(body): Json<serde_json::Value>) -> Json<serde_json::Value> {
744+
let incoming = body
745+
.get("refresh_token")
746+
.and_then(|v| v.as_str())
747+
.unwrap_or("");
748+
assert_eq!(incoming, "old_refresh");
749+
Json(serde_json::json!({
750+
"access_token": "new_access",
751+
"refresh_token": "new_refresh",
752+
"expires_in_ms": 3_600_000u64,
753+
}))
756754
}
757755

758756
let app = Router::new().route("/_matrix/client/v3/refresh", post(refresh_handler));
@@ -779,10 +777,7 @@ mod tests {
779777
drop(guard);
780778

781779
// Refresh with no refresh token configured must fail cleanly.
782-
let no_refresh: TokenPair = Arc::new(RwLock::new((
783-
Zeroizing::new("a".to_string()),
784-
None,
785-
)));
780+
let no_refresh: TokenPair = Arc::new(RwLock::new((Zeroizing::new("a".to_string()), None)));
786781
let err = try_refresh_tokens(&client, &homeserver, &no_refresh)
787782
.await
788783
.unwrap_err();

crates/openfang-channels/src/router.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,8 @@ mod tests {
722722
assert_eq!(resolved, None);
723723

724724
// Missing channel_id on the wire — no match (the binding is restrictive).
725-
let resolved = router.resolve_with_channel_id(&ChannelType::Discord, "any-user", None, None);
725+
let resolved =
726+
router.resolve_with_channel_id(&ChannelType::Discord, "any-user", None, None);
726727
assert_eq!(resolved, None);
727728
}
728729

crates/openfang-channels/src/slack.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,7 @@ impl ChannelAdapter for SlackAdapter {
329329
// connection during the rotation overlap. Ack on
330330
// both, but only forward to the agent once.
331331
if is_duplicate_envelope(&seen_envelopes, envelope_id) {
332-
debug!(
333-
"Slack: skipping duplicate envelope_id {envelope_id}"
334-
);
332+
debug!("Slack: skipping duplicate envelope_id {envelope_id}");
335333
continue;
336334
}
337335

0 commit comments

Comments
 (0)