# ryo-server

[![crates.io](https://img.shields.io/crates/v/ryo-server.svg)](https://crates.io/crates/ryo-server)
[![docs.rs](https://docs.rs/ryo-server/badge.svg)](https://docs.rs/ryo-server)
[![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](#license)

> **Status:** preview. APIs may change in v0.x.
> Part of the [ryo](https://github.com/ynishi/ryo-rs) workspace —
> AST-centric Rust programming for AI agents.

ryo Server — tarpc-based RPC server. Wraps [`ryo-app`](https://crates.io/crates/ryo-app)'s
`Api` and exposes it over Unix Domain Socket using `tarpc` with named
MessagePack serialisation. Idle-timeout auto-shutdown, optional parallel
initialisation, single-mutex locking.

## Install

```sh
cargo add ryo-server
```

## Quickstart

The server is typically started by the `ryo-cli` `connect-or-spawn` pattern,
but it can be embedded directly:

```rust,ignore
use ryo_server::RyoServer;
use ryo_app::Api;
use std::sync::{Arc, Mutex};

let api = Arc::new(Mutex::new(Api::new(storage)));
let server = RyoServer::new(api, &config);
server.serve_on_uds("/tmp/ryo.sock").await?;
```

## Configuration

`~/.ryo/config.toml`:

```toml
[server]
idle_timeout = 3600    # seconds; 0 = never timeout
parallel_init = true   # parallel project loading on startup
```

## Architecture

```text
RyoServer
├── api: Arc<Mutex<Api>>           single mutex for all operations
├── shutdown_tx: Shutdown sender
└── last_activity: Atomic timestamp

  ↓ UDS + tarpc (serde_transport, MessagePack named)

Clients (ryo-cli)
└── RyoServiceClient
```

## Status

**Preview.** RPC surface and codec format are likely to evolve.

## License

Licensed under either of [Apache-2.0](https://github.com/ynishi/ryo-rs/blob/main/LICENSE-APACHE)
or [MIT](https://github.com/ynishi/ryo-rs/blob/main/LICENSE-MIT) at your option.
