codetether_agent/search/types.rs
1//! Types shared between the search router, its backends, and the CLI.
2//!
3//! Keeping these in a dedicated module avoids circular deps and makes
4//! backend plug-ins trivial to add later.
5
6use serde::{Deserialize, Serialize};
7use serde_json::Value;
8
9/// Identifier of a search backend the router can pick.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
11#[serde(rename_all = "snake_case")]
12pub enum Backend {
13 Grep,
14 Glob,
15 Websearch,
16 Webfetch,
17 Memory,
18 Rlm,
19}
20
21impl Backend {
22 /// Short identifier used in LLM prompts and JSON output.
23 ///
24 /// # Examples
25 ///
26 /// ```rust
27 /// use codetether_agent::search::types::Backend;
28 /// assert_eq!(Backend::Grep.id(), "grep");
29 /// ```
30 pub fn id(self) -> &'static str {
31 match self {
32 Self::Grep => "grep",
33 Self::Glob => "glob",
34 Self::Websearch => "websearch",
35 Self::Webfetch => "webfetch",
36 Self::Memory => "memory",
37 Self::Rlm => "rlm",
38 }
39 }
40}
41
42/// A single backend selection plus the args the router wants passed to it.
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct BackendChoice {
45 pub backend: Backend,
46 #[serde(default)]
47 pub args: Value,
48}