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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! # slop-ai
//!
//! Rust SDK for the [SLOP protocol](https://slopai.dev) — let AI observe and
//! interact with your app's state.
//!
//! ## Core types
//!
//! - [`SlopServer`] — publish state and register affordances (actions an AI can invoke)
//! - [`SlopConsumer`] — subscribe to a provider and invoke affordances *(requires `native` feature)*
//! - [`StateMirror`] — apply JSON patches and maintain a local replica of remote state
//! - [`SlopNode`], [`Affordance`], [`PatchOp`] — protocol data types
//!
//! ## Transports
//!
//! Each transport is behind a feature flag:
//!
//! | Feature | Transport | Use case |
//! |---------|-----------|----------|
//! | `websocket` | [`transport::websocket`], [`WsClientTransport`] | Browser-compatible, cross-network |
//! | `unix` | [`transport::unix`], [`UnixClientTransport`] | Fast local IPC |
//! | `stdio` | [`transport::stdio`] | CLI tools, child processes |
//! | `axum` | [`transport::axum`] | Embed in an Axum HTTP server |
//!
//! The `native` feature (on by default) enables `websocket` + `unix` + `stdio`.
//!
//! ## LLM integration
//!
//! - [`affordances_to_tools`] — convert affordances into OpenAI-compatible tool definitions
//! - [`format_tree`] — render state as Markdown for LLM context injection
//! - [`prepare_tree`] / [`auto_compact`] — scale trees to fit token budgets
//!
//! ## Quick start
//!
//! ```
//! use slop_ai::{SlopServer, ActionOptions};
//! use serde_json::json;
//!
//! let slop = SlopServer::new("my-app", "My App");
//!
//! slop.register("todos", json!({
//! "type": "collection",
//! "props": {"count": 0},
//! }));
//!
//! slop.action_with("todos", "add", |params| {
//! let text = params["text"].as_str().unwrap_or("untitled");
//! Ok(Some(json!({ "added": text })))
//! }, ActionOptions::new().label("Add todo"));
//!
//! assert_eq!(slop.version(), 2);
//! ```
//!
//! ## Documentation
//!
//! - Project docs: <https://docs.slopai.dev/api/rust>
//! - Integration guide: <https://docs.slopai.dev/guides/rust>
//! - crates.io docs: <https://docs.rs/slop-ai>
// Re-export main types at crate root
pub use ;
pub use ;
pub use ;
pub use StateMirror;
pub use ;
pub use ;
pub use ;
pub use WsClientTransport;
pub use AcceptedWsTransport;
pub use UnixClientTransport;