objectiveai_sdk/cli/command/agents/read/id/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.agents.read.id.Request")]
7pub struct Request {
8 pub path_type: Path,
9 pub id: i64,
10 pub jq: Option<String>,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
14#[schemars(rename = "cli.command.agents.read.id.Path")]
15pub enum Path {
16 #[serde(rename = "agents/read/id")]
17 AgentsReadId,
18}
19
20impl CommandRequest for Request {
21 fn into_command(&self) -> Vec<String> {
22 let mut argv = vec![
23 "agents".to_string(),
24 "read".to_string(),
25 "id".to_string(),
26 self.id.to_string(),
27 ];
28 if let Some(jq) = &self.jq {
29 argv.push("--jq".to_string());
30 argv.push(jq.clone());
31 }
32 argv
33 }
34}
35
36#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
37#[serde(untagged)]
38#[schemars(rename = "cli.command.agents.read.id.Response")]
39pub enum Response {
40 #[schemars(title = "AgentsCompletionsResponse")]
44 AgentsCompletionsResponse(crate::cli::command::logs::agents::completions::response::get::Response),
45 #[schemars(title = "AgentsCompletionsRequest")]
46 AgentsCompletionsRequest(crate::cli::command::logs::agents::completions::request::get::Response),
47 #[schemars(title = "AgentsCompletionsResponseMessages")]
48 AgentsCompletionsResponseMessages(crate::cli::command::logs::agents::completions::response::messages::get::Response),
49 #[schemars(title = "AgentsCompletionsResponseMessagesLogprobs")]
50 AgentsCompletionsResponseMessagesLogprobs(crate::cli::command::logs::agents::completions::response::messages::logprobs::get::Response),
51 #[schemars(title = "AgentsCompletionsResponseMessagesToolCalls")]
52 AgentsCompletionsResponseMessagesToolCalls(crate::cli::command::logs::agents::completions::response::messages::tool_calls::get::Response),
53
54 #[schemars(title = "VectorCompletionsResponse")]
55 VectorCompletionsResponse(crate::cli::command::logs::vector::completions::response::get::Response),
56 #[schemars(title = "VectorCompletionsRequest")]
57 VectorCompletionsRequest(crate::cli::command::logs::vector::completions::request::get::Response),
58
59 #[schemars(title = "FunctionsExecutionsResponse")]
60 FunctionsExecutionsResponse(crate::cli::command::logs::functions::executions::response::get::Response),
61 #[schemars(title = "FunctionsExecutionsRequest")]
62 FunctionsExecutionsRequest(crate::cli::command::logs::functions::executions::request::get::Response),
63
64 #[schemars(title = "FunctionsInventionsResponse")]
65 FunctionsInventionsResponse(crate::cli::command::logs::functions::inventions::response::get::Response),
66 #[schemars(title = "FunctionsInventionsRequest")]
67 FunctionsInventionsRequest(crate::cli::command::logs::functions::inventions::request::get::Response),
68
69 #[schemars(title = "FunctionsInventionsRecursiveResponse")]
70 FunctionsInventionsRecursiveResponse(crate::cli::command::logs::functions::inventions::recursive::response::get::Response),
71 #[schemars(title = "FunctionsInventionsRecursiveRequest")]
72 FunctionsInventionsRecursiveRequest(crate::cli::command::logs::functions::inventions::recursive::request::get::Response),
73
74 #[schemars(title = "Text")]
77 Text(String),
78 #[schemars(title = "Image")]
79 Image(crate::agent::completions::message::ImageUrl),
80 #[schemars(title = "Audio")]
81 Audio(crate::agent::completions::message::InputAudio),
82 #[schemars(title = "Video")]
83 Video(crate::agent::completions::message::VideoUrl),
84 #[schemars(title = "File")]
85 File(crate::agent::completions::message::File),
86}
87
88#[derive(clap::Args)]
89pub struct Args {
90 pub id: i64,
92 #[arg(long)]
94 pub jq: Option<String>,
95}
96
97#[derive(clap::Args)]
98#[command(args_conflicts_with_subcommands = true)]
99pub struct Command {
100 #[command(flatten)]
101 pub args: Args,
102 #[command(subcommand)]
103 pub schema: Option<Schema>,
104}
105
106#[derive(clap::Subcommand)]
107pub enum Schema {
108 RequestSchema(request_schema::Args),
110 ResponseSchema(response_schema::Args),
112}
113
114impl TryFrom<Args> for Request {
115 type Error = crate::cli::command::FromArgsError;
116 fn try_from(args: Args) -> Result<Self, Self::Error> {
117 Ok(Self { path_type: Path::AgentsReadId,
118 id: args.id,
119 jq: args.jq,
120 })
121 }
122}
123
124#[cfg(feature = "mcp")]
125impl crate::cli::command::CommandResponse for Response {
126 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
127 match self {
133 Response::AgentsCompletionsResponse(v) => v.into_mcp(),
134 Response::AgentsCompletionsRequest(v) => v.into_mcp(),
135 Response::AgentsCompletionsResponseMessages(v) => v.into_mcp(),
136 Response::AgentsCompletionsResponseMessagesLogprobs(v) => v.into_mcp(),
137 Response::AgentsCompletionsResponseMessagesToolCalls(v) => v.into_mcp(),
138 Response::VectorCompletionsResponse(v) => v.into_mcp(),
139 Response::VectorCompletionsRequest(v) => v.into_mcp(),
140 Response::FunctionsExecutionsResponse(v) => v.into_mcp(),
141 Response::FunctionsExecutionsRequest(v) => v.into_mcp(),
142 Response::FunctionsInventionsResponse(v) => v.into_mcp(),
143 Response::FunctionsInventionsRequest(v) => v.into_mcp(),
144 Response::FunctionsInventionsRecursiveResponse(v) => v.into_mcp(),
145 Response::FunctionsInventionsRecursiveRequest(v) => v.into_mcp(),
146 Response::Text(v) => v.into_mcp(),
147 Response::Image(v) => v.into_mcp(),
148 Response::Audio(v) => v.into_mcp(),
149 Response::Video(v) => v.into_mcp(),
150 Response::File(v) => v.into_mcp(),
151 }
152 }
153}
154
155#[cfg(feature = "cli-executor")]
156pub async fn execute<E: crate::cli::command::CommandExecutor>(
157 executor: &E,
158 mut request: Request,
159
160 agent_arguments: Option<&crate::cli::command::AgentArguments>,
161 ) -> Result<Response, E::Error> {
162 request.jq = None;
163 executor.execute_one(request, agent_arguments).await
164}
165
166#[cfg(feature = "cli-executor")]
167pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
168 executor: &E,
169 mut request: Request,
170 jq: String,
171
172 agent_arguments: Option<&crate::cli::command::AgentArguments>,
173 ) -> Result<serde_json::Value, E::Error> {
174 request.jq = Some(jq);
175 executor.execute_one(request, agent_arguments).await
176}
177
178pub mod request_schema;
179
180
181pub mod response_schema;