Skip to main content

Crate execkit

Crate execkit 

Source
Expand description

§execkit

Stateful, structured, safe shell sessions for AI agents on real infrastructure. The agent driving execkit can be prompt-injected, so the library’s job is to contain its own caller: every command passes a policy fence, output is redacted of secrets, and results are recorded.

Sessions persist state (cwd, env) across commands and run over a local PTY, SSH, or Docker (Session::local / Session::ssh / Session::docker), returning a structured ExecResult checked by an advisory Policy, with secret redaction, bounded output, and an append-only audit log. Remote sessions also support git-backed workspace checkpoints - a filesystem “undo” for an agent’s changes (Session::checkpoint / Session::restore). An MCP server (execkit-mcp) exposes the same sessions to MCP agents.

use execkit::Session;
let mut s = Session::local()?;
let r = s.exec("echo hello")?;
assert_eq!(r.stdout, "hello");
assert_eq!(r.exit_code, 0);

Re-exports§

pub use budget::Budget;
pub use budget::BudgetReport;
pub use budget::Grep;
pub use budget::Keep;
pub use budget::StreamReport;
pub use checkpoint::Checkpoint;
pub use checkpoint::CheckpointId;
pub use checkpoint::RestoreReport;
pub use transport::ssh::HostKeyVerification;
pub use transport::ssh::SshAuth;
pub use transport::ssh::SshConfig;

Modules§

budget
Output budgets: per-stream shaping of command output so huge logs do not blow an agent’s context window. Pure logic - the pipeline (grep -> line-keep -> char-cap) operates on already ANSI-stripped, secret-redacted text and is applied independently to stdout and stderr by Session.
checkpoint
Remote workspace checkpoints: git-backed “undo” for an agent’s file changes.
transport
Transports - how a session reaches an environment.

Structs§

AuditLog
Records every command result as one JSON object per line.
ExecResult
The structured result of running one command - the agent-facing contract.
Policy
Default-deny-capable allow/deny fence over command program names.
Session
A live, stateful shell session.
ShellState
A snapshot of shell state carried alongside results.

Enums§

Error
Errors returned by execkit.

Functions§

strip_ansi
Strip ANSI/VT escapes (CSI, OSC, simple two-char ESC).

Type Aliases§

Result