mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-30 08:17:53 +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]>
59 lines
1.9 KiB
Rust
59 lines
1.9 KiB
Rust
use std::path::PathBuf;
|
|
use std::time::Duration;
|
|
|
|
use crate::config::helpers::{optional_env, parse_bool_env, parse_optional_env};
|
|
use crate::error::ConfigError;
|
|
|
|
/// Builder mode configuration.
|
|
#[derive(Debug, Clone)]
|
|
pub struct BuilderModeConfig {
|
|
/// Whether the software builder tool is enabled.
|
|
pub enabled: bool,
|
|
/// Directory for build artifacts (default: temp dir).
|
|
pub build_dir: Option<PathBuf>,
|
|
/// Maximum iterations for the build loop.
|
|
pub max_iterations: u32,
|
|
/// Build timeout in seconds.
|
|
pub timeout_secs: u64,
|
|
/// Whether to automatically register built WASM tools.
|
|
pub auto_register: bool,
|
|
}
|
|
|
|
impl Default for BuilderModeConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
enabled: true,
|
|
build_dir: None,
|
|
max_iterations: 20,
|
|
timeout_secs: 600,
|
|
auto_register: true,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl BuilderModeConfig {
|
|
pub(crate) fn resolve() -> Result<Self, ConfigError> {
|
|
Ok(Self {
|
|
enabled: parse_bool_env("BUILDER_ENABLED", true)?,
|
|
build_dir: optional_env("BUILDER_DIR")?.map(PathBuf::from),
|
|
max_iterations: parse_optional_env("BUILDER_MAX_ITERATIONS", 20)?,
|
|
timeout_secs: parse_optional_env("BUILDER_TIMEOUT_SECS", 600)?,
|
|
auto_register: parse_bool_env("BUILDER_AUTO_REGISTER", true)?,
|
|
})
|
|
}
|
|
|
|
/// Convert to BuilderConfig for the builder tool.
|
|
pub fn to_builder_config(&self) -> crate::tools::BuilderConfig {
|
|
crate::tools::BuilderConfig {
|
|
build_dir: self.build_dir.clone().unwrap_or_else(std::env::temp_dir),
|
|
max_iterations: self.max_iterations,
|
|
timeout: Duration::from_secs(self.timeout_secs),
|
|
cleanup_on_failure: true,
|
|
validate_wasm: true,
|
|
run_tests: true,
|
|
auto_register: self.auto_register,
|
|
wasm_output_dir: None,
|
|
}
|
|
}
|
|
}
|