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:
parent
25f4cfabbb
commit
f33b1767da
10 changed files with 17 additions and 16 deletions
|
|
@ -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<()>);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
// Journal entries are loaded from the memory graph store, not from
|
||||
// a flat file — the parse functions are gone.
|
||||
|
||||
use crate::agent::api::types::*;
|
||||
use crate::agent::api::*;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tiktoken_rs::CoreBPE;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use anyhow::Result;
|
|||
use tiktoken_rs::CoreBPE;
|
||||
|
||||
use api::{ApiClient, ToolCall};
|
||||
use api::types::{ContentPart, Message, MessageContent, Role};
|
||||
use api::{ContentPart, Message, MessageContent, Role};
|
||||
use context::{ConversationEntry, ContextState};
|
||||
use tools::{summarize_args, working_stack};
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@ use std::fs;
|
|||
use std::path::PathBuf;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use super::api::ApiClient;
|
||||
use super::api::types::*;
|
||||
use super::api::{self, ApiClient, Message, Usage};
|
||||
use super::tools::{self as agent_tools};
|
||||
use super::Agent;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ impl Tool {
|
|||
}
|
||||
|
||||
// Re-export API wire types used by the agent turn loop
|
||||
use super::api::types::ToolCall;
|
||||
use super::api::ToolCall;
|
||||
|
||||
/// A tool call in flight — metadata for TUI + JoinHandle for
|
||||
/// result collection and cancellation.
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ impl Subconscious {
|
|||
let rendered = store_guard.as_ref()
|
||||
.and_then(|s| crate::cli::node::render_node(s, key));
|
||||
if let Some(rendered) = rendered {
|
||||
let mut msg = crate::agent::api::types::Message::user(format!(
|
||||
let mut msg = crate::agent::api::Message::user(format!(
|
||||
"<system-reminder>\n--- {} (surfaced) ---\n{}\n</system-reminder>",
|
||||
key, rendered,
|
||||
));
|
||||
|
|
@ -447,7 +447,7 @@ impl Subconscious {
|
|||
|
||||
if let Some(reflection) = outputs.get("reflection") {
|
||||
if !reflection.trim().is_empty() {
|
||||
ag.push_message(crate::agent::api::types::Message::user(format!(
|
||||
ag.push_message(crate::agent::api::Message::user(format!(
|
||||
"<system-reminder>\n--- subconscious reflection ---\n{}\n</system-reminder>",
|
||||
reflection.trim(),
|
||||
)));
|
||||
|
|
@ -457,7 +457,7 @@ impl Subconscious {
|
|||
if let Some(nudge) = outputs.get("thalamus") {
|
||||
let nudge = nudge.trim();
|
||||
if !nudge.is_empty() && nudge != "ok" {
|
||||
ag.push_message(crate::agent::api::types::Message::user(format!(
|
||||
ag.push_message(crate::agent::api::Message::user(format!(
|
||||
"<system-reminder>\n--- thalamus ---\n{}\n</system-reminder>",
|
||||
nudge,
|
||||
)));
|
||||
|
|
|
|||
|
|
@ -363,10 +363,10 @@ impl Mind {
|
|||
let mut ag = self.agent.lock().await;
|
||||
match target {
|
||||
StreamTarget::Conversation => {
|
||||
ag.push_message(crate::agent::api::types::Message::user(text));
|
||||
ag.push_message(crate::agent::api::Message::user(text));
|
||||
}
|
||||
StreamTarget::Autonomous => {
|
||||
let mut msg = crate::agent::api::types::Message::user(text);
|
||||
let mut msg = crate::agent::api::Message::user(text);
|
||||
msg.stamp();
|
||||
ag.push_entry(crate::agent::context::ConversationEntry::Dmn(msg));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
// hasn't internalized. 2 API calls.
|
||||
|
||||
use crate::agent::api::ApiClient;
|
||||
use crate::agent::api::types::*;
|
||||
use crate::agent::api::*;
|
||||
use crate::agent::context::{ConversationEntry, ContextState};
|
||||
|
||||
const SCORE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(120);
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ impl InteractScreen {
|
|||
/// Route an agent entry to pane items.
|
||||
/// Returns empty vec for entries that shouldn't be displayed.
|
||||
fn route_entry(entry: &crate::agent::context::ConversationEntry) -> Vec<(PaneTarget, String, Marker)> {
|
||||
use crate::agent::api::types::Role;
|
||||
use crate::agent::api::Role;
|
||||
use crate::agent::context::ConversationEntry;
|
||||
|
||||
if let ConversationEntry::Memory { .. } = entry {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use ratatui::{
|
|||
|
||||
use super::{App, ScreenView, screen_legend};
|
||||
use crate::agent::context::ConversationEntry;
|
||||
use crate::agent::api::types::Role;
|
||||
use crate::agent::api::Role;
|
||||
|
||||
pub(crate) struct SubconsciousScreen {
|
||||
selected: usize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue