Sign In

sandbox-cli-detector

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sandbox-cli-detector

Detect whether a CLI is running inside a sandboxed environment

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

sandbox-cli-detector

Detect whether the current process is running inside a sandboxed developer environment.

Please open an issue if your sandbox is not properly detected.

npm Tests License

Installation

npm install sandbox-cli-detector

Usage

import { detectSandbox } from "sandbox-cli-detector";

const result = detectSandbox();

if (result.detected && result.sandbox) {
  console.log("The name of the sandbox is:", result.sandbox.name);
} else {
  console.log("This program is not running inside a known sandbox");
}

Supported sandboxes

Officially supported sandbox environments:

NameID
Replitreplit
bolt.newbolt
E2Be2b
Vercel Sandboxvercel-sandbox
Daytonadaytona
Modalmodal
Cloudflare Sandboxcloudflare-sandbox
GitHub Codespacescodespaces
CodeSandboxcodesandbox

Detection is data-driven. The exact environment variables for each sandbox live in src/sandboxes.ts.

API

detectSandbox(options?)

Returns a detection result:

{
  detected: true,
  sandbox: {
    id: "e2b",
    name: "E2B"
  }
}

When no sandbox is detected, it returns { detected: false }.

result.detected

A boolean that is true when the process is running inside a known sandbox and false otherwise.

result.sandbox.id

A stable identifier for the detected sandbox. Prefer comparing this value over result.sandbox.name.

result.sandbox.name

The display name of the detected sandbox. This may change without it being a breaking change.

isRunningInSandbox(options?)

A convenience function that returns result.detected as a boolean:

import { isRunningInSandbox } from "sandbox-cli-detector";

if (isRunningInSandbox()) {
  // Adjust CLI behavior for sandboxed execution.
}

Custom sandboxes

Pass custom definitions when you need to detect an internal environment:

import { defaultSandboxes, detectSandbox } from "sandbox-cli-detector";

const result = detectSandbox({
  sandboxes: [
    {
      id: "internal",
      name: "Internal Sandbox",
      env: [{ name: "INTERNAL_SANDBOX", value: "true" }],
    },
    ...defaultSandboxes,
  ],
});

Each environment signal matches either an exact value or any non-empty value when value is omitted. If multiple sandboxes match, the first definition is returned.

CLI

The package also ships a CLI:

npx sandbox-cli-detector
npx sandbox-cli-detector --json
npx sandbox-cli-detector --quiet

It exits with 0 when a sandbox is detected and 1 otherwise.

Contributing detections

Please include the platform name, a redacted env | sort captured inside the platform, and the variables that identify it.

License

MIT

Keywords

sandbox

FAQs

Package last updated on 18 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts