OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Add event search endpoint with pagination and filtering

Open tofarr opened this issue 1 year ago • 0 comments

Added Endpoint to get the content of the EventStream via REST

(I think the line above should be included in release notes)

I needed this for debugging. e.g.:

fetch('/api/events/search', {
  headers: {
    'Authorization': 'Bearer YOUR_SESSION_TOKEN'
  }
}).then((response) => {
  response.json().then((content) => {
    console.log(content)
  })
})

Auto Generated by OpenHands

This PR adds a new /api/events/search endpoint that allows searching through the event stream with pagination and filtering capabilities.

Features:

  • Pagination with configurable page size (default 20, max 100)
  • Text search across event content
  • Filter by event type
  • Filter by event source
  • Filter by date range
  • Returns page metadata for navigation

Example usage:

# Basic usage with default pagination
GET /api/events/search

# With text search and custom page size
GET /api/events/search?query=error&page_size=50

# With type filter and date range
GET /api/events/search?event_type=FileReadAction&start_date=2024-01-01T00:00:00

To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:6c29dc5-nikolaik   --name openhands-app-6c29dc5   docker.all-hands.dev/all-hands-ai/openhands:6c29dc5

tofarr avatar Nov 01 '24 18:11 tofarr