Expand description
Expect engine backed by expectrl — implements goexpect-equivalent semantics.
This module provides:
PtyStream: a wrapper aroundOwnedFdthat implementsRead + Write + NonBlockingfor use with expectrl’sSession.StubProcess: aHealthcheckimpl for processes managed externally (by runc/runsc) rather than spawned by expectrl.ExpectCase,BatchStep, etc.: types for the LLM tool layer.
§goexpect compatibility
| goexpect | expectrl | Our tool |
|---|---|---|
Expect(re, timeout) | session.expect(Regex("...")) | shell_expect |
ExpectSwitchCase([]Caser) | session.expect(Any::boxed(..)) | shell_expect_cases |
ExpectBatch([]Batcher) | Sequential send+expect | shell_batch |
Send(string) | session.send(string) | shell_write |
SendSignal(sig) | External kill | shell_signal |
| Tags: OK/Fail/Continue/Next | CaseTag | flow control |
§macOS compatibility
expectrl handles platform differences internally. On macOS it uses
posix_openpt / grantpt / unlockpt for PTY allocation and
fcntl(O_NONBLOCK) for non-blocking I/O — no Linux-specific APIs needed
in this module.
Structs§
- Batch
Step Result - Result of a single batch step.
- Expect
Case - A single case in a switch/case expect operation.
- PtyStream
- A stream wrapper around an
OwnedFdthat implements the traits expectrl needs:Read + Write + NonBlocking. - Stub
Process - A stub process for use with expectrl’s
Sessionwhen the actual process is managed externally (by runc/runsc).
Enums§
- Batch
Step - A single step in a batch sequence.
- CaseTag
- Flow control tag for expect cases (maps to goexpect’s
Tag).
Functions§
- expand_
captures - Substitute
$1,$2, etc. intemplatewith captured groups. - extract_
matches - Extract captures from expectrl’s
Capturesinto aVec<String>. - session_
from_ fd - Create an expectrl
Sessionfrom a PTY controller fd.