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

@kb-labs/core-resource-broker

v1.2.0

Published

Centralized resource broker for queue management, rate limiting, and retry logic

Readme

@kb-labs/core-resource-broker

Centralized queue, rate limiting, and retry management for heavy platform resources (LLM, embeddings, vector store).

Overview

Wraps platform adapters with a priority queue, configurable rate limits, and automatic retry with exponential backoff. Supports single-process (in-memory) and distributed (state-broker HTTP daemon) rate limiting backends.

Quick Start

import {
  ResourceBroker,
  InMemoryRateLimitBackend,
  createQueuedLLM,
} from '@kb-labs/core-resource-broker';

const backend = new InMemoryRateLimitBackend();
const broker = new ResourceBroker(backend);

// Wrap existing LLM adapter — transparent drop-in replacement
const llm = createQueuedLLM(broker, rawLLMAdapter);

// Requests are now automatically queued, rate-limited, and retried
const response = await llm.complete({ prompt: 'Hello' });

Queued Adapters

Drop-in wrappers that add queuing and rate limiting to existing adapters:

| Factory | Wraps | |---------|-------| | createQueuedLLM() | LLMAdapter | | createQueuedEmbeddings() | EmbeddingsAdapter | | createQueuedVectorStore() | VectorStoreAdapter |

Rate Limit Backends

| Backend | Use case | |---------|----------| | InMemoryRateLimitBackend | Single process — development, CLI tools | | StateBrokerRateLimitBackend | Distributed — multi-instance REST API deployments |

// Distributed mode (requires core-state-daemon running)
import { StateBrokerRateLimitBackend } from '@kb-labs/core-resource-broker';

const backend = new StateBrokerRateLimitBackend({
  url: 'http://localhost:7777',
});

Rate Limit Presets

import { RATE_LIMIT_PRESETS, getRateLimitConfig } from '@kb-labs/core-resource-broker';

broker.register('llm', {
  rateLimits: 'openai-tier-2',  // preset: 3500 RPM, 90k TPM
  executor: (op, args) => llmAdapter[op](...args),
});

// Or custom config
broker.register('embeddings', {
  rateLimits: { requestsPerMinute: 1000, tokensPerMinute: 1_000_000 },
  executor: (op, args) => embeddingsAdapter[op](...args),
});

Priority Queue

// High-priority requests jump the queue
const result = await broker.execute('llm', 'complete', [prompt], {
  priority: 'high',   // 'high' | 'normal' | 'low'
});

Retry Configuration

const broker = new ResourceBroker(backend, {
  retry: {
    maxAttempts: 3,
    initialDelay: 1000,   // ms
    maxDelay: 30_000,
    jitter: true,
  },
});
// Automatically retries on 429 (respects Retry-After header) and 5xx errors

License

KB Public License v1.1 © KB Labs