summaryrefslogtreecommitdiff
path: root/libpanto/src/tool.zig
diff options
context:
space:
mode:
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,
};
};