Skip to main content

Multi-level secrets management plugin for elizaOS with encryption and dynamic plugin activation

Project description

elizaOS Plugin - Secrets Manager (Python)

Multi-level secrets management plugin for elizaOS with encryption, validation, and dynamic plugin activation.

Features

  • Multi-level storage: Global (agent-wide), World (server/channel), and User (per-user) secrets
  • Strong encryption: AES-256-GCM encryption with secure key derivation
  • Validation: Built-in validators for common API keys (OpenAI, Anthropic, Groq, etc.)
  • Dynamic activation: Plugins can be activated once their required secrets are available
  • Access logging: Track who accessed what secrets and when
  • Natural language: Set and manage secrets via natural language commands

Installation

pip install elizaos-plugin-secrets-manager

Quick Start

from elizaos_plugin_secrets_manager import secrets_manager_plugin, SecretsService

# Register the plugin with your runtime
runtime.register_plugin(secrets_manager_plugin)

# Or use the service directly
service = SecretsService(runtime)
await service.start()

# Set a global secret
await service.set_global("OPENAI_API_KEY", "sk-...")

# Get the secret
value = await service.get_global("OPENAI_API_KEY")

Secret Levels

Global Secrets

Agent-wide secrets like API keys that apply across all interactions.

await service.set_global("OPENAI_API_KEY", "sk-...")
value = await service.get_global("OPENAI_API_KEY")

World Secrets

Server/channel-specific secrets for multi-tenant scenarios.

await service.set_world("ADMIN_TOKEN", "token-...", world_id="discord-server-123")
value = await service.get_world("ADMIN_TOKEN", world_id="discord-server-123")

User Secrets

Per-user secrets for personalized configurations.

await service.set_user("WALLET_ADDRESS", "0x...", user_id="user-123")
value = await service.get_user("WALLET_ADDRESS", user_id="user-123")

Validation

Built-in validators ensure API keys match expected formats:

from elizaos_plugin_secrets_manager import validate_secret

result = await validate_secret("OPENAI_API_KEY", "sk-abc123...", "openai")
if result.is_valid:
    print("Valid OpenAI key!")
else:
    print(f"Invalid: {result.error}")

Supported validators:

  • openai - OpenAI API keys (sk-...)
  • anthropic - Anthropic API keys (sk-ant-...)
  • groq - Groq API keys (gsk_...)
  • google / gemini - Google API keys
  • discord - Discord bot tokens
  • telegram - Telegram bot tokens
  • github - GitHub tokens
  • url - URL validation

Plugin Activation

Register plugins that depend on secrets:

from elizaos_plugin_secrets_manager import PluginActivatorService, PluginWithSecrets, PluginSecretRequirement

activator = PluginActivatorService(runtime)

# Define requirements
requirements = {
    "OPENAI_API_KEY": PluginSecretRequirement(
        key="OPENAI_API_KEY",
        description="OpenAI API key for completions",
        required=True,
        validation_method="openai"
    )
}

# Register plugin for activation
plugin_with_secrets = PluginWithSecrets(
    plugin=my_plugin,
    secret_requirements=requirements,
    on_secrets_ready=my_activation_callback
)

await activator.register_plugin(plugin_with_secrets)

Actions

The plugin provides natural language actions:

SET_SECRET

Set a secret via natural language:

"Set my OpenAI key to sk-abc123xyz"

MANAGE_SECRET

Manage secrets:

"List all my secrets" "Delete my GROQ_API_KEY" "Is ANTHROPIC_API_KEY configured?"

Encryption

All secrets are encrypted by default using AES-256-GCM:

from elizaos_plugin_secrets_manager import KeyManager, encrypt, decrypt

# Key derivation
key_manager = KeyManager()
key_manager.initialize_from_agent_id("agent-123", "salt")

# Encrypt
encrypted = key_manager.encrypt("my secret")

# Decrypt
plaintext = key_manager.decrypt(encrypted)

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Type checking
mypy elizaos_plugin_secrets_manager

# Linting
ruff check elizaos_plugin_secrets_manager

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elizaos_plugin_secrets_manager-2.0.0a5.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file elizaos_plugin_secrets_manager-2.0.0a5.tar.gz.

File metadata

File hashes

Hashes for elizaos_plugin_secrets_manager-2.0.0a5.tar.gz
Algorithm Hash digest
SHA256 7bea3f5251b15e1947901912e6bf4fa49b1933413b98a447955a3beb49e3c7b8
MD5 38bf2947179fa730d5e5b85fa8196be8
BLAKE2b-256 7fb74ee4cef6bca87af3833dd7472308aad68ce0845659280a4105911d34d61d

See more details on using hashes here.

File details

Details for the file elizaos_plugin_secrets_manager-2.0.0a5-py3-none-any.whl.

File metadata

File hashes

Hashes for elizaos_plugin_secrets_manager-2.0.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 a4050623bbf206c2a6f72fbde146b0057fd50c9d79fe8dc60ba833d0c087fb6f
MD5 bced5ff537e96155e7b9d5de00049d76
BLAKE2b-256 3a81d6797eda1e8082cf1177bc80747b2c4e9c178f01ef051f8cf879f4016790

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page