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
//! Ratatui adapter for taria, the agent accessibility layer for terminal UIs.
//!
//! Embed a [`TariaLayer`] in your ratatui app and each rendered frame can also
//! publish a semantic [`taria::Snapshot`] over the taria transport (one JSON
//! message per line over a Unix domain socket on Linux and macOS, or a named
//! pipe on Windows). Agent inputs come back as [`taria::AgentInput`] values
//! your event loop handles like any other input source.
//!
//! [`taria::AgentInput::Text`] is the one that needs aiming rather than
//! handling: typed text belongs wherever your app puts typing, not in your key
//! handler, or an agent's two characters meet your bindings instead of your
//! text field. Route it to that surface yourself, and use [`text_to_keys`] to
//! lower it if the surface is made of key events.
//!
//! # Usage
//!
//! ```no_run
//! use ratatui::widgets::Paragraph;
//! use taria::{Node, Role};
//! use taria_ratatui::{InputStatus, TariaLayer, sem};
//!
//! fn main() -> std::io::Result<()> {
//! // Never fails: if the socket (a named pipe on Windows) cannot be
//! // bound, the layer is inert and the app runs exactly as it would
//! // without taria.
//! let mut layer = TariaLayer::bind_or_disabled("my-app");
//! let mut terminal = ratatui::init();
//!
//! // Each render pass: record semantics alongside drawing, then publish.
//! let rec = layer.frame();
//! terminal.draw(|frame| {
//! let widget = Paragraph::new("hello");
//! let node = Node::new("greeting", Role::Text).label("hello");
//! frame.render_widget(sem(&rec, widget, node), frame.area());
//! })?;
//! rec.publish();
//!
//! // Drain agent input alongside terminal events. Each input is acked
//! // `Delivered` as it is handed over; return `Ignored` for one you
//! // looked at and deliberately did nothing with, and the layer sends it.
//! layer.drain(|_input| {
//! // Apply to app state exactly like a keyboard event.
//! InputStatus::Delivered
//! });
//!
//! ratatui::restore();
//! // Only now the alternate screen is gone is printing safe.
//! if let Some(err) = layer.bind_error() {
//! eprintln!("taria disabled: {err}");
//! }
//! Ok(())
//! }
//! ```
pub use SnapshotTooLarge;
pub use ;
pub use ;
pub use FrameRecorder;
pub use ;
// Re-export the protocol crate so apps can depend on `taria-ratatui` alone,
// and the two ack types the layer's own signatures use, so acking an input
// needs no second import path.
pub use taria;
pub use ;