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

@cubby/js

v1.0.2

Published

typescript sdk for [cubby](https://cubby.sh) - capture everything, search anything, automate everywhere.

Readme

@cubby/js

typescript sdk for cubby - capture everything, search anything, automate everywhere.

works in node, cloudflare workers, and browsers.

installation

npm i @cubby/js

authentication

get your api credentials at cubby.sh/dashboard:

  1. log in to your cubby account
  2. click "generate new credentials"
  3. save your client_id and client_secret
  4. set them as environment variables:
export CUBBY_CLIENT_ID="your_client_id"
export CUBBY_CLIENT_SECRET="your_client_secret"

the sdk automatically exchanges these credentials for access tokens and handles token refresh.

quick start

local usage

import { createClient } from '@cubby/js';

const client = createClient({ baseUrl: 'http://localhost:3030' });

// search your screen and audio history
const results = await client.search({ 
  q: 'project deadline', 
  limit: 10 
});

console.log(`found ${results.pagination.total} results`);

remote usage

import { createClient } from '@cubby/js';

// credentials are auto-detected from environment variables
// or pass them explicitly
const client = createClient({ 
  baseUrl: 'https://api.cubby.sh',
  clientId: process.env.CUBBY_CLIENT_ID,
  clientSecret: process.env.CUBBY_CLIENT_SECRET,
});

// list devices and select one
const { devices } = await client.listDevices();
client.setDeviceId(devices[0].id);

// now all methods use the selected device
await client.search({ q: 'hello' });
await client.notify({ title: 'test', body: 'works!' });

api reference

client creation

import { createClient } from '@cubby/js';

const client = createClient({
  baseUrl: 'http://localhost:3030', // or 'https://api.cubby.sh'
  clientId: 'your-client-id', // optional, auto-detected from CUBBY_CLIENT_ID env var
  clientSecret: 'your-client-secret', // optional, auto-detected from CUBBY_CLIENT_SECRET env var
});

device management

// list all enrolled devices
const { devices } = await client.listDevices();
// => { devices: [{ id: 'device-123' }, ...] }

// set device for subsequent calls (remote only)
client.setDeviceId('device-123');

// clear selected device
client.clearDeviceId();

search

// unified search across screen, audio, and ui
const results = await client.search({
  q: 'search query',
  limit: 50,
  offset: 0,
  content_type: 'all', // 'ocr' | 'audio' | 'ui' | 'all'
  start_time: '2024-01-01T00:00:00Z',
  end_time: '2024-01-02T00:00:00Z',
  app_name: 'Slack',
  window_name: 'general',
  include_frames: false,
  speaker_ids: [1, 2],
  deviceId: 'device-123' // optional override
});

// speaker search
const speakers = await client.speakersSearch({
  name: 'john',
  deviceId: 'device-123' // optional
});

streaming

// stream all events (transcriptions + vision)
for await (const event of client.streamEvents(false)) {
  console.log(event.name, event.data);
}

// stream transcriptions only
for await (const event of client.streamTranscriptions()) {
  console.log('transcription:', event.text);
}

// stream vision events (ocr + ui frames)
for await (const event of client.streamVision(false)) {
  if (event.name === 'ocr_result') {
    console.log('ocr:', event.data.text);
  }
}

// include images in stream
for await (const event of client.streamVision(true)) {
  console.log(event.data.image); // base64 image data
}

device automation

// open applications
await client.device.openApplication('Slack');
await client.device.openApplication('Visual Studio Code');

// open urls in browser
await client.device.openUrl('https://github.com');
await client.device.openUrl('https://google.com', 'Safari');

// send desktop notifications
await client.notify({
  title: 'reminder',
  body: 'meeting in 5 minutes'
});

configuration

// update base url
client.setBaseUrl('https://api.cubby.sh');

// update credentials
client.setCredentials('new-client-id', 'new-client-secret');

// get current access token (mainly for debugging)
const token = await client.getAccessToken();

environment variables

the sdk automatically reads from environment variables:

# node / bun
export CUBBY_API_BASE_URL="https://api.cubby.sh"
export CUBBY_CLIENT_ID="your-client-id"
export CUBBY_CLIENT_SECRET="your-client-secret"
// cloudflare workers / browser
globalThis.__CUBBY_ENV__ = {
  CUBBY_API_BASE_URL: 'https://api.cubby.sh',
  CUBBY_CLIENT_ID: 'your-client-id',
  CUBBY_CLIENT_SECRET: 'your-client-secret',
};

// then create client without config
const client = createClient();

important for browsers/next.js: in browser environments, you need to use public environment variables:

# .env.local for next.js
NEXT_PUBLIC_CUBBY_API_BASE_URL=https://api.cubby.sh
NEXT_PUBLIC_CUBBY_CLIENT_ID=your-client-id
NEXT_PUBLIC_CUBBY_CLIENT_SECRET=your-client-secret

note: exposing client credentials in browser code is generally not recommended for production apps. consider creating an api route that proxies requests to cubby.

examples

basic search

import { createClient } from '@cubby/js';

const client = createClient({ baseUrl: 'http://localhost:3030' });

const results = await client.search({ 
  q: 'api keys',
  content_type: 'ocr',
  limit: 10 
});

for (const item of results.data) {
  console.log(`[${item.content.timestamp}] ${item.content.text}`);
}

real-time transcription

import { createClient } from '@cubby/js';

const client = createClient({ baseUrl: 'http://localhost:3030' });

console.log('listening for transcriptions...');

for await (const event of client.streamTranscriptions()) {
  console.log(event.text);
}

remote device control

import { createClient } from '@cubby/js';

const client = createClient({ 
  baseUrl: 'https://api.cubby.sh',
  clientId: process.env.CUBBY_CLIENT_ID,
  clientSecret: process.env.CUBBY_CLIENT_SECRET,
});

// list and select device
const { devices } = await client.listDevices();
console.log(`found ${devices.length} devices`);

client.setDeviceId(devices[0].id);

// search on remote device
const results = await client.search({ 
  q: 'meeting notes',
  limit: 5 
});

console.log(`found ${results.pagination.total} results`);

// automate remote device
await client.device.openApplication('Slack');
await client.notify({
  title: 'task complete',
  body: 'your automation finished'
});

type definitions

the sdk is fully typed. import types for better intellisense:

import { 
  createClient, 
  CubbyClient, 
  ClientOptions,
  cubbyQueryParams,
  cubbyResponse,
  NotificationOptions
} from '@cubby/js';

links

license

see LICENSE.md