open-index/open-npm huggingface dataset:
npm package: @kb-labs/core-resource-broker
Description: Centralized resource broker for queue management, rate limiting, and retry logic
Latest version: 1.9.0

# @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

```typescript
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 |

```typescript
// 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

```typescript
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

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

## Retry Configuration

```typescript
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
npm package: @kb-labs/core-types
Description: Shared TypeScript type definitions for KB Labs core packages
Latest version: 1.9.0

# @kb-labs/core-types

> **Shared TypeScript type definitions for KB Labs core packages.** Provides common types used across all KB Labs packages for consistency and type safety.

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Node.js](https://img.shields.io/badge/Node.js-18.18.0+-green.svg)](https://nodejs.org/)
[![pnpm](https://img.shields.io/badge/pnpm-9.0.0+-orange.svg)](https://pnpm.io/)

## 🎯 Vision & Purpose

**@kb-labs/core-types** provides shared TypeScript type definitions for KB Labs core packages. It ensures type consistency across the ecosystem and provides a single source of truth for common types like `ProductId`.

## 🏗️ Architecture

### Core Components

#### Type Definitions

- **Purpose**: Define shared types
- **Responsibilities**: Export types for use in other packages
- **Dependencies**: None (types only)

### Design Patterns

- **Type Library Pattern**: Centralized type definitions
- **Union Types**: ProductId as union type for type safety

### Data Flow

```
Import from @kb-labs/core-types
    │
    ├──► TypeScript compiler resolves types
    ├──► Types available at compile time
    └──► No runtime code
```

## 🚀 Quick Start

### Installation

```bash
pnpm add @kb-labs/core-types
```

### Basic Usage

```typescript
import type { ProductId } from '@kb-labs/core-types';

function processProduct(product: ProductId) {
  // Type-safe product handling
  switch (product) {
    case 'aiReview':
      // ...
      break;
    case 'aiDocs':
      // ...
      break;
  }
}
```

## ✨ Features

### Type Definitions

- **ProductId**: Union type for all KB Labs products
- **Type Safety**: Strong typing prevents invalid values
- **Consistency**: Single source of truth for product IDs

## 🔧 Configuration

### Configuration Options

No configuration needed (types only).

### Environment Variables

None (compile-time only).

## 🤝 Contributing

See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development guidelines.

## 📄 License

KB Public License v1.1 © KB Labs
npm package: @kb-labs/infra-worker-contracts
Description: Public contracts package for infra worker plugin invoke payloads and results.
Latest version: 0.5.0

# @kb-labs/infra-worker-contracts

Shared types/contracts for infra worker plugin integration.

Use this package when orchestrator and infra worker need a stable typed payload/result contract.

## Build

```bash
pnpm --filter @kb-labs/infra-worker-contracts build
```
npm package: @kb-labs/infra-worker-core
Description: Infra worker plugin core for workspace/environment/snapshot lifecycle operations.
Latest version: 0.5.0

# @kb-labs/infra-worker-core

Core package for the KB Labs infra worker plugin.

Exports:
- V3 plugin manifest (`./plugin-manifest`)
- CLI command handlers under `src/cli/commands`

## Commands

- `infra-worker:prepare`
- `infra-worker:capture-snapshot`
- `infra-worker:restore-snapshot`

## Build

```bash
pnpm --filter @kb-labs/infra-worker-core build
```
npm package: @kb-labs/marketplace-contracts
Description: Shared types and interfaces for KB Labs marketplace
Latest version: 0.1.4

# @product-name/package-name

Baseline library package inside KB Labs Product Template.

## Vision & Purpose

**@product-name/package-name** is a minimal example library shipped with `kb-labs-product-template`.  
It shows how a typical package is structured (source, tests, types) and is intended to be **renamed or removed** when creating a real product.

### Core Goals

- Demonstrate the standard KB Labs package layout (src/types/tests/build tooling)
- Provide a simple, testable function (`hello`) as a starting point
- Act as a safe playground for verifying DevKit configs (tsup, Vitest, ESLint)

## Package Status

- **Version**: 0.1.0  
- **Stage**: Template / Example  
- **Status**: Not for Production ⚠️

## Architecture

### Structure

```
packages/package-name/
├── src/
│   ├── index.ts        # Public entrypoint
│   └── types/          # Shared types and re-exports
│       ├── types.ts
│       └── index.ts
├── index.test.ts       # Vitest example
└── tsup.config.ts      # Build configuration
```

The default implementation is intentionally tiny:

```ts
export const hello = (name = 'KB Labs') => `Hello, ${name}!`;
```

## Dependencies

### Runtime

None by default — this is a pure TypeScript example.

### Development

- `@kb-labs/devkit`: shared TS/ESLint/Vitest/TSUP presets
- `tsup`, `vitest`, `tsx`, `typescript`

## Scripts

From the `kb-labs-product-template` root:

```bash
pnpm --filter @product-name/package-name build
pnpm --filter @product-name/package-name test
pnpm --filter @product-name/package-name lint
```

## How to Adapt for a Real Package

When using the product template for your own project:

1. Rename the package in `package.json` (e.g. `@kb-labs/my-product-core`).
2. Replace the `hello` function with your actual public API.
3. Update tests in `index.test.ts` to cover real behaviour.
4. Adjust `types/` to expose the correct public types.

This package is meant as a scaffold only; don’t ship it as-is to production.
npm package: @kb-labs/marketplace-core
Description: Marketplace service — unified install/uninstall/enable/disable for all entity types
Latest version: 0.1.4

# @product-name/package-name

Baseline library package inside KB Labs Product Template.

## Vision & Purpose

**@product-name/package-name** is a minimal example library shipped with `kb-labs-product-template`.  
It shows how a typical package is structured (source, tests, types) and is intended to be **renamed or removed** when creating a real product.

### Core Goals

- Demonstrate the standard KB Labs package layout (src/types/tests/build tooling)
- Provide a simple, testable function (`hello`) as a starting point
- Act as a safe playground for verifying DevKit configs (tsup, Vitest, ESLint)

## Package Status

- **Version**: 0.1.0  
- **Stage**: Template / Example  
- **Status**: Not for Production ⚠️

## Architecture

### Structure

```
packages/package-name/
├── src/
│   ├── index.ts        # Public entrypoint
│   └── types/          # Shared types and re-exports
│       ├── types.ts
│       └── index.ts
├── index.test.ts       # Vitest example
└── tsup.config.ts      # Build configuration
```

The default implementation is intentionally tiny:

```ts
export const hello = (name = 'KB Labs') => `Hello, ${name}!`;
```

## Dependencies

### Runtime

None by default — this is a pure TypeScript example.

### Development

- `@kb-labs/devkit`: shared TS/ESLint/Vitest/TSUP presets
- `tsup`, `vitest`, `tsx`, `typescript`

## Scripts

From the `kb-labs-product-template` root:

```bash
pnpm --filter @product-name/package-name build
pnpm --filter @product-name/package-name test
pnpm --filter @product-name/package-name lint
```

## How to Adapt for a Real Package

When using the product template for your own project:

1. Rename the package in `package.json` (e.g. `@kb-labs/my-product-core`).
2. Replace the `hello` function with your actual public API.
3. Update tests in `index.test.ts` to cover real behaviour.
4. Adjust `types/` to expose the correct public types.

This package is meant as a scaffold only; don’t ship it as-is to production.
npm package: @kb-labs/marketplace-npm
Description: npm/pnpm package source for KB Labs marketplace
Latest version: 0.1.4

# @product-name/package-name

Baseline library package inside KB Labs Product Template.

## Vision & Purpose

**@product-name/package-name** is a minimal example library shipped with `kb-labs-product-template`.  
It shows how a typical package is structured (source, tests, types) and is intended to be **renamed or removed** when creating a real product.

### Core Goals

- Demonstrate the standard KB Labs package layout (src/types/tests/build tooling)
- Provide a simple, testable function (`hello`) as a starting point
- Act as a safe playground for verifying DevKit configs (tsup, Vitest, ESLint)

## Package Status

- **Version**: 0.1.0  
- **Stage**: Template / Example  
- **Status**: Not for Production ⚠️

## Architecture

### Structure

```
packages/package-name/
├── src/
│   ├── index.ts        # Public entrypoint
│   └── types/          # Shared types and re-exports
│       ├── types.ts
│       └── index.ts
├── index.test.ts       # Vitest example
└── tsup.config.ts      # Build configuration
```

The default implementation is intentionally tiny:

```ts
export const hello = (name = 'KB Labs') => `Hello, ${name}!`;
```

## Dependencies

### Runtime

None by default — this is a pure TypeScript example.

### Development

- `@kb-labs/devkit`: shared TS/ESLint/Vitest/TSUP presets
- `tsup`, `vitest`, `tsx`, `typescript`

## Scripts

From the `kb-labs-product-template` root:

```bash
pnpm --filter @product-name/package-name build
pnpm --filter @product-name/package-name test
pnpm --filter @product-name/package-name lint
```

## How to Adapt for a Real Package

When using the product template for your own project:

1. Rename the package in `package.json` (e.g. `@kb-labs/my-product-core`).
2. Replace the `hello` function with your actual public API.
3. Update tests in `index.test.ts` to cover real behaviour.
4. Adjust `types/` to expose the correct public types.

This package is meant as a scaffold only; don’t ship it as-is to production.
npm package: @kb-labs/mind-adapters
Description: Git adapters for KB Labs Mind
Latest version: 1.5.0

# @kb-labs/mind-adapters

Git adapters for KB Labs Mind.

## Vision & Purpose

**@kb-labs/mind-adapters** provides Git adapters for KB Labs Mind. It includes adapters for Git diff and staged file operations.

### Core Goals

- **Git Diff**: Get Git diff since a specific revision
- **Staged Files**: List staged files in Git repository

## Package Status

- **Version**: 0.1.0
- **Stage**: Stable
- **Status**: Production Ready ✅

## Architecture

### High-Level Overview

```
Mind Adapters
    │
    ├──► Git Diff
    └──► Staged Files
```

### Key Components

1. **Git Diff** (`git/diff.ts`): Get Git diff since revision
2. **Staged Files** (`git/staged.ts`): List staged files

## ✨ Features

- **Git Diff**: Get Git diff since a specific revision
- **Staged Files**: List staged files in Git repository

## 📦 API Reference

### Main Exports

#### Git Diff

- `gitDiffSince`: Get Git diff since a specific revision

#### Staged Files

- `listStagedFiles`: List staged files in Git repository

## 🔧 Configuration

### Configuration Options

All configuration via function parameters.

## 🔗 Dependencies

### Runtime Dependencies

- `@kb-labs/mind-core` (`link:../mind-core`): Mind core

### Development Dependencies

- `@kb-labs/devkit` (`link:../../../kb-labs-devkit`): DevKit presets
- `@types/node` (`^24.7.0`): Node.js types
- `tsup` (`^8.5.0`): TypeScript bundler
- `typescript` (`^5.6.3`): TypeScript compiler
- `vitest` (`^3.2.4`): Test runner

## 🧪 Testing

### Test Structure

```
src/__tests__/
└── git.spec.ts
```

### Test Coverage

- **Current Coverage**: ~70%
- **Target Coverage**: 90%

## 📈 Performance

### Performance Characteristics

- **Time Complexity**: O(n) for diff operations, O(n) for staged file listing
- **Space Complexity**: O(n) where n = diff size
- **Bottlenecks**: Large diff processing

## 🔒 Security

### Security Considerations

- **Git Operations**: Secure Git operations
- **Path Validation**: Path validation for file operations

### Known Vulnerabilities

- None

## 🐛 Known Issues & Limitations

### Known Issues

- None currently

### Limitations

- **Git Operations**: Requires Git repository
- **Diff Size**: Performance degrades with very large diffs

### Future Improvements

- **Performance**: Optimize for large diffs
- **More Git Operations**: Additional Git operations

## 🔄 Migration & Breaking Changes

### Migration from Previous Versions

No breaking changes in current version (0.1.0).

### Breaking Changes in Future Versions

- None planned

## 📚 Examples

### Example 1: Get Git Diff

```typescript
import { gitDiffSince } from '@kb-labs/mind-adapters';

const diff = await gitDiffSince({
  cwd: process.cwd(),
  since: 'HEAD~1',
});
```

### Example 2: List Staged Files

```typescript
import { listStagedFiles } from '@kb-labs/mind-adapters';

const files = await listStagedFiles({
  cwd: process.cwd(),
});
```

## 🤝 Contributing

See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development guidelines.

## 📄 License

MIT © KB Labs
npm package: @kb-labs/perm-presets
Description: Composable permission presets for KB Labs plugins
Latest version: 1.4.0

# @kb-labs/perm-presets

> Composable permission presets for KB Labs plugin manifests.

## Installation

```bash
pnpm add @kb-labs/perm-presets
```

Or use via `@kb-labs/sdk` (already bundled):

```typescript
import { minimalPreset, combinePermissions } from '@kb-labs/sdk';
```

## Quick Start

```typescript
import { combine, minimal, llmAccess, gitWorkflow } from '@kb-labs/perm-presets';
import { defineManifest } from '@kb-labs/sdk';

export default defineManifest({
  schema: 'kb.plugin/3',
  id: 'my-plugin',
  version: '1.0.0',
  permissions: combine(minimal, llmAccess, gitWorkflow),
});
```

## Available Presets

| Preset | Description |
|--------|-------------|
| `minimal` | Minimal permissions (read-only workspace) |
| `gitWorkflow` | Git read/write operations |
| `npmPublish` | npm publish permissions |
| `fullEnv` | Full environment variable access |
| `kbPlatform` | KB Labs platform API access |
| `llmAccess` | LLM API access |
| `vectorStore` | Vector store access |
| `ciEnvironment` | CI/CD environment permissions |

## API

### `combine(...presets)`

Merge multiple presets into a single `PermissionSpec`:

```typescript
import { combine, minimal, llmAccess } from '@kb-labs/perm-presets';

const permissions = combine(minimal, llmAccess);
```

### `combinePresets(presets[])`

Same as `combine` but accepts an array:

```typescript
import { combinePresets, presets } from '@kb-labs/perm-presets';

const permissions = combinePresets([presets.minimal, presets.llmAccess]);
```

### `presets` namespace

All presets accessible as a namespace:

```typescript
import { presets, combine } from '@kb-labs/perm-presets';

const permissions = combine(presets.minimal, presets.kbPlatform);
```

## License

MIT