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
//! # writ-client
//!
//! Official Rust SDK for the **Writ local agent** (`writ-agentd`) — the loopback
//! HTTP API on `127.0.0.1:8131` (see `sdks/DESIGN.md` and
//! `sdks/openapi/writ-agent.yaml` in the Writ repository).
//!
//! ```no_run
//! use writ_client::{WritAgent, RunOptions};
//!
//! # async fn demo() -> Result<(), writ_client::WritError> {
//! let agent = WritAgent::discover().await?; // env → ~/.writ/runtime.json → probe
//! let workflows = agent.workflows().list().await?;
//! let first = &workflows.data[0];
//! let outcome = agent
//! .workflows()
//! .run_and_wait(first.id, &RunOptions::default())
//! .await?;
//! println!("{} → {}", first.name, outcome.run.status);
//! # Ok(())
//! # }
//! ```
//!
//! ## Design notes
//! - **Async-only**, built on `reqwest`; the library itself has no tokio
//! dependency (any reqwest-compatible runtime works).
//! - Every list method returns a uniform [`Page`], whatever envelope the daemon
//! used on the wire.
//! - Errors are the three-kind model of DESIGN.md §5: [`WritError::Api`],
//! [`WritError::Connection`], [`WritError::Discovery`]. No automatic retries.
//! - Models type the stable scalar fields and keep everything else in an
//! `extra` map, so a newer daemon never breaks deserialization.
// [`WritError`] is a deliberately flat, public error enum: every non-2xx shape
// (including the cloud-tier `RateLimited`/`ApiKeyRequired`/`InsufficientCredits`
// variants) carries its parsed `body` and fields inline rather than behind a
// `Box`, so callers can match on them without indirection. That makes the enum
// wider than clippy's `result_large_err` threshold — an accepted trade-off for an
// SDK error type; boxing would only muddy the public API.
pub use Bytes;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Page;
pub use ;