This document provides detailed information about the implementation of the Anarchy Agent project components. All components have been implemented using the Anarchy-Inference language, following its symbolic syntax and design principles.
File: string_dictionary.json
The string dictionary centralizes all strings used throughout the application, following Anarchy-Inference's minimalist design philosophy. This approach:
- Reduces token usage for LLMs
- Makes the codebase more maintainable
- Allows for easier localization
- Provides consistent messaging across the application
The dictionary includes strings for:
- Initialization and status messages
- Error messages
- User interface text
- Operation descriptions
- Common responses
File: sandbox.a.i
The Sandbox module provides a secure execution environment for Anarchy-Inference code. Key features:
- Permission System: Controls access to sensitive operations
- Resource Limits: Prevents excessive resource usage
- Symbol Registration: Manages available operations
- Secure Execution: Safely runs parsed Anarchy-Inference code
- Error Handling: Captures and reports execution errors
The sandbox is the core security component, ensuring that Anarchy-Inference code cannot perform unauthorized operations.
File: parser.a.i
The Parser module transforms Anarchy-Inference code into an Abstract Syntax Tree (AST) for execution. Key features:
- Tokenization: Breaks code into tokens
- AST Generation: Builds a structured representation of the code
- Syntax Validation: Ensures code follows Anarchy-Inference syntax
- Error Detection: Identifies and reports syntax errors
- Unicode Support: Handles Anarchy-Inference's symbolic syntax
The parser supports all Anarchy-Inference language features, including its unique symbolic operators.
File: file.a.i
The File System module provides secure file operations. Key features:
- Directory Listing: Lists contents of directories
- File Reading/Writing: Reads from and writes to files
- File/Directory Removal: Safely removes files and directories
- File Copying/Moving: Copies and moves files
- Path Validation: Prevents access to sensitive directories
- Error Handling: Reports file operation errors
All operations include security checks to prevent unauthorized access to sensitive files.
File: shell.a.i
The Shell module enables secure command execution. Key features:
- Command Execution: Runs shell commands
- Output Capturing: Captures command output
- OS Information: Retrieves system information
- Environment Variables: Accesses environment variables
- Security Validation: Prevents dangerous commands
- Error Handling: Reports command execution errors
The module includes extensive security checks to prevent execution of dangerous commands.
File: network.a.i
The Network module provides HTTP request functionality. Key features:
- HTTP GET: Performs GET requests
- HTTP POST: Performs POST requests with data
- URL Validation: Prevents access to internal networks
- Response Handling: Processes HTTP responses
- JSON Parsing: Parses JSON responses
- Error Handling: Reports network operation errors
All network operations include security validation to prevent access to internal networks.
File: db.a.i
The Database module provides persistent storage. Key features:
- Key-Value Storage: Stores and retrieves values by key
- Execution History: Records task execution history
- Relevance Queries: Finds relevant past executions
- Persistence: Saves data to disk
- Error Handling: Reports database operation errors
The database provides both simple key-value storage and more complex query capabilities.
File: llm.a.i
The LLM Engine enables interaction with language models. Key features:
- Model Loading: Loads language models from files
- Prompt Generation: Creates effective prompts
- Response Generation: Generates responses from prompts
- Context Management: Maintains conversation context
- Fallback Generation: Provides basic functionality when no model is loaded
- Error Handling: Reports LLM operation errors
The LLM Engine is designed to work with local quantized models for offline operation.
File: browser.a.i
The Browser module enables web automation. Key features:
- Page Navigation: Opens web pages
- Element Interaction: Clicks on elements and inputs text
- Content Extraction: Gets text from elements
- JavaScript Execution: Runs JavaScript in the browser
- Screenshot Capture: Takes screenshots of pages
- URL Validation: Prevents access to internal networks
- Error Handling: Reports browser operation errors
The browser implementation replaces the previous placeholder code with functional automation.
File: integration.a.i
The Integration module connects all components. Key features:
- Component Initialization: Initializes all components
- Symbol Registration: Registers all symbols with the sandbox
- Code Execution: Executes Anarchy-Inference code
- Task Execution: Generates and executes code for tasks
- Component Access: Provides access to individual components
- Shutdown: Properly shuts down all components
The integration module serves as the main entry point for the Anarchy Agent.
The following symbols are registered for use in Anarchy-Inference code:
| Symbol | Operation | Component |
|---|---|---|
| 📂 | List directory | File System |
| 📖 | Read file | File System |
| ✍ | Write file | File System |
| ✂ | Remove file/directory | File System |
| ⧉ | Copy file | File System |
| ↷ | Move file | File System |
| ? | Check if file exists | File System |
| ! | Execute shell command | Shell |
| 🖥 | Get OS information | Shell |
| ↗ | HTTP GET request | Network |
| ↓ | HTTP POST request | Network |
| 🌐 | Open web page | Browser |
| 🖱 | Click element | Browser |
| ⌨ | Input text | Browser |
| 👁 | Get text | Browser |
| 🧠 | Execute JavaScript | Browser |
| ❌ | Close browser | Browser |
| 📸 | Take screenshot | Browser |
| 📝 | Set memory value | Database |
| 📚 | Get memory value | Database |
| 🗑 | Delete memory value | Database |
A comprehensive test suite has been implemented in test.a.i to verify the functionality of all components. The tests include:
- Individual component tests
- Integration tests
- Security validation tests
- Error handling tests
The test suite provides detailed reporting of test results and can be used to verify the correct operation of the Anarchy Agent.
// Initialize the agent
ι agent = Integration();
agent.initialize({});
// Run a task
ι result = agent.run_task("List files in the current directory");
// Print the result
⌽(result.result);
// Initialize the agent
ι agent = Integration();
agent.initialize({});
// Execute Anarchy-Inference code
ι code = `
ƒmain() {
// List files in the current directory
ι files = 📂(".");
// Print each file
∀(files.files, λfile {
⌽(file);
});
↩ files;
}
main();
`;
ι result = agent.execute(code);
// Print the result
⌽(result.result);
The implementation includes several security measures:
- Sandbox Isolation: All code execution occurs within a sandbox
- Permission Controls: Operations can be restricted based on permissions
- Resource Limits: Execution time and memory usage are limited
- Path Validation: File operations are restricted to safe directories
- Command Validation: Shell commands are checked for dangerous operations
- URL Validation: Network and browser operations are restricted to external networks
These measures ensure that the Anarchy Agent operates safely and securely.
Potential areas for future improvement include:
- Enhanced LLM Integration: Support for more sophisticated models and prompting
- Expanded Browser Automation: More advanced web interaction capabilities
- Improved Memory Management: Vector storage for more effective context retrieval
- Additional System Operations: More comprehensive system interaction
- User Interface Improvements: Better visualization of agent operations
- Performance Optimization: Faster code execution and response generation
The Anarchy Agent implementation provides a fully functional, cross-platform AI assistant that operates entirely offline using the Anarchy-Inference language. The modular architecture allows for easy extension and customization, while the minimalist design ensures efficiency and simplicity.