Restrict API types visibility — types module is now private

Only Message, Role, MessageContent, ContentPart, ToolCall,
FunctionCall, Usage, ImageUrl are pub-exported from agent::api.

Internal types (ChatRequest, ChatCompletionChunk, ChunkChoice,
Delta, ReasoningConfig, ToolCallDelta, FunctionCallDelta) are
pub(crate) — invisible outside the crate.

All callers updated to import from agent::api:: instead of
agent::api::types::.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-07 13:39:20 -04:00
parent 25f4cfabbb
commit f33b1767da
10 changed files with 17 additions and 16 deletions

View file

@ -8,10 +8,13 @@
pub mod http;
pub mod parsing;
pub mod types;
mod types;
mod openai;
pub use types::*;
// Public API types — used outside agent::api
pub use types::{Message, MessageContent, ContentPart, ImageUrl, Role, ToolCall, FunctionCall, Usage};
// Internal types — re-exported for sibling modules within agent/
pub(crate) use types::{ChatRequest, ReasoningConfig, ChatCompletionChunk, ChunkChoice, Delta, ToolCallDelta, FunctionCallDelta};
use anyhow::Result;
use std::time::{Duration, Instant};
@ -21,7 +24,6 @@ use self::http::{HttpClient, HttpResponse};
use tokio::sync::mpsc;
use crate::agent::tools::{self as agent_tools, summarize_args, ActiveToolCall};
pub use types::ToolCall;
/// A JoinHandle that aborts its task when dropped.
pub struct AbortOnDrop(tokio::task::JoinHandle<()>);