The RegistrySyncTool synchronizes runtime agent registries with persistent registry files, ensuring all agents have proper cryptographic identities and signatures. It maintains consistency between in-memory and on-disk registries.
File: tools/registry_sync_tool.py
Class: RegistrySyncTool
Version: 1.0.0
Status: ✅ Active
class RegistrySyncTool(BaseTool):
- memory_agent: MemoryAgent - For workspace management
- coordinator_ref: CoordinatorAgent - Runtime registry access
- agents_registry_path: Path - Persistent agents registry
- tools_registry_path: Path - Persistent tools registry
sync_allSynchronizes all registries comprehensively.
Parameters:
action (str, default: "sync_all"): Action to performvalidate_signatures (bool, default: True): Validate signaturesupdate_missing_keys (bool, default: True): Create missing keysReturns:
Tuple[bool, Dict[str, Any]] # (success, sync_results)
Sync Results:
{
"agents_synced": int,
"keys_updated": int,
"signatures_validated": int,
"errors": List[str]
}
update_keysUpdates missing public keys for all agents.
Parameters:
action (str, required): "update_keys"Returns:
Tuple[bool, Dict[str, Any]] # (success, update_results)
Update Results:
{
"keys_created": int,
"keys_updated": int,
"errors": List[str]
}
from tools.registry_sync_tool import RegistrySyncTool
from agents.memory_agent import MemoryAgent
from orchestration.coordinator_agent import CoordinatorAgent
tool = RegistrySyncTool(
memory_agent=memory_agent,
coordinator_ref=coordinator
)
Sync all registries
success, results = await tool.execute(
action="sync_all",
validate_signatures=True,
update_missing_keys=True
)
if success:
print(f"Agents synced: {results['agents_synced']}")
print(f"Keys updated: {results['keys_updated']}")
# Update missing keys only
success, results = await tool.execute(action="update_keys")
if success:
print(f"Keys created: {results['keys_created']}")
Creates missing identities:
Validates cryptographic signatures:
Syncs both directions:
Comprehensive error handling:
Accesses runtime registry:
runtime_registry = self.coordinator_ref.agent_registry
Manages identities:
id_manager = await IDManagerAgent.get_instance()
public_key = await id_manager.get_public_address(agent_id)
# Regular sync operation
success, results = await tool.execute("sync_all")
if results["errors"]:
print(f"Sync completed with {len(results['errors'])} errors")
# Update missing keys without full sync
success, results = await tool.execute("update_keys")
core.id_manager_agent.IDManagerAgent: Identity managementagents.memory_agent.MemoryAgent: Workspace managementorchestration.coordinator_agent.CoordinatorAgent: Runtime registrycore.bdi_agent.BaseTool: Base tool classdata/config/official_agents_registry.jsondata/config/official_tools_registry.jsonSignatures created for: