From 73645129a9de90f867908d35e77c9252bae4e534 Mon Sep 17 00:00:00 2001 From: t Date: Fri, 5 Jun 2026 13:55:20 -0600 Subject: refactor: Agent.run() -> Stream -> Stream.next() -> Event converted the main agent loop from push-based (into callbacks on a Receiver vtable) to pull-based, where `next()` re-enters a state-machine Stream until the next event can be returned. --- libpanto/src/root.zig | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'libpanto/src/root.zig') diff --git a/libpanto/src/root.zig b/libpanto/src/root.zig index a49a428..b5fab1a 100644 --- a/libpanto/src/root.zig +++ b/libpanto/src/root.zig @@ -2,6 +2,7 @@ const std = @import("std"); pub const conversation = @import("conversation.zig"); pub const provider = @import("provider.zig"); +pub const stream = @import("stream.zig"); pub const agent = @import("agent.zig"); pub const config = @import("config.zig"); pub const sse = @import("sse.zig"); @@ -32,12 +33,17 @@ pub const ToolRegistry = tool_registry.ToolRegistry; pub const Config = config.Config; pub const ProviderConfig = config.ProviderConfig; +// Re-export the pull-streaming surface for embedders. +pub const Event = stream.Event; +pub const Stream = agent.Stream; +pub const Agent = agent.Agent; + // Internal modules. Not part of the public API — callers drive turns via -// `provider.streamStep(allocator, io, &config, conv, receiver)` (or via the -// `Agent`, which holds a swappable `*const Config`). The process-global HTTP -// client is initialized with `config.initHttp` / torn down with -// `config.deinitHttp`. These impls are exposed here only so `refAllDecls` -// picks up their tests. +// the `Agent` (which holds a swappable `*const Config`): `agent.run()` +// returns a `*Stream` whose `next()` pulls one `Event` at a time. The +// process-global HTTP client is initialized with `config.initHttp` / torn +// down with `config.deinitHttp`. These impls are exposed here only so +// `refAllDecls` picks up their tests. const openai_chat_json = @import("openai_chat_json.zig"); const provider_openai_chat = @import("provider_openai_chat.zig"); const anthropic_messages_json = @import("anthropic_messages_json.zig"); -- cgit v1.3