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

@giselles-ai/sandbox-policy-builder

v0.1.0

Published

Product-oriented network policy builder for @vercel/sandbox.

Downloads

11

Readme

sandbox-policy-builder

Build network policies for Vercel Sandbox around services instead of raw domains.

Instead of writing low-level domain rules like this:

const sandbox = await Sandbox.create({
  networkPolicy: {
    allow: {
      "api.openai.com": [
        {
          transform: [
            {
              headers: {
                Authorization: `Bearer ${apiKey}`,
              },
            },
          ],
        },
      ],
    },
  },
});

you can write this:

import { allow } from "sandbox-policy-builder";

const sandbox = await Sandbox.create({
  networkPolicy: allow({
    openai: { apiKey: process.env.OPENAI_API_KEY! },
    claude: { apiKey: process.env.ANTHROPIC_API_KEY! },
    github: { apiKey: process.env.GITHUB_TOKEN! },
  }),
});

The package expands service names into the domain-level NetworkPolicy shape required by @vercel/sandbox.

Why

Vercel Sandbox credentials brokering is powerful, but the raw SDK API is domain-oriented.

That is precise, but repetitive in real apps:

  • codex and openai both target api.openai.com
  • claude requires x-api-key and anthropic-version
  • github often needs multiple related domains
  • aiGateway is conceptually one service, not one header rule

This package gives you a small DSL that matches how people usually think about these integrations: service first, transport details second.

Installation

bun add sandbox-policy-builder

Or:

npm install sandbox-policy-builder

Usage

OpenAI

import { allow } from "sandbox-policy-builder";

const sandbox = await Sandbox.create({
  networkPolicy: allow({
    openai: { apiKey: process.env.OPENAI_API_KEY! },
  }),
});

Claude

import { allow } from "sandbox-policy-builder";

const sandbox = await Sandbox.create({
  networkPolicy: allow({
    claude: { apiKey: process.env.ANTHROPIC_API_KEY! },
  }),
});

GitHub

const sandbox = await Sandbox.create({
  networkPolicy: allow({
    github: { apiKey: process.env.GITHUB_TOKEN! },
  }),
});

This expands to GitHub-related domains including:

  • github.com
  • *.github.com
  • api.github.com

AI Gateway

const sandbox = await Sandbox.create({
  networkPolicy: allow({
    aiGateway: { apiKey: process.env.AI_GATEWAY_TOKEN! },
  }),
});

Multiple Products

const sandbox = await Sandbox.create({
  networkPolicy: allow({
    openai: { apiKey: process.env.OPENAI_API_KEY! },
    claude: { apiKey: process.env.ANTHROPIC_API_KEY! },
    github: { apiKey: process.env.GITHUB_TOKEN! },
    aiGateway: { apiKey: process.env.AI_GATEWAY_TOKEN! },
  }),
});

Supported Products

  • codex
  • openai
  • gemini
  • claude
  • github
  • aiGateway

Use listSupportedProducts() to inspect the current set:

import { listSupportedProducts } from "sandbox-policy-builder";

console.log(listSupportedProducts());

API

allow(input)

Builds a Vercel Sandbox NetworkPolicy.

type AllowInput = Partial<{
  codex: { apiKey: string };
  openai: { apiKey: string };
  gemini: { apiKey: string };
  claude: { apiKey: string };
  github: { apiKey: string };
  aiGateway: { apiKey: string };
}>;

Returns:

type NetworkPolicy =
  | "allow-all"
  | "deny-all"
  | {
      allow?: string[] | Record<string, NetworkPolicyRule[]>;
      subnets?: {
        allow?: string[];
        deny?: string[];
      };
    };

listSupportedProducts()

Returns the list of known product names.

Conflict Handling

Some products compile to the same underlying domain.

For example:

  • codex -> api.openai.com
  • openai -> api.openai.com

If two products generate different rules for the same domain, allow() throws.

This is intentional. Silent last-write-wins behavior would make credential brokering hard to reason about.

Vercel Sandbox Example

import { Sandbox } from "@vercel/sandbox";
import { allow } from "sandbox-policy-builder";

const sandbox = await Sandbox.create({
  networkPolicy: allow({
    github: { apiKey: process.env.GITHUB_TOKEN! },
    aiGateway: { apiKey: process.env.AI_GATEWAY_TOKEN! },
  }),
});

Updating an Existing Sandbox

If you need open network access during setup and want to lock the sandbox down afterward, allow() also works with updateNetworkPolicy():

await sandbox.updateNetworkPolicy(
  allow({
    openai: { apiKey: process.env.OPENAI_API_KEY! },
  }),
);

Notes

  • This package does not change how Vercel Sandbox works. It only builds the NetworkPolicy object.
  • Product names are convenience abstractions over domains, headers, and credential brokering transforms.
  • If a CLI requires a local env var just to start, you may still need a non-secret dummy value in the sandbox process. This package only handles network policy generation.

References