causa-protocol 0.0.2

Causa — a minimal context kernel for Rust agents (facts, ports, adapters)
Documentation
//! Translation between kernel DTOs and provider-native DTOs.
//!
//! The translation layer is intentionally provider-SDK-free. It operates on
//! kernel facts and `serde_json::Value` payloads so concrete adapters can use
//! direct HTTP without leaking provider-native types into the kernel.
//!
//! `ContextFrame → provider wire body` rendering and `wire response →
//! ModelOutput` parsing for the context kernel's `ModelGateway` seam
//! (`anthropic`, `openai_chat`, `openai_responses`, sharing one policy
//! walk in `context_frame`).
//!
//! # `BlockMeta::source` vocabulary
//!
//! The kernel records `source` verbatim and never interprets it; this
//! layer is its interpreter. The vocabulary is open — unknown tags fall
//! back to the user role rather than failing, because renderers must be
//! total over frames that outlive any single vocabulary revision.
//!
//! | `BlockMeta::source`       | Rendering semantics                                    |
//! |---------------------------|--------------------------------------------------------|
//! | `None`                    | assistant — the model door never stamps `source`        |
//! | `"assistant"`             | assistant — host-prepared model turn (history replay)   |
//! | `"system"`                | system — Anthropic/Responses: top-level parameter; Chat: inline message |
//! | `"user"`                  | user role                                               |
//! | `"inject"` / `"inject:…"` | user role (rendering policy for injected context)       |
//! | anything else             | user role (documented open-vocabulary fallback)         |
//!
//! Shared structural policy (applied once in `context_frame`, so the
//! three renderers cannot drift): empty text blocks are skipped
//! (mirroring the kernel model door); adjacent same-role text blocks
//! join into one text with `\n`; tool ids come from
//! `meta.provider_call_id` with the declaration `BlockId` UUID as fallback,
//! and tool result ids resolve through their declaration block identity
//! (unpaired, duplicate, incomplete or ambiguously identified exchanges
//! fail with InvalidRequest before HTTP); non-string tool observations
//! serialize to a string. Ordered result notes render with the same tool
//! result, while remaining separate from the stored output payload.

/// The schema name rendered into OpenAI-family structured-output envelopes
/// (Chat `response_format.json_schema.name`, Responses `text.format.name`).
/// The kernel carries no schema name; this placeholder keeps the wire shape
/// complete without widening the `GenerationOptions` contract.
pub(crate) const OUTPUT_SCHEMA_NAME: &str = "response";

pub mod anthropic;
pub(crate) mod context_frame;
pub mod media;
pub mod openai_chat;
pub mod openai_responses;
pub mod sse_parser;
mod tool_history;
pub mod usage;

#[cfg(test)]
pub(crate) mod test_support;