ishaan1013 / ishaan1013/shadow
Add Public API Route for Task Streaming
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 178
- PR merge metrics
- No merged PRs in 30d
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 `apiKeyAuth` middleware)
- Request body: repository details, initial message, model selection
- Response: Server-Sent Events (SSE) stream with task progress and AI responses
### **Streaming Architecture**
- Leverage existing `StreamChunk` types and `emitStreamChunk` infrastructure
- Convert WebSocket events to SSE format for REST compatibility
- Support same event types: content, tool-calls, tool-results, init-progress, etc.
- Reuse `StreamProcessor` and `ChunkHandlers` for consistent streaming behavior
### **Integration Points**
- Extend current task creation flow (`createTask` + `/initiate` endpoints)
- Reuse `TaskInitializationEngine` and `ChatService` components
- Maintain same security model with API key validation
- Support both local and remote execution modes
### **Response Format**
- SSE data format containing `StreamChunk` JSON 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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.