feat(onboard): refresh model discovery and canonicalize provider aliases (#341)

* feat(onboard): add model refresh command with ttl cache

* fix(onboard): refresh curated models and canonicalize provider aliases

* fix(channels): align agent_turn call signature

* fix(channels): call run_tool_call_loop for stable channel runtime
This commit is contained in:
Chummy 2026-02-16 22:32:30 +08:00 committed by GitHub
parent 0995c57776
commit c842ece12c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 1150 additions and 148 deletions

View file

@ -20,7 +20,7 @@ pub use telegram::TelegramChannel;
pub use traits::Channel; pub use traits::Channel;
pub use whatsapp::WhatsAppChannel; pub use whatsapp::WhatsAppChannel;
use crate::agent::loop_::{agent_turn, build_tool_instructions}; use crate::agent::loop_::{build_tool_instructions, run_tool_call_loop};
use crate::config::Config; use crate::config::Config;
use crate::identity; use crate::identity;
use crate::memory::{self, Memory}; use crate::memory::{self, Memory};
@ -181,7 +181,7 @@ async fn process_channel_message(ctx: Arc<ChannelRuntimeContext>, msg: traits::C
let llm_result = tokio::time::timeout( let llm_result = tokio::time::timeout(
Duration::from_secs(CHANNEL_MESSAGE_TIMEOUT_SECS), Duration::from_secs(CHANNEL_MESSAGE_TIMEOUT_SECS),
agent_turn( run_tool_call_loop(
ctx.provider.as_ref(), ctx.provider.as_ref(),
&mut history, &mut history,
ctx.tools_registry.as_ref(), ctx.tools_registry.as_ref(),

View file

@ -178,6 +178,12 @@ enum Commands {
cron_command: CronCommands, cron_command: CronCommands,
}, },
/// Manage provider model catalogs
Models {
#[command(subcommand)]
model_command: ModelCommands,
},
/// Manage channels (telegram, discord, slack) /// Manage channels (telegram, discord, slack)
Channel { Channel {
#[command(subcommand)] #[command(subcommand)]
@ -235,6 +241,20 @@ enum CronCommands {
}, },
} }
#[derive(Subcommand, Debug)]
enum ModelCommands {
/// Refresh and cache provider models
Refresh {
/// Provider name (defaults to configured default provider)
#[arg(long)]
provider: Option<String>,
/// Force live refresh and ignore fresh cache
#[arg(long)]
force: bool,
},
}
#[derive(Subcommand, Debug)] #[derive(Subcommand, Debug)]
enum ChannelCommands { enum ChannelCommands {
/// List configured channels /// List configured channels
@ -435,6 +455,12 @@ async fn main() -> Result<()> {
Commands::Cron { cron_command } => cron::handle_command(cron_command, &config), Commands::Cron { cron_command } => cron::handle_command(cron_command, &config),
Commands::Models { model_command } => match model_command {
ModelCommands::Refresh { provider, force } => {
onboard::run_models_refresh(&config, provider.as_deref(), force)
}
},
Commands::Service { service_command } => service::handle_command(&service_command, &config), Commands::Service { service_command } => service::handle_command(&service_command, &config),
Commands::Doctor => doctor::run(&config), Commands::Doctor => doctor::run(&config),

View file

@ -1,6 +1,6 @@
pub mod wizard; pub mod wizard;
pub use wizard::{run_channels_repair_wizard, run_quick_setup, run_wizard}; pub use wizard::{run_channels_repair_wizard, run_models_refresh, run_quick_setup, run_wizard};
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
@ -13,5 +13,6 @@ mod tests {
assert_reexport_exists(run_wizard); assert_reexport_exists(run_wizard);
assert_reexport_exists(run_channels_repair_wizard); assert_reexport_exists(run_channels_repair_wizard);
assert_reexport_exists(run_quick_setup); assert_reexport_exists(run_quick_setup);
assert_reexport_exists(run_models_refresh);
} }
} }

File diff suppressed because it is too large Load diff