Skip to main content

claude_rust_tools/infrastructure/
remote_trigger_tool.rs

1use claude_rust_errors::AppResult;
2use claude_rust_types::{PermissionLevel, Tool};
3use serde_json::{Value, json};
4
5/// Tool to fire a remote trigger.
6///
7/// TODO: Phase 4 — integrate with real remote trigger service.
8pub struct RemoteTriggerTool;
9
10impl RemoteTriggerTool {
11    pub fn new() -> Self {
12        Self
13    }
14}
15
16#[async_trait::async_trait]
17impl Tool for RemoteTriggerTool {
18    fn name(&self) -> &str {
19        "remote_trigger"
20    }
21
22    fn description(&self) -> &str {
23        "Fire a remote trigger by ID, optionally with a JSON payload."
24    }
25
26    fn input_schema(&self) -> Value {
27        json!({
28            "type": "object",
29            "properties": {
30                "trigger_id": {
31                    "type": "string",
32                    "description": "The ID of the remote trigger to fire"
33                },
34                "payload": {
35                    "description": "Optional JSON payload to send with the trigger"
36                }
37            },
38            "required": ["trigger_id"]
39        })
40    }
41
42    fn permission_level(&self) -> PermissionLevel {
43        PermissionLevel::Dangerous
44    }
45
46    async fn execute(&self, input: Value) -> AppResult<String> {
47        let trigger_id = input
48            .get("trigger_id")
49            .and_then(|v| v.as_str())
50            .ok_or_else(|| claude_rust_errors::AppError::Tool("missing 'trigger_id' field".into()))?;
51
52        let payload = input.get("payload");
53
54        // TODO: Phase 4 — replace stub with real remote trigger integration
55        tracing::info!(trigger_id, ?payload, "firing remote trigger (stub)");
56
57        Ok(format!("Trigger '{trigger_id}' acknowledged. (stub)"))
58    }
59}