mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-12 01:56:19 -04:00
agent: remove unused code and add recorder guard
This commit is contained in:
@@ -28,11 +28,6 @@ pub const SchemaInfo = struct {
|
||||
hints: []const HintSlot,
|
||||
};
|
||||
|
||||
pub const Parsed = struct {
|
||||
schema: *const SchemaInfo,
|
||||
args_json: []const u8,
|
||||
};
|
||||
|
||||
pub const ParseError = error{
|
||||
MissingName,
|
||||
UnknownTool,
|
||||
@@ -152,14 +147,6 @@ pub fn splitNameRest(input: []const u8) ?Split {
|
||||
};
|
||||
}
|
||||
|
||||
/// Parse a slash command body (without the leading `/`).
|
||||
/// `arena` is used for the resulting JSON string and any temporary storage.
|
||||
pub fn parse(arena: std.mem.Allocator, schemas: []const SchemaInfo, input: []const u8) ParseError!Parsed {
|
||||
const split = splitNameRest(input) orelse return error.MissingName;
|
||||
const schema = findSchema(schemas, split.name) orelse return error.UnknownTool;
|
||||
return .{ .schema = schema, .args_json = try parseArgs(arena, schema, split.rest) };
|
||||
}
|
||||
|
||||
/// Parse the args portion of a slash command for an already-resolved schema.
|
||||
pub fn parseArgs(arena: std.mem.Allocator, schema: *const SchemaInfo, rest: []const u8) ParseError![]const u8 {
|
||||
if (rest.len == 0) {
|
||||
@@ -315,7 +302,12 @@ fn lookupFieldType(schema: *const SchemaInfo, key: []const u8) FieldType {
|
||||
|
||||
const testing = std.testing;
|
||||
|
||||
fn parseWithCache(arena: std.mem.Allocator, input: []const u8) !Parsed {
|
||||
const ParsedTest = struct {
|
||||
schema: *const SchemaInfo,
|
||||
args_json: []const u8,
|
||||
};
|
||||
|
||||
fn parseWithCache(arena: std.mem.Allocator, input: []const u8) !ParsedTest {
|
||||
const tools = try arena.alloc(zenai.provider.Tool, browser_tools.tool_defs.len);
|
||||
for (browser_tools.tool_defs, 0..) |td, i| {
|
||||
tools[i] = .{
|
||||
@@ -325,7 +317,9 @@ fn parseWithCache(arena: std.mem.Allocator, input: []const u8) !Parsed {
|
||||
};
|
||||
}
|
||||
const schemas = try buildSchemas(arena, tools);
|
||||
return parse(arena, schemas, input);
|
||||
const split = splitNameRest(input) orelse return error.MissingName;
|
||||
const schema = findSchema(schemas, split.name) orelse return error.UnknownTool;
|
||||
return .{ .schema = schema, .args_json = try parseArgs(arena, schema, split.rest) };
|
||||
}
|
||||
|
||||
fn expectParse(input: []const u8, expected_tool: []const u8, expected_json: []const u8) !void {
|
||||
|
||||
Reference in New Issue
Block a user