npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@anyany/sandbox_provider

v0.1.2

Published

Unified abstraction layer for cloud sandbox providers with adapter pattern and feature polyfilling

Readme

sandbox_provider

A unified, high-level abstraction layer for cloud sandbox providers with strict OOP/SOLID principles, Adapter Pattern, and comprehensive feature polyfilling.

Features

  • Adapter Pattern: Clean abstraction over provider-specific implementations
  • Feature Polyfilling: Automatic emulation of missing features via command execution
  • SOLID Principles: Interface segregation, dependency inversion, open/closed
  • Full TypeScript: Type-safe with strict configuration
  • TDD: Comprehensive test suite with Bun test runner
  • Provider Support:
    • OpenSandbox (full native support)
    • MinimalProvider (command-only with polyfills)
    • Extensible for Daytona, Modal, Runloop, etc.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│  CONSUMER API                                                   │
│  - SandboxProviderFactory, ISandbox interface                   │
├─────────────────────────────────────────────────────────────────┤
│  SERVICE INTERFACES (Abstract Contracts)                        │
│  - ISandboxLifecycle, ICommandExecution, IFileSystem, etc.      │
├─────────────────────────────────────────────────────────────────┤
│  ADAPTER LAYER (Provider Implementations)                       │
│  - OpenSandboxAdapter, MinimalProviderAdapter                   │
├─────────────────────────────────────────────────────────────────┤
│  CAPABILITY BRIDGE (Polyfill Engine)                            │
│  - CommandPolyfillService implements FS via exec                │
├─────────────────────────────────────────────────────────────────┤
│  TRANSPORT & ERRORS                                             │
│  - Exception hierarchy, connection management                   │
└─────────────────────────────────────────────────────────────────┘

Installation

bun install

Usage

Basic Usage with OpenSandbox

import { createSandbox } from 'sandbox_provider';

// Create a sandbox
const sandbox = createSandbox({
  provider: 'opensandbox',
  connection: {
    apiKey: process.env.OPEN_SANDBOX_API_KEY,
  },
});

// Create and initialize
await sandbox.create({
  image: { repository: 'node', tag: '18' },
  entrypoint: ['node', '--version'],
});

// Execute commands
const result = await sandbox.execute('npm install');
console.log(result.stdout);

// File operations
await sandbox.writeFiles([
  { path: '/app/index.js', data: 'console.log("Hello")' },
]);

const files = await sandbox.readFiles(['/app/index.js']);

// Cleanup
await sandbox.delete();
await sandbox.close();

Minimal Provider (SSH/Command-only)

import { MinimalProviderAdapter } from 'sandbox_provider';

// Connect to a minimal provider (e.g., SSH-based sandbox)
const adapter = new MinimalProviderAdapter();

await adapter.connect({
  id: 'my-sandbox',
  execute: async (cmd) => {
    // Your SSH execution logic here
    return { stdout: '', stderr: '', exitCode: 0 };
  },
  getStatus: async () => ({ state: 'Running' }),
  close: async () => {},
});

// Filesystem operations work via polyfill!
await adapter.writeFiles([
  { path: '/tmp/test.txt', data: 'Hello' },
]);

const files = await adapter.readFiles(['/tmp/test.txt']);

Feature Detection

const sandbox = createSandbox({ provider: 'opensandbox' });

// Check capabilities
if (sandbox.capabilities.nativeFileSystem) {
  console.log('Native FS available');
}

if (sandbox.capabilities.supportsStreamingOutput) {
  await sandbox.executeStream('long-running', {
    onStdout: (msg) => console.log(msg.text),
  });
}

API Reference

Interfaces

ISandbox

The main interface combining all capabilities:

interface ISandbox
  extends ISandboxLifecycle,
    ICommandExecution,
    IFileSystem,
    IHealthCheck {
  readonly provider: string;
  readonly capabilities: ProviderCapabilities;
  close(): Promise<void>;
}

ICommandExecution

interface ICommandExecution {
  execute(command: string, options?: ExecuteOptions): Promise<ExecuteResult>;
  executeStream(command: string, handlers: StreamHandlers, options?: ExecuteOptions): Promise<void>;
  executeBackground(command: string, options?: ExecuteOptions): Promise<{ sessionId: string; kill(): Promise<void> }>;
  interrupt(sessionId: string): Promise<void>;
}

IFileSystem

interface IFileSystem {
  readFiles(paths: string[], options?: ReadFileOptions): Promise<FileReadResult[]>;
  writeFiles(entries: FileWriteEntry[]): Promise<FileWriteResult[]>;
  deleteFiles(paths: string[]): Promise<FileDeleteResult[]>;
  createDirectories(paths: string[], options?: { mode?: number; owner?: string; group?: string }): Promise<void>;
  listDirectory(path: string): Promise<DirectoryEntry[]>;
  getFileInfo(paths: string[]): Promise<Map<string, FileInfo>>;
  search(pattern: string, path?: string): Promise<SearchResult[]>;
  // ... and more
}

Error Handling

import {
  SandboxException,
  FeatureNotSupportedError,
  FileOperationError,
  CommandExecutionError,
  TimeoutError,
} from 'sandbox_provider';

try {
  await sandbox.readFiles(['/secret']);
} catch (error) {
  if (error instanceof FileOperationError) {
    console.log(`File error: ${error.fileErrorCode}`);
  }
}

Provider Capabilities

| Feature | OpenSandbox | MinimalProvider | |---------|-------------|-----------------| | Native Filesystem | ✅ | ❌ (polyfilled) | | Streaming Output | ✅ | ❌ (fallback) | | Background Exec | ✅ | ⚠️ (simulated) | | Pause/Resume | ✅ | ❌ | | Health Check | ✅ | ⚠️ (polyfilled) | | Metrics | ✅ | ⚠️ (polyfilled) | | File Search | ✅ | ⚠️ (polyfilled) |

Development

Run Tests

# Run all tests
bun test

# Watch mode
bun test --watch

# Coverage
bun test --coverage

Build

bun run build

Lint

bun run lint

Adding a New Provider

To add a new provider:

  1. Create src/adapters/FooBarAdapter.ts
  2. Extend BaseSandboxAdapter
  3. Implement native methods
  4. Set appropriate capability flags
  5. Register in SandboxProviderFactory
export class FooBarAdapter extends BaseSandboxAdapter {
  readonly provider = 'foobar';
  readonly capabilities: ProviderCapabilities = {
    nativeFileSystem: true,
    supportsStreamingOutput: true,
    // ... etc
  };

  // Implement abstract methods...
}

License

MIT