Skip to main content

nab/
lib.rs

1// Cast-precision and float-comparison lints are noise in audio/PDF processing
2// code where exact precision is irrelevant and the casts are intentional.
3#![allow(
4    clippy::cast_possible_truncation,
5    clippy::cast_possible_wrap,
6    clippy::cast_precision_loss,
7    clippy::cast_sign_loss,
8    clippy::cast_lossless,
9    clippy::float_cmp
10)]
11
12//! `nab` - Multimodal web microfetch for LLM agents
13//!
14//! # Features
15//!
16//! - **HTTP Acceleration**: HTTP/2 multiplexing, TLS 1.3, Brotli/Zstd compression
17//! - **Browser Fingerprinting**: Realistic Chrome/Firefox/Safari profiles
18//! - **Authentication**: 1Password CLI integration, cookie extraction
19//! - **JavaScript**: `QuickJS` engine with minimal DOM
20//!
21//! # Example
22//!
23//! ```rust,no_run
24//! use nab::AcceleratedClient;
25//!
26//! #[tokio::main]
27//! async fn main() -> anyhow::Result<()> {
28//!     let client = AcceleratedClient::new()?;
29//!     let html = client.fetch_text("https://example.com").await?;
30//!     println!("Fetched {} bytes", html.len());
31//!     Ok(())
32//! }
33//! ```
34
35pub mod error;
36
37/// Internal implementation modules — not stable public API.
38#[doc(hidden)]
39pub mod analyze;
40/// Internal implementation modules — not stable public API.
41#[doc(hidden)]
42pub mod annotate;
43pub mod api_discovery;
44pub mod arena;
45pub mod auth;
46#[cfg(any(feature = "browser", feature = "browser-launcher"))]
47pub mod browser;
48pub mod browser_detect;
49pub mod content;
50pub mod detect;
51/// Internal implementation modules — not stable public API.
52#[doc(hidden)]
53pub mod fetch_bridge;
54pub mod fingerprint;
55pub mod form;
56pub mod http3_client;
57pub mod http_client;
58#[cfg(feature = "impersonate")]
59pub mod impersonate_client;
60/// Internal implementation modules — not stable public API.
61#[doc(hidden)]
62pub mod js_engine;
63pub mod login;
64pub mod mfa;
65pub mod plugin;
66pub mod prefetch;
67pub mod rate_limit;
68pub mod security;
69pub mod session;
70pub mod site;
71pub mod ssrf;
72pub mod stream;
73/// Task-engine schema (experimental). Feature-gated; shared by the `nab` CLI
74/// executor and the `nab-mcp` self-contained loop.
75#[cfg(feature = "task")]
76pub mod task;
77pub mod url_class;
78/// Internal implementation modules — not stable public API.
79#[doc(hidden)]
80pub mod util;
81pub mod waf;
82pub mod watch;
83pub mod webmcp;
84pub mod websocket;
85
86pub use error::NabError;
87
88pub use api_discovery::{ApiDiscovery, ApiEndpoint};
89pub use auth::{
90    CookieSource, Credential, CredentialRetriever, CredentialSource, OnePasswordAuth, OtpCode,
91    OtpRetriever, OtpSource,
92};
93#[cfg(any(feature = "browser", feature = "browser-launcher"))]
94pub use browser::open_and_wait;
95#[cfg(feature = "browser")]
96pub use browser::{BrowserLogin, Cookie};
97pub use browser_detect::{BrowserType, detect_default_browser};
98pub use fingerprint::{
99    BrowserProfile, chrome_profile, firefox_profile, random_profile, safari_profile,
100};
101pub use form::{Form, parse_field_args};
102pub use http_client::{
103    AcceleratedClient, SafeFetchConfig, SafeFetchResponse, SafeRequestOptions, TOR_PROXY_URL,
104};
105pub use http3_client::Http3Client;
106#[cfg(feature = "http3")]
107pub use http3_client::Http3Response;
108pub use login::{LoginFlow, LoginResult};
109pub use mfa::{MfaHandler, MfaResult, MfaType, NotificationConfig, detect_mfa_type};
110pub use prefetch::{EarlyHintLink, EarlyHints, PrefetchManager, extract_link_hints};
111pub use session::{MAX_SESSIONS, SessionStore, get_session_dir};
112pub use ssrf::{
113    ALLOW_PRIVATE_ENV, ALLOWLIST_ENV, DEFAULT_MAX_BODY_SIZE, DEFAULT_MAX_REDIRECTS, IpCidr,
114    SsrfPolicy, extract_mapped_ipv4, is_denied_ipv4, is_denied_ipv4_with_policy, is_denied_ipv6,
115    is_denied_ipv6_with_policy, resolve_and_validate, resolve_and_validate_with_policy,
116    validate_ip, validate_ip_with_policy, validate_redirect_target,
117    validate_redirect_target_with_policy, validate_url, validate_url_with_policy,
118};
119pub use stream::{StreamBackend, StreamInfo, StreamProvider};
120pub use watch::{AddOptions, Watch, WatchEvent, WatchId, WatchManager, WatchOptions};
121pub use webmcp::{
122    DiscoveryResult, McpManifest, McpTool, extract_link_href, parse_manifest_bytes,
123    resolve_manifest_url, well_known_url,
124};
125pub use websocket::{JsonRpcWebSocket, WebSocket, WebSocketMessage};
126
127/// Version of nab
128pub const VERSION: &str = env!("CARGO_PKG_VERSION");