Skip to main content

Module expect_engine

Module expect_engine 

Source
Expand description

Expect engine backed by expectrl — implements goexpect-equivalent semantics.

This module provides:

  • PtyStream: a wrapper around OwnedFd that implements Read + Write + NonBlocking for use with expectrl’s Session.
  • StubProcess: a Healthcheck impl for processes managed externally (by runc/runsc) rather than spawned by expectrl.
  • ExpectCase, BatchStep, etc.: types for the LLM tool layer.

§goexpect compatibility

goexpectexpectrlOur tool
Expect(re, timeout)session.expect(Regex("..."))shell_expect
ExpectSwitchCase([]Caser)session.expect(Any::boxed(..))shell_expect_cases
ExpectBatch([]Batcher)Sequential send+expectshell_batch
Send(string)session.send(string)shell_write
SendSignal(sig)External killshell_signal
Tags: OK/Fail/Continue/NextCaseTagflow 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§

BatchStepResult
Result of a single batch step.
ExpectCase
A single case in a switch/case expect operation.
PtyStream
A stream wrapper around an OwnedFd that implements the traits expectrl needs: Read + Write + NonBlocking.
StubProcess
A stub process for use with expectrl’s Session when the actual process is managed externally (by runc/runsc).

Enums§

BatchStep
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. in template with captured groups.
extract_matches
Extract captures from expectrl’s Captures into a Vec<String>.
session_from_fd
Create an expectrl Session from a PTY controller fd.