Skip to main content

sc_command/
lib.rs

1//! Lossless sc-ai-cli response envelope and the two server conversions.
2//!
3//! Default features export [`Envelope`], [`OpError`], and [`ErrorKind`].
4//! Feature `server` adds the HTTP response conversion and the sealed MCP
5//! conversion. That feature is off by default.
6//!
7//! The envelope contract version for values this crate creates is
8//! [`ENVELOPE_VERSION`] (`"1"`). A value read from JSON keeps the `version`
9//! string it arrived with.
10
11#![doc = include_str!("../README.md")]
12
13mod envelope;
14mod error;
15mod exact;
16
17#[cfg(feature = "server")]
18mod server;
19
20#[doc(inline)]
21pub use envelope::Envelope;
22#[doc(inline)]
23pub use error::{ErrorKind, OpError};
24
25#[cfg(feature = "server")]
26#[doc(inline)]
27pub use server::{IntoMcp, McpError};
28
29/// Envelope contract version written by constructors in this crate.
30///
31/// Deserialization keeps the version string from the input instead of
32/// replacing it with this constant.
33pub const ENVELOPE_VERSION: &str = "1";
34
35/// Stable code for an envelope whose `ok` flag disagrees with `data` or
36/// `error`, or whose object is missing a required key.
37pub const DISCRIMINANT_CODE: &str = "ENVELOPE.DISCRIMINANT";
38
39/// Stable code for a payload whose `Serialize` implementation fails.
40pub const SERIALIZATION_CODE: &str = "ENVELOPE.SERIALIZATION";
41
42/// Application-owned canonical logging injection without a logging runtime.
43pub mod observability;