Skip to content

Commit d3385f2

Browse files
committed
batch fixes
1 parent 516f163 commit d3385f2

File tree

9 files changed

+295
-54
lines changed

9 files changed

+295
-54
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ members = [
1818
]
1919

2020
[workspace.package]
21-
version = "0.2.9"
21+
version = "0.3.0"
2222
edition = "2021"
2323
license = "Apache-2.0 OR MIT"
2424
repository = "https://github.com/RightNow-AI/openfang"

crates/openfang-api/src/middleware.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ pub async fn auth(
8282
// Public endpoints that don't require auth (dashboard needs these)
8383
let path = request.uri().path();
8484
if path == "/"
85+
|| path == "/logo.png"
86+
|| path == "/favicon.ico"
87+
|| path == "/.well-known/agent.json"
88+
|| path.starts_with("/a2a/")
8589
|| path == "/api/health"
8690
|| path == "/api/health/detail"
8791
|| path == "/api/status"

crates/openfang-api/src/routes.rs

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ const CHANNEL_REGISTRY: &[ChannelMeta] = &[
11231123
ChannelField { key: "bot_token_env", label: "Bot Token", field_type: FieldType::Secret, env_var: Some("DISCORD_BOT_TOKEN"), required: true, placeholder: "MTIz...", advanced: false },
11241124
ChannelField { key: "allowed_guilds", label: "Allowed Guild IDs", field_type: FieldType::List, env_var: None, required: false, placeholder: "123456789, 987654321", advanced: true },
11251125
ChannelField { key: "default_agent", label: "Default Agent", field_type: FieldType::Text, env_var: None, required: false, placeholder: "assistant", advanced: true },
1126-
ChannelField { key: "intents", label: "Intents Bitmask", field_type: FieldType::Number, env_var: None, required: false, placeholder: "33280", advanced: true },
1126+
ChannelField { key: "intents", label: "Intents Bitmask", field_type: FieldType::Number, env_var: None, required: false, placeholder: "37376", advanced: true },
11271127
],
11281128
setup_steps: &["Go to discord.com/developers/applications", "Create a bot and copy the token", "Paste it below"],
11291129
config_template: "[channels.discord]\nbot_token_env = \"DISCORD_BOT_TOKEN\"",
@@ -3022,13 +3022,18 @@ pub async fn clawhub_install(
30223022
)
30233023
}
30243024
Err(e) => {
3025-
let status = if e.to_string().contains("SecurityBlocked") {
3025+
let msg = format!("{e}");
3026+
let status = if msg.contains("SecurityBlocked") {
30263027
StatusCode::FORBIDDEN
3028+
} else if msg.contains("429") || msg.contains("rate limit") {
3029+
StatusCode::TOO_MANY_REQUESTS
3030+
} else if msg.contains("Network error") || msg.contains("returned 4") || msg.contains("returned 5") {
3031+
StatusCode::BAD_GATEWAY
30273032
} else {
30283033
StatusCode::INTERNAL_SERVER_ERROR
30293034
};
3030-
tracing::warn!("ClawHub install failed: {e}");
3031-
(status, Json(serde_json::json!({"error": format!("{e}")})))
3035+
tracing::warn!("ClawHub install failed: {msg}");
3036+
(status, Json(serde_json::json!({"error": msg})))
30323037
}
30333038
}
30343039
}
@@ -6987,6 +6992,29 @@ pub async fn create_schedule(
69876992
}
69886993

69896994
let agent_id_str = req["agent_id"].as_str().unwrap_or("").to_string();
6995+
if agent_id_str.is_empty() {
6996+
return (
6997+
StatusCode::BAD_REQUEST,
6998+
Json(serde_json::json!({"error": "Missing required field: agent_id"})),
6999+
);
7000+
}
7001+
// Validate agent exists (UUID or name lookup)
7002+
let agent_exists = if let Ok(aid) = agent_id_str.parse::<AgentId>() {
7003+
state.kernel.registry.get(aid).is_some()
7004+
} else {
7005+
state
7006+
.kernel
7007+
.registry
7008+
.list()
7009+
.iter()
7010+
.any(|a| a.name == agent_id_str)
7011+
};
7012+
if !agent_exists {
7013+
return (
7014+
StatusCode::NOT_FOUND,
7015+
Json(serde_json::json!({"error": format!("Agent not found: {agent_id_str}")})),
7016+
);
7017+
}
69907018
let message = req["message"].as_str().unwrap_or("").to_string();
69917019
let enabled = req.get("enabled").and_then(|v| v.as_bool()).unwrap_or(true);
69927020

@@ -7160,10 +7188,14 @@ pub async fn run_schedule(
71607188
.unwrap_or("Scheduled task triggered manually.");
71617189
let name = schedule["name"].as_str().unwrap_or("(unnamed)");
71627190

7163-
// Find the target agent
7191+
// Find the target agent — require explicit agent_id, no silent fallback
71647192
let target_agent = if !agent_id_str.is_empty() {
71657193
if let Ok(aid) = agent_id_str.parse::<AgentId>() {
7166-
Some(aid)
7194+
if state.kernel.registry.get(aid).is_some() {
7195+
Some(aid)
7196+
} else {
7197+
None
7198+
}
71677199
} else {
71687200
state
71697201
.kernel
@@ -7174,7 +7206,7 @@ pub async fn run_schedule(
71747206
.map(|a| a.id)
71757207
}
71767208
} else {
7177-
state.kernel.registry.list().first().map(|a| a.id)
7209+
None
71787210
};
71797211

71807212
let target_agent = match target_agent {

crates/openfang-channels/src/discord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ mod tests {
684684

685685
#[test]
686686
fn test_discord_adapter_creation() {
687-
let adapter = DiscordAdapter::new("test-token".to_string(), vec!["123".to_string(), "456".to_string()], 33280);
687+
let adapter = DiscordAdapter::new("test-token".to_string(), vec!["123".to_string(), "456".to_string()], 37376);
688688
assert_eq!(adapter.name(), "discord");
689689
assert_eq!(adapter.channel_type(), ChannelType::Discord);
690690
}

0 commit comments

Comments
 (0)