feat(#1685): surface attachments in read_room + add download_file

This commit is contained in:
damocles 2026-06-15 18:17:35 +02:00
commit 73c53c7d4a
4 changed files with 147 additions and 12 deletions

View file

@ -138,6 +138,19 @@ struct ReadRoomArgs {
limit: Option<usize>,
}
#[derive(Debug, Deserialize, JsonSchema)]
struct DownloadFileArgs {
/// Matrix room id (`!abc:server`) or canonical alias (`#name:server`).
room: String,
/// Event id of the attachment message (from `read_room`, where media
/// events show a `[file: …]` / `[image: …]` marker).
event_id: String,
/// Optional absolute destination path. Omit to write a temp file
/// named after the attachment; the returned `path` is where to read it.
#[serde(default)]
dest_path: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
struct ListInvitesArgs {}
@ -380,6 +393,24 @@ impl MatrixBridge {
.await,
)
}
#[tool(
description = "Download a media attachment from a matrix message to a local \
file and return its path. `room` is a room id/alias; `event_id` is the \
attachment message (read_room shows media as `[file: ]`/`[image: ]`); \
optional `dest_path` overrides the temp destination. The read-side \
counterpart of send_file."
)]
async fn download_file(&self, Parameters(args): Parameters<DownloadFileArgs>) -> String {
render(
round_trip(DaemonRequest::DownloadFile {
room: args.room,
event_id: args.event_id,
dest_path: args.dest_path,
})
.await,
)
}
}
#[tool_handler(instructions = "Matrix client for an agent on a hyperhive swarm. Use \