Files
optimclaw/src/lib.rs
T
369741fc60 Add generic host-verified /webhook/tools/{tool} ingress (#757)
* Add generic host-verified webhook ingress for tools

* Stabilize trace E2E test rig and approval behavior

* Fix webhook security issues from review feedback

- Reject tools without webhook_capability() (was unauthenticated RCE)
- Remove secret-in-query-string fallback (leak via logs/referrers)
- Require approval for event_emit tool (escalation via routine triggers)
- Simplify header_value() (HeaderMap already case-insensitive)
- Redact internal errors from webhook HTTP responses
- Remove unused hmac_timestamp_tolerance_secs field
- Add regression test for tool without webhook capability

[skip-regression-check]

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

* Harden webhook ingress: require auth mechanism, body limit layer, health check

- Reject webhook capabilities that declare no auth mechanism (empty
  WebhookCapability would previously allow unauthenticated access)
- Add DefaultBodyLimit layer to reject oversized payloads before buffering
- Health check (GET) now verifies tool has webhook_capability(), not just
  existence
- Add regression tests for all three fixes

[skip-regression-check]

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

* Fix auto_approve_tools inconsistency between dispatcher and thread_ops

dispatcher.rs skips all approval checks (including Always) when
auto_approve_tools is true, but thread_ops.rs still required approval
for Always tools. This caused deferred tool calls to unexpectedly halt
in test rigs and auto-approve configurations.

Match dispatcher behavior: short-circuit all approval when
auto_approve_tools is enabled.

[skip-regression-check]

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

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
2026-03-11 03:36:25 +00:00

98 lines
5.2 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 document_extraction;
pub mod error;
pub mod estimation;
pub mod evaluation;
pub mod extensions;
pub mod history;
pub mod hooks;
#[cfg(feature = "import")]
pub mod import;
pub mod llm;
pub mod observability;
pub mod orchestrator;
pub mod pairing;
pub mod registry;
pub mod safety;
pub mod sandbox;
pub mod secrets;
pub mod service;
pub mod settings;
pub mod setup;
pub mod skills;
pub mod timezone;
pub mod tools;
pub mod tracing_fmt;
pub mod transcription;
pub mod tunnel;
pub mod util;
pub mod webhooks;
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};
}