objectiveai_sdk/cli/command/kill_all/
mod.rs1use crate::cli::command::CommandRequest;
12
13#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
14#[schemars(rename = "cli.command.kill_all.Request")]
15pub struct Request {
16 pub path_type: Path,
17 #[serde(flatten)]
18 pub base: crate::cli::command::RequestBase,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
22#[schemars(rename = "cli.command.kill_all.Path")]
23pub enum Path {
24 #[serde(rename = "kill-all")]
25 KillAll,
26}
27
28impl CommandRequest for Request {
29 fn request_base(&self) -> &crate::cli::command::RequestBase {
30 &self.base
31 }
32
33 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
34 Some(&mut self.base)
35 }
36}
37
38#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
39#[schemars(rename = "cli.command.kill_all.Response")]
40pub struct Response {
41 pub killed: usize,
42}
43
44#[derive(clap::Args)]
45pub struct Args {
46 #[command(flatten)]
47 pub base: crate::cli::command::RequestBaseArgs,
48}
49
50#[derive(clap::Args)]
51#[command(args_conflicts_with_subcommands = true)]
52pub struct Command {
53 #[command(flatten)]
54 pub args: Args,
55 #[command(subcommand)]
56 pub schema: Option<Schema>,
57}
58
59#[derive(clap::Subcommand)]
60pub enum Schema {
61 RequestSchema(request_schema::Args),
63 ResponseSchema(response_schema::Args),
65}
66
67impl TryFrom<Args> for Request {
68 type Error = crate::cli::command::FromArgsError;
69 fn try_from(args: Args) -> Result<Self, Self::Error> {
70 Ok(Self { path_type: Path::KillAll, base: args.base.into() })
71 }
72}
73
74#[cfg(feature = "cli-executor")]
75pub async fn execute<E: crate::cli::command::CommandExecutor>(
76 executor: &E,
77 mut request: Request,
78
79 agent_arguments: Option<&crate::cli::command::AgentArguments>,
80 ) -> Result<Response, E::Error> {
81 request.base.clear_transform();
82 executor.execute_one(request, agent_arguments).await
83}
84
85#[cfg(feature = "cli-executor")]
86pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
87 executor: &E,
88 mut request: Request,
89 transform: crate::cli::command::Transform,
90
91 agent_arguments: Option<&crate::cli::command::AgentArguments>,
92 ) -> Result<serde_json::Value, E::Error> {
93 request.base.set_transform(transform);
94 executor.execute_one(request, agent_arguments).await
95}
96
97#[cfg(feature = "mcp")]
98impl crate::cli::command::CommandResponse for Response {
99 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
100 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
101 }
102}
103
104pub mod request_schema;
105
106pub mod response_schema;