HttpSessionEnv adapts a remote sandbox service to the SessionEnv trait. It
sends one JSON POST to the configured endpoint for each operation.
Native binaries can use HttpSessionEnv::new(...), which uses the built-in HTTP
client. Non-native adapters can use HttpSessionEnv::with_transport(...) and
provide an HttpSessionTransport backed by platform HTTP, such as Worker
fetch.
For named hosted providers that already expose this protocol, prefer
SandboxConnector::vercel(...), SandboxConnector::daytona(...), or
SandboxConnector::e2b(...). Those helpers tag requests with the provider name
and return an HttpSessionEnv.
Every request contains an op field:
{ "op": "read", "path": "src/main.rs" }Supported operations:
exec: sendscommand,cwd,env, and optionaltimeoutMs; returnsShellOutputJSON withstdout,stderr, andexitCode.read: sendspath; returns a JSON string.write: sendspathplus either UTF-8contentorcontentBase64; returns any JSON value.stat: sendspath; returnsFileStatJSON withisFile,isDirectory,isSymbolicLink,size, andmodifiedUnixMs.readdir: sendspath; returns a JSON array of entry names.exists: sendspath; returns a JSON boolean.mkdir: sendspath; returns any JSON value.rm: sendspathandrecursive; returns any JSON value.
All paths are interpreted relative to the sandbox root configured when the
HttpSessionEnv is constructed. The server side should reject path traversal
outside that root.
For text writes, Agentic Harness sends:
{ "op": "write", "path": "notes.txt", "content": "alpha" }For binary writes, it sends:
{ "op": "write", "path": "bin/blob.dat", "contentBase64": "/wAB" }For command execution, it sends:
{
"op": "exec",
"command": "cargo test",
"cwd": "/workspace/project",
"env": { "RUST_LOG": "info" },
"timeoutMs": 120000
}The corresponding success response should use this shape:
{
"stdout": "test result: ok\n",
"stderr": "",
"exitCode": 0
}Any non-2xx response is converted into an AgenticHarnessError::Handler. If the
response body contains { "error": { "message": "..." } } or
{ "message": "..." }, that message is included in the error.
Pass provider credentials as HTTP headers from trusted Rust code:
use agentic_harness::HttpSessionEnv;
let env = HttpSessionEnv::new("https://sandbox.example/session", "/workspace")
.header("Authorization", format!("Bearer {}", token));Do not put secrets in prompts or workspace context.
A compatible sandbox service should:
- Authenticate every request before reading
op. - Enforce the configured workspace root for all path operations.
- Apply command timeouts.
- Return non-2xx responses with a JSON
messageorerror.message. - Avoid logging bearer tokens, payload secrets, or file contents by default.