1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! 协议规范层:负责加载、验证和管理 AI-Protocol 规范文件。
//!
//! # Protocol Specification Layer
//!
//! This module handles loading, validating, and managing AI-Protocol specifications.
//! It provides the foundation for the protocol-driven architecture where all provider
//! behaviors are defined declaratively rather than through hardcoded logic.
//!
//! ## Overview
//!
//! The protocol layer is responsible for:
//! - Loading protocol manifests from various sources (local files, URLs, GitHub)
//! - Validating manifests against the AI-Protocol JSON Schema
//! - Providing structured access to protocol configuration
//! - Managing authentication, streaming, and endpoint configurations
//!
//! ## Module Structure
//!
//! | Module | Description |
//! |--------|-------------|
//! | [`loader`] | Protocol loading from local files, remote URLs, and GitHub |
//! | [`schema`] | Protocol schema definitions and versioning |
//! | [`validator`] | Protocol validation using JSON Schema |
//! | [`manifest`] | Protocol manifest structure and operations |
//! | [`config`] | Configuration structures (streaming, auth, endpoints) |
//! | [`error`] | Protocol-specific error types |
//! | [`request`] | Unified request format for cross-provider compatibility |
//!
//! ## Example
//!
//! ```rust,no_run
//! use ai_lib_core::protocol::{ProtocolLoader, ProtocolValidator};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Load a protocol manifest
//! let loader = ProtocolLoader::new();
//! let manifest = loader.load_provider("openai").await?;
//!
//! // Validate the manifest
//! let validator = ProtocolValidator::new()?;
//! validator.validate(&manifest)?;
//!
//! println!(
//! "Protocol: {} v{}",
//! manifest.name.as_deref().unwrap_or(&manifest.id),
//! manifest.version.as_deref().unwrap_or("unknown")
//! );
//! Ok(())
//! }
//! ```
/// In-memory YAML manifest parse + validate (WASI and host; no async / remote loader).
// Re-export main types for convenient access
pub use *;
pub use ProtocolError;
pub use ProtocolLoader;
pub use ProtocolManifest;
pub use UnifiedRequest;
pub use ProtocolSchema;
pub use ;
pub use ProtocolValidator;
pub use load_manifest_validated;