fixup: consolidate tool types, fix build after reorganization

Move FunctionCall, FunctionDef, FunctionCallDelta from user/types
to agent/tools. Re-export from user/types for backward compat.
Merge duplicate dispatch functions in tools/mod.rs into dispatch
(agent-specific) + dispatch_shared (with provenance). Fix orphaned
derive, missing imports, runner→agent module path.

Co-Developed-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
ProofOfConcept 2026-04-03 23:21:16 -04:00
parent 474b66c834
commit 17a018ff12
9 changed files with 1356 additions and 1380 deletions

View file

@ -307,10 +307,6 @@ pub(crate) fn parse_markdown(md: &str) -> Vec<Line<'static>> {
.collect()
}
/// A tool call currently in flight — shown above the status bar.
// ActiveTool moved to ui_channel — shared between Agent and TUI
pub(crate) use crate::user::ui_channel::ActiveTool;
/// Main TUI application state.
pub struct App {
pub(crate) autonomous: PaneState,

View file

@ -9,6 +9,12 @@
use chrono::Utc;
use serde::{Deserialize, Serialize};
// Re-export tool types that moved to agent::tools
pub use crate::agent::tools::{
ToolDef, ToolCall, ToolCallDelta, ToolOutput,
FunctionCall, FunctionDef, FunctionCallDelta,
};
/// Message content — either plain text or an array of content parts
/// (for multimodal messages with images). Serializes as a JSON string
/// for text-only, or a JSON array for multimodal.
@ -79,35 +85,7 @@ pub enum Role {
Tool,
}
/// 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,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FunctionCall {
pub name: String,
pub arguments: String, // JSON string
}
/// Tool definition sent to the model.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolDef {
#[serde(rename = "type")]
pub tool_type: String,
pub function: FunctionDef,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FunctionDef {
pub name: String,
pub description: String,
pub parameters: serde_json::Value,
}
// FunctionCall, FunctionDef moved to agent::tools
/// Chat completion request.
#[derive(Debug, Serialize)]
@ -202,23 +180,7 @@ pub struct Delta {
pub tool_calls: Option<Vec<ToolCallDelta>>,
}
/// 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>,
}
#[derive(Debug, Deserialize)]
pub struct FunctionCallDelta {
pub name: Option<String>,
pub arguments: Option<String>,
}
// FunctionCallDelta moved to agent::tools
// --- Convenience constructors ---