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

@kokolabs-io/sdk

v1.0.0

Published

Complete SDK for Koko user pods and remote runtime environments

Readme

@kokolabs-io/sdk

Complete SDK for Koko user pods and remote runtime environments.

Features

  • SQL API: Execute SQL queries with parameter binding
  • File System API: Read/write files in pod storage
  • Authentication: User authentication and authorization
  • Environment Variables: Access to pod environment
  • KV Store: Key-value storage (coming soon)
  • Queue: Task queue management (coming soon)
  • Logging: Structured logging (coming soon)
  • Dual Mode: Works in both native and remote environments

Installation

pnpm add @kokolabs-io/sdk

Usage

Basic Setup

import { koko } from '@kokolabs-io/sdk';

// Check pod connection
console.log(koko.ping()); // "pong"
console.log(koko.podId()); // Your pod ID

SQL API

import { sql } from '@kokolabs-io/sdk';

// Execute a query
const result = await sql.query('SELECT * FROM users WHERE age > ?', [18]);
console.log(result.columns); // ['id', 'name', 'age']
console.log(result.rows);    // [[1, 'Alice', 25], [2, 'Bob', 30]]

// Execute a statement (INSERT, UPDATE, DELETE)
await sql.execute('INSERT INTO users (name, age) VALUES (?, ?)', ['Charlie', 35]);

// Query each row with callback
await sql.queryEach(
  'SELECT * FROM large_table',
  [],
  undefined,
  (row) => {
    console.log(row);
    return true; // Continue iteration
  }
);

// Attach another database
await sql.attach('/data/other.db', 'other_db');
await sql.query('SELECT * FROM other_db.table_name');
await sql.detach('other_db');

File System API

import { fs } from '@kokolabs-io/sdk';

// Read text file
const content = await fs.readText('/data/config.json');

// Write text file
await fs.writeText('/data/output.txt', 'Hello, world!');

// Write with conditional update (optimistic locking)
await fs.writeText('/data/config.json', newConfig, {
  ifMatch: previousETag,
  force: false
});

// Read binary data
const bytes = await fs.readBytes('/data/image.png');
const buffer = await fs.readBuffer('/data/file.bin');

// File operations
const exists = await fs.exists('/data/file.txt');
const stat = await fs.stat('/data/file.txt');
const files = await fs.readdir('/data/');

// Directory operations
await fs.mkdir('/data/new-folder', true);
await fs.rm('/data/old-folder', true);

// Get file tree
const tree = await fs.tree('/data/', {
  typed: true,
  filesOnly: false
});

Authentication API

import { auth } from '@kokolabs-io/sdk';

// Get current user
const user = auth.getUser();
if (user) {
  console.log(user.id);
  console.log(user.roles);
  console.log(user.scopes);
}

// Require authentication
try {
  const user = auth.require();
  console.log('Authenticated:', user.id);
} catch (error) {
  console.error('Unauthorized');
}

// Check whitelist
if (auth.isWhitelisted()) {
  console.log('User is whitelisted');
}

// Server-side authentication
import { auth } from '@kokolabs-io/sdk';

async function handler(req: Request) {
  // Require authentication for this request
  const user = await auth.requireAuth(req, {
    mode: 'auth',
    whitelist: true
  });

  return new Response(`Hello, ${user.id}`);
}

// Token management
auth.setToken('your-access-token');
const token = auth.getToken();

// Provider info
console.log(auth.provider()); // 'koko', 'custom', etc.
console.log(auth.isProviderPod()); // true/false

Environment Variables

import { env } from '@kokolabs-io/sdk';

const apiKey = env.API_KEY;
const dbUrl = env.DATABASE_URL;
const port = env.PORT || '3000';

Custom Client

import { createClient } from '@kokolabs-io/sdk';

const client = createClient({
  apiUrl: 'https://api.example.com',
  apiKey: 'your-api-key',
  podId: 'your-pod-id',
  token: 'your-access-token'
});

// Use the custom client
await client.sql.query('SELECT * FROM users');
const content = await client.fs.readText('/data/config.json');

API Reference

SQL API

interface SqlApi {
  query(statement: string, params?: unknown[], options?: SqlOptions): Promise<SqlQueryResult>;
  execute(statement: string, params?: unknown[], options?: SqlOptions): Promise<SqlExecResult>;
  queryRaw(statement: string, params?: unknown[], options?: SqlOptions): Promise<SqlQueryResult>;
  queryEach(
    statement: string,
    params: unknown[] | undefined,
    options: SqlOptions | undefined,
    onRow: (row: unknown[]) => boolean | void
  ): Promise<SqlEachResult>;
  attach(targetPath: string, alias: string, options?: SqlOptions): Promise<SqlExecResult>;
  detach(alias: string, options?: SqlOptions): Promise<SqlExecResult>;
}

File System API

interface FsApi {
  read(path: string): string | Promise<string>;
  write(path: string, data: string, options?: { ifMatch?: string; force?: boolean }): unknown | Promise<unknown>;
  readText(path: string): Promise<string>;
  writeText(path: string, data: string, options?: { ifMatch?: string; force?: boolean }): Promise<boolean>;
  readBytes?(path: string): Promise<Uint8Array>;
  readBuffer?(path: string): Promise<ArrayBuffer>;
  writeBytes?(path: string, data: Uint8Array | ArrayBuffer): Promise<unknown>;
  tree?(path?: string, options?: { typed?: boolean; filesOnly?: boolean }): Promise<unknown>;
  mkdir?(path: string, recursive?: boolean): Promise<unknown>;
  rm?(path: string, recursive?: boolean): Promise<unknown>;
  exists?(path: string): Promise<boolean>;
  stat?(path: string): Promise<unknown>;
  readdir?(path: string): Promise<string[]>;
}

Authentication API

interface AuthApi {
  getUser(): KokoUser | null;
  provider(): string;
  isProviderPod(): boolean;
  whitelist(): string[];
  isWhitelisted(userId?: string): boolean;
  require(options?: { mode?: AuthMode; whitelist?: boolean }): KokoUser;
  requireAuth(req: Request, options?: { mode?: AuthMode; whitelist?: boolean; token?: string; accessToken?: string }): Promise<KokoUser>;
  getToken(): string;
  setToken(token: string): void;
  loadPodAuthConfig?(): Promise<PodAuthConfig>;
  loginPassword?(input: PasswordLoginInput): Promise<LoginResult>;
}

Build

Build from root:

pnpm -C .. build

Build this package only:

pnpm --filter @kokolabs-io/sdk build

License

MIT - Copyright (c) 2026 KokoLabs.io