codetether_agent/agent/types.rs
1//! Public agent data types.
2//!
3//! This module groups the serializable metadata and result types shared by the
4//! agent runtime, server, and session layers.
5//!
6//! # Examples
7//!
8//! ```ignore
9//! let mode = AgentMode::Primary;
10//! assert_eq!(mode, AgentMode::Primary);
11//! ```
12
13use serde::{Deserialize, Serialize};
14
15/// Describes a registered agent profile and runtime defaults.
16///
17/// These fields are exposed through the server and UI so callers can inspect
18/// the agent catalog and choose an execution mode.
19///
20/// # Examples
21///
22/// ```ignore
23/// let info = AgentInfo { name: "build".into(), description: None, mode: AgentMode::Primary, native: true, hidden: false, model: None, temperature: None, top_p: None, max_steps: Some(100) };
24/// ```
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct AgentInfo {
27 pub name: String,
28 pub description: Option<String>,
29 pub mode: AgentMode,
30 pub native: bool,
31 pub hidden: bool,
32 pub model: Option<String>,
33 pub temperature: Option<f32>,
34 pub top_p: Option<f32>,
35 pub max_steps: Option<usize>,
36}
37
38/// Categorizes where an agent can be presented or spawned.
39///
40/// Primary agents are visible entrypoints, subagents are delegated workers, and
41/// `All` is used for filters that should include both groups.
42///
43/// # Examples
44///
45/// ```ignore
46/// match AgentMode::Primary { AgentMode::Primary => (), _ => unreachable!() }
47/// ```
48#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
49#[serde(rename_all = "lowercase")]
50pub enum AgentMode {
51 Primary,
52 Subagent,
53 All,
54}
55
56/// Metadata describing a tool registered with an agent.
57///
58/// The agent surfaces this alongside the raw tool registry so UIs and remote
59/// clients can render descriptions and parameter schemas.
60///
61/// # Examples
62///
63/// ```ignore
64/// let metadata = ToolMetadata { name: "bash".into(), description: "Run shell commands".into(), parameters: serde_json::json!({}) };
65/// ```
66#[derive(Debug, Clone, Serialize, Deserialize)]
67pub struct ToolMetadata {
68 pub name: String,
69 pub description: String,
70 pub parameters: serde_json::Value,
71}
72
73/// Final response returned from a completed agent run.
74///
75/// This includes the textual answer along with recorded tool activity and
76/// provider usage metadata captured in the session.
77///
78/// # Examples
79///
80/// ```ignore
81/// let response = AgentResponse { text: String::new(), tool_uses: vec![], usage: Default::default() };
82/// ```
83#[derive(Debug, Clone, Serialize, Deserialize)]
84pub struct AgentResponse {
85 pub text: String,
86 pub tool_uses: Vec<ToolUse>,
87 pub usage: crate::provider::Usage,
88}
89
90/// Records a single tool invocation executed during an agent run.
91///
92/// Sessions store these values so downstream tooling can inspect tool history
93/// without re-parsing provider messages.
94///
95/// # Examples
96///
97/// ```ignore
98/// let use_record = ToolUse { id: "1".into(), name: "bash".into(), input: "{}".into(), output: "ok".into(), success: true };
99/// ```
100#[derive(Debug, Clone, Serialize, Deserialize)]
101pub struct ToolUse {
102 pub id: String,
103 pub name: String,
104 pub input: String,
105 pub output: String,
106 pub success: bool,
107}