New:Socket for Asana Is Now Available.Learn more
Sign In

@agentforge-ai/sandbox

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@agentforge-ai/sandbox

Docker-based sandbox provider for AgentForge agent tool execution isolation

Source
npmnpm
Version
0.7.1
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@agentforge-ai/sandbox

Docker-based sandbox provider for AgentForge agent tool execution isolation.

Overview

This package implements container-based isolation for agent tool execution using Docker. It provides:

  • DockerSandbox — a container-backed SandboxProvider that manages the full lifecycle of a Docker container
  • ContainerPool — a warm-container pool to amortise Docker cold-start latency (LRU eviction, idle timeout)
  • SandboxManager — factory that creates the right sandbox type (Docker vs E2B) based on config, with graceful shutdown on process exit

Installation

pnpm add @agentforge-ai/sandbox dockerode

Quick Start

import { SandboxManager } from '@agentforge-ai/sandbox';

const manager = new SandboxManager({ provider: 'docker' });
await manager.initialize();

const sb = await manager.create({ scope: 'agent', workspaceAccess: 'none' });

const { stdout, exitCode } = await sb.exec('node --version');
console.log(stdout); // v22.x.x

await sb.writeFile('/tmp/hello.js', 'console.log("hello from container")');
const result = await sb.exec('node /tmp/hello.js');
console.log(result.stdout); // hello from container

await manager.destroy(sb);
await manager.shutdown();

Configuration

DockerSandboxConfig

FieldTypeDefaultDescription
scope'session' | 'agent' | 'shared'requiredLifecycle scope
workspaceAccess'none' | 'ro' | 'rw'requiredHost workspace mount mode
imagestring'node:22-slim'Docker image
workspacePathstringHost workspace directory
containerWorkspacePathstring'/workspace'Mount point inside container
resourceLimits.cpuSharesnumberDocker defaultCPU weight
resourceLimits.memoryMbnumberunlimitedMemory cap in MB
resourceLimits.pidsLimitnumber256Max PIDs in container
resourceLimits.networkDisabledbooleanfalseDisable networking
bindsstring[][]Extra bind mounts (host:container:mode)
envRecord<string, string>{}Environment variables
timeoutnumbernoneAuto-kill after N seconds

PoolConfig

const pool = new ContainerPool({
  image: 'node:22-slim',
  scope: 'agent',
  maxSize: 3,             // warm containers to keep ready (default: 3)
  idleTimeoutSeconds: 300 // evict after 5 min idle (default: 300)
});

await pool.warmUp();
const sb = await pool.acquire();
// ... use sandbox ...
await pool.release(sb);
await pool.drain(); // cleanup

Environment Variables

VariableDescription
DOCKER_HOSTDocker daemon host (default: Unix socket)
DOCKER_IMAGEDefault image for agent sandboxes
AGENTFORGE_ALLOWED_IMAGESComma-separated image prefixes allowed in production

Security

  • Blocked bind mounts: /var/run/docker.sock, /etc, /proc, /sys, /dev, /boot, /root
  • Capabilities: All Linux capabilities dropped by default (CapDrop: ALL)
  • No new privileges: SecurityOpt: no-new-privileges:true applied to every container
  • PID limit: Default 256 PIDs per container to prevent fork bombs
  • Image validation: In production (NODE_ENV=production), only images with approved prefixes are allowed
  • Command validation: Defense-in-depth checks block docker.sock access and nsenter attempts

Docker Connection

Connects to the Docker daemon via:

  • Unix socket (default): /var/run/docker.sock
  • TCP: configure via SandboxManager({ dockerHost: { host, port, protocol } })
  • Env: DOCKER_HOST environment variable

Requirements

  • Node.js ≥ 18
  • Docker Engine installed and running on the host
  • dockerode peer dependency

License

Apache-2.0

Keywords

agentforge

FAQs

Package last updated on 23 Feb 2026

Related posts