summaryrefslogtreecommitdiff
path: root/libpanto/src/tool.zig
diff options
context:
space:
mode:
authorT <t@tjp.lol>2026-05-26 20:14:37 -0600
committerT <t@tjp.lol>2026-05-27 06:26:36 -0600
commit1f0915edbe0213e8bc134922f10933468d35a172 (patch)
tree11834769555c7037f3393ef8d98bf5841846144a /libpanto/src/tool.zig
parentb788eb05c6d194b91fdc141b6655e61ccaa76ddb (diff)
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
Diffstat (limited to 'libpanto/src/tool.zig')
-rw-r--r--libpanto/src/tool.zig27
1 files changed, 12 insertions, 15 deletions
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,
};
};