diff options
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig index 6fbdb4b..6407611 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,14 +1,18 @@ const std = @import("std"); const panto = @import("panto"); const ping_tool = @import("ping_tool.zig"); +const lua_bridge = @import("lua_bridge.zig"); +const lua_tool = @import("lua_tool.zig"); -// Lua 5.4 C API. Linked statically via build.zig from the upstream lua.org -// source tarball pinned in build.zig.zon. -const lua = @cImport({ - @cInclude("lua.h"); - @cInclude("lauxlib.h"); - @cInclude("lualib.h"); -}); +// Shorthand alias for the Lua C API. The bridge module owns the actual +// `@cImport`; we re-use it here so the smoke check uses identical types. +const lua = lua_bridge.c; + +test { + std.testing.refAllDecls(@This()); + _ = lua_bridge; + _ = lua_tool; +} const Receiver = panto.provider.Receiver; const ReceiverVTable = panto.provider.ReceiverVTable; @@ -221,6 +225,27 @@ pub fn main(init: std.process.Init) !void { // the tool-call loop against a real LLM. try agent.registerTool(ping_tool.tool()); + // Load any Lua extensions specified via `--lua <path>` flags. This is a + // slice-2 manual hook — slice 3 will replace it with directory discovery. + const argv = try init.minimal.args.toSlice(init.arena.allocator()); + var i: usize = 1; + while (i < argv.len) : (i += 1) { + const a = argv[i]; + if (std.mem.eql(u8, a, "--lua")) { + i += 1; + if (i >= argv.len) { + std.log.err("--lua requires a path argument", .{}); + return error.MissingLuaPath; + } + const path = argv[i]; + const n = lua_tool.loadExtension(alloc, &agent.registry, path) catch |err| { + std.log.err("failed to load Lua extension {s}: {t}", .{ path, err }); + return err; + }; + std.log.debug("lua: loaded {d} tool(s) from {s}", .{ n, path }); + } + } + const banner_model: []const u8 = switch (config) { inline else => |c| c.model, }; |
