soothe-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- soothe_sdk-0.1.0/.gitignore +34 -0
- soothe_sdk-0.1.0/MANIFEST.md +196 -0
- soothe_sdk-0.1.0/MIGRATION.md +179 -0
- soothe_sdk-0.1.0/PKG-INFO +270 -0
- soothe_sdk-0.1.0/README.md +239 -0
- soothe_sdk-0.1.0/pyproject.toml +67 -0
- soothe_sdk-0.1.0/src/soothe_sdk/__init__.py +68 -0
- soothe_sdk-0.1.0/src/soothe_sdk/decorators/__init__.py +12 -0
- soothe_sdk-0.1.0/src/soothe_sdk/decorators/plugin.py +124 -0
- soothe_sdk-0.1.0/src/soothe_sdk/decorators/subagent.py +83 -0
- soothe_sdk-0.1.0/src/soothe_sdk/decorators/tool.py +135 -0
- soothe_sdk-0.1.0/src/soothe_sdk/depends.py +55 -0
- soothe_sdk-0.1.0/src/soothe_sdk/exceptions.py +43 -0
- soothe_sdk-0.1.0/src/soothe_sdk/types/__init__.py +12 -0
- soothe_sdk-0.1.0/src/soothe_sdk/types/context.py +87 -0
- soothe_sdk-0.1.0/src/soothe_sdk/types/health.py +19 -0
- soothe_sdk-0.1.0/src/soothe_sdk/types/manifest.py +57 -0
- soothe_sdk-0.1.0/tests/conftest.py +24 -0
- soothe_sdk-0.1.0/tests/test_decorators.py +82 -0
- soothe_sdk-0.1.0/tests/test_integration.py +85 -0
- soothe_sdk-0.1.0/tests/test_types.py +44 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.so
|
|
5
|
+
.Python
|
|
6
|
+
build/
|
|
7
|
+
develop-eggs/
|
|
8
|
+
dist/
|
|
9
|
+
downloads/
|
|
10
|
+
eggs/
|
|
11
|
+
.eggs/
|
|
12
|
+
lib/
|
|
13
|
+
lib64/
|
|
14
|
+
parts/
|
|
15
|
+
sdist/
|
|
16
|
+
var/
|
|
17
|
+
wheels/
|
|
18
|
+
*.egg-info/
|
|
19
|
+
.installed.cfg
|
|
20
|
+
*.egg
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
.coverage
|
|
23
|
+
htmlcov/
|
|
24
|
+
.ruff_cache/
|
|
25
|
+
.mypy_cache/
|
|
26
|
+
.vscode/
|
|
27
|
+
.idea/
|
|
28
|
+
*.swp
|
|
29
|
+
*.swo
|
|
30
|
+
.env
|
|
31
|
+
.venv
|
|
32
|
+
venv/
|
|
33
|
+
ENV/
|
|
34
|
+
env/
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Soothe SDK Package Structure
|
|
2
|
+
|
|
3
|
+
This document describes the final polished structure of the soothe-sdk package.
|
|
4
|
+
|
|
5
|
+
## Package Layout
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
soothe-sdk-pkg/
|
|
9
|
+
├── .gitignore # Git ignore patterns
|
|
10
|
+
├── MIGRATION.md # Migration guide for standalone repo
|
|
11
|
+
├── README.md # Package overview and API reference
|
|
12
|
+
├── pyproject.toml # Package configuration
|
|
13
|
+
├── src/
|
|
14
|
+
│ └── soothe_sdk/
|
|
15
|
+
│ ├── __init__.py # Package initialization and public API
|
|
16
|
+
│ ├── decorators/ # Decorator implementations
|
|
17
|
+
│ │ ├── __init__.py
|
|
18
|
+
│ │ ├── plugin.py # @plugin decorator
|
|
19
|
+
│ │ ├── subagent.py # @subagent decorator
|
|
20
|
+
│ │ └── tool.py # @tool and @tool_group decorators
|
|
21
|
+
│ ├── types/ # Type definitions
|
|
22
|
+
│ │ ├── __init__.py
|
|
23
|
+
│ │ ├── context.py # PluginContext for lifecycle hooks
|
|
24
|
+
│ │ ├── health.py # PluginHealth status
|
|
25
|
+
│ │ └── manifest.py # PluginManifest metadata
|
|
26
|
+
│ ├── exceptions.py # SDK-specific exceptions
|
|
27
|
+
│ └── depends.py # Dependency utilities
|
|
28
|
+
└── tests/
|
|
29
|
+
├── conftest.py # Shared test fixtures
|
|
30
|
+
├── test_decorators.py # Decorator functionality tests
|
|
31
|
+
├── test_types.py # Type definition tests
|
|
32
|
+
└── test_integration.py # Plugin lifecycle integration tests
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Key Features
|
|
36
|
+
|
|
37
|
+
### 1. Clean Package Structure
|
|
38
|
+
- No nested directories
|
|
39
|
+
- Proper `src/` layout following Python packaging best practices
|
|
40
|
+
- Tests colocated with package
|
|
41
|
+
|
|
42
|
+
### 2. Minimal Dependencies
|
|
43
|
+
- Only `pydantic>=2.0.0` for data validation
|
|
44
|
+
- Only `langchain-core>=1.2.0` for base types
|
|
45
|
+
- No runtime dependency on Soothe itself
|
|
46
|
+
|
|
47
|
+
### 3. Decorator-Based API
|
|
48
|
+
- Simple, declarative plugin definition
|
|
49
|
+
- Type-safe with Pydantic validation
|
|
50
|
+
- Clear separation of concerns
|
|
51
|
+
|
|
52
|
+
### 4. Comprehensive Testing
|
|
53
|
+
- Unit tests for all decorators
|
|
54
|
+
- Type validation tests
|
|
55
|
+
- Integration tests for plugin lifecycle
|
|
56
|
+
|
|
57
|
+
### 5. Documentation
|
|
58
|
+
- **README.md**: Quick start and full API reference
|
|
59
|
+
- **MIGRATION.md**: Standalone repository migration guide
|
|
60
|
+
- Inline docstrings with Google-style formatting
|
|
61
|
+
|
|
62
|
+
### 6. Build Configuration
|
|
63
|
+
- Proper `pyproject.toml` with all metadata
|
|
64
|
+
- Python 3.10-3.14 support
|
|
65
|
+
- Development dependencies
|
|
66
|
+
- Ruff configuration for code quality
|
|
67
|
+
- MyPy configuration for type checking
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
|
|
71
|
+
### Installation
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install soothe-sdk
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Development Installation
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install -e ".[dev]"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Running Tests
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pytest tests/
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Type Checking
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
mypy src/soothe_sdk/
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Code Quality
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
ruff format src/ tests/
|
|
99
|
+
ruff check --fix src/ tests/
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## API Components
|
|
103
|
+
|
|
104
|
+
### Decorators
|
|
105
|
+
|
|
106
|
+
1. **@plugin**: Define plugin metadata and class
|
|
107
|
+
- Required: name, version, description
|
|
108
|
+
- Optional: dependencies, trust_level
|
|
109
|
+
|
|
110
|
+
2. **@tool**: Define a tool function
|
|
111
|
+
- Required: name, description
|
|
112
|
+
- Automatically wrapped as langchain tool
|
|
113
|
+
|
|
114
|
+
3. **@tool_group**: Define a group of related tools
|
|
115
|
+
- Required: name, description
|
|
116
|
+
- Contains multiple @tool methods
|
|
117
|
+
|
|
118
|
+
4. **@subagent**: Define a subagent factory
|
|
119
|
+
- Required: name, description
|
|
120
|
+
- Optional: default model
|
|
121
|
+
- Returns dict with name, description, runnable
|
|
122
|
+
|
|
123
|
+
### Types
|
|
124
|
+
|
|
125
|
+
1. **PluginManifest**: Plugin metadata
|
|
126
|
+
- name, version, description
|
|
127
|
+
- dependencies, trust_level
|
|
128
|
+
- Semantic version validation
|
|
129
|
+
|
|
130
|
+
2. **PluginContext**: Lifecycle hook context
|
|
131
|
+
- config: Plugin-specific configuration
|
|
132
|
+
- soothe_config: Global Soothe configuration
|
|
133
|
+
- logger: Plugin logger
|
|
134
|
+
- emit_event: Event emission function
|
|
135
|
+
|
|
136
|
+
3. **PluginHealth**: Health check status
|
|
137
|
+
- status: healthy, degraded, unhealthy
|
|
138
|
+
- details: Optional error information
|
|
139
|
+
|
|
140
|
+
### Exceptions
|
|
141
|
+
|
|
142
|
+
1. **PluginError**: Base exception for all SDK errors
|
|
143
|
+
2. **DiscoveryError**: Plugin discovery failures
|
|
144
|
+
3. **ValidationError**: Metadata validation failures
|
|
145
|
+
4. **DependencyError**: Dependency resolution failures
|
|
146
|
+
5. **InitializationError**: Plugin initialization failures
|
|
147
|
+
6. **ToolCreationError**: Tool creation failures
|
|
148
|
+
7. **SubagentCreationError**: Subagent creation failures
|
|
149
|
+
|
|
150
|
+
## Extensibility Points
|
|
151
|
+
|
|
152
|
+
The SDK is designed to support:
|
|
153
|
+
|
|
154
|
+
1. **Plugin Discovery**: Entry points for automatic plugin loading
|
|
155
|
+
2. **Type Safety**: Full type hints for IDE support
|
|
156
|
+
3. **Validation**: Pydantic models for configuration validation
|
|
157
|
+
4. **Lifecycle Management**: Optional hooks for initialization and cleanup
|
|
158
|
+
5. **Health Monitoring**: Standardized health check interface
|
|
159
|
+
|
|
160
|
+
## Design Principles
|
|
161
|
+
|
|
162
|
+
1. **Lightweight**: Minimal dependencies for fast installation
|
|
163
|
+
2. **Type-safe**: Full type hints and Pydantic validation
|
|
164
|
+
3. **Decorator-based**: Simple, declarative plugin definition
|
|
165
|
+
4. **Runtime-agnostic**: No dependency on Soothe runtime
|
|
166
|
+
5. **Extensible**: Support for tools, subagents, and custom events
|
|
167
|
+
|
|
168
|
+
## Next Steps
|
|
169
|
+
|
|
170
|
+
This package is ready for:
|
|
171
|
+
|
|
172
|
+
1. **Testing**: Verify all tests pass
|
|
173
|
+
2. **Distribution**: Publish to PyPI
|
|
174
|
+
3. **Migration**: Move to standalone repository if desired
|
|
175
|
+
4. **Integration**: Use in Soothe plugin development
|
|
176
|
+
|
|
177
|
+
## Verification Checklist
|
|
178
|
+
|
|
179
|
+
- [x] Clean directory structure
|
|
180
|
+
- [x] Source files in `src/soothe_sdk/`
|
|
181
|
+
- [x] Comprehensive test suite
|
|
182
|
+
- [x] Python 3.10-3.14 support
|
|
183
|
+
- [x] Updated README with full API reference
|
|
184
|
+
- [x] Proper pyproject.toml configuration
|
|
185
|
+
- [x] MIGRATION.md for standalone repository
|
|
186
|
+
- [ ] Tests passing (requires pytest installation)
|
|
187
|
+
- [ ] Package installable with `pip install -e .`
|
|
188
|
+
|
|
189
|
+
## Success Metrics
|
|
190
|
+
|
|
191
|
+
The package structure is complete and ready for:
|
|
192
|
+
|
|
193
|
+
1. Independent development and testing
|
|
194
|
+
2. Publication to PyPI
|
|
195
|
+
3. Use as dependency for Soothe plugins
|
|
196
|
+
4. Migration to separate repository if desired
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Standalone Package Migration Guide
|
|
2
|
+
|
|
3
|
+
This document describes how to migrate soothe_sdk to a standalone repository.
|
|
4
|
+
|
|
5
|
+
## Current Status
|
|
6
|
+
|
|
7
|
+
The `soothe-sdk` package is currently located in the Soothe monorepo at:
|
|
8
|
+
- `soothe-sdk-pkg/` - Standalone package structure
|
|
9
|
+
- `src/soothe_sdk/` - Original location (to be removed after migration)
|
|
10
|
+
|
|
11
|
+
## Migration Steps
|
|
12
|
+
|
|
13
|
+
### 1. Create Standalone Repository
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Create new repository on GitHub/GitLab
|
|
17
|
+
# Repository: soothe-sdk
|
|
18
|
+
|
|
19
|
+
# Clone the standalone package structure
|
|
20
|
+
git clone <soothe-repo>
|
|
21
|
+
cd soothe
|
|
22
|
+
|
|
23
|
+
# Copy standalone package to new location
|
|
24
|
+
cp -r soothe-sdk-pkg ../soothe-sdk/
|
|
25
|
+
cd ../soothe-sdk
|
|
26
|
+
git init
|
|
27
|
+
git add .
|
|
28
|
+
git commit -m "Initial commit: soothe-sdk standalone package"
|
|
29
|
+
git remote add origin <soothe-sdk-repo-url>
|
|
30
|
+
git push -u origin main
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 2. Remove from Soothe Monorepo
|
|
34
|
+
|
|
35
|
+
After the standalone package is tested and working:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# In Soothe monorepo
|
|
39
|
+
rm -rf src/soothe_sdk
|
|
40
|
+
rm -rf soothe-sdk-pkg
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 3. Update Soothe Dependencies
|
|
44
|
+
|
|
45
|
+
Update `pyproject.toml` in Soothe monorepo:
|
|
46
|
+
|
|
47
|
+
```toml
|
|
48
|
+
dependencies = [
|
|
49
|
+
# ... existing dependencies ...
|
|
50
|
+
"soothe-sdk>=0.1.0,<1.0.0",
|
|
51
|
+
]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 4. Update Soothe Documentation
|
|
55
|
+
|
|
56
|
+
Add to Soothe's README.md:
|
|
57
|
+
|
|
58
|
+
```markdown
|
|
59
|
+
## Plugin Development
|
|
60
|
+
|
|
61
|
+
To develop plugins for Soothe, use the soothe-sdk package:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install soothe-sdk
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
See [soothe-sdk](https://github.com/caesar0301/soothe-sdk) for details.
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 5. Publish to PyPI
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Build the package
|
|
74
|
+
cd soothe-sdk
|
|
75
|
+
python -m build
|
|
76
|
+
|
|
77
|
+
# Upload to PyPI
|
|
78
|
+
twine upload dist/*
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 6. Verify Installation
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Install from PyPI
|
|
85
|
+
pip install soothe-sdk
|
|
86
|
+
|
|
87
|
+
# Verify import
|
|
88
|
+
python -c "from soothe_sdk import plugin, tool, subagent; print('OK')"
|
|
89
|
+
|
|
90
|
+
# Test with Soothe plugin
|
|
91
|
+
python -c "from soothe.plugin.global_registry import load_plugins; print('OK')"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Directory Structure
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
soothe-sdk/
|
|
98
|
+
├── README.md
|
|
99
|
+
├── pyproject.toml
|
|
100
|
+
├── .gitignore
|
|
101
|
+
├── src/
|
|
102
|
+
│ └── soothe_sdk/
|
|
103
|
+
│ ├── __init__.py
|
|
104
|
+
│ ├── decorators/
|
|
105
|
+
│ │ ├── __init__.py
|
|
106
|
+
│ │ ├── plugin.py
|
|
107
|
+
│ │ ├── subagent.py
|
|
108
|
+
│ │ └── tool.py
|
|
109
|
+
│ ├── types/
|
|
110
|
+
│ │ ├── __init__.py
|
|
111
|
+
│ │ ├── context.py
|
|
112
|
+
│ │ ├── health.py
|
|
113
|
+
│ │ └── manifest.py
|
|
114
|
+
│ ├── exceptions.py
|
|
115
|
+
│ └── depends.py
|
|
116
|
+
└── tests/
|
|
117
|
+
├── conftest.py
|
|
118
|
+
├── test_decorators.py
|
|
119
|
+
├── test_types.py
|
|
120
|
+
└── test_integration.py
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Usage
|
|
124
|
+
|
|
125
|
+
After installing soothe-sdk:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from soothe_sdk import plugin, tool, subagent
|
|
129
|
+
|
|
130
|
+
@plugin(name="my-plugin", version="1.0.0", description="My plugin")
|
|
131
|
+
class MyPlugin:
|
|
132
|
+
@tool(name="greet", description="Greet someone")
|
|
133
|
+
def greet(self, name: str) -> str:
|
|
134
|
+
return f"Hello, {name}!"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
For SDK development:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Clone the repo
|
|
143
|
+
git clone <soothe-sdk-repo>
|
|
144
|
+
cd soothe-sdk
|
|
145
|
+
|
|
146
|
+
# Install in dev mode
|
|
147
|
+
pip install -e ".[dev]"
|
|
148
|
+
|
|
149
|
+
# Run tests
|
|
150
|
+
pytest tests/
|
|
151
|
+
|
|
152
|
+
# Type checking
|
|
153
|
+
mypy src/soothe_sdk/
|
|
154
|
+
|
|
155
|
+
# Format and lint
|
|
156
|
+
ruff format src/ tests/
|
|
157
|
+
ruff check --fix src/ tests/
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Dependencies
|
|
161
|
+
|
|
162
|
+
The SDK maintains minimal dependencies:
|
|
163
|
+
|
|
164
|
+
- **pydantic>=2.0.0**: For data validation and settings management
|
|
165
|
+
- **langchain-core>=1.2.0**: For tool and subagent base types
|
|
166
|
+
|
|
167
|
+
## Version Compatibility
|
|
168
|
+
|
|
169
|
+
The SDK declares compatibility with Soothe:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
__soothe_required_version__ = ">=0.1.0,<1.0.0"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Support
|
|
176
|
+
|
|
177
|
+
- **Issues**: <soothe-sdk-repo>/issues
|
|
178
|
+
- **Documentation**: <soothe-sdk-repo>/README.md
|
|
179
|
+
- **Soothe Docs**: <soothe-repo>/docs/
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: soothe-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: SDK for building Soothe plugins with decorator-based API
|
|
5
|
+
Project-URL: Homepage, https://github.com/caesar0301/soothe
|
|
6
|
+
Project-URL: Documentation, https://soothe.readthedocs.io
|
|
7
|
+
Project-URL: Repository, https://github.com/caesar0301/soothe
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: agents,ai,llm,plugins,sdk,soothe
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: <3.15,>=3.10
|
|
22
|
+
Requires-Dist: langchain-core<2.0.0,>=1.2.0
|
|
23
|
+
Requires-Dist: pydantic<3.0.0,>=2.0.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-asyncio>=1.3.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff>=0.12.0; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# Soothe SDK
|
|
33
|
+
|
|
34
|
+
A lightweight, decorator-based SDK for building Soothe plugins.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install soothe-sdk
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from soothe_sdk import plugin, tool, subagent
|
|
46
|
+
|
|
47
|
+
@plugin(
|
|
48
|
+
name="my-plugin",
|
|
49
|
+
version="1.0.0",
|
|
50
|
+
description="My awesome plugin",
|
|
51
|
+
dependencies=["langchain>=0.1.0"],
|
|
52
|
+
)
|
|
53
|
+
class MyPlugin:
|
|
54
|
+
"""My custom plugin with tools and subagents."""
|
|
55
|
+
|
|
56
|
+
@tool(name="greet", description="Greet someone by name")
|
|
57
|
+
def greet(self, name: str) -> str:
|
|
58
|
+
"""Greet a person."""
|
|
59
|
+
return f"Hello, {name}!"
|
|
60
|
+
|
|
61
|
+
@subagent(
|
|
62
|
+
name="researcher",
|
|
63
|
+
description="Research subagent with web search",
|
|
64
|
+
model="openai:gpt-4o-mini",
|
|
65
|
+
)
|
|
66
|
+
async def create_researcher(self, model, config, context):
|
|
67
|
+
"""Create research subagent."""
|
|
68
|
+
from langgraph.prebuilt import create_react_agent
|
|
69
|
+
|
|
70
|
+
# Get tools
|
|
71
|
+
tools = [self.greet]
|
|
72
|
+
|
|
73
|
+
# Create agent
|
|
74
|
+
agent = create_react_agent(model, tools)
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
"name": "researcher",
|
|
78
|
+
"description": "Research subagent",
|
|
79
|
+
"runnable": agent,
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Features
|
|
84
|
+
|
|
85
|
+
- **Decorator-based API**: Simple `@plugin`, `@tool`, `@subagent` decorators
|
|
86
|
+
- **Lightweight**: Only requires `pydantic` and `langchain-core`
|
|
87
|
+
- **Type-safe**: Full type hints and Pydantic validation
|
|
88
|
+
- **No runtime dependency**: SDK is separate from Soothe runtime
|
|
89
|
+
|
|
90
|
+
## API Reference
|
|
91
|
+
|
|
92
|
+
### @plugin
|
|
93
|
+
|
|
94
|
+
Defines a Soothe plugin with metadata.
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
@plugin(
|
|
98
|
+
name="my-plugin", # Required: unique identifier
|
|
99
|
+
version="1.0.0", # Required: semantic version
|
|
100
|
+
description="My plugin", # Required: description
|
|
101
|
+
dependencies=["arxiv>=2.0.0"], # Optional: library dependencies
|
|
102
|
+
trust_level="standard", # Optional: built-in, trusted, standard, untrusted
|
|
103
|
+
)
|
|
104
|
+
class MyPlugin:
|
|
105
|
+
pass
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### @tool
|
|
109
|
+
|
|
110
|
+
Defines a tool that can be used by the agent.
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
@tool(name="my-tool", description="What this tool does")
|
|
114
|
+
def my_tool(self, arg: str) -> str:
|
|
115
|
+
return f"Result: {arg}"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### @tool_group
|
|
119
|
+
|
|
120
|
+
Organizes multiple related tools.
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
@tool_group(name="research", description="Research tools")
|
|
124
|
+
class ResearchTools:
|
|
125
|
+
@tool(name="arxiv")
|
|
126
|
+
def search_arxiv(self, query: str) -> list:
|
|
127
|
+
pass
|
|
128
|
+
|
|
129
|
+
@tool(name="scholar")
|
|
130
|
+
def search_scholar(self, query: str) -> list:
|
|
131
|
+
pass
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### @subagent
|
|
135
|
+
|
|
136
|
+
Defines a subagent factory.
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
@subagent(
|
|
140
|
+
name="researcher",
|
|
141
|
+
description="Research subagent",
|
|
142
|
+
model="openai:gpt-4o-mini", # Optional default model
|
|
143
|
+
)
|
|
144
|
+
async def create_researcher(self, model, config, context):
|
|
145
|
+
# Create and return subagent
|
|
146
|
+
return {
|
|
147
|
+
"name": "researcher",
|
|
148
|
+
"description": "Research subagent",
|
|
149
|
+
"runnable": agent,
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### PluginContext
|
|
154
|
+
|
|
155
|
+
Provides access to Soothe internals in lifecycle hooks.
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
class MyPlugin:
|
|
159
|
+
async def on_load(self, context: PluginContext):
|
|
160
|
+
# Plugin-specific config
|
|
161
|
+
self.api_key = context.config.get("api_key")
|
|
162
|
+
|
|
163
|
+
# Global Soothe config
|
|
164
|
+
self.model = context.soothe_config.resolve_model("default")
|
|
165
|
+
|
|
166
|
+
# Logging
|
|
167
|
+
context.logger.info("Plugin loaded")
|
|
168
|
+
|
|
169
|
+
# Events
|
|
170
|
+
context.emit_event("plugin.loaded", {"name": "my-plugin"})
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Plugin Lifecycle
|
|
174
|
+
|
|
175
|
+
Plugins can implement optional lifecycle hooks:
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
class MyPlugin:
|
|
179
|
+
async def on_load(self, context: PluginContext):
|
|
180
|
+
"""Called when plugin is loaded. Initialize resources."""
|
|
181
|
+
pass
|
|
182
|
+
|
|
183
|
+
async def on_unload(self):
|
|
184
|
+
"""Called when plugin is unloaded. Clean up resources."""
|
|
185
|
+
pass
|
|
186
|
+
|
|
187
|
+
async def health_check(self):
|
|
188
|
+
"""Return plugin health status."""
|
|
189
|
+
from soothe_sdk.types import PluginHealth
|
|
190
|
+
return PluginHealth(status="healthy")
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Publishing Your Plugin
|
|
194
|
+
|
|
195
|
+
1. Create a Python package with your plugin class
|
|
196
|
+
2. Add the entry point in `pyproject.toml`:
|
|
197
|
+
|
|
198
|
+
```toml
|
|
199
|
+
[project.entry-points."soothe.plugins"]
|
|
200
|
+
my_plugin = "my_package:MyPlugin"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
3. Publish to PyPI:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
pip install build
|
|
207
|
+
python -m build
|
|
208
|
+
twine upload dist/*
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
4. Users can install and use your plugin:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
pip install my-plugin
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Development
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Install dev dependencies
|
|
221
|
+
pip install -e ".[dev]"
|
|
222
|
+
|
|
223
|
+
# Run tests
|
|
224
|
+
pytest tests/
|
|
225
|
+
|
|
226
|
+
# Type checking
|
|
227
|
+
mypy src/soothe_sdk/
|
|
228
|
+
|
|
229
|
+
# Linting
|
|
230
|
+
ruff check src/soothe_sdk/
|
|
231
|
+
|
|
232
|
+
# Formatting
|
|
233
|
+
ruff format src/soothe_sdk/
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Architecture
|
|
237
|
+
|
|
238
|
+
The SDK provides decorator-based APIs for defining plugins:
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
soothe_sdk/
|
|
242
|
+
├── decorators/
|
|
243
|
+
│ ├── plugin.py # @plugin decorator
|
|
244
|
+
│ ├── tool.py # @tool and @tool_group decorators
|
|
245
|
+
│ └── subagent.py # @subagent decorator
|
|
246
|
+
├── types/
|
|
247
|
+
│ ├── manifest.py # PluginManifest metadata
|
|
248
|
+
│ ├── context.py # PluginContext for lifecycle hooks
|
|
249
|
+
│ └── health.py # PluginHealth status
|
|
250
|
+
├── exceptions.py # SDK-specific exceptions
|
|
251
|
+
└── depends.py # Dependency utilities
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Key Design Principles
|
|
255
|
+
|
|
256
|
+
1. **Lightweight**: Minimal dependencies (only `pydantic` and `langchain-core`)
|
|
257
|
+
2. **Type-safe**: Full type hints and Pydantic validation
|
|
258
|
+
3. **Decorator-based**: Simple, declarative plugin definition
|
|
259
|
+
4. **Runtime-agnostic**: No dependency on Soothe runtime
|
|
260
|
+
5. **Extensible**: Support for tools, subagents, and custom events
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
265
|
+
|
|
266
|
+
## Links
|
|
267
|
+
|
|
268
|
+
- [Soothe Documentation](https://soothe.readthedocs.io)
|
|
269
|
+
- [Plugin Development Guide](https://soothe.readthedocs.io/plugins/)
|
|
270
|
+
- [GitHub Repository](https://github.com/caesar0301/soothe)
|