mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-29 08:59:31 +00:00
Finishes the remaining isolation work from phases 2–4 of #59: Phase 2 (DB scoping): Fix /status and /list commands to use _for_user DB variants instead of global queries that leaked cross-user job data. Phase 3 (Runtime isolation): Per-user workspace in routine engine's spawn_fire so lightweight routines run in the correct user context. Per-user daily cost tracking in CostGuard with configurable budget via MAX_COST_PER_USER_PER_DAY_CENTS. Multi-user heartbeat that cycles through all users with routines, auto-detected from GATEWAY_USER_TOKENS. Phase 4 (Provider/tools): Per-user model selection via preferred_model setting — looked up from SettingsStore on first iteration, threaded through ReasoningContext.model_override to CompletionRequest. Works with providers that support per-request model overrides (NearAI). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
52 lines
1.7 KiB
Rust
52 lines
1.7 KiB
Rust
//! Core agent logic.
|
|
//!
|
|
//! The agent orchestrates:
|
|
//! - Message routing from channels
|
|
//! - Job scheduling and execution
|
|
//! - Tool invocation with safety
|
|
//! - Self-repair for stuck jobs
|
|
//! - Proactive heartbeat execution
|
|
//! - Routine-based scheduled and reactive jobs
|
|
//! - Turn-based session management with undo
|
|
//! - Context compaction for long conversations
|
|
|
|
mod agent_loop;
|
|
pub mod agentic_loop;
|
|
mod attachments;
|
|
mod commands;
|
|
pub mod compaction;
|
|
pub mod context_monitor;
|
|
pub mod cost_guard;
|
|
mod dispatcher;
|
|
mod heartbeat;
|
|
pub mod job_monitor;
|
|
mod router;
|
|
pub mod routine;
|
|
pub mod routine_engine;
|
|
pub(crate) mod scheduler;
|
|
mod self_repair;
|
|
pub mod session;
|
|
mod session_manager;
|
|
pub mod submission;
|
|
pub mod task;
|
|
mod thread_ops;
|
|
pub mod undo;
|
|
|
|
pub(crate) use agent_loop::truncate_for_preview;
|
|
pub use agent_loop::{Agent, AgentDeps};
|
|
pub use compaction::{CompactionResult, ContextCompactor};
|
|
pub use context_monitor::{CompactionStrategy, ContextBreakdown, ContextMonitor};
|
|
pub use heartbeat::{
|
|
HeartbeatConfig, HeartbeatResult, HeartbeatRunner, spawn_heartbeat, spawn_multi_user_heartbeat,
|
|
};
|
|
pub use router::{MessageIntent, Router};
|
|
pub use routine::{Routine, RoutineAction, RoutineRun, Trigger};
|
|
pub use routine_engine::{RoutineEngine, SandboxReadiness};
|
|
pub use scheduler::{Scheduler, SchedulerDeps};
|
|
pub use self_repair::{BrokenTool, RepairResult, RepairTask, SelfRepair, StuckJob};
|
|
pub use session::{PendingApproval, PendingAuth, Session, Thread, ThreadState, Turn, TurnState};
|
|
pub use session_manager::SessionManager;
|
|
pub use submission::{Submission, SubmissionParser, SubmissionResult};
|
|
pub use task::{Task, TaskContext, TaskHandler, TaskOutput};
|
|
pub use undo::{Checkpoint, UndoManager};
|