Skip to content

Commit caf0b6b

Browse files
gHashTagAntigravity Agentclaude
authored
fix(agent): Add emojis to Telegram messages (#53)
* fix(agent): Add emojis to Telegram messages + document memory leak - agent_loop.zig: 10 emoji prefixes (🤖 WAKE, 😴 Sleep, ✅ Done, ❌ FAILED, etc.) - ralph_hook.zig: 5 emoji prefixes (✅ tool done, ❌ FAILED, 🔧 running, etc.) - main.zig: Document intentional stdout lifetime (not a real leak) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(agent): Add emojis to Telegram messages + document memory leak - agent_loop.zig: emoji prefixes on all TG messages (🤖 WAKE, 😴 Sleep, ✅ Done, etc.) - ralph_hook.zig: emoji prefixes on hook messages (✅ done, ❌ FAILED, 🔧 running) - telegram.zig: remove parse_mode HTML (plain text with emojis) - main.zig: document intentional stdout leak for project_root lifetime 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(agent): TRI branding + emojis in Telegram messages Rename ralph → TRI (uppercase) in all Telegram messages. Add emojis: 🤖 WAKE, 📋 Issues, 🧠 Spawning, ✅ done, ❌ FAILED, 😴 Sleep. Remove HTML parse_mode — plain text renders better in Telegram. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Antigravity Agent <antigravity@vibee.org> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 59bbf2c commit caf0b6b

4 files changed

Lines changed: 19 additions & 16 deletions

File tree

tools/mcp/trinity_mcp/agent/agent_loop.zig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ pub fn run(allocator: std.mem.Allocator, config: Config) !void {
4545

4646
// Telegram: announce wake
4747
var tg_buf: [512]u8 = undefined;
48-
telegram.sendFmt(config.tg_config, &tg_buf, "<b>ralph</b> | WAKE #{d}", .{wake_count});
48+
telegram.sendFmt(config.tg_config, &tg_buf, "\xf0\x9f\xa4\x96 TRI WAKE #{d}", .{wake_count});
4949

5050
if (config.max_wakes > 0 and wake_count > config.max_wakes) {
5151
log("Max wakes ({d}) reached. Exiting.", .{config.max_wakes});
52-
telegram.send(config.tg_config, "<b>ralph</b> | Max wakes reached. Stopping.");
52+
telegram.send(config.tg_config, "\xf0\x9f\x9b\x91 TRI Max wakes reached.");
5353
break;
5454
}
5555

@@ -73,14 +73,14 @@ pub fn run(allocator: std.mem.Allocator, config: Config) !void {
7373

7474
if (issues_json == null) {
7575
log("No pending issues or GitHub API unavailable. Sleeping.", .{});
76-
telegram.send(config.tg_config, "<b>ralph</b> | No issues found. Sleeping.");
76+
telegram.send(config.tg_config, "\xf0\x9f\x98\xb4 TRI No issues. Sleeping.");
7777
if (config.single_shot) break;
7878
std.Thread.sleep(config.sleep_interval_s * std.time.ns_per_s);
7979
continue;
8080
}
8181

8282
// Telegram: issues found
83-
telegram.sendFmt(config.tg_config, &tg_buf, "<b>ralph</b> | Issues found, building context...", .{});
83+
telegram.sendFmt(config.tg_config, &tg_buf, "\xf0\x9f\x93\x8b TRI Issues found, building context...", .{});
8484

8585
// Read current state
8686
const current_issue = state.read("current_issue");
@@ -105,7 +105,7 @@ pub fn run(allocator: std.mem.Allocator, config: Config) !void {
105105
const use_continue = wake_count > 1;
106106

107107
// Telegram: spawning Claude
108-
telegram.sendFmt(config.tg_config, &tg_buf, "<b>ralph</b> | Spawning Claude ({d}b context, {s})...", .{
108+
telegram.sendFmt(config.tg_config, &tg_buf, "\xf0\x9f\xa7\xa0 TRI Spawning Claude ({d}b, {s})...", .{
109109
prompt.len,
110110
if (use_continue) "--continue" else "new session",
111111
});
@@ -119,7 +119,7 @@ pub fn run(allocator: std.mem.Allocator, config: Config) !void {
119119
use_continue,
120120
) catch |err| {
121121
log("Claude spawn error: {s}", .{@errorName(err)});
122-
telegram.sendFmt(config.tg_config, &tg_buf, "<b>ralph</b> | Claude spawn FAILED: {s}", .{@errorName(err)});
122+
telegram.sendFmt(config.tg_config, &tg_buf, "\xe2\x9d\x8c TRI Claude spawn FAILED: {s}", .{@errorName(err)});
123123
if (config.single_shot) break;
124124
std.Thread.sleep(config.sleep_interval_s * std.time.ns_per_s);
125125
continue;
@@ -130,9 +130,9 @@ pub fn run(allocator: std.mem.Allocator, config: Config) !void {
130130

131131
// Telegram: Claude finished
132132
if (result.exit_code == 0) {
133-
telegram.sendFmt(config.tg_config, &tg_buf, "<b>ralph</b> | Claude done ({d}b output)", .{result.stdout.len});
133+
telegram.sendFmt(config.tg_config, &tg_buf, "\xe2\x9c\x85 TRI Claude done ({d}b)", .{result.stdout.len});
134134
} else {
135-
telegram.sendFmt(config.tg_config, &tg_buf, "<b>ralph</b> | Claude exit={d} ({d}b output)", .{ result.exit_code, result.stdout.len });
135+
telegram.sendFmt(config.tg_config, &tg_buf, "\xe2\x9a\xa0\xef\xb8\x8f TRI exit={d} ({d}b)", .{ result.exit_code, result.stdout.len });
136136
}
137137

138138
// Save session log
@@ -146,12 +146,12 @@ pub fn run(allocator: std.mem.Allocator, config: Config) !void {
146146

147147
if (config.single_shot) {
148148
log("Single-shot mode. Exiting.", .{});
149-
telegram.send(config.tg_config, "<b>ralph</b> | Single-shot done. Exiting.");
149+
telegram.send(config.tg_config, "\xf0\x9f\x8f\x81 TRI Done.");
150150
break;
151151
}
152152

153153
log("Sleeping for {d}s...", .{config.sleep_interval_s});
154-
telegram.sendFmt(config.tg_config, &tg_buf, "<b>ralph</b> | Sleeping {d}s...", .{config.sleep_interval_s});
154+
telegram.sendFmt(config.tg_config, &tg_buf, "\xf0\x9f\x98\xb4 TRI Sleeping {d}s...", .{config.sleep_interval_s});
155155
std.Thread.sleep(config.sleep_interval_s * std.time.ns_per_s);
156156
}
157157

tools/mcp/trinity_mcp/agent/main.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ pub fn main() !void {
5858
std.process.exit(1);
5959
};
6060
defer allocator.free(result.stderr);
61+
// Note: result.stdout is intentionally NOT freed here — it's used as project_root
62+
// for the lifetime of the program. The GPA will report it as "leaked" but it's
63+
// needed until process exit.
6164
if (result.stdout.len == 0) {
6265
std.debug.print("[ralph-agent] ERROR: Not in a git repository.\n", .{});
6366
std.process.exit(1);

tools/mcp/trinity_mcp/agent/ralph_hook.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ pub fn main() !void {
3939
// Format message based on event type
4040
var buf: [512]u8 = undefined;
4141
const msg = if (std.mem.eql(u8, event, "PostToolUse"))
42-
std.fmt.bufPrint(&buf, "<b>ralph</b> | {s} done", .{truncate(tool, 40)}) catch return
42+
std.fmt.bufPrint(&buf, "\xe2\x9c\x85 {s} done", .{truncate(tool, 40)}) catch return
4343
else if (std.mem.eql(u8, event, "PostToolUseFailure"))
44-
std.fmt.bufPrint(&buf, "<b>ralph</b> | {s} FAILED", .{truncate(tool, 40)}) catch return
44+
std.fmt.bufPrint(&buf, "\xe2\x9d\x8c {s} FAILED", .{truncate(tool, 40)}) catch return
4545
else if (std.mem.eql(u8, event, "PreToolUse"))
46-
std.fmt.bufPrint(&buf, "<b>ralph</b> | {s}...", .{truncate(tool, 40)}) catch return
46+
std.fmt.bufPrint(&buf, "\xf0\x9f\x94\xa7 {s}...", .{truncate(tool, 40)}) catch return
4747
else if (std.mem.eql(u8, event, "Stop"))
48-
std.fmt.bufPrint(&buf, "<b>ralph</b> | Session finished", .{}) catch return
48+
std.fmt.bufPrint(&buf, "\xf0\x9f\x98\xb4 TRI Session finished", .{}) catch return
4949
else if (std.mem.eql(u8, event, "SessionStart"))
50-
std.fmt.bufPrint(&buf, "<b>ralph</b> | Session started", .{}) catch return
50+
std.fmt.bufPrint(&buf, "\xf0\x9f\xa4\x96 TRI Session started", .{}) catch return
5151
else
5252
return; // Unknown event, skip
5353

tools/mcp/trinity_mcp/agent/telegram.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn sendToEndpoint(config: TelegramConfig, endpoint: []const u8, text: []const u8
8080
}
8181
}
8282

83-
const suffix = "\",\"parse_mode\":\"HTML\"}";
83+
const suffix = "\"}";
8484
if (i + suffix.len <= body_buf.len) {
8585
@memcpy(body_buf[i..][0..suffix.len], suffix);
8686
i += suffix.len;

0 commit comments

Comments
 (0)