Extending Python Core
Relevant source files
The following files were used as context for generating this wiki page:
The Python Core of the WIREDUP system serves as a revolutionary AI auto-wiring framework designed to handle environment management, Model Context Protocol (MCP) integration, and secure SSH management. Its primary purpose is to provide an intelligent dependency injection engine that automatically resolves and injects necessary services into AI agents, enabling a modular and scalable architecture for autonomous systems.
Extending the core involves leveraging the established Auto-Wiring Engine to register new services, defining custom capabilities within the Skills Registry, and implementing specialized agent types. This extensibility allows developers to bridge the gap between high-level AI orchestration and low-level system operations, such as remote server management or specialized data processing.
Auto-Wiring Engine and Dependency Injection
The Auto-Wiring Engine is the central nervous system of the project, facilitating intelligent dependency injection. It automatically resolves dependencies for agents and services based on type-based service location and multi-scope management.
Core Registration Logic
Developers can extend the system by registering new components with the AutoWire engine. This engine supports different lifecycle scopes and uses a factory pattern for instantiation.
The diagram above illustrates the service registration and instantiation flow within the AutoWire engine.
Sources: README.md:46-56, AGENT.md:27-40
Dependency Resolution
Dependency injection can be achieved through two primary methods:
- Manual Registration: Using the
autowire.register()method to link names to factories. - Decorator-Based: Utilizing the
@autowire.register_decorator()for cleaner class-level registration.
| Component | Responsibility | Source File |
|---|---|---|
AutoWire | Main dependency injection engine | src/__init__.py:9 |
Scope | Defines lifecycle (SINGLETON, etc.) | src/__init__.py:9 |
inject | Decorator for injecting dependencies into functions/classes | src/__init__.py:9 |
Sources: src/__init__.py:9-15, AGENT.md:144-165
Agent Extensibility
The system provides a BaseAgent class that serves as the foundation for all specialized AI agents. Extending the core agent system involves inheriting from this class and implementing the asynchronous execute method.
Agent Types
The framework facilitates the creation of various agent archetypes:
- Research Agents: Focused on information gathering and analysis using search skills.
- Execution Agents: Handle code execution and remote system operations via SSH.
- Coordination Agents: Act as orchestrators for multiple sub-agents.
This class diagram shows the inheritance structure used to extend agent capabilities.
Sources: AGENT.md:95-139
Agent Context and State
Extensions often require managing session-specific data. The AgentContext data structure carries session_id, user_id, and metadata through the execution flow.
Sources: AGENT.md:385-391
Skills Registry System
The Skills System provides a modular framework for discrete capabilities. Extending the core functionality often involves creating new Skill subclasses and registering them in the SkillRegistry.
Skill Categories
The project includes several built-in skill categories that can be extended:
| Category | Description | Examples |
|---|---|---|
| Research | Information gathering | Web Search, Scraping, Document Analysis |
| Execution | System interactions | Code Execution, SSH Command, File Ops |
| Reasoning | Logic and NLP | Text Generation, Classification, Logic |
| Communication | External messaging | Email, Notifications |
Sources: SKILLS.md:47-245
Custom Skill Implementation
A custom skill requires defining parameters using SkillParameter and implementing an asynchronous execute method.
from src.agents.skills import Skill, SkillParameter
class CustomSkill(Skill):
def __init__(self):
super().__init__(
name='custom_op',
description='Custom core extension',
parameters=[SkillParameter(name='data', type='string', required=True)]
)
async def execute(self, context, data):
# Implementation logic here
return {"success": True, "data": data}
Sources: SKILLS.md:310-355
Rust-Python Interoperability
Extending the core also involves the bridge between the Python auto-wiring logic and the Rust-based terminal (NexTerm).
Auto-Wire Bridge
The Rust terminal implements an AutoWire Bridge that communicates with the Python system. The terminal TUI provides dedicated panels to visualize the status of the auto-wiring services.
The sequence diagram details the communication flow between the Rust terminal and the Python core services.
Sources: rust-terminal/src/ui/tui.rs:136-170, rust-terminal/BUILD.md:120-135
UI Integration Features
The TUI is extended to support core features through specific keybindings:
- Ctrl+A: Toggle Auto-wire status panel.
- Ctrl+S: View registered auto-wire services.
- Ctrl+Space: Trigger AI suggestions via the Python core.
Sources: rust-terminal/src/ui/tui.rs:65-75, rust-terminal/src/ui/tui.rs:315-325
Summary
Extending the WIREDUP Python Core is achieved through a structured approach involving the Auto-Wiring engine for dependency management, the inheritance of BaseAgent for specialized logic, and the modular Skill system for discrete capabilities. This architecture ensures that new features remain decoupled yet fully integrated with the system's core orchestration and the Rust-based terminal interface.
Sources: README.md:30-45, AGENT.md:13-25