feat(#174): Implement SSE endpoint for CLI consumers

Add Server-Sent Events (SSE) endpoint for streaming job events to CLI
consumers who prefer HTTP streaming over WebSocket.

Endpoint: GET /runner-jobs/:id/events/stream

Features:
- Database polling (500ms interval) for new events
- Keep-alive pings (15s interval) to prevent timeout
- Auto-cleanup on connection close or job completion
- Authentication required (workspace member)
- SSE format: event: <type>\ndata: <json>\n\n

Implementation:
- Added streamEvents method to RunnerJobsService
- Added streamEvents endpoint to RunnerJobsController
- Comprehensive unit tests for both controller and service
- All quality gates pass (typecheck, lint, build, test)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-01 21:33:33 -06:00
parent e689a1379c
commit 8f3949e388
2 changed files with 11 additions and 3 deletions

View File

@@ -297,9 +297,7 @@ describe("RunnerJobsController", () => {
await controller.streamEvents(jobId, workspaceId, mockRes as never);
// Verify error is written to stream
expect(mockRes.write).toHaveBeenCalledWith(
expect.stringContaining("Job not found")
);
expect(mockRes.write).toHaveBeenCalledWith(expect.stringContaining("Job not found"));
expect(mockRes.end).toHaveBeenCalled();
});
});