Skip to content

Commit 0803f54

Browse files
committed
Refactor Email Summarizer plugin configuration for improved clarity and security
- Removed outdated migration instructions from `plugin-configuration.md` to streamline documentation. - Enhanced `README.md` to clearly outline the three-file separation for plugin configuration, emphasizing the roles of `.env`, `config.yml`, and `plugins.yml`. - Updated `setup.py` to reflect changes in orchestration settings, ensuring only relevant configurations are included in `config/plugins.yml`. - Improved security messaging to highlight the importance of not committing secrets to version control.
1 parent 86d0975 commit 0803f54

File tree

3 files changed

+53
-91
lines changed

3 files changed

+53
-91
lines changed

backends/advanced/Docs/plugin-configuration.md

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -239,44 +239,6 @@ class MyPlugin(BasePlugin):
239239

240240
✅ **Unified interface**: All plugins loaded with same pattern via `load_plugin_config()`
241241

242-
## Migration from Old System
243-
244-
If you have existing plugins using the old configuration system:
245-
246-
**Old way** (everything in `config/plugins.yml`):
247-
```yaml
248-
plugins:
249-
email_summarizer:
250-
enabled: true
251-
events: [...]
252-
subject_prefix: "Summary" # ❌ Config mixed with orchestration
253-
smtp_host: smtp.gmail.com # ❌ Non-secret in wrong place
254-
smtp_password: app-password # ❌ SECRET IN VERSION CONTROL!
255-
```
256-
257-
**New way** (properly separated):
258-
259-
1. **Orchestration** in `config/plugins.yml`:
260-
```yaml
261-
plugins:
262-
email_summarizer:
263-
enabled: true
264-
events: [conversation.complete]
265-
```
266-
267-
2. **Settings** in `plugins/email_summarizer/config.yml`:
268-
```yaml
269-
subject_prefix: "Summary"
270-
smtp_host: ${SMTP_HOST}
271-
smtp_password: ${SMTP_PASSWORD}
272-
```
273-
274-
3. **Secrets** in `.env`:
275-
```bash
276-
SMTP_HOST=smtp.gmail.com
277-
SMTP_PASSWORD=app-password
278-
```
279-
280242
## Troubleshooting
281243

282244
### Plugin not loading

backends/advanced/src/advanced_omi_backend/plugins/email_summarizer/README.md

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ Automatically sends email summaries when conversations complete.
2020
5. Formats beautiful HTML and plain text emails
2121
6. Sends email via configured SMTP server
2222

23+
## Configuration Architecture
24+
25+
Chronicle uses a clean three-file separation for plugin configuration:
26+
27+
1. **`backends/advanced/.env`** - Secrets only (SMTP credentials, API keys)
28+
- Gitignored for security
29+
- Never commit to version control
30+
31+
2. **`plugins/email_summarizer/config.yml`** - Plugin-specific settings
32+
- Email content options (subject prefix, max sentences, etc.)
33+
- References environment variables using `${VAR_NAME}` syntax
34+
- Defaults work for most users - typically no editing needed
35+
36+
3. **`config/plugins.yml`** - Orchestration only
37+
- `enabled` flag
38+
- Event subscriptions
39+
- Trigger conditions
40+
41+
This separation keeps secrets secure and configuration organized. See [`plugin-configuration.md`](../../../Docs/plugin-configuration.md) for details.
42+
2343
## Configuration
2444

2545
### Step 1: Get SMTP Credentials
@@ -55,7 +75,7 @@ FROM_NAME=Chronicle AI
5575

5676
### Step 3: Enable Plugin
5777

58-
Add to `config/plugins.yml`:
78+
Add to `config/plugins.yml` (orchestration only):
5979

6080
```yaml
6181
plugins:
@@ -65,23 +85,14 @@ plugins:
6585
- conversation.complete
6686
condition:
6787
type: always
68-
69-
# SMTP Configuration
70-
smtp_host: ${SMTP_HOST:-smtp.gmail.com}
71-
smtp_port: ${SMTP_PORT:-587}
72-
smtp_username: ${SMTP_USERNAME}
73-
smtp_password: ${SMTP_PASSWORD}
74-
smtp_use_tls: ${SMTP_USE_TLS:-true}
75-
from_email: ${FROM_EMAIL:-noreply@chronicle.ai}
76-
from_name: ${FROM_NAME:-Chronicle AI}
77-
78-
# Email Content Options
79-
subject_prefix: "Conversation Summary"
80-
summary_max_sentences: 3
81-
include_conversation_id: true
82-
include_duration: true
8388
```
8489
90+
**That's it!** Plugin-specific settings are already configured in:
91+
- **`plugins/email_summarizer/config.yml`** - Email content options (subject prefix, max sentences, etc.)
92+
- **SMTP credentials** are automatically read from `.env` via environment variable references
93+
94+
You typically don't need to edit `config.yml` - the defaults work for most users. If you want to customize email content settings, see the Configuration Options section below.
95+
8596
### Step 4: Restart Backend
8697

8798
```bash
@@ -91,6 +102,8 @@ docker compose restart
91102

92103
## Configuration Options
93104

105+
All configuration options below are in **`plugins/email_summarizer/config.yml`** and have sensible defaults. You typically don't need to modify these unless you want to customize email content.
106+
94107
| Option | Type | Default | Description |
95108
|--------|------|---------|-------------|
96109
| `smtp_host` | string | `smtp.gmail.com` | SMTP server hostname |
@@ -180,17 +193,12 @@ This will:
180193

181194
## 🔒 Security Best Practices
182195

183-
### NEVER Commit Secrets to YAML Files
196+
### NEVER Commit Secrets to Version Control
184197

185-
**WRONG** ❌:
186-
```yaml
187-
# config/plugins.yml
188-
smtp_password: xnetcqctkkfgzllh # Hardcoded secret - SECURITY RISK!
189-
```
198+
Always use environment variable references in configuration files:
190199

191-
**CORRECT** ✅:
192200
```yaml
193-
# config/plugins.yml
201+
# plugins/email_summarizer/config.yml
194202
smtp_password: ${SMTP_PASSWORD} # Reference to environment variable
195203
```
196204
@@ -199,12 +207,13 @@ smtp_password: ${SMTP_PASSWORD} # Reference to environment variable
199207
SMTP_PASSWORD=xnetcqctkkfgzllh # Actual secret stored safely
200208
```
201209

202-
### Configuration Architecture
210+
### How Configuration Works
203211

204-
The setup wizard automatically:
205-
- ✅ Saves SMTP credentials to `backends/advanced/.env`
206-
- ✅ Updates `config/plugins.yml` with `${ENV_VAR}` references
207-
- ✅ Prevents accidental secret commits
212+
The plugin system automatically:
213+
- ✅ Loads settings from `plugins/email_summarizer/config.yml`
214+
- ✅ Expands `${ENV_VAR}` references from `backends/advanced/.env`
215+
- ✅ Merges orchestration settings (enabled, events) from `config/plugins.yml`
216+
- ✅ Prevents accidental secret commits (only .env has secrets, and it's gitignored)
208217

209218
**Always use the setup wizard** instead of manual configuration:
210219
```bash

backends/advanced/src/advanced_omi_backend/plugins/email_summarizer/setup.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
console = Console()
3232

3333

34-
def update_plugins_yml_with_env_refs():
34+
def update_plugins_yml_orchestration():
3535
"""
36-
Update config/plugins.yml with environment variable references.
37-
This ensures secrets are NOT hardcoded in plugins.yml.
36+
Update config/plugins.yml with orchestration settings only.
37+
Plugin-specific settings are in plugins/email_summarizer/config.yml.
38+
This follows Chronicle's three-file configuration architecture.
3839
"""
3940
plugins_yml_path = project_root / "config" / "plugins.yml"
4041

@@ -55,24 +56,12 @@ def update_plugins_yml_with_env_refs():
5556
if 'plugins' not in config:
5657
config['plugins'] = {}
5758

58-
# Build plugin config with env var references (NOT actual values!)
59+
# Only orchestration settings in config/plugins.yml
60+
# Plugin-specific settings are in plugins/email_summarizer/config.yml
5961
plugin_config = {
6062
'enabled': False, # Let user enable manually or prompt
6163
'events': ['conversation.complete'],
62-
'condition': {'type': 'always'},
63-
# Use env var references - these get expanded at runtime
64-
'smtp_host': '${SMTP_HOST:-smtp.gmail.com}',
65-
'smtp_port': '${SMTP_PORT:-587}',
66-
'smtp_username': '${SMTP_USERNAME}',
67-
'smtp_password': '${SMTP_PASSWORD}',
68-
'smtp_use_tls': '${SMTP_USE_TLS:-true}',
69-
'from_email': '${FROM_EMAIL}',
70-
'from_name': '${FROM_NAME:-Chronicle AI}',
71-
# Non-secret settings (literal values OK)
72-
'subject_prefix': 'Conversation Summary',
73-
'summary_max_sentences': 3,
74-
'include_conversation_id': True,
75-
'include_duration': True
64+
'condition': {'type': 'always'}
7665
}
7766

7867
# Update or create plugin entry
@@ -90,7 +79,7 @@ def update_plugins_yml_with_env_refs():
9079
with open(plugins_yml_path, 'w') as f:
9180
yaml.dump(config, f, default_flow_style=False, sort_keys=False)
9281

93-
console.print("[green]✅ Updated config/plugins.yml with environment variable references[/green]")
82+
console.print("[green]✅ Updated config/plugins.yml (orchestration only)[/green]")
9483

9584
return plugins_yml_path
9685

@@ -164,9 +153,9 @@ def main():
164153

165154
console.print("[green]✅ SMTP credentials saved to backends/advanced/.env[/green]")
166155

167-
# Auto-update plugins.yml with env var references
156+
# Auto-update plugins.yml with orchestration settings only
168157
console.print("\n📝 [bold]Updating plugin configuration...[/bold]")
169-
plugins_yml_path = update_plugins_yml_with_env_refs()
158+
plugins_yml_path = update_plugins_yml_orchestration()
170159

171160
# Prompt to enable plugin
172161
enable_now = Confirm.ask("\nEnable email_summarizer plugin now?", default=True)
@@ -181,7 +170,8 @@ def main():
181170
console.print("\n[bold cyan]✅ Email Summarizer configured successfully![/bold cyan]")
182171
console.print("\n[bold]Configuration saved to:[/bold]")
183172
console.print(" • [green]backends/advanced/.env[/green] - SMTP credentials (secrets)")
184-
console.print(" • [green]config/plugins.yml[/green] - Plugin orchestration (env var references)")
173+
console.print(" • [green]config/plugins.yml[/green] - Plugin orchestration (enabled, events)")
174+
console.print(" • [green]plugins/email_summarizer/config.yml[/green] - Plugin settings (already configured)")
185175
console.print()
186176

187177
if not enable_now:
@@ -192,8 +182,9 @@ def main():
192182
console.print("[bold]Restart backend to apply:[/bold]")
193183
console.print(" [dim]cd backends/advanced && docker compose restart[/dim]")
194184
console.print()
195-
console.print("[yellow]⚠️ SECURITY: Never paste actual passwords in config/plugins.yml![/yellow]")
196-
console.print("[yellow] Secrets go in .env, YAML files use ${ENV_VAR} references.[/yellow]")
185+
console.print("[yellow]⚠️ SECURITY: Never commit secrets to git![/yellow]")
186+
console.print("[yellow] • Secrets go in backends/advanced/.env (gitignored)[/yellow]")
187+
console.print("[yellow] • Config files use ${ENV_VAR} references only[/yellow]")
197188

198189

199190
if __name__ == '__main__':

0 commit comments

Comments
 (0)