Skip to main content

Module events

Module events 

Source
Expand description

Cursor-paginated event polling exposed as a futures::Stream.

Two entry points:

  • list_events_page — single-page GET /agents/me/events; useful for CLI events poll --cursor … invocations that want manual control.
  • stream_events — long-running Stream of AgentEvent that chases has_more without sleeping and falls back to poll_interval only when it hits the page tip.

§Cursor discipline

When the server returns next_cursor: null, we’ve reached the tip. On the next poll we reuse the last-known cursor — sending None again would risk reprocessing the entire backlog. The server treats the cursor as opaque; the client must too.

Structs§

PollOptions
TolerantEventPage
Event page tolerant of per-item decode failures.
UnparseableEvent
One unparseable event carried alongside the decoded page so callers can surface partial success instead of failing the whole batch.

Constants§

DEFAULT_PAGE_LIMIT
DEFAULT_POLL_INTERVAL
Default knobs. Page size of 100 matches the server’s ceiling for this endpoint; a 5-second sleep at the tip balances liveness vs. quota pressure on long-idle agents.

Functions§

decode_event_item
Decode a single event JSON value tolerantly into an AgentEvent.
list_events_page
One-shot GET /agents/me/events?cursor=…&limit=….
list_events_page_tolerant
Tolerant variant of list_events_page.
stream_events
Long-running event stream. The returned Stream never ends on its own — drop it when the consumer is done. Each Result item is independent: the stream surfaces transient errors but does not abort, so consumers can .next() again to retry.