Skip to main content

causa_kernel/
lib.rs

1//! causa-kernel — ContextBlock conversation kernel.
2//! No dependency on a host application, a UI shell, or another agent framework.
3//!
4//! The kernel holds ordered material and atomic identity-preserving edits, plus
5//! third-party model, preparation, tool and cancellation contracts. It performs
6//! no I/O, execution policy or conversation management. Reference execution
7//! lives in causa-runtime; concrete transports live in edge crates.
8//! [`GenerationOptions`] describes requested generation settings; hosts own
9//! model capability selection and persisted definitions.
10
11#![deny(unsafe_code)]
12#![deny(missing_docs)]
13
14mod context;
15mod ports;
16
17// --- context: the external rule interface ------------------------------------
18pub use context::block::{
19    BlockContent, BlockMeta, ContentPart, ContextBlock, MediaRef, SealedPart, TextPayload,
20    ToolCallPayload, WireMeta,
21};
22pub use context::ids::{BlockId, InvocationId, RoundId, TurnId};
23pub use context::material::{
24    Context, ContextEdit, ContextFrame, EditError, EditFailure, Replacement, ToolResultError,
25    validate_tool_result_append,
26};
27pub use context::model::{
28    ModelBlockError, ModelItem, ModelItemContent, ModelResponse, ModelStopReason, ToolCallDraft,
29};
30pub use context::tool_data::{
31    ArtifactKind, ArtifactRef, ToolCallId, ToolOutput, ToolOutputMeta, ToolResultPayload,
32    ToolResultStatus, Truncation,
33};
34
35// --- ports: behavior seams for external implementors ------------------------
36pub use ports::batch::{
37    BatchError, ProcessorContext, ProcessorError, RejectedToolResult, ToolBatch,
38    ToolBatchProcessor, ToolCallEntry,
39};
40pub use ports::control::{CallControl, ControlError};
41pub use ports::gateway::{
42    CacheDirective, GenerationOptions, ModelGateway, ModelInvokeError, ModelInvokeErrorKind,
43    ModelOutput, ModelRef, ModelRequest, ModelStream, ModelUsage, ReasoningPayload, StreamDelta,
44    completed_model_stream,
45};
46pub use ports::prepare::{ContextPreparer, PrepareError, RoundInfo};
47pub use ports::source::{DynamicToolSource, SourceError, ToolExecutionError};
48pub use ports::tool::{
49    ArtifactHint, ArtifactStore, StoreError, Tool, ToolCallContext, ToolDefinition, ToolSurface,
50};
51/// The cancellation primitive behind the control planes, re-exported so the
52/// port is self-contained for external drivers.
53pub use tokio_util::sync::CancellationToken;