Skip to content

Add task file content and logs API#71

Merged
lewiszlw merged 7 commits intomainfrom
feature/get-task-file-content
Apr 5, 2026
Merged

Add task file content and logs API#71
lewiszlw merged 7 commits intomainfrom
feature/get-task-file-content

Conversation

@lewiszlw
Copy link
Copy Markdown
Member

@lewiszlw lewiszlw commented Apr 5, 2026

This PR adds HTTP endpoints for:

  • GET /tasks/{task_id}/files/{path} - Retrieve file content (text or binary)
  • GET /tasks/{task_id}/logs - Retrieve task logs with pagination

Features:

  • Support for both text and binary file content
  • Pagination support for logs (limit/offset)
  • Max 1000 lines per request for performance
  • Returns has_more flag for pagination

lewiszlw added 7 commits April 4, 2026 18:51
- Add new endpoint for retrieving individual file content
- Text files: return content as UTF-8 string
- Binary files: return metadata only (detected by Content-Type)
- Security: prevent directory traversal attacks
- Support various file types: text, code, images, documents, archives
- Add base64 encoding utility for binary fallback
- Include comprehensive tests
- Text files: return raw content directly with appropriate Content-Type
- Binary files: return base64-encoded content as plain text
- Remove JSON wrapper with metadata (name, path, size, modified)
- Simplify response to only contain the file content itself
- Binary files now return raw bytes with correct Content-Type
- Text files continue to return raw content
- Removed custom base64 encoding module
- Removed base64-related tests
- Simplified response handling
- Add new get_task_logs module with limit/offset pagination
- Filter logs by task_id from babata.log file
- Return structured response with total_lines, has_more, and logs array
- Limit max page size to 1000 lines for performance
- Add unit tests for default limit and response serialization
- All tests pass (124 passed), clippy clean
@lewiszlw lewiszlw merged commit aba1922 into main Apr 5, 2026
4 of 6 checks passed
@lewiszlw lewiszlw deleted the feature/get-task-file-content branch April 5, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant