Skip to main content

Crate ai6_terminal_pty

Crate ai6_terminal_pty 

Source
Expand description

ai6-terminal-pty: the pty terminal provider, on portable-pty, which is openpty on Unix and ConPTY on Windows. The run logic is shared; what differs per platform (owning the child’s process tree, the terminal’s mode, translating input) is in unix.rs and windows.rs behind one os interface.

Output is read on a thread into a channel, so read can time out: a blocking master read is not reliably interrupted by killing the child. The child’s exit is asked of the child itself, never inferred from EOF, because a pseudo-console can stay readable after its program has exited. For the same reason the end of the output is not left to the master: once the child has exited and nothing more has arrived for 200 ms, read reports it.

On Windows the reading thread also removes cursor position queries (ESC[6n) from the output, and another thread answers them, so the reader never waits on the writer. ConPTY sends one before its program’s first output and holds that output until it is answered (portable-pty creates every pseudo-console with PSEUDOCONSOLE_INHERIT_CURSOR), and nothing else is there to answer it. On Unix queries pass through, for whoever reads.

§ai6-terminal-pty

Version Rust version License: MPL-2.0 Docs CI

The pty terminal provider for AI6, on portable-pty: one provider for openpty on Unix and ConPTY on Windows. The run code is shared; the platform parts (owning the child’s process tree, translating input) live in unix.rs and windows.rs. See the API header.

§Features

  • Interactive pseudo-terminal Runs for agent harnesses, with resize and bounded reads.
  • On Unix, no line editing or echo: an input line of any length reaches the harness whole.
  • Kills the whole process tree: the process group and the processes found by parent from it on Unix, a Job Object on Windows.
  • Builds as both a Rust library and the Guatiao provider library a Station loads.
  • Its read size, waits and process-tree scans are config keys ([providers.pty]), listed in the API header.

§Installation

Part of the AI6 workspace; built with it:

cargo build -p ai6 --features cli -p ai6-terminal-pty

§Quick start

cargo run -p ai6 --features cli -- serve --plugin-path target/debug

§Development

cargo test -p ai6-terminal-pty
cargo clippy -p ai6-terminal-pty --all-targets -- -D warnings

§License

MPL-2.0. See LICENSE.

Structs§

Pty
Starts programs on a pseudo-terminal.
PtyConfig
pty provider configuration; every field has a default.

Statics§

guatiao_declares
What this library declares, read by a scanner as data.

Functions§

guatiao_library_entry⚠
The symbol a guatiao host loads this library by.