Skip to content

Proxy Reference

Version: 0.1.0

Rust-based bridge that hardens execution calls and provides MCP access.

This sentinel acts as the “Muscle” of the PocketCoder architecture, ensuring that tools are executed within a secure sandbox environment.

  • Execution Driver: Manages tmux sessions and command execution in the sandbox.
  • MCP Proxy: Bridges WebSocket-based Model Context Protocol requests.
  • Shell Bridge: Implements the pocketcoder shell command-line interface.

The proxy runs as a high-performance Rust service that exposes an SSE and WebSocket API. It translates high-level AI intents into low-level sandbox commands while maintaining isolation and security.

ItemKindDescription
drivermod# Execution Driver This module manages the lifecycle of the sandbox execution environment via tmux socket interaction.
shellmod# Shell Bridge This module provides the client-side logic for the pocketcoder shell command, which routes commands from the reasoning engine to the persistent proxy.
AppStatestruct
Clistruct
McpQuerystructQuery parameters for established sessions.
Commandsenum
exec_handlerfn
health_handlerfn
mainfn
sse_handlerfn
SessionMaptype
  • driver — # Execution Driver
  • shell — # Shell Bridge

struct AppState {
pub sessions: std::sync::Arc<parking_lot::RwLock<std::collections::HashMap<String, mpsc::Sender<serde_json::Value>>>>,
pub driver: std::sync::Arc<crate::driver::PocketCoderDriver>,
}
impl<A, B> HttpServerConnExec<A, B> for AppState
Section titled “impl<A, B> HttpServerConnExec<A, B> for AppState”
  • fn vzip(self) -> V
struct Cli {
command: Commands,
}
  • fn group_id() -> Option<clap::Id>

  • fn augment_args<'b>(__clap_app: clap::Command) -> clap::Command

  • fn augment_args_for_update<'b>(__clap_app: clap::Command) -> clap::Command

  • fn command<'b>() -> clap::Command

  • fn command_for_update<'b>() -> clap::Command

  • fn from_arg_matches(__clap_arg_matches: &clap::ArgMatches) -> ::std::result::Result<Self, clap::Error>

  • fn from_arg_matches_mut(__clap_arg_matches: &mut clap::ArgMatches) -> ::std::result::Result<Self, clap::Error>

  • fn update_from_arg_matches(&mut self, __clap_arg_matches: &clap::ArgMatches) -> ::std::result::Result<(), clap::Error>

  • fn update_from_arg_matches_mut(&mut self, __clap_arg_matches: &mut clap::ArgMatches) -> ::std::result::Result<(), clap::Error>

impl<A, B> HttpServerConnExec<A, B> for Cli
Section titled “impl<A, B> HttpServerConnExec<A, B> for Cli”
  • fn vzip(self) -> V
struct McpQuery {
pub session_id: Option<String>,
}

Query parameters for established sessions.

  • session_id: Option<String>

    Optional session ID to resume or identify the connection

  • fn deserialize<__D>(__deserializer: __D) -> _serde::__private228::Result<Self, <__D as >::Error>
impl<A, B> HttpServerConnExec<A, B> for McpQuery
Section titled “impl<A, B> HttpServerConnExec<A, B> for McpQuery”
  • fn vzip(self) -> V
enum Commands {
Server {
port: String,
},
Shell {
command: Option<String>,
args: Vec<String>,
},
}
  • Server

    Start the proxy server (MCP Relay + Execution Bridge)

  • Shell

    Run in shell bridge mode (client)

  • fn from_arg_matches(__clap_arg_matches: &clap::ArgMatches) -> ::std::result::Result<Self, clap::Error>

  • fn from_arg_matches_mut(__clap_arg_matches: &mut clap::ArgMatches) -> ::std::result::Result<Self, clap::Error>

  • fn update_from_arg_matches(&mut self, __clap_arg_matches: &clap::ArgMatches) -> ::std::result::Result<(), clap::Error>

  • fn update_from_arg_matches_mut<'b>(&mut self, __clap_arg_matches: &mut clap::ArgMatches) -> ::std::result::Result<(), clap::Error>

impl<A, B> HttpServerConnExec<A, B> for Commands
Section titled “impl<A, B> HttpServerConnExec<A, B> for Commands”
  • fn augment_subcommands<'b>(__clap_app: clap::Command) -> clap::Command

  • fn augment_subcommands_for_update<'b>(__clap_app: clap::Command) -> clap::Command

  • fn has_subcommand(__clap_name: &str) -> bool

  • fn vzip(self) -> V
type SessionMap = std::sync::Arc<parking_lot::RwLock<std::collections::HashMap<String, mpsc::Sender<serde_json::Value>>>>;

async fn exec_handler(__arg0: axum::extract::State<std::sync::Arc<AppState>>, __arg1: axum::Json<crate::driver::ExecRequest>) -> axum::Json<serde_json::Value>

Types: AppState, ExecRequest

async fn health_handler() -> &'static str
fn main() -> anyhow::Result<()>
async fn sse_handler(__arg0: axum::extract::State<std::sync::Arc<AppState>>, __arg1: axum::extract::Query<McpQuery>) -> axum::response::sse::Sse<impl Stream<Item = anyhow::Result<axum::response::sse::Event, std::convert::Infallible>>>

Types: AppState, McpQuery


pocketcoder_proxy / driver


This module manages the lifecycle of the sandbox execution environment via tmux socket interaction.

ItemKindDescription
CommandResultstructResult of a command execution in the sandbox.
ExecRequeststructRequest to execute a command.
ExecResponsestruct
PocketCoderDriverstruct
default_agent_namefn
struct CommandResult {
pub output: String,
pub exit_code: i32,
}

Result of a command execution in the sandbox.

  • output: String

    Combined stdout and stderr

  • exit_code: i32

    Unix exit code

  • fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
  • fn deserialize<__D>(__deserializer: __D) -> _serde::__private228::Result<Self, <__D as >::Error>
  • fn from_ref(input: &T) -> T
impl<A, B> HttpServerConnExec<A, B> for CommandResult
Section titled “impl<A, B> HttpServerConnExec<A, B> for CommandResult”
  • fn serialize<__S>(&self, __serializer: __S) -> _serde::__private228::Result<<__S as >::Ok, <__S as >::Error>
  • fn vzip(self) -> V
struct ExecRequest {
pub cmd: String,
pub cwd: String,
pub usage_id: Option<String>,
pub session_id: Option<String>,
pub agent_name: String,
}

Request to execute a command.

  • cmd: String

    Bash command string

  • cwd: String

    Working directory relative to workspace root

  • usage_id: Option<String>

    Internal audit ID

  • session_id: Option<String>

    Session identifier

  • agent_name: String

    Agent identity executing the command (e.g., “poco”)

  • fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
  • fn deserialize<__D>(__deserializer: __D) -> _serde::__private228::Result<Self, <__D as >::Error>
  • fn from_ref(input: &T) -> T
impl<A, B> HttpServerConnExec<A, B> for ExecRequest
Section titled “impl<A, B> HttpServerConnExec<A, B> for ExecRequest”
  • fn serialize<__S>(&self, __serializer: __S) -> _serde::__private228::Result<<__S as >::Ok, <__S as >::Error>
  • fn vzip(self) -> V
struct ExecResponse {
pub stdout: Option<String>,
pub exit_code: Option<i32>,
pub error: Option<String>,
}
  • fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
  • fn deserialize<__D>(__deserializer: __D) -> _serde::__private228::Result<Self, <__D as >::Error>
impl<A, B> HttpServerConnExec<A, B> for ExecResponse
Section titled “impl<A, B> HttpServerConnExec<A, B> for ExecResponse”
  • fn vzip(self) -> V
struct PocketCoderDriver {
pub socket_path: String,
pub session_name: String,
}
  • fn new(socket: &str, session: &str) -> Self

  • fn session_exists(&self, session: &str) -> bool

  • async fn exec(&self, cmd: &str, cwd: Option<&str>, agent_name: &str) -> Result<CommandResult>CommandResult

    Execute a command in the target agent’s isolated tmux workspace.

    The proxy strictly targets pocketcoder:[agent_name]:terminal.

  • fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Deserialize<'de> for PocketCoderDriver
Section titled “impl Deserialize<'de> for PocketCoderDriver”
  • fn deserialize<__D>(__deserializer: __D) -> _serde::__private228::Result<Self, <__D as >::Error>
impl DeserializeOwned for PocketCoderDriver
Section titled “impl DeserializeOwned for PocketCoderDriver”
impl<A, B> HttpServerConnExec<A, B> for PocketCoderDriver
Section titled “impl<A, B> HttpServerConnExec<A, B> for PocketCoderDriver”
  • fn vzip(self) -> V

fn default_agent_name() -> String

pocketcoder_proxy / shell


This module provides the client-side logic for the pocketcoder shell command, which routes commands from the reasoning engine to the persistent proxy.

ItemKindDescription
runfn
fn run(command: Option<String>, args: Vec<String>) -> anyhow::Result<()>