Skip to main content

ai_lib_core/
lib.rs

1//! # ai-lib-core
2//!
3//! AI-Protocol 执行层:协议加载、客户端、流水线、传输与核心类型。策略模块见 `ai-lib-contact` / 聚合 crate `ai-lib-rust`。
4//!
5//! Execution-layer runtime for AI-Protocol (protocol, client, pipeline, transport, types).
6//!
7//! On `wasm32` targets, only protocol parsing, drivers, types, and structured helpers are built
8//! (no async client, transport, or pipeline). See PT-072 / `ai-lib-wasm`.
9
10#[cfg(not(target_arch = "wasm32"))]
11pub mod client;
12pub mod drivers;
13#[cfg(not(target_arch = "wasm32"))]
14pub mod feedback;
15#[cfg(not(target_arch = "wasm32"))]
16pub mod pipeline;
17pub mod protocol;
18#[cfg(not(target_arch = "wasm32"))]
19pub mod registry;
20pub mod structured;
21#[cfg(not(target_arch = "wasm32"))]
22pub mod transport;
23pub mod types;
24pub mod utils;
25
26#[cfg(all(not(target_arch = "wasm32"), feature = "computer_use"))]
27pub mod computer_use;
28#[cfg(all(not(target_arch = "wasm32"), feature = "embeddings"))]
29pub mod embeddings;
30#[cfg(all(not(target_arch = "wasm32"), feature = "mcp"))]
31pub mod mcp;
32#[cfg(all(not(target_arch = "wasm32"), feature = "multimodal"))]
33pub mod multimodal;
34#[cfg(all(not(target_arch = "wasm32"), feature = "reranking"))]
35pub mod rerank;
36#[cfg(all(not(target_arch = "wasm32"), feature = "stt"))]
37pub mod stt;
38#[cfg(all(not(target_arch = "wasm32"), feature = "tts"))]
39pub mod tts;
40
41#[cfg(not(target_arch = "wasm32"))]
42pub use client::CallStats;
43#[cfg(not(target_arch = "wasm32"))]
44pub use client::CancelHandle;
45#[cfg(not(target_arch = "wasm32"))]
46pub use client::ChatBatchRequest;
47#[cfg(not(target_arch = "wasm32"))]
48pub use client::ClientMetrics;
49#[cfg(not(target_arch = "wasm32"))]
50pub use client::EndpointExt;
51#[cfg(not(target_arch = "wasm32"))]
52pub use client::{AiClient, AiClientBuilder};
53
54#[cfg(not(target_arch = "wasm32"))]
55pub use feedback::{FeedbackEvent, FeedbackSink};
56pub use types::{
57    events::StreamingEvent,
58    execution_result::{ExecutionMetadata, ExecutionResult, ExecutionUsage},
59    message::{Message, MessageRole},
60    tool::ToolCall,
61};
62
63#[cfg(not(target_arch = "wasm32"))]
64use futures::Stream;
65#[cfg(not(target_arch = "wasm32"))]
66use std::pin::Pin;
67
68/// Result type alias for the library
69pub type Result<T> = std::result::Result<T, Error>;
70
71/// A specialized Result for pipeline operations
72pub type PipeResult<T> = std::result::Result<T, Error>;
73
74/// A unified pinned, boxed stream that emits `PipeResult<T>`
75#[cfg(not(target_arch = "wasm32"))]
76pub type BoxStream<'a, T> = Pin<Box<dyn Stream<Item = PipeResult<T>> + Send + 'a>>;
77
78pub mod error;
79pub mod error_code;
80pub use error::{Error, ErrorContext};
81pub use error_code::StandardErrorCode;