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

ai-sdk-sandbox-docker

v0.1.2

Published

HarnessV1SandboxProvider implementation backed by a Docker container.

Readme

AI SDK - Docker Sandbox

This package is experimental.

A HarnessV1SandboxProvider backed by a Docker container. Each session runs its file I/O, run, and spawn through docker exec, so the container is the trust boundary.

Requirements

A running Docker daemon and the docker CLI on the host.

Install

npm i ai-sdk-sandbox-docker @ai-sdk/harness

Usage

The factory is synchronous. createSession() creates the container and publishes its ports to 127.0.0.1.

import { createDockerSandbox } from 'ai-sdk-sandbox-docker';

const dockerSandbox = createDockerSandbox({
  image: 'node:22',
  ports: [3000],
});

const networkSession = await dockerSandbox.createSession();
const session = networkSession.restricted();

await session.writeTextFile({ path: 'hello.txt', content: 'hi' });

const { stdout } = await session.run({ command: 'cat hello.txt' });
console.log(stdout); // "hi"

await networkSession.stop(); // removes the created container

networkSession.restricted() is typed as Experimental_SandboxSession, the reduced surface (file I/O, run, spawn) safe to pass to AI SDK tools via experimental_sandbox. The network session keeps the infra surface (ports, getPortUrl, setPorts, setNetworkPolicy, stop) that only the harness reaches for.

Configuration

const dockerSandbox = createDockerSandbox({
  image: 'node:22',
  workdir: '/workspace',
  ports: [3000],
  createArgs: ['-v', `${process.cwd()}:/workspace`],
  keep: false,
});
  • image Image for a created container. Ignored when container is set. Defaults to node:22.
  • container Attach to an existing container by name or id. The caller owns its lifecycle and port publishing; the provider never creates or removes it.
  • workdir Working directory inside the container. Defaults to /workspace. Relative paths in file operations resolve against it.
  • docker Path to the docker binary. Defaults to docker.
  • createArgs Extra arguments passed to docker run. Use it for volume mounts (-v), container env (-e), and networking (--network).
  • ports Ports to publish from container to host. The first port serves as the bridge; when omitted the provider leases one.
  • keep Keep a created container after the session stops. Defaults to false.

Mount a host directory to run the agent against a real repository:

createDockerSandbox({
  image: 'node:22',
  workdir: '/repo',
  createArgs: ['-v', `${process.cwd()}:/repo`],
});

Authentication

The provider uses the host's Docker configuration. To pull a private image, run docker login first. To target a remote daemon, set DOCKER_HOST or select a Docker context; the provider shells out to the same docker CLI and inherits that configuration.

Lifecycle

A created container is named ai-sdk-sandbox-<sessionId>. resumeSession({ sessionId }) rebinds to it by name without checking that it is still running; if the container is gone the first exec fails rather than the resume. stop() removes a container the provider created, unless keep is set. For an attached container (container set), stop() leaves it running.

Ports and network policy

Ports are published container to host 1:1 at creation, so getPortUrl resolves to http://127.0.0.1:<port> and throws HarnessCapabilityUnsupportedError for a port that was not published. Docker cannot publish new ports to a running container, so a port requested after creation must already be in ports, and resumeSession and attach mode expose only the ports declared in ports. setNetworkPolicy is a no-op; fix the container network at boot with createArgs (for example --network).

Cancellation

spawn records the in-container PID and terminates it on kill() or stop(). Use those to cancel a spawned process. docker exec does not forward signals, so aborting through abortSignal only kills the local docker exec client: an aborted run, or an aborted spawn whose kill() you never call, leaves its command running in the container until the container stops.

License

Apache-2.0