mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-31 16:49:34 +00:00
* refactor: simplify config resolution and consolidate main.rs init into AppBuilder - Add parse_bool_env() and parse_string_env() helpers to eliminate repetitive 5-line optional_env/parse/map_err/unwrap_or boilerplate across 12 config files - Add EmbeddingsConfig::create_provider() to centralize embeddings construction (fixes hardcoded 1536 dimensions and missing Ollama provider in app.rs) - Extract init_cli_tracing(), setup_wasm_channels(), start_tunnel(), run_memory_command(), run_worker(), run_claude_bridge() from main.rs - Replace ~600 lines of inline init in main.rs with AppBuilder::build_all() - Expose catalog_entries from AppComponents for gateway registry entries - Net reduction: ~738 lines across 15 files Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: propagate dev_loaded_tool_names from AppBuilder and add parse_option_env helper Address PR review feedback: - Capture dev_loaded_tool_names from WASM loading in init_extensions() and expose via AppComponents so bootstrap_hooks receives the actual dev tool names instead of an empty slice (fixes silent hook skip) - Add parse_option_env<T>() helper for Option<T> config fields, simplifying max_cost_per_day_cents and max_actions_per_hour in agent.rs Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: fetch real NEAR AI pricing and unify cost calculation path CostGuard was independently looking up pricing via costs::model_cost(), falling back to GPT-4o default rates when NEAR AI model names didn't match the static table — causing ~3x cost overestimates in logs. - Add pricing map to NearAiChatProvider that fetches real rates from /v1/model/list at startup (background, non-blocking) - Update cost_per_token() to check fetched pricing first, then static table, then default - Add cost_per_token parameter to CostGuard::record_llm_call() so the dispatcher passes provider-sourced rates directly Co-Authored-By: Claude Opus 4.6 <[email protected]> * chore: update default NEAR AI model to GLM-latest Replace fireworks llama4-maverick-instruct-basic with zai-org/GLM-latest as the default model in config and setup wizard. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: align wizard default model name with config Change "zai/GLM-latest" to "zai-org/GLM-latest" in wizard.rs to match the default in config/llm.rs. Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
42 lines
1.4 KiB
Rust
42 lines
1.4 KiB
Rust
use crate::config::helpers::{parse_bool_env, parse_optional_env};
|
|
use crate::error::ConfigError;
|
|
|
|
/// Routines configuration.
|
|
#[derive(Debug, Clone)]
|
|
pub struct RoutineConfig {
|
|
/// Whether the routines system is enabled.
|
|
pub enabled: bool,
|
|
/// How often (seconds) to poll for cron routines that need firing.
|
|
pub cron_check_interval_secs: u64,
|
|
/// Max routines executing concurrently across all users.
|
|
pub max_concurrent_routines: usize,
|
|
/// Default cooldown between fires (seconds).
|
|
pub default_cooldown_secs: u64,
|
|
/// Max output tokens for lightweight routine LLM calls.
|
|
pub max_lightweight_tokens: u32,
|
|
}
|
|
|
|
impl Default for RoutineConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
enabled: true,
|
|
cron_check_interval_secs: 15,
|
|
max_concurrent_routines: 10,
|
|
default_cooldown_secs: 300,
|
|
max_lightweight_tokens: 4096,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl RoutineConfig {
|
|
pub(crate) fn resolve() -> Result<Self, ConfigError> {
|
|
Ok(Self {
|
|
enabled: parse_bool_env("ROUTINES_ENABLED", true)?,
|
|
cron_check_interval_secs: parse_optional_env("ROUTINES_CRON_INTERVAL", 15)?,
|
|
max_concurrent_routines: parse_optional_env("ROUTINES_MAX_CONCURRENT", 10)?,
|
|
default_cooldown_secs: parse_optional_env("ROUTINES_DEFAULT_COOLDOWN", 300)?,
|
|
max_lightweight_tokens: parse_optional_env("ROUTINES_MAX_TOKENS", 4096)?,
|
|
})
|
|
}
|
|
}
|