diff options
| author | t <t@tjp.lol> | 2026-06-10 10:06:07 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-10 12:17:27 -0600 |
| commit | bb85e867bc938138f29fb45230169af1ba60761c (patch) | |
| tree | 5ad1cf50274c61ccfffab7048b4a4e28003d82b5 /build.zig | |
| parent | d26890bbc52e9f0050db40f208763a7f2b714ddd (diff) | |
Add addUserText helper; update all call sites
Conversation.addUserMessage now takes a []ContentBlock (symmetric with
addAssistantMessage). Introduce a thin addUserText wrapper in agent.zig
for the plain-text case and update every call site in agent.zig and
anthropic_messages_json.zig accordingly.
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -13,6 +13,18 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); + // The native Lua C-module (`libpanto-lua`). We embed its compiled + // `panto.so` into the panto binary and stage it onto the embedded + // VM's `package.cpath` at bootstrap, so `require('panto')` resolves + // to the native agent/stream module on a cold, network-less machine + // (the guaranteed initial module load — see + // docs/step19-cli-panto-module-plan.md). + const panto_lua_dep = b.dependency("panto_lua", .{ + .target = target, + .optimize = optimize, + }); + const panto_so_embed_path = generatePantoSoEmbed(b, panto_lua_dep); + // TOML parser (used by the CLI for ~/.config/panto/models.toml). // We disable the upstream's optional thread-pool dep — we only need // sequential parsing of a small config file. @@ -76,6 +88,9 @@ pub fn build(b: *std.Build) void { exe_mod.addImport("embedded_agent", b.createModule(.{ .root_source_file = agent_embed_path, })); + exe_mod.addImport("embedded_panto_so", b.createModule(.{ + .root_source_file = panto_so_embed_path, + })); // Link Lua. We can't use a static library here because the // standard archive-linking behavior drops object files whose // symbols nothing in our code references — e.g. `lua_settable`, @@ -136,6 +151,9 @@ pub fn build(b: *std.Build) void { test_mod.addImport("embedded_agent", b.createModule(.{ .root_source_file = agent_embed_path, })); + test_mod.addImport("embedded_panto_so", b.createModule(.{ + .root_source_file = panto_so_embed_path, + })); addLuaSources(test_mod, lua_src, lua_anchor_path); test_mod.addIncludePath(lua_src.path("src")); test_mod.linkLibrary(lua_repl); @@ -421,6 +439,41 @@ fn generateLuaHeadersEmbed( return out_zig; } +/// Codegen step: embed the compiled `libpanto-lua` `panto.so` into a Zig +/// module the bootstrap stages onto the embedded VM's `package.cpath`. +/// +/// We address the artifact via `dep.artifact("panto")` (the `addLibrary` +/// Compile step named `panto` in `libpanto-lua/build.zig`) and embed its +/// emitted binary by bytes — name-agnostic, so the upstream `libpanto.so`/ +/// `libpanto.dylib` filename is irrelevant; we always stage it as +/// `panto.so`. The `.so` is copied next to the generated module so +/// `@embedFile` can resolve it. +fn generatePantoSoEmbed( + b: *std.Build, + panto_lua_dep: *std.Build.Dependency, +) std.Build.LazyPath { + const so_path = panto_lua_dep.artifact("panto").getEmittedBin(); + + const tool = b.addExecutable(.{ + .name = "gen-panto-so-embed", + .root_module = b.createModule(.{ + .root_source_file = b.path("build/gen_panto_so_embed.zig"), + .target = b.graph.host, + .optimize = .Debug, + }), + }); + + const run = b.addRunArtifact(tool); + // The generated module `@embedFile`s exactly this name. + run.addArg("panto.so"); + const gen_file = run.addOutputFileArg("embedded_panto_so.zig"); + + const wf = b.addWriteFiles(); + const out_zig = wf.addCopyFile(gen_file, "embedded_panto_so.zig"); + _ = wf.addCopyFile(so_path, "panto.so"); + return out_zig; +} + // Lua 5.4.x core VM + standard library. Excludes lua.c (interpreter entry // point) and luac.c (compiler entry point). const lua_files = [_][]const u8{ |
