@@ -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]\n bot_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 {
0 commit comments