Files
optimclaw/src/lib.rs
T
ffb1cc9be8 refactor: architecture improvements for contributor velocity (#198)
* refactor: split large files and consolidate test stubs for contributor velocity

- Extract 7 Database sub-traits (ConversationStore, JobStore, SandboxStore,
  RoutineStore, ToolFailureStore, SettingsStore, WorkspaceStore) with Database
  as a supertrait combining them all
- Split libsql_backend.rs (2769 lines) into src/db/libsql/ directory with
  one file per sub-trait implementation
- Split config.rs (1753 lines) into src/config/ directory with 16 domain files
- Consolidate 3 duplicate test LLM stubs into shared StubLlm in src/testing.rs
- Split server.rs handlers into src/channels/web/handlers/ directory
- Extract main.rs init phases into AppBuilder (src/app.rs)
- Add developer setup script (scripts/dev-setup.sh)

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* refactor: move heartbeat test from examples/ to tests/

Convert standalone example binary into a proper #[ignore] integration
test, matching the convention of the other integration tests.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* style: fix rustfmt formatting for CI

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix: address PR review comments from Copilot

- tunnel.rs: replace .ok().flatten() with ? to propagate env var errors
- secrets.rs: remove misleading "process-wide cache" comment
- database.rs: use uppercase "DATABASE_URL" in error key
- testing.rs: gate harness tests with #[cfg(feature = "libsql")]

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Illia Polosukhin <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
2026-02-18 23:05:47 +00:00

91 lines
5.1 KiB
Rust

//! NEAR AI Agentic Worker Framework
//!
//! An LLM-powered autonomous agent that operates on the NEAR AI marketplace.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────────────────────┐
//! │ User Interaction Layer │
//! │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
//! │ │ CLI │ │ Slack │ │ Telegram │ │ HTTP │ │
//! │ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
//! │ └─────────────┴────────────┬┴─────────────┘ │
//! └──────────────────────────────────┼──────────────────────────────────────────────┘
//! ▼
//! ┌──────────────────────────────────────────────────────────────────────────────────┐
//! │ Main Agent Loop │
//! │ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │
//! │ │ Message Router │──│ LLM Reasoning │──│ Action Executor│ │
//! │ └────────────────┘ └───────┬────────┘ └───────┬────────┘ │
//! │ ▲ │ │ │
//! │ │ ┌──────────┴───────────────────┴──────────┐ │
//! │ │ ▼ ▼ │
//! │ ┌──────┴─────────────┐ ┌───────────────────────┐ │
//! │ │ Safety Layer │ │ Self-Repair │ │
//! │ │ - Input sanitizer │ │ - Stuck job detection │ │
//! │ │ - Injection defense│ │ - Tool fixer │ │
//! │ └────────────────────┘ └───────────────────────┘ │
//! └──────────────────────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Features
//!
//! - **Multi-channel interaction** - CLI, Slack, Telegram, HTTP webhooks
//! - **Parallel job execution** - Run multiple jobs with isolated contexts
//! - **Pluggable tools** - MCP, 3rd party services, dynamic tools
//! - **Self-repair** - Detect and fix stuck jobs and broken tools
//! - **Prompt injection defense** - Sanitize all external data
//! - **Continuous learning** - Improve estimates from historical data
pub mod agent;
pub mod app;
pub mod boot_screen;
pub mod bootstrap;
pub mod channels;
pub mod cli;
pub mod config;
pub mod context;
pub mod db;
pub mod error;
pub mod estimation;
pub mod evaluation;
pub mod extensions;
pub mod history;
pub mod hooks;
pub mod llm;
pub mod observability;
pub mod orchestrator;
pub mod pairing;
pub mod safety;
pub mod sandbox;
pub mod secrets;
pub mod service;
pub mod settings;
pub mod setup;
pub mod skills;
pub mod tools;
pub mod tracing_fmt;
pub mod tunnel;
pub mod util;
pub mod worker;
pub mod workspace;
#[cfg(test)]
pub mod testing;
pub use config::Config;
pub use error::{Error, Result};
/// Re-export commonly used types.
pub mod prelude {
pub use crate::channels::{Channel, IncomingMessage, MessageStream};
pub use crate::config::Config;
pub use crate::context::{JobContext, JobState};
pub use crate::error::{Error, Result};
pub use crate::llm::LlmProvider;
pub use crate::safety::{SanitizedOutput, Sanitizer};
pub use crate::tools::{Tool, ToolOutput, ToolRegistry};
pub use crate::workspace::{MemoryDocument, Workspace};
}