ai_agent/commands/
version.rs1use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct CommandCallResult {
6 #[serde(rename = "type")]
7 pub result_type: String,
8 pub value: String,
9}
10
11impl CommandCallResult {
12 pub fn text(value: impl Into<String>) -> Self {
13 Self {
14 result_type: "text".to_string(),
15 value: value.into(),
16 }
17 }
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct Command {
22 pub name: String,
23 pub description: String,
24 #[serde(rename = "argumentHint", skip_serializing_if = "Option::is_none")]
25 pub argument_hint: Option<String>,
26 #[serde(skip_serializing_if = "Option::is_none")]
27 pub is_hidden: Option<bool>,
28 #[serde(
29 rename = "supportsNonInteractive",
30 skip_serializing_if = "Option::is_none"
31 )]
32 pub supports_non_interactive: Option<bool>,
33 #[serde(default)]
34 pub command_type: String,
35}
36
37impl Command {
38 pub fn local(name: impl Into<String>, description: impl Into<String>) -> Self {
39 Self {
40 name: name.into(),
41 description: description.into(),
42 argument_hint: None,
43 is_hidden: None,
44 supports_non_interactive: None,
45 command_type: "local".to_string(),
46 }
47 }
48
49 pub fn prompt(name: impl Into<String>, description: impl Into<String>) -> Self {
50 Self {
51 name: name.into(),
52 description: description.into(),
53 argument_hint: None,
54 is_hidden: None,
55 supports_non_interactive: None,
56 command_type: "prompt".to_string(),
57 }
58 }
59
60 pub fn argument_hint(mut self, hint: impl Into<String>) -> Self {
61 self.argument_hint = Some(hint.into());
62 self
63 }
64
65 pub fn is_hidden(mut self, hidden: bool) -> Self {
66 self.is_hidden = Some(hidden);
67 self
68 }
69
70 pub fn supports_non_interactive(mut self, supported: bool) -> Self {
71 self.supports_non_interactive = Some(supported);
72 self
73 }
74}
75
76#[derive(Debug, Clone)]
77pub struct CommandContext;
78
79pub fn create_version_command() -> Command {
80 Command::local(
81 "version",
82 "Print the version this session is running (not what autoupdate downloaded)",
83 )
84 .supports_non_interactive(true)
85}