replace send_file_dm with open_dm resolver (per review)
This commit is contained in:
parent
19f1fa4f28
commit
07941421c1
4 changed files with 26 additions and 44 deletions
|
|
@ -93,16 +93,10 @@ struct SendFileArgs {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
struct SendFileDmArgs {
|
||||
/// Matrix user id of the recipient (`@user:server`). DM room is
|
||||
struct OpenDmArgs {
|
||||
/// Matrix user id (`@user:server`) to open a DM with. The DM room is
|
||||
/// created if one doesn't already exist.
|
||||
user_id: String,
|
||||
/// Absolute path to a local file readable by the agent. MIME type is
|
||||
/// inferred from the extension. 50 MiB cap.
|
||||
path: String,
|
||||
/// Optional caption, sent as a follow-up text message in the DM.
|
||||
#[serde(default)]
|
||||
caption: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
|
|
@ -240,19 +234,14 @@ impl MatrixBridge {
|
|||
)
|
||||
}
|
||||
|
||||
#[tool(
|
||||
description = "Open (or reuse) a DM with `user_id` (@user:server) and upload \
|
||||
a local file as an attachment. `path` is an absolute local file path (MIME \
|
||||
inferred, 50 MiB cap); optional `caption` is sent as a follow-up message. \
|
||||
If the DM room already exists with unread messages, the send is rejected \
|
||||
— read_room then mark_read first."
|
||||
)]
|
||||
async fn send_file_dm(&self, Parameters(args): Parameters<SendFileDmArgs>) -> String {
|
||||
#[tool(description = "Resolve (find-or-create) the DM room with `user_id` \
|
||||
(@user:server) and return its room id, without sending anything. Use the \
|
||||
returned room id with the room-based tools (`send_file`, `send_message`, \
|
||||
…) to deliver into the DM — there is no per-tool DM variant.")]
|
||||
async fn open_dm(&self, Parameters(args): Parameters<OpenDmArgs>) -> String {
|
||||
render(
|
||||
round_trip(DaemonRequest::SendFileDm {
|
||||
round_trip(DaemonRequest::OpenDm {
|
||||
user_id: args.user_id,
|
||||
path: args.path,
|
||||
caption: args.caption,
|
||||
})
|
||||
.await,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue