Skip to main content

SDK for building Soothe plugins with decorator-based API

Project description

Soothe SDK

A lightweight, decorator-based SDK for building Soothe plugins.

Installation

pip install soothe-sdk

Quick Start

from soothe_sdk import plugin, tool, subagent

@plugin(
    name="my-plugin",
    version="1.0.0",
    description="My awesome plugin",
    dependencies=["langchain>=0.1.0"],
)
class MyPlugin:
    """My custom plugin with tools and subagents."""

    @tool(name="greet", description="Greet someone by name")
    def greet(self, name: str) -> str:
        """Greet a person."""
        return f"Hello, {name}!"

    @subagent(
        name="researcher",
        description="Research subagent with web search",
        model="openai:gpt-4o-mini",
    )
    async def create_researcher(self, model, config, context):
        """Create research subagent."""
        from langgraph.prebuilt import create_react_agent

        # Get tools
        tools = [self.greet]

        # Create agent
        agent = create_react_agent(model, tools)

        return {
            "name": "researcher",
            "description": "Research subagent",
            "runnable": agent,
        }

Features

  • Decorator-based API: Simple @plugin, @tool, @subagent decorators
  • Lightweight: Only requires pydantic and langchain-core
  • Type-safe: Full type hints and Pydantic validation
  • No runtime dependency: SDK is separate from Soothe runtime

API Reference

@plugin

Defines a Soothe plugin with metadata.

@plugin(
    name="my-plugin",           # Required: unique identifier
    version="1.0.0",           # Required: semantic version
    description="My plugin",   # Required: description
    dependencies=["arxiv>=2.0.0"],  # Optional: library dependencies
    trust_level="standard",    # Optional: built-in, trusted, standard, untrusted
)
class MyPlugin:
    pass

@tool

Defines a tool that can be used by the agent.

@tool(name="my-tool", description="What this tool does")
def my_tool(self, arg: str) -> str:
    return f"Result: {arg}"

@tool_group

Organizes multiple related tools.

@tool_group(name="research", description="Research tools")
class ResearchTools:
    @tool(name="arxiv")
    def search_arxiv(self, query: str) -> list:
        pass

    @tool(name="scholar")
    def search_scholar(self, query: str) -> list:
        pass

@subagent

Defines a subagent factory.

@subagent(
    name="researcher",
    description="Research subagent",
    model="openai:gpt-4o-mini",  # Optional default model
)
async def create_researcher(self, model, config, context):
    # Create and return subagent
    return {
        "name": "researcher",
        "description": "Research subagent",
        "runnable": agent,
    }

PluginContext

Provides access to Soothe internals in lifecycle hooks.

class MyPlugin:
    async def on_load(self, context: PluginContext):
        # Plugin-specific config
        self.api_key = context.config.get("api_key")

        # Global Soothe config
        self.model = context.soothe_config.resolve_model("default")

        # Logging
        context.logger.info("Plugin loaded")

        # Events
        context.emit_event("plugin.loaded", {"name": "my-plugin"})

Plugin Lifecycle

Plugins can implement optional lifecycle hooks:

class MyPlugin:
    async def on_load(self, context: PluginContext):
        """Called when plugin is loaded. Initialize resources."""
        pass

    async def on_unload(self):
        """Called when plugin is unloaded. Clean up resources."""
        pass

    async def health_check(self):
        """Return plugin health status."""
        from soothe_sdk.types import PluginHealth
        return PluginHealth(status="healthy")

Publishing Your Plugin

  1. Create a Python package with your plugin class
  2. Add the entry point in pyproject.toml:
[project.entry-points."soothe.plugins"]
my_plugin = "my_package:MyPlugin"
  1. Publish to PyPI:
pip install build
python -m build
twine upload dist/*
  1. Users can install and use your plugin:
pip install my-plugin

Development

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

# Run tests
pytest tests/

# Type checking
mypy src/soothe_sdk/

# Linting
ruff check src/soothe_sdk/

# Formatting
ruff format src/soothe_sdk/

Architecture

The SDK provides decorator-based APIs for defining plugins:

soothe_sdk/
├── decorators/
│   ├── plugin.py      # @plugin decorator
│   ├── tool.py        # @tool and @tool_group decorators
│   └── subagent.py    # @subagent decorator
├── types/
│   ├── manifest.py    # PluginManifest metadata
│   ├── context.py     # PluginContext for lifecycle hooks
│   └── health.py      # PluginHealth status
├── exceptions.py      # SDK-specific exceptions
└── depends.py         # Dependency utilities

Key Design Principles

  1. Lightweight: Minimal dependencies (only pydantic and langchain-core)
  2. Type-safe: Full type hints and Pydantic validation
  3. Decorator-based: Simple, declarative plugin definition
  4. Runtime-agnostic: No dependency on Soothe runtime
  5. Extensible: Support for tools, subagents, and custom events

License

MIT License - see LICENSE for details.

Links

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

soothe_sdk-0.1.1.tar.gz (104.8 kB view details)

Uploaded Source

Built Distribution

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

soothe_sdk-0.1.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file soothe_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: soothe_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 104.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for soothe_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e3b2c0b87f7ba0b084dfa4823537cd7bec478163cabe6fe0711d24c351aa21c9
MD5 73f0362dc3967445645cc0fc9253b47d
BLAKE2b-256 87dae11cdb09c6de7581f558ee370926a465e316a3646dc2c801d02d42da9c1e

See more details on using hashes here.

File details

Details for the file soothe_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: soothe_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for soothe_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2b7a51695ae4e96ff4d56b152c785a7df3f68357c201bbdcef9cd24d7154bda
MD5 caf8aef25e5e9ef80fd79d339beb77bb
BLAKE2b-256 62272bdbd64905c7659df516a15702298ae957059a1826c8c073bcf457fb0c2f

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