diff options
| author | t <t@tjp.lol> | 2026-06-07 14:49:20 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-07 14:49:20 -0600 |
| commit | 1eddee33902757f7e06993825a3ad1011e7ec346 (patch) | |
| tree | 37671194f5b15f542cfcb8ed69b46bc21196afa5 /src/main.zig | |
| parent | 11818552dad254649af012df3b4277633943d2b6 (diff) | |
Plug the deep-embedder holes; remove public.zig escape hatch
Close the gap that forced the CLI to import internal libpanto namespaces,
then delete the transitional re-exports. The CLI now uses only the curated
public surface.
Additions to the public Agent facade:
- init/deinit (heap-pin the inner; the handle is a copyable value).
- addSystemMessage (.append) and setSystemPrompt (.replace).
- compact(override_system_prompt, extra) falling back to the config prompt.
- sessionId() accessor.
CompactionConfig gains compaction_prompt, which owns the compaction system
prompt for both auto-compaction and the explicit compact() default; the
Agent.compaction_system_prompt field is deleted. ConversationData is the
public name for the owned conversation value type (Session.load returns it,
Agent.init adopts it), distinct from the borrowed Conversation handle.
Agent.addSystemMessage/setSystemPrompt are kept on Agent (they persist with
the SystemMode) rather than dropped as the plan first proposed.
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main.zig b/src/main.zig index 995735f..61a88bd 100644 --- a/src/main.zig +++ b/src/main.zig @@ -144,7 +144,7 @@ const CLIRenderer = struct { /// it terminates (`turn_complete` → `next()` returns null). A failure /// surfaces as the error from `next()`; the caller renders it. The stream is /// always `deinit`ed (persisting the turn tail) on every exit path. -fn driveTurn(agent: *panto.agent.Agent, message: panto.agent.Agent.UserMessage, renderer: *CLIRenderer) !void { +fn driveTurn(agent: panto.Agent, message: panto.UserMessage, renderer: *CLIRenderer) !void { var stream = try agent.run(message); defer stream.deinit(); while (try stream.next()) |ev| try renderer.render(ev); @@ -358,7 +358,7 @@ pub fn main(init: std.process.Init) !void { // On resume, reconstruct the conversation from the store. (The // dangling-prompt recovery feature was dropped in R2.) On a fresh // session, the agent starts with an empty conversation. - var adopted_conversation: ?panto.conversation.Conversation = null; + var adopted_conversation: ?panto.ConversationData = null; if (is_resume) { adopted_conversation = try session.load(); const sid = session.info.id; @@ -376,11 +376,11 @@ pub fn main(init: std.process.Init) !void { // built but before the first turn, so in-place registration is visible. // System-prompt seeding/reconciliation below runs *through* the agent // so those entries persist. - const active_config: panto.Config = .{ + var active_config: panto.Config = .{ .provider = provider_config, .compaction = compaction_cfg, }; - var agent = panto.agent.Agent.init( + const agent = try panto.Agent.init( alloc, io, &active_config, @@ -424,7 +424,7 @@ pub fn main(init: std.process.Init) !void { io, init.environ_map, luarocks_rt.layout.agent_dir, - &agent, + agent, ); } else { // Fresh session — source and install the system prompt. @@ -433,7 +433,7 @@ pub fn main(init: std.process.Init) !void { io, init.environ_map, luarocks_rt.layout.agent_dir, - &agent, + agent, ); } @@ -476,7 +476,9 @@ pub fn main(init: std.process.Init) !void { init.environ_map, luarocks_rt.layout.agent_dir, ); - agent.compaction_system_prompt = compaction_prompt; + // The compaction prompt is resolved after extension load; set it on the + // config the agent re-reads each turn (visible before the first turn). + active_config.compaction.compaction_prompt = compaction_prompt; const banner_base: []const u8 = switch (provider_config) { inline else => |c| c.base_url, @@ -521,7 +523,7 @@ pub fn main(init: std.process.Init) !void { var cmd_ctx: command.Context = .{ .allocator = alloc, - .agent = &agent, + .agent = agent, .stdout = stdout, .stdout_file = &stdout_file, .compaction_prompt = compaction_prompt, @@ -570,7 +572,7 @@ pub fn main(init: std.process.Init) !void { // auto-compaction) through its session store — the CLI no longer // touches persistence. cli_renderer.beginTurn(); - driveTurn(&agent, .{ .text = line }, &cli_renderer) catch |err| { + driveTurn(agent, .{ .text = line }, &cli_renderer) catch |err| { cli_renderer.renderError(err); try stdout.print("\n[error: {s}]\n", .{@errorName(err)}); }; |
