-
Notifications
You must be signed in to change notification settings - Fork 166
Open
Description
Add Public API Route for Task Streaming
Overview
Create a public REST API endpoint that allows external systems to trigger Shadow tasks and receive streaming responses without requiring WebSocket connections.
Proposed Implementation
API Endpoint
POST /api/v1/tasks/stream- RESTful endpoint for task creation and streaming- Authentication via Bearer token (reuse existing
apiKeyAuthmiddleware) - Request body: repository details, initial message, model selection
- Response: Server-Sent Events (SSE) stream with task progress and AI responses
Streaming Architecture
- Leverage existing
StreamChunktypes andemitStreamChunkinfrastructure - Convert WebSocket events to SSE format for REST compatibility
- Support same event types: content, tool-calls, tool-results, init-progress, etc.
- Reuse
StreamProcessorandChunkHandlersfor consistent streaming behavior
Integration Points
- Extend current task creation flow (
createTask+/initiateendpoints) - Reuse
TaskInitializationEngineandChatServicecomponents - Maintain same security model with API key validation
- Support both local and remote execution modes
Response Format
- SSE data format containing
StreamChunkJSON payloads - Task metadata in initial response headers
- Proper error handling and connection management
- Graceful stream termination on completion/failure
Benefits
- Enable headless integrations and CI/CD pipelines
- Support external tools without WebSocket complexity
- Maintain consistency with existing streaming infrastructure
- Preserve security and execution isolation features
Implementation Considerations
- Rate limiting for public API usage
- Documentation and examples for integration
- Error handling for malformed requests
- Proper cleanup of resources on client disconnect
Metadata
Metadata
Assignees
Labels
No labels