From 1f0915edbe0213e8bc134922f10933468d35a172 Mon Sep 17 00:00:00 2001 From: T Date: Tue, 26 May 2026 20:14:37 -0600 Subject: finish lua runtime makeover - new multi-tool registration via ToolSource - thread per source-or-standalone-tool - switched to zig 0.16 Io threading interface - cli: include `luv` package and run concurrent lua tools via libuv - one single long-lived lua_State for the whole cli program --- libpanto/src/tool.zig | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'libpanto/src/tool.zig') diff --git a/libpanto/src/tool.zig b/libpanto/src/tool.zig index 1d8d113..d9fb178 100644 --- a/libpanto/src/tool.zig +++ b/libpanto/src/tool.zig @@ -6,20 +6,17 @@ const std = @import("std"); const Allocator = std.mem.Allocator; +const tool_source = @import("tool_source.zig"); -pub const Tool = struct { - /// Tool name. Borrowed — lifetime is owned by whoever constructs the - /// `Tool`. Typically the same owner that backs `ctx` (e.g. a LuaTool - /// adapter, or a static const in a native tool). - name: []const u8, - - /// Human-readable purpose of the tool. Emitted to the LLM alongside the - /// schema. Borrowed; same lifetime contract as `name`. - description: []const u8, +pub const ToolDecl = tool_source.ToolDecl; - /// JSON Schema for the tool's input, as raw JSON bytes. Emitted verbatim - /// into provider request bodies. Borrowed; same lifetime contract. - schema_json: []const u8, +pub const Tool = struct { + /// Metadata: `name`, `description`, `schema_json`. Borrowed — the + /// lifetime of every string in `decl` is owned by whoever + /// constructs the `Tool`. Typically the same owner that backs + /// `ctx` (e.g. an adapter for an out-of-process runtime, or a + /// `comptime` static in a native tool). + decl: ToolDecl, /// Opaque context pointer passed back to every vtable call. ctx: *anyopaque, @@ -53,9 +50,9 @@ pub const Tool = struct { /// down. Frees any resources owned by `ctx`, including `ctx` /// itself if it was heap-allocated. /// - /// `name`, `description`, and `schema_json` are also typically - /// owned by the same allocation as `ctx` — the tool's deinit - /// hook is responsible for freeing them. + /// The strings inside `decl` are also typically owned by the + /// same allocation as `ctx` — the tool's deinit hook is + /// responsible for freeing them. deinit: *const fn (ctx: *anyopaque, allocator: Allocator) void, }; }; -- cgit v1.3