api: extract collect_stream() from agent turn loop

Move the entire stream event processing loop (content accumulation,
leaked tool call detection/dispatch, ToolCallDelta assembly, UI
forwarding, display buffering) into api::collect_stream(). The turn
loop now calls collect_stream() and processes the StreamResult.

Also move FunctionCall, ToolCall, ToolCallDelta to api/types.rs where
they belong (API wire format, not tool definitions). Move parsing.rs
to api/parsing.rs.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
ProofOfConcept 2026-04-04 18:05:16 -04:00 committed by Kent Overstreet
parent 6845644f7b
commit a14e85afe1
3 changed files with 155 additions and 118 deletions

View file

@ -57,7 +57,7 @@ impl Tool {
}
// Re-export API wire types used by the agent turn loop
pub use super::api::types::{FunctionCall, ToolCall, ToolCallDelta};
use super::api::types::ToolCall;
/// A tool call in flight — metadata for TUI + JoinHandle for
/// result collection and cancellation.