chore(add-req): update active directories list for requirement generation

Enable automation, basic, config, context, session, kb, and tools directories while disabling bootstrap, file, and drive_monitor to refine which modules are processed by add-req.sh.
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2025-11-04 07:03:20 -03:00
parent 191ff1a7d8
commit c079d6e452
7 changed files with 33 additions and 74 deletions

View file

@ -20,25 +20,25 @@ done
dirs=(
# "auth"
# "automation"
# "basic"
"automation"
"basic"
"bot"
"bootstrap"
#"package_manager"
# "bootstrap"
# "package_manager"
# "channels"
# "config"
# "context"
"config"
"context"
# "email"
"file"
# "file"
# "llm"
"drive_monitor"
# "drive_monitor"
# "llm_legacy"
# "org"
# "session"
#"kb"
"session"
"kb"
"shared"
#"tests"
# "tools"
"tools"
# "web_automation"
# "whatsapp"
)

View file

@ -0,0 +1,4 @@
- On code return identifiers in english language.
- Do not emmit any comment, and remove any existants in Rust/html.
- Compact the code emission where possible.
- On change code, ensure cargo check cycle to remove warnings and errors.

View file

@ -379,7 +379,6 @@ impl AutomationService {
user_id: Uuid::new_v4(),
bot_id,
title: "Automation".to_string(),
answer_mode: 0,
current_tool: None,
context_data: serde_json::Value::Null,
created_at: Utc::now(),

View file

@ -229,20 +229,6 @@ impl BotOrchestrator {
self.state.response_channels.lock().await.remove(session_id);
}
pub async fn set_user_answer_mode(
&self,
user_id: &str,
bot_id: &str,
mode: i32,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
info!(
"Setting answer mode for user {} with bot {} to mode {}",
user_id, bot_id, mode
);
let mut session_manager = self.state.session_manager.lock().await;
session_manager.update_answer_mode(user_id, bot_id, mode)?;
Ok(())
}
pub async fn send_event(
&self,
@ -447,7 +433,7 @@ impl BotOrchestrator {
}
if session.answer_mode == 1 && session.current_tool.is_some() {
if session.current_tool.is_some() {
self.state.tool_manager.provide_user_response(
&message.user_id,
&message.bot_id,
@ -641,7 +627,7 @@ impl BotOrchestrator {
.parse::<usize>()
.unwrap_or(0);
let current_context_length = 0usize;
let current_context_length = crate::shared::utils::estimate_token_count(&context_data);
let final_msg = BotResponse {
bot_id: message.bot_id,
@ -783,14 +769,14 @@ impl BotOrchestrator {
user_id: "system".to_string(),
session_id: session_id.to_string(),
channel: channel.to_string(),
content: format!("⚠️ WARNING: {}", message),
message_type: 1,
stream_token: None,
is_complete: true,
suggestions: Vec::new(),
context_name: None,
context_length: 0,
context_max_length: 0,
content: format!("⚠️ WARNING: {}", message),
message_type: 1,
stream_token: None,
is_complete: true,
suggestions: Vec::new(),
context_name: None,
context_length: 0,
context_max_length: 0,
};
adapter.send_message(warn_response).await
} else {

View file

@ -167,7 +167,6 @@ impl SessionManager {
bot_id.eq(bid),
title.eq(session_title),
context_data.eq(serde_json::json!({})),
answer_mode.eq(0),
current_tool.eq(None::<String>),
created_at.eq(now),
updated_at.eq(now),
@ -406,41 +405,6 @@ impl SessionManager {
Ok(sessions)
}
pub fn update_answer_mode(
&mut self,
uid: &str,
bid: &str,
mode: i32,
) -> Result<(), Box<dyn Error + Send + Sync>> {
use crate::shared::models::user_sessions::dsl::*;
let user_uuid = Uuid::parse_str(uid).map_err(|e| {
warn!("Invalid user ID format: {}", uid);
e
})?;
let bot_uuid = Uuid::parse_str(bid).map_err(|e| {
warn!("Invalid bot ID format: {}", bid);
e
})?;
let updated_count = diesel::update(
user_sessions
.filter(user_id.eq(user_uuid))
.filter(bot_id.eq(bot_uuid)),
)
.set((answer_mode.eq(mode), updated_at.eq(chrono::Utc::now())))
.execute(&mut self.conn)?;
if updated_count == 0 {
warn!("No session found for user {} and bot {}", uid, bid);
} else {
info!(
"Answer mode updated to {} for user {} and bot {}",
mode, uid, bid
);
}
Ok(())
}
pub fn update_user_id(
&mut self,

View file

@ -82,7 +82,6 @@ pub struct UserSession {
pub bot_id: Uuid,
pub title: String,
pub context_data: serde_json::Value,
pub answer_mode: i32,
pub current_tool: Option<String>,
pub created_at: chrono::DateTime<Utc>,
pub updated_at: chrono::DateTime<Utc>,
@ -283,7 +282,6 @@ pub mod schema {
bot_id -> Uuid,
title -> Text,
context_data -> Jsonb,
answer_mode -> Int4,
current_tool -> Nullable<Text>,
created_at -> Timestamptz,
updated_at -> Timestamptz,

View file

@ -192,6 +192,14 @@ pub async fn call_llm(
Ok(format!("Generated response for: {}", prompt))
}
/// Estimates token count for text using simple heuristic (1 token ≈ 4 chars)
pub fn estimate_token_count(text: &str) -> usize {
// Basic token estimation - count whitespace-separated words
// Add 1 token for every 4 characters as a simple approximation
let char_count = text.chars().count();
(char_count / 4).max(1) // Ensure at least 1 token
}
/// Establishes a PostgreSQL connection using DATABASE_URL environment variable
pub fn establish_pg_connection() -> Result<PgConnection> {
let database_url = std::env::var("DATABASE_URL")