api: move wire types and parsing to api module

Move FunctionCall, FunctionCallDelta, ToolCall, ToolCallDelta from
tools/mod.rs to api/types.rs — these are API wire format, not tool
definitions. Re-export from tools for existing callers.

Move parsing.rs to api/parsing.rs — leaked tool call parsing is API
plumbing.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-04 17:58:49 -04:00 committed by Kent Overstreet
parent 618121067b
commit 6845644f7b
5 changed files with 41 additions and 42 deletions

View file

@ -20,7 +20,6 @@ mod control;
mod vision;
pub mod working_stack;
use serde::{Serialize, Deserialize};
use std::future::Future;
use std::pin::Pin;
use std::time::Instant;
@ -57,40 +56,8 @@ impl Tool {
}
}
/// Function call within a tool call — name + JSON arguments.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FunctionCall {
pub name: String,
pub arguments: String,
}
/// Partial function call within a streaming delta.
#[derive(Debug, Deserialize)]
pub struct FunctionCallDelta {
pub name: Option<String>,
pub arguments: Option<String>,
}
/// A tool call requested by the model.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolCall {
pub id: String,
#[serde(rename = "type")]
pub call_type: String,
pub function: FunctionCall,
}
/// A partial tool call within a streaming delta. The first chunk for a
/// given tool call carries the id and function name; subsequent chunks
/// carry argument fragments.
#[derive(Debug, Deserialize)]
pub struct ToolCallDelta {
pub index: usize,
pub id: Option<String>,
#[serde(rename = "type")]
pub call_type: Option<String>,
pub function: Option<FunctionCallDelta>,
}
// Re-export API wire types used by the agent turn loop
pub use super::api::types::{FunctionCall, ToolCall, ToolCallDelta};
/// A tool call in flight — metadata for TUI + JoinHandle for
/// result collection and cancellation.