2026-01-14 12:36:18 -03:00
|
|
|
#![recursion_limit = "512"]
|
|
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
// Module declarations
|
|
|
|
|
pub mod main_module;
|
|
|
|
|
|
|
|
|
|
// Re-export commonly used items from main_module
|
|
|
|
|
pub use main_module::{BootstrapProgress, health_check, health_check_simple, receive_client_errors};
|
|
|
|
|
|
Fix tasks UI, WebSocket progress, memory monitoring, and app generator
Tasks UI fixes:
- Fix task list to query auto_tasks table instead of tasks table
- Fix task detail endpoint to use UUID binding for auto_tasks query
- Add proper filter handling: complete, active, awaiting, paused, blocked
- Add TaskStats fields: awaiting, paused, blocked, time_saved
- Add /api/tasks/time-saved endpoint
- Add count-all to stats HTML response
App generator improvements:
- Add AgentActivity struct for detailed terminal-style progress
- Add emit_activity method for rich progress events
- Add detailed logging for LLM calls with timing
- Track files_written, tables_synced, bytes_generated
Memory and performance:
- Add memory_monitor module for tracking RSS and thread activity
- Skip 0-byte files in drive monitor and document processor
- Change DRIVE_MONITOR checking logs from info to trace
- Remove unused profile_section macro
WebSocket progress:
- Ensure TaskProgressEvent includes activity field
- Add with_activity builder method
2025-12-30 22:42:32 -03:00
|
|
|
// Use jemalloc as the global allocator when the feature is enabled
|
|
|
|
|
#[cfg(feature = "jemalloc")]
|
|
|
|
|
use tikv_jemallocator::Jemalloc;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "jemalloc")]
|
|
|
|
|
#[global_allocator]
|
|
|
|
|
static GLOBAL: Jemalloc = Jemalloc;
|
|
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
// Module declarations for feature-gated modules
|
2026-01-27 16:28:36 -03:00
|
|
|
#[cfg(feature = "analytics")]
|
|
|
|
|
pub mod analytics;
|
|
|
|
|
#[cfg(feature = "attendant")]
|
|
|
|
|
pub mod attendant;
|
2026-01-22 13:57:40 -03:00
|
|
|
#[cfg(feature = "automation")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod auto_task;
|
2026-01-24 22:04:47 -03:00
|
|
|
#[cfg(feature = "scripting")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod basic;
|
2026-01-22 19:45:18 -03:00
|
|
|
#[cfg(feature = "billing")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod billing;
|
2026-01-27 16:28:36 -03:00
|
|
|
pub mod botmodels;
|
2026-01-22 13:57:40 -03:00
|
|
|
#[cfg(feature = "canvas")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod canvas;
|
|
|
|
|
pub mod channels;
|
2026-01-22 19:45:18 -03:00
|
|
|
#[cfg(feature = "people")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod contacts;
|
|
|
|
|
pub mod core;
|
2026-01-22 13:57:40 -03:00
|
|
|
#[cfg(feature = "designer")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod designer;
|
2026-01-18 19:53:34 -03:00
|
|
|
#[cfg(feature = "docs")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod docs;
|
2026-01-27 16:28:36 -03:00
|
|
|
pub mod embedded_ui;
|
2026-01-22 13:57:40 -03:00
|
|
|
#[cfg(feature = "learn")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod learn;
|
2026-01-27 16:28:36 -03:00
|
|
|
#[cfg(feature = "compliance")]
|
|
|
|
|
pub mod legal;
|
|
|
|
|
pub mod maintenance;
|
|
|
|
|
#[cfg(feature = "monitoring")]
|
|
|
|
|
pub mod monitoring;
|
|
|
|
|
pub mod multimodal;
|
2026-01-18 19:53:34 -03:00
|
|
|
#[cfg(feature = "paper")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod paper;
|
2026-01-27 16:28:36 -03:00
|
|
|
#[cfg(feature = "people")]
|
|
|
|
|
pub mod people;
|
|
|
|
|
#[cfg(feature = "player")]
|
|
|
|
|
pub mod player;
|
|
|
|
|
#[cfg(feature = "billing")]
|
|
|
|
|
pub mod products;
|
|
|
|
|
#[cfg(feature = "project")]
|
|
|
|
|
pub mod project;
|
2026-01-22 13:57:40 -03:00
|
|
|
#[cfg(feature = "research")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod research;
|
2026-01-27 16:28:36 -03:00
|
|
|
pub mod search;
|
|
|
|
|
pub mod security;
|
|
|
|
|
pub mod settings;
|
2026-02-05 11:50:32 -03:00
|
|
|
#[cfg(feature = "dashboards")]
|
2026-01-27 16:28:36 -03:00
|
|
|
pub mod shared;
|
2026-01-18 19:53:34 -03:00
|
|
|
#[cfg(feature = "sheet")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod sheet;
|
2026-01-18 19:53:34 -03:00
|
|
|
#[cfg(feature = "slides")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod slides;
|
2026-01-22 13:57:40 -03:00
|
|
|
#[cfg(feature = "social")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod social;
|
2026-01-22 13:57:40 -03:00
|
|
|
#[cfg(feature = "sources")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod sources;
|
2026-01-27 16:28:36 -03:00
|
|
|
#[cfg(feature = "tickets")]
|
|
|
|
|
pub mod tickets;
|
2026-01-22 13:57:40 -03:00
|
|
|
#[cfg(feature = "video")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod video;
|
2026-01-22 19:45:18 -03:00
|
|
|
#[cfg(feature = "workspaces")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod workspaces;
|
|
|
|
|
|
2026-01-16 11:29:22 -03:00
|
|
|
#[cfg(feature = "attendant")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod attendance;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "calendar")]
|
|
|
|
|
pub mod calendar;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "compliance")]
|
|
|
|
|
pub mod compliance;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "console")]
|
|
|
|
|
pub mod console;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "directory")]
|
|
|
|
|
pub mod directory;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "drive")]
|
|
|
|
|
pub mod drive;
|
|
|
|
|
|
2026-01-19 15:43:45 -03:00
|
|
|
#[cfg(feature = "mail")]
|
2026-01-14 12:36:18 -03:00
|
|
|
pub mod email;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "instagram")]
|
|
|
|
|
pub mod instagram;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "llm")]
|
|
|
|
|
pub mod llm;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "meet")]
|
|
|
|
|
pub mod meet;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "msteams")]
|
|
|
|
|
pub mod msteams;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "nvidia")]
|
|
|
|
|
pub mod nvidia;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "tasks")]
|
|
|
|
|
pub mod tasks;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "vectordb")]
|
|
|
|
|
#[path = "vector-db/mod.rs"]
|
|
|
|
|
pub mod vector_db;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "weba")]
|
|
|
|
|
pub mod weba;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "whatsapp")]
|
|
|
|
|
pub mod whatsapp;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "telegram")]
|
|
|
|
|
pub mod telegram;
|
|
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
// Re-export commonly used types
|
2026-01-14 12:36:18 -03:00
|
|
|
#[cfg(feature = "drive")]
|
|
|
|
|
pub use drive::drive_monitor::DriveMonitor;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "llm")]
|
|
|
|
|
pub use llm::cache::{CacheConfig, CachedLLMProvider, CachedResponse, LocalEmbeddingService};
|
|
|
|
|
#[cfg(feature = "llm")]
|
|
|
|
|
pub use llm::DynamicLLMProvider;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "tasks")]
|
|
|
|
|
pub use tasks::TaskEngine;
|
|
|
|
|
|
2025-12-02 21:09:43 -03:00
|
|
|
use dotenvy::dotenv;
|
2025-11-28 13:50:28 -03:00
|
|
|
use log::{error, info, trace, warn};
|
2025-11-11 09:42:52 -03:00
|
|
|
use std::sync::Arc;
|
feat(security): Complete security infrastructure implementation
SECURITY MODULES ADDED:
- security/auth.rs: Full RBAC with roles (Anonymous, User, Moderator, Admin, SuperAdmin, Service, Bot, BotOwner, BotOperator, BotViewer) and permissions
- security/cors.rs: Hardened CORS (no wildcard in production, env-based config)
- security/panic_handler.rs: Panic catching middleware with safe 500 responses
- security/path_guard.rs: Path traversal protection, null byte prevention
- security/request_id.rs: UUID request tracking with correlation IDs
- security/error_sanitizer.rs: Sensitive data redaction from responses
- security/zitadel_auth.rs: Zitadel token introspection and role mapping
- security/sql_guard.rs: SQL injection prevention with table whitelist
- security/command_guard.rs: Command injection prevention
- security/secrets.rs: Zeroizing secret management
- security/validation.rs: Input validation utilities
- security/rate_limiter.rs: Rate limiting with governor crate
- security/headers.rs: Security headers (CSP, HSTS, X-Frame-Options)
MAIN.RS UPDATES:
- Replaced tower_http::cors::Any with hardened create_cors_layer()
- Added panic handler middleware
- Added request ID tracking middleware
- Set global panic hook
SECURITY STATUS:
- 0 unwrap() in production code
- 0 panic! in production code
- 0 unsafe blocks
- cargo audit: PASS (no vulnerabilities)
- Estimated completion: ~98%
Remaining: Wire auth middleware to handlers, audit logs for sensitive data
2025-12-28 19:29:18 -03:00
|
|
|
|
2025-10-19 14:02:47 -03:00
|
|
|
#[tokio::main]
|
2025-10-16 11:43:02 -03:00
|
|
|
async fn main() -> std::io::Result<()> {
|
2026-02-12 21:09:30 +00:00
|
|
|
use main_module::{
|
|
|
|
|
init_database, init_logging_and_i18n, load_config, parse_cli_args, run_axum_server,
|
|
|
|
|
run_bootstrap, start_background_services, BootstrapProgress,
|
|
|
|
|
};
|
|
|
|
|
use crate::core::shared::memory_monitor::MemoryStats;
|
|
|
|
|
use crate::core::shared::memory_monitor::register_thread;
|
|
|
|
|
use crate::security::set_global_panic_hook;
|
|
|
|
|
|
feat(security): Complete security infrastructure implementation
SECURITY MODULES ADDED:
- security/auth.rs: Full RBAC with roles (Anonymous, User, Moderator, Admin, SuperAdmin, Service, Bot, BotOwner, BotOperator, BotViewer) and permissions
- security/cors.rs: Hardened CORS (no wildcard in production, env-based config)
- security/panic_handler.rs: Panic catching middleware with safe 500 responses
- security/path_guard.rs: Path traversal protection, null byte prevention
- security/request_id.rs: UUID request tracking with correlation IDs
- security/error_sanitizer.rs: Sensitive data redaction from responses
- security/zitadel_auth.rs: Zitadel token introspection and role mapping
- security/sql_guard.rs: SQL injection prevention with table whitelist
- security/command_guard.rs: Command injection prevention
- security/secrets.rs: Zeroizing secret management
- security/validation.rs: Input validation utilities
- security/rate_limiter.rs: Rate limiting with governor crate
- security/headers.rs: Security headers (CSP, HSTS, X-Frame-Options)
MAIN.RS UPDATES:
- Replaced tower_http::cors::Any with hardened create_cors_layer()
- Added panic handler middleware
- Added request ID tracking middleware
- Set global panic hook
SECURITY STATUS:
- 0 unwrap() in production code
- 0 panic! in production code
- 0 unsafe blocks
- cargo audit: PASS (no vulnerabilities)
- Estimated completion: ~98%
Remaining: Wire auth middleware to handlers, audit logs for sensitive data
2025-12-28 19:29:18 -03:00
|
|
|
// Set global panic hook to log panics that escape async boundaries
|
|
|
|
|
set_global_panic_hook();
|
|
|
|
|
|
2025-12-08 23:35:33 -03:00
|
|
|
let args: Vec<String> = std::env::args().collect();
|
|
|
|
|
let no_ui = args.contains(&"--noui".to_string());
|
2026-01-27 16:28:36 -03:00
|
|
|
|
|
|
|
|
#[cfg(feature = "console")]
|
2025-12-08 23:35:33 -03:00
|
|
|
let no_console = args.contains(&"--noconsole".to_string());
|
|
|
|
|
|
2026-01-27 16:28:36 -03:00
|
|
|
#[cfg(not(feature = "console"))]
|
|
|
|
|
let no_console = true;
|
|
|
|
|
|
2025-12-07 02:13:28 -03:00
|
|
|
let _ = rustls::crypto::ring::default_provider().install_default();
|
|
|
|
|
|
|
|
|
|
dotenvy::dotenv().ok();
|
|
|
|
|
|
2025-12-09 08:10:47 -03:00
|
|
|
let env_path_early = std::path::Path::new("./.env");
|
|
|
|
|
let vault_init_path_early = std::path::Path::new("./botserver-stack/conf/vault/init.json");
|
|
|
|
|
let bootstrap_ready = env_path_early.exists() && vault_init_path_early.exists() && {
|
|
|
|
|
std::fs::read_to_string(env_path_early)
|
|
|
|
|
.map(|content| content.contains("VAULT_TOKEN="))
|
|
|
|
|
.unwrap_or(false)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if bootstrap_ready {
|
2026-02-12 21:09:30 +00:00
|
|
|
if let Err(e) = crate::core::shared::utils::init_secrets_manager().await {
|
2025-12-09 08:10:47 -03:00
|
|
|
warn!(
|
|
|
|
|
"Failed to initialize SecretsManager: {}. Falling back to env vars.",
|
|
|
|
|
e
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
info!("SecretsManager initialized - fetching secrets from Vault");
|
|
|
|
|
}
|
2025-12-07 02:13:28 -03:00
|
|
|
} else {
|
2025-12-09 08:10:47 -03:00
|
|
|
trace!("Bootstrap not complete - skipping early SecretsManager init");
|
2025-12-07 02:13:28 -03:00
|
|
|
}
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
|
2026-01-27 16:28:36 -03:00
|
|
|
let noise_filters = "vaultrs=off,rustify=off,rustify_derive=off,\
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
aws_sigv4=off,aws_smithy_checksums=off,aws_runtime=off,aws_smithy_http_client=off,\
|
|
|
|
|
aws_smithy_runtime=off,aws_smithy_runtime_api=off,aws_sdk_s3=off,aws_config=off,\
|
|
|
|
|
aws_credential_types=off,aws_http=off,aws_sig_auth=off,aws_types=off,\
|
|
|
|
|
mio=off,tokio=off,tokio_util=off,tower=off,tower_http=off,\
|
|
|
|
|
reqwest=off,hyper=off,hyper_util=off,h2=off,\
|
|
|
|
|
rustls=off,rustls_pemfile=off,tokio_rustls=off,\
|
|
|
|
|
tracing=off,tracing_core=off,tracing_subscriber=off,\
|
2025-11-28 13:50:28 -03:00
|
|
|
diesel=off,diesel_migrations=off,r2d2=warn,\
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
serde=off,serde_json=off,\
|
|
|
|
|
axum=off,axum_core=off,\
|
|
|
|
|
tonic=off,prost=off,\
|
|
|
|
|
lettre=off,imap=off,mailparse=off,\
|
|
|
|
|
crossterm=off,ratatui=off,\
|
|
|
|
|
tauri=off,tauri_runtime=off,tauri_utils=off,\
|
|
|
|
|
notify=off,ignore=off,walkdir=off,\
|
|
|
|
|
want=off,try_lock=off,futures=off,\
|
|
|
|
|
base64=off,bytes=off,encoding_rs=off,\
|
|
|
|
|
url=off,percent_encoding=off,\
|
|
|
|
|
ring=off,webpki=off,\
|
2026-01-11 20:10:23 -03:00
|
|
|
hickory_resolver=off,hickory_proto=off";
|
|
|
|
|
|
|
|
|
|
let rust_log = match std::env::var("RUST_LOG") {
|
|
|
|
|
Ok(existing) if !existing.is_empty() => format!("{},{}", existing, noise_filters),
|
2026-01-27 18:45:41 -03:00
|
|
|
_ => format!("info,{}", noise_filters),
|
2025-12-02 21:09:43 -03:00
|
|
|
};
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
|
|
|
|
|
std::env::set_var("RUST_LOG", &rust_log);
|
|
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
init_logging_and_i18n(no_console, no_ui);
|
2026-01-06 22:56:35 -03:00
|
|
|
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
let (progress_tx, _progress_rx) = tokio::sync::mpsc::unbounded_channel::<BootstrapProgress>();
|
2026-02-12 21:09:30 +00:00
|
|
|
let (state_tx, _state_rx) = tokio::sync::mpsc::channel::<Arc<crate::core::shared::state::AppState>>(1);
|
2025-11-15 09:48:46 -03:00
|
|
|
|
2025-11-15 19:08:26 -03:00
|
|
|
if args.len() > 1 {
|
|
|
|
|
let command = &args[1];
|
|
|
|
|
match command.as_str() {
|
2025-11-20 13:28:35 -03:00
|
|
|
"install" | "remove" | "list" | "status" | "start" | "stop" | "restart" | "--help"
|
2026-02-12 21:09:30 +00:00
|
|
|
| "-h" => match crate::core::package_manager::cli::run().await {
|
2025-11-15 19:08:26 -03:00
|
|
|
Ok(_) => return Ok(()),
|
|
|
|
|
Err(e) => {
|
2025-12-26 08:59:25 -03:00
|
|
|
eprintln!("CLI error: {e}");
|
|
|
|
|
return Err(std::io::Error::other(format!("CLI command failed: {e}")));
|
2025-11-15 19:08:26 -03:00
|
|
|
}
|
|
|
|
|
},
|
2025-11-19 14:00:57 -03:00
|
|
|
_ => {}
|
2025-11-15 19:08:26 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-07 02:13:28 -03:00
|
|
|
let ui_handle: Option<std::thread::JoinHandle<()>> = if !no_console && !no_ui {
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
#[cfg(feature = "console")]
|
|
|
|
|
{
|
|
|
|
|
let progress_rx = Arc::new(tokio::sync::Mutex::new(_progress_rx));
|
|
|
|
|
let state_rx = Arc::new(tokio::sync::Mutex::new(_state_rx));
|
|
|
|
|
|
|
|
|
|
Some(
|
|
|
|
|
std::thread::Builder::new()
|
|
|
|
|
.name("ui-thread".to_string())
|
|
|
|
|
.spawn(move || {
|
2026-01-27 16:28:36 -03:00
|
|
|
let mut ui = crate::console::XtreeUI::new();
|
2025-12-26 08:59:25 -03:00
|
|
|
ui.set_progress_channel(progress_rx);
|
|
|
|
|
ui.set_state_channel(state_rx);
|
2025-12-23 18:40:58 -03:00
|
|
|
|
2025-11-22 22:54:45 -03:00
|
|
|
if let Err(e) = ui.start_ui() {
|
2025-12-26 08:59:25 -03:00
|
|
|
eprintln!("UI error: {e}");
|
2025-11-22 22:54:45 -03:00
|
|
|
}
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
})
|
2026-01-27 16:28:36 -03:00
|
|
|
.map_err(|e| {
|
|
|
|
|
std::io::Error::other(format!("Failed to spawn UI thread: {}", e))
|
|
|
|
|
})?,
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
#[cfg(not(feature = "console"))]
|
|
|
|
|
{
|
2025-11-28 13:50:28 -03:00
|
|
|
if !no_console {
|
|
|
|
|
eprintln!("Console feature not compiled. Rebuild with --features console or use --noconsole to suppress this message");
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
}
|
|
|
|
|
None
|
|
|
|
|
}
|
2025-11-11 09:42:52 -03:00
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
};
|
2025-11-19 14:00:57 -03:00
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
let (install_mode, tenant) = parse_cli_args(&args);
|
2025-11-19 14:00:57 -03:00
|
|
|
|
2025-12-06 14:55:42 -03:00
|
|
|
if let Some(idx) = args.iter().position(|a| a == "--stack-path") {
|
|
|
|
|
if let Some(path) = args.get(idx + 1) {
|
|
|
|
|
std::env::set_var("BOTSERVER_STACK_PATH", path);
|
|
|
|
|
info!("Using custom stack path: {}", path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
let cfg = run_bootstrap(install_mode, tenant, &progress_tx).await?;
|
2025-11-19 14:00:57 -03:00
|
|
|
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
trace!("Bootstrap config phase complete");
|
|
|
|
|
trace!("Reloading dotenv...");
|
2025-11-11 09:42:52 -03:00
|
|
|
dotenv().ok();
|
2025-11-19 14:00:57 -03:00
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
let pool = init_database(&progress_tx).await?;
|
|
|
|
|
let refreshed_cfg = load_config(&pool).await?;
|
2025-12-08 00:19:29 -03:00
|
|
|
let config = std::sync::Arc::new(refreshed_cfg.clone());
|
|
|
|
|
|
2026-01-23 13:14:20 -03:00
|
|
|
#[cfg(feature = "cache")]
|
2026-02-12 21:09:30 +00:00
|
|
|
let redis_client = main_module::init_redis().await;
|
2025-11-27 08:34:24 -03:00
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
#[cfg(not(feature = "cache"))]
|
|
|
|
|
let redis_client: Option<Arc<redis::Client>> = None;
|
2026-01-04 08:48:27 -03:00
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
let app_state = main_module::create_app_state(cfg, pool, &redis_client).await?;
|
2025-11-27 13:53:16 -03:00
|
|
|
|
2026-01-25 10:29:54 -03:00
|
|
|
// Resume workflows after server restart
|
2026-01-27 16:28:36 -03:00
|
|
|
if let Err(e) =
|
|
|
|
|
crate::basic::keywords::orchestration::resume_workflows_on_startup(app_state.clone()).await
|
|
|
|
|
{
|
2026-01-25 10:29:54 -03:00
|
|
|
log::warn!("Failed to resume workflows on startup: {}", e);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-23 13:14:20 -03:00
|
|
|
#[cfg(feature = "tasks")]
|
2026-01-16 11:29:22 -03:00
|
|
|
let task_scheduler = Arc::new(crate::tasks::scheduler::TaskScheduler::new(
|
2025-11-27 13:53:16 -03:00
|
|
|
app_state.clone(),
|
|
|
|
|
));
|
|
|
|
|
|
2026-01-23 13:14:20 -03:00
|
|
|
#[cfg(feature = "tasks")]
|
2025-12-26 08:59:25 -03:00
|
|
|
task_scheduler.start();
|
2025-12-23 18:40:58 -03:00
|
|
|
|
2026-01-24 22:04:47 -03:00
|
|
|
#[cfg(any(feature = "research", feature = "llm"))]
|
2026-01-27 16:28:36 -03:00
|
|
|
if let Err(e) = crate::core::kb::ensure_crawler_service_running(app_state.clone()).await {
|
2025-11-26 22:54:22 -03:00
|
|
|
log::warn!("Failed to start website crawler service: {}", e);
|
|
|
|
|
}
|
|
|
|
|
|
Fix tasks UI, WebSocket progress, memory monitoring, and app generator
Tasks UI fixes:
- Fix task list to query auto_tasks table instead of tasks table
- Fix task detail endpoint to use UUID binding for auto_tasks query
- Add proper filter handling: complete, active, awaiting, paused, blocked
- Add TaskStats fields: awaiting, paused, blocked, time_saved
- Add /api/tasks/time-saved endpoint
- Add count-all to stats HTML response
App generator improvements:
- Add AgentActivity struct for detailed terminal-style progress
- Add emit_activity method for rich progress events
- Add detailed logging for LLM calls with timing
- Track files_written, tables_synced, bytes_generated
Memory and performance:
- Add memory_monitor module for tracking RSS and thread activity
- Skip 0-byte files in drive monitor and document processor
- Change DRIVE_MONITOR checking logs from info to trace
- Remove unused profile_section macro
WebSocket progress:
- Ensure TaskProgressEvent includes activity field
- Add with_activity builder method
2025-12-30 22:42:32 -03:00
|
|
|
// Start memory monitoring - check every 30 seconds, warn if growth > 50MB
|
2026-02-12 21:09:30 +00:00
|
|
|
use crate::core::shared::memory_monitor::{log_process_memory, start_memory_monitor};
|
Fix tasks UI, WebSocket progress, memory monitoring, and app generator
Tasks UI fixes:
- Fix task list to query auto_tasks table instead of tasks table
- Fix task detail endpoint to use UUID binding for auto_tasks query
- Add proper filter handling: complete, active, awaiting, paused, blocked
- Add TaskStats fields: awaiting, paused, blocked, time_saved
- Add /api/tasks/time-saved endpoint
- Add count-all to stats HTML response
App generator improvements:
- Add AgentActivity struct for detailed terminal-style progress
- Add emit_activity method for rich progress events
- Add detailed logging for LLM calls with timing
- Track files_written, tables_synced, bytes_generated
Memory and performance:
- Add memory_monitor module for tracking RSS and thread activity
- Skip 0-byte files in drive monitor and document processor
- Change DRIVE_MONITOR checking logs from info to trace
- Remove unused profile_section macro
WebSocket progress:
- Ensure TaskProgressEvent includes activity field
- Add with_activity builder method
2025-12-30 22:42:32 -03:00
|
|
|
start_memory_monitor(30, 50);
|
|
|
|
|
info!("Memory monitor started");
|
|
|
|
|
log_process_memory();
|
|
|
|
|
|
feat(autotask): Implement AutoTask system with intent classification and app generation
- Add IntentClassifier with 7 intent types (APP_CREATE, TODO, MONITOR, ACTION, SCHEDULE, GOAL, TOOL)
- Add AppGenerator with LLM-powered app structure analysis
- Add DesignerAI for modifying apps through conversation
- Add app_server for serving generated apps with clean URLs
- Add db_api for CRUD operations on bot database tables
- Add ask_later keyword for pending info collection
- Add migration 6.1.1 with tables: pending_info, auto_tasks, execution_plans, task_approvals, task_decisions, safety_audit_log, generated_apps, intent_classifications, designer_changes
- Write apps to S3 drive and sync to SITE_ROOT for serving
- Clean URL structure: /apps/{app_name}/
- Integrate with DriveMonitor for file sync
Based on Chapter 17 - Autonomous Tasks specification
2025-12-27 21:10:09 -03:00
|
|
|
let _ = state_tx.try_send(app_state.clone());
|
2025-11-11 09:42:52 -03:00
|
|
|
progress_tx.send(BootstrapProgress::BootstrapComplete).ok();
|
2025-11-19 14:00:57 -03:00
|
|
|
|
2025-11-11 09:42:52 -03:00
|
|
|
info!(
|
|
|
|
|
"Starting HTTP server on {}:{}",
|
|
|
|
|
config.server.host, config.server.port
|
|
|
|
|
);
|
2025-11-19 14:00:57 -03:00
|
|
|
|
2025-11-11 09:42:52 -03:00
|
|
|
let worker_count = std::thread::available_parallelism()
|
|
|
|
|
.map(|n| n.get())
|
|
|
|
|
.unwrap_or(4);
|
2025-11-15 09:48:46 -03:00
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
let bot_orchestrator = crate::core::bot::BotOrchestrator::new(app_state.clone());
|
feat(autotask): Implement AutoTask system with intent classification and app generation
- Add IntentClassifier with 7 intent types (APP_CREATE, TODO, MONITOR, ACTION, SCHEDULE, GOAL, TOOL)
- Add AppGenerator with LLM-powered app structure analysis
- Add DesignerAI for modifying apps through conversation
- Add app_server for serving generated apps with clean URLs
- Add db_api for CRUD operations on bot database tables
- Add ask_later keyword for pending info collection
- Add migration 6.1.1 with tables: pending_info, auto_tasks, execution_plans, task_approvals, task_decisions, safety_audit_log, generated_apps, intent_classifications, designer_changes
- Write apps to S3 drive and sync to SITE_ROOT for serving
- Clean URL structure: /apps/{app_name}/
- Integrate with DriveMonitor for file sync
Based on Chapter 17 - Autonomous Tasks specification
2025-12-27 21:10:09 -03:00
|
|
|
if let Err(e) = bot_orchestrator.mount_all_bots() {
|
|
|
|
|
error!("Failed to mount bots: {}", e);
|
|
|
|
|
}
|
2025-11-19 14:00:57 -03:00
|
|
|
|
2026-02-04 13:29:29 -03:00
|
|
|
#[cfg(feature = "llm")]
|
|
|
|
|
{
|
|
|
|
|
let app_state_for_llm = app_state.clone();
|
|
|
|
|
trace!("ensure_llama_servers_running starting...");
|
2026-02-12 21:09:30 +00:00
|
|
|
if let Err(e) = crate::llm::local::ensure_llama_servers_running(app_state_for_llm).await {
|
2026-02-04 13:29:29 -03:00
|
|
|
error!("Failed to start LLM servers: {}", e);
|
|
|
|
|
}
|
|
|
|
|
trace!("ensure_llama_servers_running completed");
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-12 21:09:30 +00:00
|
|
|
start_background_services(app_state.clone(), &app_state.conn).await;
|
2026-02-09 15:10:27 +00:00
|
|
|
|
2026-01-22 13:57:40 -03:00
|
|
|
#[cfg(feature = "automation")]
|
|
|
|
|
{
|
|
|
|
|
let automation_state = app_state.clone();
|
|
|
|
|
tokio::spawn(async move {
|
|
|
|
|
register_thread("automation-service", "automation");
|
2026-02-12 21:09:30 +00:00
|
|
|
let automation = crate::core::automation::AutomationService::new(automation_state);
|
2026-01-27 16:28:36 -03:00
|
|
|
trace!(
|
|
|
|
|
"[TASK] AutomationService starting, RSS={}",
|
|
|
|
|
MemoryStats::format_bytes(MemoryStats::current().rss_bytes)
|
|
|
|
|
);
|
2026-01-22 13:57:40 -03:00
|
|
|
loop {
|
2026-02-12 21:09:30 +00:00
|
|
|
crate::core::shared::memory_monitor::record_thread_activity("automation-service");
|
2026-01-22 13:57:40 -03:00
|
|
|
if let Err(e) = automation.check_scheduled_tasks().await {
|
|
|
|
|
error!("Error checking scheduled tasks: {}", e);
|
|
|
|
|
}
|
|
|
|
|
tokio::time::sleep(tokio::time::Duration::from_secs(60)).await;
|
Fix tasks UI, WebSocket progress, memory monitoring, and app generator
Tasks UI fixes:
- Fix task list to query auto_tasks table instead of tasks table
- Fix task detail endpoint to use UUID binding for auto_tasks query
- Add proper filter handling: complete, active, awaiting, paused, blocked
- Add TaskStats fields: awaiting, paused, blocked, time_saved
- Add /api/tasks/time-saved endpoint
- Add count-all to stats HTML response
App generator improvements:
- Add AgentActivity struct for detailed terminal-style progress
- Add emit_activity method for rich progress events
- Add detailed logging for LLM calls with timing
- Track files_written, tables_synced, bytes_generated
Memory and performance:
- Add memory_monitor module for tracking RSS and thread activity
- Skip 0-byte files in drive monitor and document processor
- Change DRIVE_MONITOR checking logs from info to trace
- Remove unused profile_section macro
WebSocket progress:
- Ensure TaskProgressEvent includes activity field
- Add with_activity builder method
2025-12-30 22:42:32 -03:00
|
|
|
}
|
2026-01-22 13:57:40 -03:00
|
|
|
});
|
|
|
|
|
}
|
2025-11-19 14:00:57 -03:00
|
|
|
|
Add .env.example with comprehensive configuration template
The commit adds a complete example environment configuration file
documenting all available settings for BotServer, including logging,
database, server, drive, LLM, Redis, email, and feature flags.
Also removes hardcoded environment variable usage throughout the
codebase, replacing them with configuration via config.csv or
appropriate defaults. This includes:
- WhatsApp, Teams, Instagram adapter configurations
- Weather API key handling
- Email and directory service configurations
- Console feature conditionally compiles monitoring code
- Improved logging configuration with library suppression
2025-11-28 13:19:03 -03:00
|
|
|
trace!("Initial data setup task spawned");
|
MS Office 100% Compatibility - Phase 1 Implementation
- Add rust_xlsxwriter for Excel export with formatting support
- Add docx-rs for Word document import/export with HTML conversion
- Add PPTX export support with slides, shapes, and text elements
- Refactor sheet module into 7 files (types, formulas, handlers, etc)
- Refactor docs module into 6 files (types, handlers, storage, etc)
- Refactor slides module into 6 files (types, handlers, storage, etc)
- Fix collaboration modules (borrow issues, rand compatibility)
- Add ooxmlsdk dependency for future Office 2021 features
- Fix type mismatches in slides storage
- Update security protection API router type
Features:
- Excel: Read xlsx/xlsm/xls, write xlsx with styles
- Word: Read/write docx with formatting preservation
- PowerPoint: Write pptx with slides, shapes, text
- Real-time collaboration via WebSocket (already working)
- Theme-aware UI with --sentient-* CSS variables
2026-01-11 09:56:15 -03:00
|
|
|
trace!("All system threads started, starting HTTP server...");
|
2025-11-19 14:00:57 -03:00
|
|
|
|
2026-01-06 22:56:35 -03:00
|
|
|
info!("Starting HTTP server on port {}...", config.server.port);
|
2025-12-29 08:45:46 -03:00
|
|
|
if let Err(e) = run_axum_server(app_state, config.server.port, worker_count).await {
|
|
|
|
|
error!("Failed to start HTTP server: {}", e);
|
2025-12-29 10:28:49 -03:00
|
|
|
std::process::exit(1);
|
2025-12-29 08:45:46 -03:00
|
|
|
}
|
2026-01-06 22:56:35 -03:00
|
|
|
trace!("run_axum_server returned (should not happen normally)");
|
2025-11-19 14:00:57 -03:00
|
|
|
|
2025-12-02 21:09:43 -03:00
|
|
|
if let Some(handle) = ui_handle {
|
|
|
|
|
handle.join().ok();
|
2025-11-19 14:00:57 -03:00
|
|
|
}
|
|
|
|
|
|
2025-11-15 09:48:46 -03:00
|
|
|
Ok(())
|
2025-10-06 10:30:17 -03:00
|
|
|
}
|
2026-02-14 19:04:47 +00:00
|
|
|
|