Skip to main content

agent_office/cli/
mod.rs

1use clap::{Parser, Subcommand};
2use uuid::Uuid;
3
4#[derive(Parser)]
5#[command(name = "agent-office")]
6#[command(about = "A graph-based data structure tool for AI agents")]
7#[command(version = "0.1.0")]
8pub struct Cli {
9    #[command(subcommand)]
10    pub command: Commands,
11}
12
13#[derive(Subcommand)]
14pub enum Commands {
15    #[command(subcommand)]
16    Mail(MailCommands),
17    #[command(subcommand)]
18    Agent(AgentCommands),
19    #[command(subcommand)]
20    Db(DbCommands),
21    #[command(subcommand)]
22    Kb(KbCommands),
23    /// Start web interface
24    Web {
25        /// Host to bind to
26        #[arg(short = 'H', long, default_value = "127.0.0.1")]
27        host: String,
28        /// Port to listen on
29        #[arg(short, long, default_value = "8080")]
30        port: u16,
31    },
32}
33
34#[derive(Subcommand)]
35pub enum MailCommands {
36    /// View recent mail for an agent (last 24 hours)
37    Recent {
38        /// Agent ID to view mail for
39        agent_id: String,
40    },
41    /// Send mail from one agent to another (SIMPLE - uses agent names only!)
42    Send {
43        #[arg(short, long)]
44        from: String,
45        #[arg(short, long)]
46        to: String,
47        #[arg(short, long)]
48        subject: String,
49        #[arg(short, long)]
50        body: String,
51    },
52    /// View inbox of an agent
53    Inbox {
54        #[arg(short, long)]
55        agent_id: String,
56    },
57    /// View outbox (sent items) of an agent
58    Outbox {
59        #[arg(short, long)]
60        agent_id: String,
61    },
62    /// Mark mail as read
63    Read {
64        #[arg(short, long)]
65        mail_id: Uuid,
66    },
67    /// Check if agent should look at their mail (has unread messages)
68    ShouldLook {
69        #[arg(short, long)]
70        agent_id: String,
71    },
72    /// Watch for new mail and execute command when unread mail arrives
73    Watch {
74        #[arg(short, long)]
75        agent_id: String,
76        /// Interval in seconds between checks
77        #[arg(short, long, default_value = "60")]
78        interval: u64,
79        /// Bash command to execute when unread mail is found
80        #[arg(short, long)]
81        bash: String,
82    },
83    /// Search mail by subject or body content
84    Search {
85        /// Agent ID to search mail for
86        agent_id: String,
87        /// Search query string (searches in subject and body)
88        query: String,
89    },
90}
91
92#[derive(Subcommand)]
93pub enum AgentCommands {
94    /// Create a new agent
95    Create {
96        #[arg(short, long)]
97        name: String,
98    },
99    /// List all agents
100    List,
101    /// Get agent details
102    Get {
103        #[arg(short, long)]
104        id: String,
105    },
106    /// Set agent status (online, offline, away, etc.)
107    Status {
108        #[arg(short, long)]
109        id: String,
110        #[arg(short, long)]
111        status: String,
112    },
113}
114
115#[derive(Subcommand)]
116pub enum DbCommands {
117    /// Setup database tables (drops existing tables if they exist)
118    Setup,
119}
120
121#[derive(Subcommand)]
122pub enum KbCommands {
123    /// Initialize a knowledge base for an agent
124    Init {
125        #[arg(short, long)]
126        agent_id: String,
127        #[arg(short, long)]
128        name: String,
129    },
130    /// Create a new note with auto-generated Luhmann ID
131    Note {
132        #[arg(short, long)]
133        agent_id: String,
134        #[arg(short, long)]
135        title: String,
136        #[arg(short, long)]
137        content: String,
138    },
139    /// Create a note with specific Luhmann ID (e.g., 1a2b)
140    NoteWithId {
141        #[arg(short, long)]
142        agent_id: String,
143        #[arg(short, long)]
144        luhmann_id: String,
145        #[arg(short, long)]
146        title: String,
147        #[arg(short, long)]
148        content: String,
149    },
150    /// Branch from an existing note (create child)
151    Branch {
152        #[arg(short, long)]
153        agent_id: String,
154        #[arg(short, long)]
155        parent_note_id: Uuid,
156        #[arg(short, long)]
157        title: String,
158        #[arg(short, long)]
159        content: String,
160    },
161    /// List all notes in an agent's knowledge base
162    List {
163        #[arg(short, long)]
164        agent_id: String,
165    },
166    /// Get a specific note by ID
167    Get {
168        #[arg(short, long)]
169        note_id: Uuid,
170    },
171    /// Get a note by its Luhmann address
172    GetByLuhmann {
173        #[arg(short, long)]
174        agent_id: String,
175        #[arg(short, long)]
176        luhmann_id: String,
177    },
178    /// Link two notes together
179    Link {
180        #[arg(short, long)]
181        from: Uuid,
182        #[arg(short, long)]
183        to: Uuid,
184        #[arg(short, long)]
185        context: Option<String>,
186    },
187    /// Show backlinks (notes that link to this note)
188    Backlinks {
189        #[arg(short, long)]
190        note_id: Uuid,
191    },
192    /// Show related notes within N hops
193    Related {
194        #[arg(short, long)]
195        note_id: Uuid,
196        #[arg(short, long, default_value = "2")]
197        depth: usize,
198    },
199    /// Show notes by Luhmann ID prefix
200    Tree {
201        #[arg(short, long)]
202        agent_id: String,
203        #[arg(short, long)]
204        prefix: String,
205    },
206    /// Search notes
207    Search {
208        #[arg(short, long)]
209        agent_id: String,
210        #[arg(short, long)]
211        query: String,
212    },
213    /// Add a tag to a note
214    Tag {
215        #[arg(short, long)]
216        note_id: Uuid,
217        #[arg(short, long)]
218        tag: String,
219    },
220    /// List all tags for an agent
221    Tags {
222        #[arg(short, long)]
223        agent_id: String,
224    },
225    /// Show the graph around a note
226    Graph {
227        #[arg(short, long)]
228        note_id: Uuid,
229        #[arg(short, long, default_value = "2")]
230        depth: usize,
231    },
232}