| Crates.io | repl-core |
| lib.rs | repl-core |
| version | 0.6.1 |
| created_at | 2025-11-17 01:16:58.421606+00 |
| updated_at | 2025-11-17 06:40:42.6349+00 |
| description | Core REPL engine for the Symbi platform |
| homepage | |
| repository | https://github.com/thirdkeyai/symbiont |
| max_upload_size | |
| id | 1936101 |
| size | 346,651 |
Core REPL engine for the Symbiont agent framework. Provides DSL evaluation, agent lifecycle management, and execution monitoring capabilities.
repl-core/
├── src/
│ ├── dsl/ # DSL implementation
│ │ ├── ast.rs # Abstract syntax tree definitions
│ │ ├── lexer.rs # Lexical analysis
│ │ ├── parser.rs # Parser implementation
│ │ ├── evaluator.rs # DSL evaluator with runtime integration
│ │ └── mod.rs # DSL module exports
│ ├── execution_monitor.rs # Execution monitoring and tracing
│ ├── eval.rs # REPL evaluation engine
│ ├── error.rs # Error handling
│ ├── runtime_bridge.rs # Runtime system integration
│ ├── session.rs # Session management
│ └── lib.rs # Library exports
└── tests/
└── golden.rs # Golden tests for parser
use repl_core::{ReplEngine, RuntimeBridge};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create runtime bridge
let runtime_bridge = Arc::new(RuntimeBridge::new());
// Create REPL engine
let engine = ReplEngine::new(runtime_bridge);
// Evaluate DSL code
let result = engine.evaluate(r#"
agent TestAgent {
name: "Test Agent"
version: "1.0.0"
}
"#).await?;
println!("Result: {}", result);
Ok(())
}
The AST module defines the structure of parsed DSL programs:
The lexer converts source text into tokens:
agent, behavior, function, let, if, etc.)30s, 100MB)The parser builds an AST from tokens using recursive descent parsing:
The evaluator executes parsed DSL programs:
print, len, upper, lower, format| Function | Description | Example |
|---|---|---|
print(...) |
Print values to output | print("Hello", name) |
len(value) |
Get length of string, list, or map | len("hello") → 5 |
upper(string) |
Convert string to uppercase | upper("hello") → "HELLO" |
lower(string) |
Convert string to lowercase | lower("HELLO") → "hello" |
format(template, ...) |
Format string with arguments | format("Hello, {}!", name) |
The execution monitor provides comprehensive tracking:
use repl_core::ExecutionMonitor;
let monitor = ExecutionMonitor::new();
// Get execution statistics
let stats = monitor.get_stats();
println!("Total executions: {}", stats.total_executions);
println!("Success rate: {:.1}%",
(stats.successful_executions as f64 / stats.total_executions as f64) * 100.0);
// Get recent traces
let traces = monitor.get_traces(Some(10));
for trace in traces {
println!("{} - {:?}", trace.timestamp, trace.event_type);
}
AgentCreated - Agent instance createdAgentStarted - Agent started executionAgentPaused - Agent pausedAgentResumed - Agent resumed from pauseAgentDestroyed - Agent destroyedBehaviorExecuted - Agent behavior executedExecutionStarted - Function execution startedExecutionCompleted - Function execution completedThe REPL core integrates with the Symbiont runtime for security:
// Capability checking
if !evaluator.check_capability("filesystem").await? {
return Err(ReplError::Security("Missing filesystem capability".to_string()));
}
// Policy enforcement
let decision = runtime_bridge.check_capability(agent_id, &capability).await?;
match decision {
PolicyDecision::Allow => {
// Proceed with operation
}
PolicyDecision::Deny => {
return Err(ReplError::Security("Access denied".to_string()));
}
}
The ReplError enum covers all error conditions:
pub enum ReplError {
Parsing(String), // Parser errors
Lexing(String), // Lexer errors
Evaluation(String), // Evaluation errors
Execution(String), // Execution errors
Security(String), // Security violations
Runtime(String), // Runtime bridge errors
Io(std::io::Error), // I/O errors
Serde(serde_json::Error), // Serialization errors
}
Run the test suite:
# Run all tests
cargo test
# Run specific test categories
cargo test dsl::lexer::tests # Lexer tests
cargo test dsl::parser::tests # Parser tests
cargo test dsl::evaluator::tests # Evaluator tests
cargo test execution_monitor::tests # Monitor tests
# Run golden tests
cargo test --test golden
tokio - Async runtimeserde - Serialization frameworkserde_json - JSON supportuuid - UUID generationchrono - Date/time handlingtracing - Structured loggingsymbi-runtime - Runtime system integrationrepl-cli - CLI interface and JSON-RPC serverrepl-proto - Protocol definitionsrepl-lsp - Language Server Protocol implementation