A minimal statically-typed actor-based language for AI agents, compiled to bytecode and executed on a Rust runtime.
- Typed actors: Each agent has a typed mailbox (
Ref[MessageType]) - Message passing: Asynchronous send with Tokio channels
- Effect system: Capability-gated side effects (HTTP, logging, etc.)
- Static typing: Compile-time type checking of messages and effects
- Supervision: Automatic restart on agent crashes
- Rust 1.75+ and Cargo
# Clone the repo
git clone https://github.com/ling0x/krill.git
cd krill
# Build
cargo build --release
# Run example
cargo run --example hello// Define message types
type TicketMsg {
NewTicket { id: Int, priority: String, replyTo: Ref[Response] }
Status { replyTo: Ref[StatusResponse] }
}
type Response {
Ack { ticket_id: Int }
}
type StatusResponse {
Count { num: Int }
}
// Define an agent
agent TicketHandler {
// Initial state
state {
tickets: Int = 0
}
// Message handlers
on NewTicket { id, priority, replyTo } -> {
state.tickets = state.tickets + 1;
log("Processing ticket", id);
send replyTo Ack { ticket_id: id };
}
on Status { replyTo } -> {
send replyTo Count { num: state.tickets };
}
}
βββββββββββββββββββββββββββββββββββββββββββ
β agentc (Compiler) β
β ββββββββββββ ββββββββββββ βββββββββ β
β β Parser ββ β Type ββ β Code β β
β β (LALRPOP)β β Checker β β Gen β β
β ββββββββββββ ββββββββββββ βββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
β
Bytecode IR
β
βββββββββββββββββββββββββββββββββββββββββββ
β agentr (Runtime) β
β ββββββββββββ ββββββββββββ βββββββββ β
β β Tokio β β Actor β βEffect β β
β β Schedulerβ β Mailboxesβ βSystem β β
β ββββββββββββ ββββββββββββ βββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
agentlang/
βββ Cargo.toml # Workspace manifest
βββ agentr/ # Runtime crate
β βββ Cargo.toml
β βββ src/
β βββ lib.rs # Public API
β βββ actor.rs # Actor system
β βββ mailbox.rs # Typed mailboxes
β βββ effects.rs # Effect system
βββ agentc/ # Compiler crate
β βββ Cargo.toml
β βββ build.rs # LALRPOP build script
β βββ src/
β βββ main.rs # CLI entry point
β βββ grammar.lalrpop # Parser grammar
β βββ ast.rs # AST definitions
β βββ typechecker.rs # Type checking
β βββ bytecode.rs # Bytecode IR
β βββ interpreter.rs # Bytecode executor
βββ examples/
βββ hello.rs # Simple example
βββ ticket_system.agent # Agent source code
See examples/ directory for complete examples.
- Basic actor system
- Static type checking
- Effect system
- BDI-style goals and plans
- Distributed runtime (NATS)
- Rust code generation backend
- Hot code reload
MIT