Skip to main content

agent_sdk_toolkit/shell/
policy.rs

1//! Concrete shell tool helpers layered over core policy and effect contracts. Use
2//! these modules only behind host approval, sandbox, timeout, and network policy.
3//! Execution starts host processes; request and policy types are data-only. This file
4//! contains the policy portion of that contract.
5//!
6use agent_sdk_core::{PolicyKind, PolicyRef};
7
8#[derive(Clone, Debug)]
9/// Shell shell execution policy request or result value.
10/// Creating the value does not spawn a process; shell executors document policy checks and command side effects.
11pub struct ShellExecutionPolicy {
12    /// Typed sandbox policy ref reference. Resolving or executing it is a
13    /// separate policy-gated step.
14    pub sandbox_policy_ref: PolicyRef,
15    /// Boolean policy/capability flag for whether allow host execution is
16    /// enabled.
17    pub allow_host_execution: bool,
18    /// Whether network enabled is enabled.
19    /// Policy, validation, or routing code uses this flag to choose the explicit behavior.
20    pub network_enabled: bool,
21    /// max timeout ms duration in milliseconds.
22    pub max_timeout_ms: u64,
23}
24
25impl ShellExecutionPolicy {
26    /// Returns an updated value with deny host execution configured.
27    /// This constructs a policy that denies host shell execution and performs no command
28    /// execution.
29    pub fn deny_host_execution() -> Self {
30        Self {
31            sandbox_policy_ref: PolicyRef::with_kind(
32                PolicyKind::Sandbox,
33                "policy.sandbox.shell.deny_host",
34            ),
35            allow_host_execution: false,
36            network_enabled: false,
37            max_timeout_ms: 30_000,
38        }
39    }
40}