Move API code from user/ to agent/

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2026-04-04 00:29:11 -04:00
parent 021eafe6da
commit 9bebbcb635
22 changed files with 259 additions and 251 deletions

View file

@ -13,6 +13,7 @@
// to send here. This module just handles single turns: prompt
// in, response out, tool calls dispatched.
pub mod api;
pub mod context;
pub mod tools;
pub mod training;
@ -20,13 +21,17 @@ pub mod training;
use anyhow::Result;
use tiktoken_rs::CoreBPE;
use crate::user::api::ApiClient;
use crate::agent::context as journal;
use api::{ApiClient, StreamEvent};
use context as journal;
use tools::{ToolCall, ToolDef, FunctionCall, summarize_args};
use crate::user::log::ConversationLog;
use crate::user::api::StreamEvent;
use crate::agent::tools::{ToolCall, ToolDef, FunctionCall, summarize_args};
use crate::user::types::*;
use crate::user::ui_channel::{ContextSection, SharedContextState, StatusInfo, StreamTarget, UiMessage, UiSender};
use crate::agent::api::types::*;
use crate::agent::context::{
ConversationEntry, ContextState, ContextBudget,
working_stack_instructions_path, working_stack_file_path,
};
use crate::user::ui_channel::{ContextSection, SharedContextState, StreamTarget, StatusInfo, UiMessage, UiSender};
/// Result of a single agent turn.
pub struct TurnResult {
@ -447,9 +452,7 @@ impl Agent {
let _ = ui_tx.send(UiMessage::TextDelta("\n".to_string(), target));
}
let msg = crate::user::api::build_response_message(content, tool_calls);
let msg = api::build_response_message(content, tool_calls);
if let Some(usage) = &usage {
self.last_prompt_tokens = usage.prompt_tokens;