agent: use action enum for tool calls and trim REPL input

- Update `buildToolCall` to use `browser_tools.Action` enum.
- Trim whitespace from REPL input in `Agent.zig`.
- Replace `expectEqualStrings` with `expectString` in tests.
This commit is contained in:
Adrià Arrufat
2026-05-21 23:06:34 +02:00
parent e9943a3976
commit 6177d51c4e
3 changed files with 16 additions and 13 deletions

View File

@@ -30,6 +30,7 @@
//! heal roundtrip themselves.
const std = @import("std");
const browser_tools = @import("browser/tools.zig");
pub const Command = @import("script/command.zig").Command;
pub const Recorder = @import("script/Recorder.zig");
@@ -369,7 +370,8 @@ test "applyReplacements: heals a multi-line /eval block using iterator span" {
fn buildToolCall(arena: std.mem.Allocator, name: []const u8, kvs: []const struct { []const u8, []const u8 }) Command {
var obj: std.json.ObjectMap = .init(arena);
for (kvs) |kv| obj.put(kv[0], .{ .string = kv[1] }) catch unreachable;
return .{ .tool_call = .{ .name = name, .args = .{ .object = obj } } };
const action = std.meta.stringToEnum(browser_tools.Action, name).?;
return .{ .tool_call = .{ .action = action, .args = .{ .object = obj } } };
}
test "formatHealReplacement: single command produces one-line replacement" {