Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1ay1 Agentty sandbox config

From Leeroopedia
Knowledge Sources
Domains Security, Configuration
Last Updated 2026-10-28 12:00 GMT

Overview

Concrete domain type and functions for user-facing sandbox policy: filesystem scope, network mode, syscall filter, resource caps, credential masking, posture selection, and trust-handoff gate.

Description

The sandbox_cfg namespace (in `domain/sandbox_config.hpp`) is the pure domain type for sandbox policy. A Config struct composes the policy fields (FsScope, NetMode, SyscallMode, resource caps, deny_paths, mask_scan_depth, HandoffPolicy). The settings registry binds rows straight into the struct.

Key functions:

  • mask_paths(cfg, workspace, home) — returns all absolute paths to mask: kAlwaysMasked ($HOME credentials) + kAlwaysMaskedNames (basename matches found by walking workspace to mask_scan_depth) + user deny_paths. ONE function, used by both backends, so the credential list is wrong everywhere or nowhere.
  • detect_posture(cfg) — derives which posture (Permissive/Balanced/Hardened/Airgapped/Custom) the config is, by comparison rather than storage. A stored posture field would drift from the rows; deriving means the label cannot be wrong, only "Custom".
  • apply_posture(base, p) — writes a posture's values over the config, preserving user-added paths and the engine.

Trust Handoff

The handoff field (HandoffPolicy, default Refuse) controls what happens when the agent writes a file the host later executes. Refuse is the default because a trust handoff is the shape of a known escape class (Pillar Security CVE-2026-48124), not a "this might be risky" prompt.

Usage

  • Sandbox pane UI: reads the Config to display the current policy; detect_posture labels it.
  • Sandbox spawn: mask_paths produces the masked list for the Posture; apply_posture applies a preset.
  • Trust handoff: read cfg.handoff to decide refuse/warn/allow for agent-authored executable config.

Code Reference

Source Location

  • Repository: agentty
  • File: include/agentty/domain/sandbox_config.hpp

Signature

namespace agentty::sandbox_cfg {

enum class FsScope : std::uint8_t { Toolchain, Minimal, HostReadable };
enum class NetMode : std::uint8_t { /* Shared, Allowlist, Airgapped, ... */ };
enum class HandoffPolicy : std::uint8_t { Refuse, Warn, Allow };

struct Config {
    FsScope fs_scope;
    NetMode net_mode;
    /* SyscallMode, resource caps, read/write/deny paths,
       mask_scan_depth, engine, handoff */
    HandoffPolicy handoff = HandoffPolicy::Refuse;
    [[nodiscard]] bool operator==(const Config&) const = default;
};

// Every absolute path that must be masked for a given config + workspace.
[[nodiscard]] std::vector<std::string> mask_paths(
    const Config& cfg, std::string_view workspace, std::string_view home);

// Write a posture's values over a config, preserving user paths + engine.
[[nodiscard]] Config apply_posture(const Config& base, Posture p);

// Which posture this config IS, or Custom (derived by comparison).
[[nodiscard]] Posture detect_posture(const Config& cfg);

// Resolve a user-typed path to absolute (~/x, relative, etc.).
[[nodiscard]] std::string resolve_user_path(
    std::string_view path, std::string_view workspace, std::string_view home);

} // namespace agentty::sandbox_cfg

Import

#include "agentty/domain/sandbox_config.hpp"

I/O Contract

Inputs

Name Type Required Description
cfg const Config& Yes Sandbox configuration
workspace string_view Yes Workspace root path
home string_view Yes $HOME (passed in, not read from env)

Outputs

Name Type Description
return (mask_paths) vector<string> All paths to mask (credentials + deny + walked)
return (detect_posture) Posture Permissive/Balanced/Hardened/Airgapped/Custom
return (apply_posture) Config New config with posture values applied

Usage Examples

Masking Credentials

#include "agentty/domain/sandbox_config.hpp"
using namespace agentty::sandbox_cfg;

Config cfg = settings.sandbox;
auto masked = mask_paths(cfg, workspace, home);
// masked contains:
//   /home/user/.ssh/id_rsa     (kAlwaysMasked)
//   /home/user/.aws/credentials (kAlwaysMasked)
//   workspace/.env              (kAlwaysMaskedNames, walked)
//   workspace/services/.env     (kAlwaysMaskedNames, walked)
//   /user/deny/path             (cfg.deny_paths)

Posture Selection

// Detect what the current config IS
Posture p = detect_posture(cfg);
if (p == Posture::Custom)
    log("sandbox config doesn't match any preset");

// Apply a preset
Config hardened = apply_posture(cfg, Posture::Hardened);
// hardened has the Hardened values; user's read_paths preserved

Trust Handoff

// When the agent writes hooks.json, check the handoff policy:
if (cfg.handoff == HandoffPolicy::Refuse) {
    refuse("agent wrote hooks.json — host-trusted file");
} else if (cfg.handoff == HandoffPolicy::Warn) {
    warn("agent wrote hooks.json — host will execute this");
}

Related Pages

Implements Principle

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment