open-index/open-npm huggingface dataset:
npm package: @kb-labs/adapters-analytics-file
Description: File-based analytics adapter for KB Labs platform (writes JSONL to .kb/analytics/buffer)
Latest version: 0.8.0

# @kb-labs/adapters-analytics-file

> Part of [KB Labs](https://github.com/KirillBaranov/kb-labs) ecosystem. Works exclusively within KB Labs platform.

File-based analytics adapter for KB Labs platform. Writes events/metrics as JSONL into `.kb/analytics/buffer`.

## Usage

`kb.config.json`:
```json
"platform": {
  "adapters": {
    "analytics": "@kb-labs/adapters-analytics-file"
  },
  "adapterOptions": {
    "analytics": {
      "baseDir": ".kb/analytics/buffer",
      "filenamePattern": "events-YYYYMMDD"
    }
  }
}
```

Options (all optional):
- `baseDir`: target directory (default `.kb/analytics/buffer` relative to `process.cwd()`).
- `filenamePattern`: filename without extension (`YYYYMMDD` will be replaced by date), default `events-YYYYMMDD`.

Record format: one JSON object per line.

## License

[KB Public License v1.1](../../LICENSE) - KB Labs Team
npm package: @kb-labs/adapters-environment-docker
Description: Docker adapter implementing IEnvironmentProvider
Latest version: 0.8.0

# @kb-labs/adapters-environment-docker

Docker-based implementation of `IEnvironmentProvider` for KB Labs full-cycle runs.

## Features

- Create long-lived environments with `docker run -d`
- Query environment status via `docker inspect`
- Idempotent destroy via `docker rm -f`
- Lease renewal contract for orchestrator integration

## Example config

```json
{
  "adapters": {
    "environment": "@kb-labs/adapters-environment-docker"
  },
  "adapterOptions": {
    "environment": {
      "defaultImage": "node:20-alpine",
      "defaultTtlMs": 3600000,
      "mountWorkspace": true,
      "workspaceMountPath": "/workspace"
    }
  }
}
```
npm package: @kb-labs/adapters-mongodb
Description: MongoDB adapter implementing IDocumentDatabase interface
Latest version: 0.8.0

# @kb-labs/adapters-mongodb

> Part of [KB Labs](https://github.com/KirillBaranov/kb-labs) ecosystem. Works exclusively within KB Labs platform.

MongoDB document database adapter with full aggregation pipeline and index support.

## Overview

| Property | Value |
|----------|-------|
| **Implements** | `IDocumentDatabase` |
| **Type** | `core` |
| **Requires** | None |
| **Category** | Database |

## Features

- **Document Storage** - Flexible JSON-like document storage
- **Aggregation Pipeline** - Complex data transformations
- **Full-Text Search** - Text indexes for search
- **Transactions** - Multi-document ACID transactions
- **Connection Pooling** - Efficient connection management

## Installation

```bash
pnpm add @kb-labs/adapters-mongodb
```

## Configuration

Add to your `kb.config.json`:

```json
{
  "platform": {
    "adapters": {
      "documentDb": "@kb-labs/adapters-mongodb"
    },
    "adapterOptions": {
      "documentDb": {
        "uri": "mongodb://localhost:27017",
        "database": "kb-labs",
        "poolSize": 10
      }
    }
  }
}
```

### Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `uri` | `string` | - | MongoDB connection URI |
| `database` | `string` | - | Database name |
| `poolSize` | `number` | `10` | Connection pool size |

## Usage

### Via Platform (Recommended)

```typescript
import { usePlatform } from '@kb-labs/sdk';

const platform = usePlatform();

// Insert document
await platform.documentDb.insert('users', {
  name: 'John',
  email: 'john@example.com'
});

// Find documents
const users = await platform.documentDb.find('users', {
  name: { $regex: 'John' }
});

// Aggregate
const stats = await platform.documentDb.aggregate('orders', [
  { $group: { _id: '$status', count: { $sum: 1 } } }
]);
```

### Standalone (Testing/Development)

```typescript
import { createAdapter } from '@kb-labs/adapters-mongodb';

const db = createAdapter({
  uri: 'mongodb://localhost:27017',
  database: 'test'
});

await db.connect();
await db.insert('collection', { key: 'value' });
```

## Adapter Manifest

```typescript
{
  id: 'mongodb-documentdb',
  name: 'MongoDB Document Database',
  version: '1.0.0',
  implements: 'IDocumentDatabase',
  capabilities: {
    transactions: true,
    search: true,
    custom: {
      aggregation: true,
      indexes: true,
      fullText: true,
    },
  },
}
```

## FAQ

<details>
<summary><strong>Q: How do I connect to MongoDB Atlas?</strong></summary>

Use the Atlas connection string:

```json
{
  "adapterOptions": {
    "documentDb": {
      "uri": "mongodb+srv://user:pass@cluster.mongodb.net",
      "database": "mydb"
    }
  }
}
```
</details>

## Related Adapters

| Adapter | Use Case |
|---------|----------|
| `@kb-labs/adapters-sqlite` | Embedded SQL database |
| `@kb-labs/adapters-qdrant` | Vector database for semantic search |

## License

[KB Public License v1.1](../../LICENSE) - KB Labs Team
npm package: @kb-labs/adapters-redis
Description: Redis adapter implementing ICache interface
Latest version: 0.8.0

# @kb-labs/adapters-redis

> Part of [KB Labs](https://github.com/KirillBaranov/kb-labs) ecosystem. Works exclusively within KB Labs platform.

High-performance distributed cache adapter using Redis with TTL, patterns, and atomic operations.

## Overview

| Property | Value |
|----------|-------|
| **Implements** | `ICache` |
| **Type** | `core` |
| **Requires** | None |
| **Category** | Cache |

## Features

- **TTL Support** - Automatic key expiration
- **Pattern Operations** - Scan and delete by pattern
- **Atomic Operations** - Increment, decrement, compare-and-set
- **Key Prefixing** - Namespace isolation
- **Connection Pooling** - Efficient connection management

## Installation

```bash
pnpm add @kb-labs/adapters-redis
```

## Configuration

Add to your `kb.config.json`:

```json
{
  "platform": {
    "adapters": {
      "cache": "@kb-labs/adapters-redis"
    },
    "adapterOptions": {
      "cache": {
        "host": "localhost",
        "port": 6379,
        "keyPrefix": "kb:"
      }
    }
  }
}
```

### Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `host` | `string` | `"localhost"` | Redis server host |
| `port` | `number` | `6379` | Redis server port |
| `keyPrefix` | `string` | `"kb:"` | Prefix for all cache keys |
| `password` | `string` | - | Redis password (optional) |

## Usage

### Via Platform (Recommended)

```typescript
import { usePlatform } from '@kb-labs/sdk';

const platform = usePlatform();

// Set with TTL (60 seconds)
await platform.cache.set('user:123', { name: 'John' }, 60000);

// Get
const user = await platform.cache.get<User>('user:123');

// Delete
await platform.cache.delete('user:123');

// Clear all with pattern
await platform.cache.deletePattern('user:*');
```

### Standalone (Testing/Development)

```typescript
import { createAdapter } from '@kb-labs/adapters-redis';

const cache = createAdapter({
  host: 'localhost',
  port: 6379,
  keyPrefix: 'test:'
});

await cache.set('key', 'value', 60000);
const value = await cache.get('key');
```

## Adapter Manifest

```typescript
{
  id: 'redis-cache',
  name: 'Redis Cache',
  version: '1.0.0',
  implements: 'ICache',
  capabilities: {
    custom: {
      ttl: true,
      patterns: true,
      atomic: true,
    },
  },
}
```

## FAQ

<details>
<summary><strong>Q: How do I connect to Redis with authentication?</strong></summary>

Add password to config:

```json
{
  "adapterOptions": {
    "cache": {
      "host": "redis.example.com",
      "port": 6379,
      "password": "your-password"
    }
  }
}
```
</details>

<details>
<summary><strong>Q: How do I use Redis Cluster?</strong></summary>

For cluster mode, use connection string format:

```json
{
  "adapterOptions": {
    "cache": {
      "url": "redis://node1:6379,node2:6379,node3:6379"
    }
  }
}
```
</details>

## Related Adapters

| Adapter | Use Case |
|---------|----------|
| `@kb-labs/adapters-eventbus-cache` | Event bus using cache backend |

## License

[KB Public License v1.1](../../LICENSE) - KB Labs Team
npm package: @kb-labs/adapters-snapshot-localfs
Description: Local filesystem adapter implementing ISnapshotProvider
Latest version: 0.8.0

# @kb-labs/adapters-snapshot-localfs

Local filesystem implementation of `ISnapshotProvider`.

## Features

- Capture snapshot by copying source directory into snapshot store
- Restore snapshot to target directory
- Status/delete/garbage-collect lifecycle
- Can resolve workspace root from workspace registry
npm package: @kb-labs/adapters-workspace-localfs
Description: Local filesystem adapter implementing IWorkspaceProvider
Latest version: 0.8.0

# @kb-labs/adapters-workspace-localfs

Local filesystem implementation of `IWorkspaceProvider`.

## Features

- Materialize workspace from existing path or create dedicated directory
- Attach/release status for environment mount lifecycle
- Workspace registry persisted for integration with snapshot adapters
npm package: @kb-labs/adapters-workspace-worktree
Description: Git worktree adapter implementing IWorkspaceProvider for isolated execution
Latest version: 0.8.0

# @kb-labs/adapters-workspace-localfs

Local filesystem implementation of `IWorkspaceProvider`.

## Features

- Materialize workspace from existing path or create dedicated directory
- Attach/release status for environment mount lifecycle
- Workspace registry persisted for integration with snapshot adapters
npm package: @kb-labs/agent-cli
Description: CLI commands for KB Labs Agents V2. Provides agent:run-v2 command.
Latest version: 0.6.0

# @kb-labs/agent-cli

CLI plugin for the KB Labs agent system. Provides the `agent:run` command and REST/WebSocket handlers for agent execution through the KB Labs platform.

## Surfaces

### CLI

```bash
# Execute a task
pnpm kb agent:run --task="Add input validation to the login form"

# Plan mode (analyze without executing)
pnpm kb agent:run --task="Refactor auth module" --mode=plan

# Edit mode (targeted file changes)
pnpm kb agent:run --task="Fix types in auth.ts" --mode=edit --files=src/auth.ts

# Debug mode (replay a trace)
pnpm kb agent:run --mode=debug --trace=./trace.ndjson

# Dry run
pnpm kb agent:run --task="Add tests" --dry-run
```

### REST API

Handlers registered as KB Labs plugin routes under `/api/v1/agents/*`.

### WebSocket

Real-time streaming of agent events (iterations, tool calls, completions) for Studio UI.

## Flags

| Flag | Type | Description |
|------|------|-------------|
| `--task` | string | Task description in natural language |
| `--mode` | enum | `execute` (default), `plan`, `edit`, `debug` |
| `--session-id` | string | Session ID (auto-generated if omitted) |
| `--complexity` | enum | `simple`, `medium`, `complex` |
| `--files` | string[] | Target files (edit mode) |
| `--trace` | string | Trace file path (debug mode) |
| `--dry-run` | boolean | Preview changes without applying |

## Plugin Manifest

Follows KB Labs V3 plugin manifest format. Exported from `src/manifest.ts` — declares commands, REST routes, WebSocket handlers, and permission requirements.

## Dependencies

- `@kb-labs/agent-core` — agent engine
- `@kb-labs/agent-contracts` — shared types
- `@kb-labs/agent-tools` — tool registry
- `@kb-labs/agent-tracing` — trace loading for debug mode
- `@kb-labs/sdk` — platform SDK
npm package: @kb-labs/agent-contracts
Description: Type definitions and contracts for KB Labs Agents. IDs, Session, Specification, Gates, Multi-Agent types.
Latest version: 0.6.0

# @kb-labs/agent-contracts

Shared type definitions and contracts for the KB Labs agent system. Provides TypeScript interfaces, event schemas, API routes, and Zod validation used by all other `agent-*` packages.

## What's Inside

| Export | Description |
|--------|-------------|
| `types.ts` | Core types — `AgentConfig`, `AgentResult`, `SessionInfo`, `TurnInfo`, execution state |
| `events.ts` | Agent event system — `AgentEvent` union type covering full lifecycle |
| `ws-messages.ts` | WebSocket message contracts for real-time streaming |
| `verification.ts` | Quality gate types — `VerificationResult`, `GateConfig` |
| `turn.ts` | Turn-based interaction models |
| `schemas.ts` | Zod validation schemas for runtime input validation |
| `routes.ts` | API route definitions (`/api/v1/agents/*`) |
| `analytics.ts` | Analytics event type constants |
| `config-types.ts` | Configuration types, `DEFAULT_FILE_HISTORY_CONFIG` |
| `detailed-trace-types.ts` | Detailed trace event types for NDJSON tracing |
| `trace-command-response.ts` | Trace CLI command response types |

## Usage

```typescript
import type { AgentConfig, AgentResult } from '@kb-labs/agent-contracts';
import type { AgentEvent } from '@kb-labs/agent-contracts';
import { AgentRunRequestSchema } from '@kb-labs/agent-contracts';
```

This package has **no runtime dependencies** on other agent packages — it's pure types + Zod schemas. Every other `agent-*` package depends on it.

## Dependencies

- `zod` — runtime schema validation