Skip to main content

theway_daemon/executor/
sandbox.rs

1//! `SandboxExecutor` — stub [`ToolExecutor`] for remote-sandbox execution
2//! (openspec change `sdk-split-local-sandbox`, "Sandbox seam" requirement).
3//!
4//! Every operation fails promptly with [`ExecutorError::UnsupportedKind`]
5//! (`ExecutorKind::Sandbox`) until a real sandbox backend (e.g. e2b) lands.
6//! The seam is real — the daemon's tool assembly dispatches through the same
7//! [`ToolExecutor`] trait — but no call may hang: each method returns
8//! immediately with the unsupported-mode error.
9
10use std::path::Path;
11use std::time::Duration;
12
13use async_trait::async_trait;
14use theway_core::executor::{CommandOutput, ExecutorError, ExecutorKind, Result, ToolExecutor};
15
16/// Stub executor for remote-sandbox mode. Reports [`ExecutorKind::Sandbox`] from
17/// [`ToolExecutor::kind`] and rejects every operation with an explicit
18/// unsupported-kind error (never hangs).
19#[derive(Debug, Clone, Copy, Default)]
20pub struct SandboxExecutor;
21
22impl SandboxExecutor {
23    pub fn new() -> Self {
24        Self
25    }
26
27    /// The single failure shape of the stub: every operation other than `kind()`
28    /// returns this immediately.
29    fn unsupported<T>() -> Result<T> {
30        Err(ExecutorError::UnsupportedKind(ExecutorKind::Sandbox))
31    }
32}
33
34#[async_trait]
35impl ToolExecutor for SandboxExecutor {
36    async fn kind(&self) -> ExecutorKind {
37        ExecutorKind::Sandbox
38    }
39
40    async fn read_file(&self, _path: &Path) -> Result<String> {
41        Self::unsupported()
42    }
43
44    async fn write_file(&self, _path: &Path, _content: &str) -> Result<()> {
45        Self::unsupported()
46    }
47
48    async fn run_command(
49        &self,
50        _cwd: &Path,
51        _argv: &[String],
52        _timeout: Duration,
53    ) -> Result<CommandOutput> {
54        Self::unsupported()
55    }
56
57    async fn list_dir(&self, _path: &Path) -> Result<Vec<String>> {
58        Self::unsupported()
59    }
60
61    async fn grep(&self, _pattern: &str, _path: &Path) -> Result<Vec<String>> {
62        Self::unsupported()
63    }
64
65    async fn find(&self, _glob: &str, _path: &Path) -> Result<Vec<String>> {
66        Self::unsupported()
67    }
68
69    async fn git(&self, _args: &[String]) -> Result<CommandOutput> {
70        Self::unsupported()
71    }
72}