harness: live tool-call bubble during agent turns (one message, m.replace edits, capped at 10 lines/3.5k chars, final reply as fresh message)

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
This commit is contained in:
pierreandLetta Code committed 2026-09-20 14:20:13 +03:00
1 parent 58a66700c6
commit 8d89e3baeb
2 files changed
+127 -3

No files matched your search

+24
View File
@@ -354,6 +354,30 @@ pub fn sendText(alloc: std.mem.Allocator, io: Io, token: []const u8, room: []con
return ev.val;
}
/// Edit an existing m.text message in place (m.replace). `orig_event_id` is
/// the event being replaced; `new_body` is the full replacement text. The
/// plain-text `body` carries the "* " legacy-edit prefix for old clients.
pub fn editText(alloc: std.mem.Allocator, io: Io, token: []const u8, room: []const u8, orig_event_id: []const u8, new_body: []const u8) ![]u8 {
const ts = Io.Clock.now(.real, io).nanoseconds;
const url = try std.fmt.allocPrint(alloc, "{s}/_matrix/client/v3/rooms/{s}/send/m.room.message/infr-edit-{d}", .{ HOMESERVER, room, ts });
defer alloc.free(url);
var payload: std.ArrayList(u8) = .empty;
defer payload.deinit(alloc);
try payload.appendSlice(alloc, "{\"msgtype\":\"m.text\",\"body\":\"* ");
try jsonEscape(alloc, &payload, new_body);
try payload.appendSlice(alloc, "\",\"m.new_content\":{\"msgtype\":\"m.text\",\"body\":\"");
try jsonEscape(alloc, &payload, new_body);
try payload.appendSlice(alloc, "\"},\"m.relates_to\":{\"rel_type\":\"m.replace\",\"event_id\":\"");
try jsonEscape(alloc, &payload, orig_event_id);
try payload.appendSlice(alloc, "\"}}");
const resp = try http(alloc, io, "PUT", url, token, payload.items);
defer alloc.free(resp);
const ev = letta.jsonStr(alloc, resp, 0, "event_id") orelse return error.SendFailed;
return ev.val;
}
/// Join a room by id (accepts invites).
pub fn joinRoom(alloc: std.mem.Allocator, io: Io, token: []const u8, room: []const u8) !void {
const url = try std.fmt.allocPrint(alloc, "{s}/_matrix/client/v3/rooms/{s}/join", .{ HOMESERVER, room });