Skip to main content

claw_core_protocol/
lib.rs

1//! # claw-core-protocol
2//!
3//! Async Rust client and protocol types for the **claw_core** daemon.
4//!
5//! The daemon communicates via **line-delimited JSON over a Unix socket**
6//! (default: `/tmp/trl.sock`). This crate provides:
7//!
8//! - **Protocol types** — [`RpcRequest`], [`RpcResponse`], method-specific
9//!   param/result structs (e.g. [`ExecRunParams`], [`ExecRunResult`]).
10//! - **Async client** — [`ClawCoreClient`] connects to the daemon and exposes
11//!   typed convenience methods (`create_session`, `exec_run`, `ping`, etc.).
12//!
13//! ## Quick start
14//!
15//! ```no_run
16//! use claw_core_protocol::{ClawCoreClient, CreateSessionParams, ExecRunParams};
17//!
18//! # async fn example() -> anyhow::Result<()> {
19//! let mut client = ClawCoreClient::connect("/tmp/trl.sock").await?;
20//!
21//! // Create a session
22//! let session = client.create_session(CreateSessionParams {
23//!     shell: Some("/bin/zsh".into()),
24//!     working_dir: Some("/tmp".into()),
25//!     ..Default::default()
26//! }).await?;
27//!
28//! // Run a command
29//! let result = client.exec_run(ExecRunParams {
30//!     session_id: session.session_id.clone(),
31//!     command: "echo hello from claw_core".into(),
32//!     timeout_s: Some(30),
33//!     stdin: None,
34//!     env: None,
35//! }).await?;
36//!
37//! assert!(result.exit_code == 0);
38//! println!("{}", result.stdout);
39//!
40//! // Clean up
41//! client.destroy_session(claw_core_protocol::DestroySessionParams {
42//!     session_id: session.session_id,
43//!     force: None,
44//! }).await?;
45//! # Ok(())
46//! # }
47//! ```
48//!
49//! ## With ZeroClaw
50//!
51//! ZeroClaw can use this crate via the `claw-core` feature flag:
52//!
53//! ```bash
54//! cargo install zeroclaw --features claw-core
55//! ```
56
57pub mod client;
58pub mod types;
59
60// Re-export the primary API at crate root for convenience.
61pub use client::{ClawCoreClient, DEFAULT_SOCKET_PATH};
62pub use types::*;