objectiveai_sdk/cli/command/viewer/kill/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.viewer.kill.Request")]
7pub struct Request {
8 pub path_type: Path,
9 pub jq: Option<String>,
10}
11
12#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
13#[schemars(rename = "cli.command.viewer.kill.Path")]
14pub enum Path {
15 #[serde(rename = "viewer/kill")]
16 ViewerKill,
17}
18impl CommandRequest for Request {
19 fn into_command(&self) -> Vec<String> {
20 let mut argv = vec!["viewer".to_string(), "kill".to_string()];
21 if let Some(jq) = &self.jq {
22 argv.push("--jq".to_string());
23 argv.push(jq.clone());
24 }
25 argv
26 }
27}
28
29#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
30#[schemars(rename = "cli.command.viewer.kill.Response")]
31pub struct Response {
32 pub killed: usize,
33}
34
35#[derive(clap::Args)]
36pub struct Args {
37 #[arg(long)]
39 pub jq: Option<String>,
40}
41
42#[derive(clap::Args)]
43#[command(args_conflicts_with_subcommands = true)]
44pub struct Command {
45 #[command(flatten)]
46 pub args: Args,
47 #[command(subcommand)]
48 pub schema: Option<Schema>,
49}
50
51#[derive(clap::Subcommand)]
52pub enum Schema {
53 RequestSchema(request_schema::Args),
55 ResponseSchema(response_schema::Args),
57}
58
59impl TryFrom<Args> for Request {
60 type Error = crate::cli::command::FromArgsError;
61 fn try_from(args: Args) -> Result<Self, Self::Error> {
62 Ok(Self { path_type: Path::ViewerKill, jq: args.jq })
63 }
64}
65
66#[cfg(feature = "cli-executor")]
67pub async fn execute<E: crate::cli::command::CommandExecutor>(
68 executor: &E,
69 mut request: Request,
70
71 agent_arguments: Option<&crate::cli::command::AgentArguments>,
72 ) -> Result<Response, E::Error> {
73 request.jq = None;
74 executor.execute_one(request, agent_arguments).await
75}
76
77#[cfg(feature = "cli-executor")]
78pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
79 executor: &E,
80 mut request: Request,
81 jq: String,
82
83 agent_arguments: Option<&crate::cli::command::AgentArguments>,
84 ) -> Result<serde_json::Value, E::Error> {
85 request.jq = Some(jq);
86 executor.execute_one(request, agent_arguments).await
87}
88
89#[cfg(feature = "mcp")]
90impl crate::cli::command::CommandResponse for Response {
91 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
92 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
93 }
94}
95
96pub mod request_schema;
97
98pub mod response_schema;