agent-cli is a Rust library (with an optional CLI) implementing the Agent Life Cycle framework, inspired by the sandy-mount/sandymount Wiki. It provides a modular and reusable implementation for managing intelligent, autonomous software agents through their lifecycle phases: Create, Add Skills, Configure, Run, and Shutdown.
-
Library Crate: Core logic in
src/lib.rs
for creating and managing agents through lifecycle phases. -
Optional CLI: Binary in
src/main.rs
(if included) allows running commands likeagent create my-agent
. -
Lifecycle Phases:
- Create: Initialize an agent with a unique ID and name.
- Add Skills: Add capabilities (e.g.,
"memory"
,"web-access"
) to the agent. - Configure: Set key-value configurations (e.g., goals, permissions).
- Run: Start the agent, displaying its skills and configuration.
- Shutdown: Save agent state to a JSON file and decommission the agent.
-
Testing: Comprehensive unit tests for all lifecycle phases.
- Rust (latest stable version, e.g., via
rustup
) - Cargo (included with Rust)
Clone or create the project:
git clone https://github.com/AI-Robotic-Labs/ai-agent-cli.git
cd agent-cli
OR create a new project:
cargo new agent-cli
cd agent-cli
Ensure your Cargo.toml
includes:
[package]
name = "agent-cli"
version = "0.1.0"
edition = "2021"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rand = "0.8"
- Place the library code in
src/lib.rs
(see Project Structure). - (Optional) Add
src/main.rs
for CLI functionality.
cargo build
The core functionality is in src/lib.rs
, which defines the AgentCLI
struct and its lifecycle methods. Use it in another Rust project by adding agent-cli
as a dependency in your Cargo.toml
:
[dependencies]
agent-cli = { path = "/path/to/agent-cli" }
Example usage:
use agent_cli::AgentCLI;
fn main() {
let mut cli = AgentCLI::new();
cli.create("my-agent").unwrap();
cli.add_skill("memory").unwrap();
cli.configure("goal", "assist user").unwrap();
cli.run().unwrap();
cli.shutdown().unwrap();
}
If src/main.rs
is included, you can run commands like:
cargo run -- create my-agent
cargo run -- skill add memory
cargo run -- skill add web-access
cargo run -- config goal "assist user"
cargo run -- run
cargo run -- shutdown
Example Output:
Created agent: my-agent (ID: agent-<random_number>)
Added skill 'memory' to agent my-agent
Added skill 'web-access' to agent my-agent
Configured goal = assist user for agent my-agent
Running agent my-agent (ID: agent-<random_number>)
Active skills: ["memory", "web-access"]
Configuration: {"goal": "assist user"}
Agent shutdown and state saved
The shutdown
command saves the agent state to a JSON file (e.g., agent-<random_number>.json
).
Run unit tests in src/lib.rs
:
cargo test
Example Output:
running 5 tests
test tests::test_create_agent ... ok
test tests::test_add_skill ... ok
test tests::test_configure ... ok
test tests::test_run ... ok
test tests::test_shutdown ... ok
test result: ok. 5 passed; 0 failed
agent-cli/
├── Cargo.toml
└── src/
├── lib.rs # Core library with AgentCLI and lifecycle logic
└── main.rs # Optional CLI binary (add for CLI usage)
- Report issues or suggest features via GitHub Issues.
- Submit pull requests with improvements or additional lifecycle phases (e.g., Scale, Monitor).
MIT License. See LICENSE for details.
- Inspired by the Agent Life Cycle from sandy-mount/sandymount.
- Built with Rust for modularity and safety.