#204 Apps: Integrate apps with tool registry
Description
Edit## Parent Epic: #195
## Description
Integrate the app system with the existing tool registry so apps can be used in workflows.
## Location
engine/apps/tool_bridge.py, engine/tools/registry.py
## Tool Name Convention
apps.{app_name}.{action_name}
Examples:
- apps.slack.send_message
- apps.github.create_issue
- apps.email.send
## AppToolBridge Class
### register_app_tools(app_id, version_id, tenant_id)
For each action in app:
1. Create wrapper function
2. Register with tool registry
3. Set waits_for_event flag
### unregister_app_tools(app_id, tenant_id)
Remove app tools from registry when uninstalled
### create_tool_wrapper(app_id, version_id, action_name)
Returns function with signature:
def wrapper(ctx: DurableContext, **kwargs) -> Any:
return app_executor.execute(
ctx=ctx,
app_id=app_id,
version_id=version_id,
action_name=action_name,
tenant_id=ctx.tenant_id,
kwargs=kwargs,
)
## Tool Registry Updates
### Tenant-Scoped Tool Registration
Apps are tenant-scoped, so tool registry needs tenant awareness.
Option 1: Prefix tools with tenant
- tools.{tenant_id}.apps.slack.send_message
- Requires tenant context in tool lookup
Option 2: Dynamic lookup
- Keep tool name as apps.slack.send_message
- Lookup tenant installation at execution time
- Fail if app not installed for tenant
Recommended: Option 2 (cleaner, runtime check)
### registry.py Changes
- Add is_app_tool(name) method
- Add get_app_executor() method
- Modify get() to handle app tools specially
## Workflow Usage
```python
builder.task(
'notify',
'apps.slack.send_message',
kwargs={'channel': '#alerts', 'message': 'Hello'}
)
```
## Lazy Loading
App tools loaded on first use, not at worker startup
## Testing
- Test tool registration
- Test tool execution through registry
- Test tenant isolation
- Test unregistration on uninstall
Comments
Loading comments...
Context
Loading context...
Audit History
View AllLoading audit history...