Skip to main content

Crate kaneru

Crate kaneru 

Source
Expand description

AIngle

The Semantic Infrastructure for Intelligent Applications

Enabling enterprises to build secure, scalable, and intelligent distributed systems

Build Status License Rust

SolutionsCapabilitiesGet StartedWebsite


§Kaneru

This crate implements the Unified Multi-Agent Execution System (Kaneru) for autonomous decision-making within the AIngle framework, providing reinforcement learning capabilities for agents.

§Kaneru — Unified Multi-Agent Execution System

Autonomous AI agents framework for AIngle semantic networks.

§Overview

Kaneru provides a complete framework for building autonomous AI agents that can:

  • Observe their environment (IoT sensors, network events, user inputs)
  • Decide based on learned policies and hierarchical goals
  • Execute actions in the AIngle network
  • Learn and adapt over time using reinforcement learning

This crate is designed for use cases ranging from simple reactive agents to complex multi-agent systems with learning capabilities

§Architecture

┌─────────────────────────────────────────────────────────────┐
│                      Kaneru Agent                            │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────┐  │
│  │   Sensors    │  │   Policy     │  │    Actuators     │  │
│  │              │  │   Engine     │  │                  │  │
│  │ • IoT data   │─►│              │─►│ • Network calls  │  │
│  │ • Events     │  │ • Goals      │  │ • State changes  │  │
│  │ • Messages   │  │ • Rules      │  │ • Messages       │  │
│  └──────────────┘  │ • Learning   │  └──────────────────┘  │
│                    └──────┬───────┘                         │
│                           │                                 │
│                    ┌──────▼───────┐                         │
│                    │   Memory     │                         │
│                    │ (Titans)     │                         │
│                    │              │                         │
│                    │ STM ◄──► LTM │                         │
│                    └──────────────┘                         │
│                                                              │
└─────────────────────────────────────────────────────────────┘

§Quick Start

§Simple Reactive Agent

use kaneru::{Agent, SimpleAgent, Goal, Observation, Rule, Condition, Action};

// Create a simple reactive agent
let mut agent = SimpleAgent::new("sensor_monitor");

// Add a rule: if temperature > 30, alert
let rule = Rule::new(
    "high_temp",
    Condition::above("temperature", 30.0),
    Action::alert("Temperature too high!"),
);
agent.add_rule(rule);

// Process observations
let obs = Observation::sensor("temperature", 35.0);
agent.observe(obs.clone());
let action = agent.decide();
let result = agent.execute(action.clone());
agent.learn(&obs, &action, &result);

§Kaneru Agent with Learning

use kaneru::{KaneruAgent, KaneruConfig, Observation, Goal, Priority, Outcome};

// Create a Kaneru agent with learning, prediction, and hierarchical goals
let mut agent = KaneruAgent::with_default_config();

// Set a goal
let goal = Goal::maintain("temperature", 20.0..25.0)
    .with_priority(Priority::High);
agent.set_goal(goal);

// Agent loop with reinforcement learning
for episode in 0..100 {
    let obs = Observation::sensor("temperature", 22.0);
    let action = agent.step(obs.clone());

    // Execute action in environment and get reward
    let reward = 1.0; // Example reward
    let next_obs = Observation::sensor("temperature", 21.0);

    let outcome = Outcome::new(action, result, reward, next_obs, false);
    agent.learn(outcome);
}

§Multi-Agent Coordination

use kaneru::{AgentCoordinator, KaneruAgent, Message, Observation};
use std::collections::HashMap;

// Create coordinator
let mut coordinator = AgentCoordinator::new();

// Register agents
let agent1 = KaneruAgent::with_default_config();
let agent2 = KaneruAgent::with_default_config();

let id1 = coordinator.register_agent(agent1);
let id2 = coordinator.register_agent(agent2);

// Broadcast message
coordinator.broadcast(Message::new("update", "System status changed"));

// Step all agents
let mut observations = HashMap::new();
observations.insert(id1, Observation::sensor("temp", 20.0));
observations.insert(id2, Observation::sensor("humidity", 60.0));

let actions = coordinator.step_all(observations);

§State Persistence

use kaneru::{KaneruAgent, AgentPersistence};
use std::path::Path;

let mut agent = KaneruAgent::with_default_config();

// Train the agent...

// Save agent state
agent.save_to_file(Path::new("agent_state.json")).unwrap();

// Later, load agent state
let loaded_agent = KaneruAgent::load_from_file(Path::new("agent_state.json")).unwrap();

§Agent Types

  • ReactiveAgent: Simple stimulus-response behavior
  • GoalBasedAgent: Works toward explicit goals
  • LearningAgent: Adapts behavior over time
  • CooperativeAgent: Coordinates with other agents

Re-exports§

pub use action::Action;
pub use action::ActionResult;
pub use action::ActionType;
pub use agent::Agent;
pub use agent::AgentId;
pub use agent::AgentState;
pub use agent::SimpleAgent;
pub use config::AgentConfig;
pub use coordination::AgentCoordinator;
pub use coordination::ConsensusResult;
pub use coordination::CoordinationError;
pub use coordination::Message;
pub use coordination::MessageBus;
pub use coordination::MessageId;
pub use coordination::MessagePayload;
pub use coordination::MessagePriority;
pub use coordination::SharedMemory;
pub use error::Error;
pub use error::Result;
pub use goal::Goal;
pub use goal::GoalPriority;
pub use goal::GoalStatus;
pub use goal::GoalType;
pub use hierarchical::default_decomposition_rules;
pub use hierarchical::ConflictResolution;
pub use hierarchical::ConflictType;
pub use hierarchical::DecompositionResult;
pub use hierarchical::DecompositionRule;
pub use hierarchical::DecompositionStrategy;
pub use hierarchical::GoalConflict;
pub use hierarchical::GoalTree;
pub use hierarchical::GoalTypeFilter;
pub use hierarchical::HierarchicalGoalSolver;
pub use hierarchical::ParallelStrategy;
pub use hierarchical::SequentialStrategy;
pub use kaneru_agent::AgentStats;
pub use kaneru_agent::GoalSelectionStrategy;
pub use kaneru_agent::KaneruAgent;
pub use kaneru_agent::KaneruConfig;
pub use kaneru_agent::OperationMode;
pub use kaneru_agent::Outcome;
pub use kaneru_agent::SerializedState;
pub use learning::ActionId;
pub use learning::Experience;
pub use learning::LearningAlgorithm;
pub use learning::LearningConfig;
pub use learning::LearningEngine;
pub use learning::QValue;
pub use learning::StateActionPair;
pub use learning::StateId;
pub use observation::Observation;
pub use observation::ObservationType;
pub use observation::Sensor;
pub use persistence::AgentPersistence;
pub use persistence::CheckpointManager;
pub use persistence::LearningSnapshot;
pub use persistence::PersistenceError;
pub use persistence::PersistenceFormat;
pub use persistence::PersistenceOptions;
pub use policy::Condition;
pub use policy::Policy;
pub use policy::PolicyEngine;
pub use policy::Rule;
pub use predictive::AnomalyDetector;
pub use predictive::PredictedState;
pub use predictive::PredictiveConfig;
pub use predictive::PredictiveModel;
pub use predictive::StateEncoder;
pub use predictive::StateSnapshot;
pub use predictive::Trajectory;
pub use predictive::TransitionModel;
pub use types::*;

Modules§

action
Action types for Kaneru.
agent
The core Agent trait and a simple, concrete implementation.
config
Configuration for Kaneru.
coordination
Multi-Agent Coordination.
error
Error types for the Kaneru framework.
goal
Goal types for Kaneru.
hierarchical
Hierarchical goal decomposition and management for Kaneru agents.
kaneru_agent
The main Kaneru Agent orchestrator.
learning
Learning module for Kaneru
observation
Observation types for Kaneru.
persistence
Agent State Persistence.
policy
Policy engine for Kaneru.
predictive
Predictive modeling for state and reward prediction in Kaneru agents.
types
Core, general-purpose data types for the Kaneru framework.

Constants§

VERSION
Kaneru framework version

Functions§

create_agent
Creates a simple agent with default configuration.
create_iot_agent
Creates an IoT-optimized agent with reduced memory footprint.