OpenPay (1 crate, 2174 LOC, 14 tests)
op-payouts Multi-rail payout engine. Visa Direct, Mastercard Send,
ACH credits (NACHA), Fedwire + SWIFT MT103 + ISO 20022
pacs.008, SEPA SCT + SCT Inst (mod-97 IBAN), UK FPS,
FedNow, RTP, PayPal, Wise. Crypto: USDC/USDT on
ETH/Polygon/Base/Solana + BTC + Lightning with real
ERC-20 transfer(address,uint256) calldata. Offline-pure
drivers (emit wire payloads — operators transmit).
Smart Byte (1 crate, 2605 LOC, 38 tests)
smart-byte-nostr Nostr adapter. NIP-01 canonical event id + BIP-340
Schnorr sign/verify; from-scratch bech32 + NIP-19 TLV
(npub/nsec/note/nprofile/nevent/nrelay); NIP-04 legacy
AES-256-CBC DMs; NIP-44 v2 HKDF-SHA256→ChaCha20+HMAC
with bucketed padding; NIP-17 gift-wrap (kind 1059) +
seal (kind 13) + rumor (kind 14); NIP-05/11/13/26/65.
Relay client message vocabulary (REQ/EVENT/CLOSE/AUTH/
EOSE/OK/NOTICE/CLOSED) + in-memory router.
EOC (1 crate, 2024 LOC, 30 tests)
eoc-streaming Token-by-token + tool-call streaming primitives.
SSE framing (data: lines); Anthropic event mapper
(message_start/content_block_*/message_delta/stop/ping);
OpenAI delta mapper; Vercel AI SDK mapper. Bounded-channel
backpressure with watermarks; CancelToken propagation;
Last-Event-ID resumable streams; per-stream joule meter.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
52 lines
1.9 KiB
Rust
52 lines
1.9 KiB
Rust
//! EOC — streaming inference primitives.
|
|
//!
|
|
//! Provider streaming has settled on a handful of patterns: line-oriented
|
|
//! SSE (`data: ...\n\n`), Anthropic's typed `event:` / `data:` pairs,
|
|
//! OpenAI's `chat.completion.chunk` deltas, the Vercel AI SDK protocol
|
|
//! (text-delta / tool-call / tool-result / finish), and WebSocket frames
|
|
//! carrying the same payloads. This crate normalizes all of those into a
|
|
//! single [`Event`] enum and a single [`TokenStream`] sink so the rest of
|
|
//! the EOC stack (cascade, agent, vendor-api) can treat streams as a
|
|
//! first-class resource with:
|
|
//!
|
|
//! * **Backpressure** via bounded channels with high/low watermarks
|
|
//! ([`backpressure`]).
|
|
//! * **Cancellation** propagated from client disconnects to upstream
|
|
//! providers ([`cancel`]).
|
|
//! * **Resumable streams** keyed on `Last-Event-ID` ([`resume`]).
|
|
//! * **Per-stream joule accounting** anchored on [`eoc_meter`]
|
|
//! ([`account`]).
|
|
//!
|
|
//! ## Discipline
|
|
//!
|
|
//! `#![forbid(unsafe_code)]`. No `.unwrap()` outside `#[cfg(test)]`. The
|
|
//! crate is `serde`-typed end-to-end; transport bindings (HTTP server,
|
|
//! WebSocket library) are intentionally **out of scope** so the same
|
|
//! primitives can ride on whatever runtime the host picks.
|
|
|
|
#![forbid(unsafe_code)]
|
|
#![warn(missing_docs)]
|
|
|
|
pub mod account;
|
|
pub mod anthropic;
|
|
pub mod backpressure;
|
|
pub mod cancel;
|
|
pub mod error;
|
|
pub mod openai;
|
|
pub mod resume;
|
|
pub mod sse;
|
|
pub mod stream;
|
|
pub mod vercel_ai;
|
|
pub mod ws;
|
|
|
|
pub use account::{StreamAccount, StreamMeter};
|
|
pub use anthropic::AnthropicMapper;
|
|
pub use backpressure::{BoundedStream, Watermarks};
|
|
pub use cancel::CancelToken;
|
|
pub use error::{StreamError, StreamResult};
|
|
pub use openai::OpenAiMapper;
|
|
pub use resume::{EventLog, LastEventId};
|
|
pub use sse::{SseEvent, SseParser};
|
|
pub use stream::{Event, FinishReason, Role, Sink, TokenStream};
|
|
pub use vercel_ai::VercelAiMapper;
|
|
pub use ws::{WsFrame, WsOpcode};
|