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