Expand description
§agentproc
Rust SDK for the AgentProc protocol — connect any agent CLI to a messaging platform via a process-based interface.
The SDK is the Rust sibling of the Python and Node SDKs, implementing the
same wire protocol (0.4) and the same in-process executor mechanism
(profile executor: field). One profile can run three ways depending on
what the host has installed: Rust executor (in-process), Node executor
(in-process), or a Python bridge script (spawn) — all producing the same
observable NDJSON.
§Quick start
use agentproc::{run, Profile, RunOptions};
let profile = Profile::from_path("profile.yaml")?;
let result = run(&profile, RunOptions::new("hello")).await?;
println!("{}", result.reply);See spec/protocol.md in the agentproc repository for the protocol
specification, including the in-process executor contract.
Re-exports§
pub use executors::executor_names;pub use executors::Executor;pub use executors::ParseResult;pub use executors::TurnHandlers;pub use executors::UnknownExecutor;
Modules§
Structs§
- Attachment
- One element of the turn object’s
attachmentsarray. - Permission
Request - A tool-permission request emitted by the agent (only when
permission: true). - Permission
Response - A permission response the bridge writes to the agent’s stdin as one NDJSON
line (only when
permission: true). - Profile
- Normalised profile — the result of parsing a YAML file or building one
programmatically. Field names mirror the wire-level profile schema in
spec/protocol.md. - Protocol
Error - Raised by an agent when it wants to signal a protocol-level error to the
bridge (emitted as
{"type":"error"}on stdout). MirrorsProtocolErrorin the Python / Node SDKs. - RunOptions
- Callbacks and inputs for a single
runcall. - RunResult
- The outcome of a run.
- Subst
Ctx - Placeholder context.
- Turn
Input - The turn object as read by an agent from its stdin (deserialized).
- Turn
Object - The turn object the bridge writes to the agent’s stdin as a single NDJSON line before the process reads its first byte.
Enums§
- Agent
Event - A parsed stdout event from the agent.
- Partial
Role - Distinguish assistant output from reasoning/thinking text on
partialevents. - Permission
Behavior - Permission
Decision - The decision returned by
on_permission: allow (optionally with an updated tool input) or deny (with a reason). - Placeholder
Error - Error returned by
substitutewhen a placeholder value contains bytes that would be unsafe in a shell-style wrapper. - Runner
Error - Runner / profile / executor errors. All SDK fallible APIs return this.
Constants§
- PROTOCOL_
VERSION - Wire-protocol version string carried in the turn object. Opaque and non-comparable per the spec — agents MUST NOT order or range-check it.
Functions§
- build_
base_ env - Build the base child environment: infra set copied from
parent. - expand_
env_ ref - Expand
${VAR}references invalueagainstenv. Unknown variables expand to the empty string (POSIX-shell semantics). - expand_
env_ ref_ with_ allowlist - Expand
${VAR}with an optional allowlist. WhenallowlistisSome, references to names not in the list expand to empty andon_blockedis called with a warning message. - parse_
event - Parse one stdout line into a typed
AgentEvent. - protocol_
error - Construct a
ProtocolError— convenience for agent handlers. - read_
turn - Read exactly one NDJSON line (the turn object) from any reader.
- run
- Run a profile for one turn. Resolves the four-case executor rule:
- substitute
- Substitute
{{PLACEHOLDER}}tokens in a string. Supported tokens:{{MESSAGE}},{{SESSION_ID}},{{SESSION_NAME}},{{PROFILE_DIR}}.
Type Aliases§
- Permission
Future - Alias for an async permission decision callback’s return type.