Skip to main content

nanocodex_agent/
lib.rs

1#![doc = include_str!("../README.md")]
2#![deny(missing_docs, rustdoc::broken_intra_doc_links)]
3#![cfg_attr(docsrs, feature(doc_cfg))]
4
5#[cfg(all(target_family = "wasm", not(target_os = "unknown")))]
6compile_error!(
7    "nanocodex-agent supports browser/JavaScript WebAssembly \
8     (`wasm32-unknown-unknown`), not WASI targets"
9);
10
11extern crate self as nanocodex_agent;
12
13mod agent;
14mod error;
15mod model;
16mod prompt_cache;
17#[cfg(not(target_family = "wasm"))]
18#[cfg_attr(docsrs, doc(cfg(not(target_family = "wasm"))))]
19/// Codex-compatible durable rollout recording and restoration.
20pub mod rollout;
21/// Durable agent session identities and snapshots.
22pub mod session;
23/// Per-turn token accounting and USD estimates.
24pub mod usage;
25
26pub use agent::{AgentHandle, Nanocodex, NanocodexBuilder, Turn, TurnControl, TurnResult};
27pub use error::{NanocodexError, Result};
28pub use nanocodex_oai_api::{
29    OpenAi, ReasoningMode, ResponseError, ResponseErrorKind, Thinking, events::AgentEvents,
30};
31#[cfg(not(target_family = "wasm"))]
32#[cfg_attr(docsrs, doc(cfg(not(target_family = "wasm"))))]
33pub use nanocodex_tools::tool;
34pub use nanocodex_tools::{Tool, Tools};
35pub use usage::{CostStatus, EstimatedUsdCost, ServiceTier, TurnUsage, UsdAmount};
36
37/// Complete typed lifecycle events emitted by an agent.
38pub mod events {
39    pub use nanocodex_oai_api::events::{
40        AgentEvent, AgentEventData, AgentEventKind, AgentEventTiming, AgentEvents, AssistantDelta,
41        AssistantEvent, AssistantMessage, CompactionCompleted, CompactionFailed, CompactionStarted,
42        ContextEvent, EventUsage, ModelCallCompleted, ModelCallFailed, ModelCallStarted,
43        ModelEvent, ModelWarmupCompleted, ModelWarmupFailed, ModelWarmupStarted, OpenAiEvent,
44        ReasoningEvent, ReasoningSummaryDelta, RunError, RunEvent, RunMetrics, RunStarted,
45        RunStatus, RunSteered, RunTerminal, TimedAgentEvent, ToolCall, ToolEvent, ToolResultEvent,
46        ToolStatus, TransportEvent, monotonic_now_ns,
47    };
48    pub use nanocodex_oai_api::responses::AgentMessageContent;
49}
50
51/// Prompts and multimodal user input accepted by the agent.
52pub mod input {
53    pub use nanocodex_oai_api::{
54        ImageDetail, Prompt, PromptInput, UserInput,
55        responses::{AgentMessageContent, ContentItem},
56    };
57}
58
59/// Advanced Responses transport and Tower service configuration.
60#[cfg(not(target_family = "wasm"))]
61#[cfg_attr(docsrs, doc(cfg(not(target_family = "wasm"))))]
62pub mod transport {
63    pub use crate::error::ResponsesError;
64    pub use nanocodex_oai_api::{
65        responses::RequestProfile,
66        tower::{
67            DefaultResponsesService, ResponsesAttempt, ResponsesAttemptKind, ResponsesClient,
68            ResponsesRetryPolicy, ResponsesServiceError, ResponsesServiceResponse,
69        },
70        transport::{ResponsesHistory, ResponsesTransport},
71    };
72}
73
74/// Complete tool contracts, registry, built-ins, Code Mode, and MCP.
75pub mod tools {
76    #[doc(inline)]
77    pub use nanocodex_tools::*;
78}
79
80#[cfg(not(target_family = "wasm"))]
81#[doc(hidden)]
82pub mod __private {
83    pub use nanocodex_tools::__private::*;
84}