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

setsuna-sdk

v0.1.5

Published

Setsuna SDK for TypeScript and JavaScript.

Readme

Setsuna SDK — TypeScript / JavaScript

setsuna-sdk is the programmatic client for Setsuna machines. It serves TypeScript and JavaScript on Node.js 24.14.0 or newer.

Installing the package does not grant access to the Setsuna service. An authorized Setsuna account is required. Learn more at semswitch.com/setsuna.

Install

npm install setsuna-sdk

TypeScript projects also need @types/node, because process output is delivered as Buffer data. The package is ESM-only: use import, or await import("setsuna-sdk") from CommonJS code, where require() fails.

Access tokens

Supply a Setsuna access token through getAccessToken: () => Promise<string>. The client calls it at connection admission and before expiry to renew the same connection. Return a current token each time. If renewal fails, work on that connection fails with UNAUTHORIZED. Errors from your provider reach your code unchanged. The SDK does not sign in, store tokens, or offer API keys.

First call

import { SetsunaClient } from "setsuna-sdk";

export async function firstCall(getAccessToken: () => Promise<string>): Promise<void> {
  const setsuna = new SetsunaClient({ remote: { getAccessToken } });
  try {
    const machine = await setsuna.machines.create({ leaseSeconds: 1800 });
    try {
      const result = await machine.exec("uname -a");
      console.log(result.exitCode, result.stdout);
    } finally {
      await setsuna.machines.destroy(machine.machineId);
    }
  } finally {
    await setsuna.close();
  }
}

setsuna.machines creates, lists, inspects, and destroys account microVMs. machines.create() returns a handle with its machineId and the lease fixed at readiness: leaseSeconds, expiresAt, and machineConfiguration. Use machine.exec() for commands and machine.processes for guest processes. machines.get(machineId) rebuilds a handle without a request. Parse stored IDs with parseMachineId(); it accepts sbx_ production and sandbox- operator-local IDs.

Files

machine.fs works on handles from machines.create() and machines.get(). Paths are absolute within the guest. This example writes text and streams bytes without collecting them in memory:

import type { Machine } from "setsuna-sdk";

export async function useFiles(machine: Machine, source: AsyncIterable<Uint8Array>): Promise<string> {
  await machine.fs.writeFile("/workspace/message.txt", "hello", { createParents: true });
  await machine.fs.writeStream("/workspace/data.bin", source);
  for await (const chunk of machine.fs.readStream("/workspace/data.bin")) {
    console.log(chunk.byteLength);
  }
  return machine.fs.readText("/workspace/message.txt");
}

fs also provides readFile, readDir, stat, exists, mkdir, remove, rename, copy, and chmod. Pass signal to cancel; streams also accept an idle timeout. Writes commit after the complete body arrives. After an unknown write outcome, inspect the file before retrying.

Pass leaseSeconds as a positive safe integer in whole seconds. The service fixes expiry at readiness; activity never extends it. Omission uses the account policy default; the SDK does not choose a lifetime. Values that cannot produce a representable expiry date are rejected. Destroy the machine when you are done. close() ends only this client's connection; it does not stop processes or machines.

Failures throw SetsunaError with a code and outcome. failed means the operation did not complete; unknown means its result cannot be established. Neither is retry advice. After an unknown outcome, check state before retrying. Machine codes use MACHINE_*; other service codes remain strings. Keep needed IDs instead of relying on machines.list(). A nonzero command exit is a result, not an error.

Examples

The source repository's examples/ covers lifecycle, execution, background processes, PTY, errors, and one-off run(). These files are not packaged. Copy one into a project with setsuna-sdk installed and call its exported function with getAccessToken. For example, await runLifecycle(getAccessToken) creates real machines on your account. Node.js 24 runs .ts files directly, or you can compile them with tsc.

The full client contract is docs/sdk.md in the source repository.

Copyright © 2026 SemSwitch, Inc. All rights reserved. Use of this package is subject to the included license and the SemSwitch Terms of Service.