Skip to main content

Crate claw_core_protocol

Crate claw_core_protocol 

Source
Expand description

§claw-core-protocol

Async Rust client and protocol types for the claw_core daemon.

The daemon communicates via line-delimited JSON over a Unix socket (default: /tmp/trl.sock). This crate provides:

§Quick start

use claw_core_protocol::{ClawCoreClient, CreateSessionParams, ExecRunParams};

let mut client = ClawCoreClient::connect("/tmp/trl.sock").await?;

// Create a session
let session = client.create_session(CreateSessionParams {
    shell: Some("/bin/zsh".into()),
    working_dir: Some("/tmp".into()),
    ..Default::default()
}).await?;

// Run a command
let result = client.exec_run(ExecRunParams {
    session_id: session.session_id.clone(),
    command: "echo hello from claw_core".into(),
    timeout_s: Some(30),
    stdin: None,
    env: None,
}).await?;

assert!(result.exit_code == 0);
println!("{}", result.stdout);

// Clean up
client.destroy_session(claw_core_protocol::DestroySessionParams {
    session_id: session.session_id,
    force: None,
}).await?;

§With ZeroClaw

ZeroClaw can use this crate via the claw-core feature flag:

cargo install zeroclaw --features claw-core

Re-exports§

pub use client::ClawCoreClient;
pub use client::DEFAULT_SOCKET_PATH;
pub use types::*;

Modules§

client
types