feat(#2479): add from/until event-id cursors to read_room
This commit is contained in:
parent
d90504b427
commit
001b1dae37
4 changed files with 189 additions and 46 deletions
|
|
@ -203,6 +203,17 @@ struct ReadRoomArgs {
|
|||
/// Maximum events to return (default 50, max 200). Newest first.
|
||||
#[serde(default)]
|
||||
limit: Option<usize>,
|
||||
/// Anchor at this event id and read *forward* from it: returns the anchor
|
||||
/// plus the `limit - 1` events after it (chronologically newer). Use to
|
||||
/// continue reading from a known event. Mutually exclusive with `until`.
|
||||
#[serde(default)]
|
||||
from: Option<String>,
|
||||
/// Anchor at this event id and read *backward* to it: returns the anchor
|
||||
/// plus the `limit - 1` events before it (into the past). Use to page
|
||||
/// older context around a known event (e.g. the target of a reply).
|
||||
/// Mutually exclusive with `from`.
|
||||
#[serde(default)]
|
||||
until: Option<String>,
|
||||
/// Matrix account to act as (a `name` from `hyperhive.matrixAccounts`).
|
||||
/// Omit to use the agent's primary account.
|
||||
#[serde(default)]
|
||||
|
|
@ -518,9 +529,15 @@ impl MatrixBridge {
|
|||
render(call(args.account, DaemonOp::ListRoomMembers { room: args.room }).await)
|
||||
}
|
||||
|
||||
#[tool(description = "Read the most recent N events from a matrix room \
|
||||
(default 50, max 200). Returns each event's id, sender, timestamp, \
|
||||
type, and best-effort plain-text body.")]
|
||||
#[tool(description = "Read events from a matrix room (default 50, max 200), \
|
||||
newest first. Returns each event's id, sender, timestamp, type, \
|
||||
best-effort plain-text body, and the id of the event it replies to \
|
||||
(when any). By default returns the most recent events. Pass `from` \
|
||||
= an event id to read forward from that event (anchor + newer \
|
||||
events), or `until` = an event id to read backward to it (anchor + \
|
||||
older events) — e.g. to fetch the context around a reply target \
|
||||
outside the current window. `from` and `until` are mutually \
|
||||
exclusive.")]
|
||||
async fn read_room(&self, Parameters(args): Parameters<ReadRoomArgs>) -> String {
|
||||
render(
|
||||
call(
|
||||
|
|
@ -528,6 +545,8 @@ impl MatrixBridge {
|
|||
DaemonOp::ReadRoom {
|
||||
room: args.room,
|
||||
limit: args.limit,
|
||||
from: args.from,
|
||||
until: args.until,
|
||||
},
|
||||
)
|
||||
.await,
|
||||
|
|
|
|||
Loading…
Reference in a new issue