|
Entropic 2.14.3
Local-first agentic inference engine
|
RAII directory swapper for sandbox-scoped tool execution. More...
#include <entropic/core/sandbox.h>
Public Types | |
| using | SwapDirFn = void(*)(const std::string &session_key, const std::filesystem::path &path, bool entering, void *user_data) |
| Callback type for directory swapping. | |
Public Member Functions | |
| ScopedSandbox (SwapDirFn swap_fn, void *user_data, std::string session_key, const std::filesystem::path &sandbox_path, const std::filesystem::path &original_path) | |
| Construct and swap directories. | |
| ~ScopedSandbox () | |
| Restore the original directory. | |
| ScopedSandbox (const ScopedSandbox &)=delete | |
| ScopedSandbox & | operator= (const ScopedSandbox &)=delete |
RAII directory swapper for sandbox-scoped tool execution.
Swaps the engine's tool working directory to the sandbox path on construction and restores it on destruction. Used by DelegationManager to route MCP server (filesystem, bash, …) calls into the sandbox during a delegation.
| using entropic::ScopedSandbox::SwapDirFn = void (*)( const std::string& session_key, const std::filesystem::path& path, bool entering, void* user_data) |
Callback type for directory swapping.
The facade implements this to iterate the registered servers of the session's workspace and call entropic_mcp_server_set_working_dir() on each.
gh#160 (v2.13.0): carries the session key. The servers a swap must move are the ones the RUNNING SESSION's tools resolve against, and with concurrent_sessions on (gh#158) two sessions delegate at the same time — a swap that names no session is a swap that cannot be routed. gh#166 re-points the facade side of this at the session's workspace without touching the signature again.
entering distinguishes the two calls of a scope: the facade takes its per-workspace swap lock on entry and releases it on restore, which is what keeps two concurrent sandboxed delegations from interleaving their swaps on one set of server objects.
| session_key | Session the delegation belongs to ("" = default). |
| path | New working directory. |
| entering | True on sandbox entry, false on restore. |
| user_data | Opaque pointer (facade context). |
| entropic::ScopedSandbox::ScopedSandbox | ( | SwapDirFn | swap_fn, |
| void * | user_data, | ||
| std::string | session_key, | ||
| const std::filesystem::path & | sandbox_path, | ||
| const std::filesystem::path & | original_path | ||
| ) |
Construct and swap directories.
| swap_fn | Directory swap callback (may be null — no-op). |
| user_data | Opaque pointer for swap_fn. |
| session_key | Session whose tool root is being swapped. |
| sandbox_path | Target sandbox directory. |
| original_path | Directory to restore on destruction — the caller's ACTIVE root, which for a nested delegation is the parent's sandbox and not the project root (gh#160). |
| swap_fn | Directory swap callback. |
| user_data | Opaque pointer for swap_fn. |
| sandbox_path | Target sandbox directory. |
| original_path | Original directory to restore. @dg_internal |
Definition at line 634 of file sandbox.cpp.
| entropic::ScopedSandbox::~ScopedSandbox | ( | ) |
Restore the original directory.
Restore the caller's active directory (gh#160).
@dg_internal
Definition at line 656 of file sandbox.cpp.