Guides / JavaScript & TypeScript / Choosing a path
JavaScript and TypeScript: choosing a path
There are four ways to use kosa8 from a Node program. Two are npm packages built for it, and two are standard protocols kosa8 speaks. They all reach the same daemon on your machine, so you can mix them. This page explains what each one is for and helps you pick.
Every code block in this section was run against a real kosa8 v0.9.10 daemon on an Apple
silicon Mac, with the published packages @kosa8/[email protected] and
@kosa8/[email protected] on Node.js 25.9.0. The output under each block is what
that run printed. The daemon ran in a separate state directory with HOME=/tmp/k8d,
so paths in the output read /tmp/k8d/… where yours will show your home folder.
Timings are from that run and will differ on your machine. A few things could not be run, such
as a GitHub Actions job and a remote worker on another machine. Those are marked
untested where they appear.
The four paths
experimental_sandbox to read and write files and run commands in, and
HarnessAgent can use it as its sandbox. Use it when the model decides what runs and
you already build on the AI SDK.kosa8 mcp serve exposes 30 kosa8 tools over the
Model Context Protocol, on stdio or HTTP. Any MCP client can use them: the AI SDK's MCP client,
Mastra, LangChain.js, Claude Code and others. The model drives kosa8 directly. Use it when you
want the agent to create and manage its own sandboxes, inside limits you set on the
command line.DOCKER_HOST. Containers run in kosa8's shared engine VM, not in sandboxes of their
own. Use it when you already have Docker code and want it off Docker Desktop, unchanged.Decision table
| You want to… | @kosa8/sdk | AI SDK adapter | MCP | Docker API |
|---|---|---|---|---|
| Run code in a microVM with its own kernel | yes | yes | yes | no: the shared engine VM |
| Close the network, or allow named hosts only | yes, per sandbox | yes, networkPolicy | yes, per sandbox | no |
| Keep API keys out of the sandbox (broker) | yes | yes, broker | no | no |
| Checkpoint and rewind a running machine | yes | stop and resume only | yes | no |
| Fork, and try N approaches in parallel | yes | no | yes | no |
| Give an AI SDK agent file and shell tools | you write the tools | yes, built in | the model calls kosa8's tools | no |
| Let the model create its own sandboxes | no | no | yes | no |
| Reuse existing dockerode or Testcontainers code | no | no | no | yes |
| Bind-mount host folders | yes, mounts | yes, mounts | below --allow-mount | below daemon start --allow-mount |
| Signed approvals for risky actions | yes, approval option | yes, approval setting | yes, approval argument | yes (the gate is in front of every route) |
| Node version | 18+ | 22+ | any | any |
How they fit together
Packages at a glance
| Package | Version | Node | Depends on | Formats |
|---|---|---|---|---|
@kosa8/sdk | 0.1.0 | 18 or later | nothing at run time | ESM and CommonJS, with .d.ts |
@kosa8/ai-sdk-sandbox | 0.1.0 | 22 or later | @kosa8/sdk, @ai-sdk/harness, @ai-sdk/provider-utils | ESM and CommonJS, with .d.ts |
Both are MIT-licensed. The licence covers the packages only, not kosa8 itself. Source: github.com/kosa8ai/kosa8-js.
What none of them can do yet
Limits in kosa8 v0.9.10 and the 0.1.0 packages
- A sandbox's network rule is fixed when it is created. There is no call to change egress on a running sandbox. Create a new one with the rule you want.
- No port forwarding from sandboxes. The native API cannot expose a sandbox port on
the host. (The Docker API's
-pworks, on the shared engine.) - Files go in and out through exec. There is no file endpoint for sandboxes. The AI SDK
adapter and the helpers on the Files page use
sh,catandbase64inside the container, so the image needs them. Alpine, Debian and the Node images have them. - No stdin for exec. A command started with
execcannot read stdin. UsestartInteractiveandwriteStdinfor a process that needs input. - Checkpoints are built from snapshots on the client side. The daemon has no
checkpoint endpoint. The SDK keeps the list in the same file as the CLI,
~/.kosa8/checkpoints.json, so both see the same checkpoints. - Remote workers are untested from the SDK. The SDK accepts
KOSA8_HOSTandKOSA8_TOKENlike the CLI. It was tested over the unix socket and over loopback TCP on one machine, not against a worker on another machine.