open-index/open-npm huggingface dataset:
npm package: @orka-js/anthropic
Description: Anthropic adapter for OrkaJS
Author: Orka Team
Latest version: 1.2.1

# @orka-js/anthropic

Anthropic adapter for OrkaJS — Claude 4, Claude 3.5, streaming, and cost tracking.

## Installation

```bash
npm install @orka-js/anthropic
```

## Quick Start

```typescript
import { AnthropicAdapter } from '@orka-js/anthropic'
import { Orka } from '@orka-js/core'

const llm = new AnthropicAdapter({
  apiKey: process.env.ANTHROPIC_API_KEY!,
  model: 'claude-sonnet-4-6',
})

const orka = new Orka({ llm })

const response = await orka.chat([
  { role: 'user', content: 'Hello!' }
])
console.log(response.content)
```

## Streaming

```typescript
const stream = await llm.stream([
  { role: 'user', content: 'Tell me a story' }
])

for await (const chunk of stream) {
  process.stdout.write(chunk.delta ?? '')
}
```

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `apiKey` | `string` | — | Anthropic API key (required) |
| `model` | `string` | `'claude-sonnet-4-6'` | Model to use |
| `temperature` | `number` | `0.7` | Sampling temperature (0–1) |
| `maxTokens` | `number` | `4096` | Max tokens in response |

## Supported Models

| Model | Description |
|-------|-------------|
| `claude-opus-4-6` | Most powerful, best for complex tasks |
| `claude-sonnet-4-6` | Balanced performance and speed |
| `claude-haiku-4-5` | Fastest and most compact |
| `claude-3-5-sonnet-20241022` | Claude 3.5 Sonnet |
| `claude-3-opus-20240229` | Claude 3 Opus |
| `claude-3-haiku-20240307` | Claude 3 Haiku |

## API

### `AnthropicAdapter`

```typescript
const adapter = new AnthropicAdapter(config)

adapter.chat(messages: ChatMessage[])   // Promise<ChatResponse>
adapter.stream(messages: ChatMessage[]) // AsyncIterable<StreamEvent>
```

Implements: `LLMAdapter`, `StreamingLLMAdapter`

## Related Packages

- [`@orka-js/core`](../core) — Core types and `LLMAdapter` interface
- [`@orka-js/openai`](../openai) — OpenAI adapter
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/cache
Description: Caching layer for OrkaJS - Memory, Redis, CachedLLM, CachedEmbeddings
Author: Orka Team
Latest version: 1.0.9

# @orka-js/cache

Caching layer for OrkaJS — reduce LLM costs and latency with in-memory or Redis-backed caching.

## Installation

```bash
npm install @orka-js/cache
```

## Quick Start

```typescript
import { CachedLLM, MemoryCache } from '@orka-js/cache'
import { OpenAIAdapter } from '@orka-js/openai'
import { Orka } from '@orka-js/core'

const llm = new OpenAIAdapter({ apiKey: process.env.OPENAI_API_KEY! })
const cache = new MemoryCache({ ttl: 3600 }) // 1 hour TTL
const cachedLLM = new CachedLLM(llm, cache)

const orka = new Orka({ llm: cachedLLM })

// First call hits the LLM
const r1 = await orka.chat([{ role: 'user', content: 'What is 2+2?' }])
// Second identical call returns cached result instantly
const r2 = await orka.chat([{ role: 'user', content: 'What is 2+2?' }])
```

## Redis Cache

```typescript
import { CachedLLM, RedisCache } from '@orka-js/cache'

const cache = new RedisCache({
  url: process.env.REDIS_URL!,
  ttl: 7200, // 2 hours
})
const cachedLLM = new CachedLLM(llm, cache)
```

## Embedding Cache

```typescript
import { CachedEmbeddings, MemoryCache } from '@orka-js/cache'

const cache = new MemoryCache({ ttl: 86400 }) // 24 hours
const cachedEmbed = new CachedEmbeddings(llm, cache)

// Repeated embed calls for the same text use the cache
const vector = await cachedEmbed.embed('Hello world')
```

## Cache Stats

```typescript
const stats = await cache.stats()
console.log(stats)
// { hits: 42, misses: 8, size: 50, hitRate: 0.84 }
```

## Configuration

### `MemoryCache`

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `ttl` | `number` | `3600` | Time-to-live in seconds |
| `maxSize` | `number` | `1000` | Maximum number of cached entries |

### `RedisCache`

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `url` | `string` | — | Redis connection URL (required) |
| `ttl` | `number` | `3600` | Time-to-live in seconds |

## API

### `MemoryCache` / `RedisCache`

Both implement `CacheStore`:

```typescript
cache.get(key)         // Promise<string | null>
cache.set(key, value)  // Promise<void>
cache.delete(key)      // Promise<void>
cache.clear()          // Promise<void>
cache.stats()          // Promise<CacheStats>
```

### `CachedLLM`

Wraps any `LLMAdapter`, transparently caches `chat()` responses.

### `CachedEmbeddings`

Wraps any `LLMAdapter`, transparently caches `embed()` responses.

## Related Packages

- [`@orka-js/core`](../core) — Core types
- [`@orka-js/resilience`](../resilience) — Retry and fallback patterns
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/chroma
Description: Chroma vector store adapter for OrkaJS
Author: Orka Team
Latest version: 1.0.8

# @orka-js/chroma

ChromaDB adapter for OrkaJS — open-source embedding database for local development.

## Installation

```bash
npm install @orka-js/chroma
```

Start ChromaDB locally with Docker:

```bash
docker run -p 8000:8000 chromadb/chroma
```

## Quick Start

```typescript
import { ChromaAdapter } from '@orka-js/chroma'
import { Orka } from '@orka-js/core'

const vectorDB = new ChromaAdapter({
  url: 'http://localhost:8000',
})

const orka = new Orka({ llm, vectorDB })

await orka.knowledge.ingest([
  { id: 'doc-1', content: 'Hello world' }
])
const results = await orka.knowledge.query('hello', 5)
```

## Direct Usage

```typescript
const adapter = new ChromaAdapter({ url: 'http://localhost:8000' })

await adapter.createCollection('documents', 1536)
await adapter.upsert('documents', [
  { id: 'doc-1', vector: [...], metadata: { text: 'Hello world' } }
])
const results = await adapter.search('documents', queryVector, 5)
await adapter.delete('documents', ['doc-1'])
```

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `url` | `string` | `'http://localhost:8000'` | ChromaDB server URL |
| `collectionName` | `string` | — | Default collection name |

## API

### `ChromaAdapter`

```typescript
adapter.createCollection(name, dimension)         // Promise<void>
adapter.deleteCollection(name)                    // Promise<void>
adapter.upsert(collection, docs)                  // Promise<void>
adapter.search(collection, vector, topK)          // Promise<SearchResult[]>
adapter.delete(collection, ids)                   // Promise<void>
```

Implements: `VectorDBAdapter`

## Related Packages

- [`@orka-js/core`](../core) — `VectorDBAdapter` interface
- [`@orka-js/memory`](../memory) — In-memory adapter (no server required)
- [`@orka-js/pgvector`](../pgvector) — PostgreSQL adapter
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/cohere
Description: Cohere adapter for OrkaJS
Author: Orka AI
Latest version: 1.0.6

# @orka-js/cohere

Cohere adapter for OrkaJS — Command R+, embeddings, and streaming.

## Installation

```bash
npm install @orka-js/cohere
```

## Quick Start

```typescript
import { CohereAdapter } from '@orka-js/cohere'
import { Orka } from '@orka-js/core'

const llm = new CohereAdapter({
  apiKey: process.env.COHERE_API_KEY!,
  model: 'command-r-plus',
})

const orka = new Orka({ llm })

const response = await orka.chat([
  { role: 'user', content: 'Hello!' }
])
console.log(response.content)
```

## Streaming

```typescript
const stream = await llm.stream([
  { role: 'user', content: 'Summarize this document...' }
])

for await (const chunk of stream) {
  process.stdout.write(chunk.delta ?? '')
}
```

## Embeddings

```typescript
const vector = await llm.embed('Hello world')
// Returns: number[]
```

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `apiKey` | `string` | — | Cohere API key (required) |
| `model` | `string` | `'command-r-plus'` | Model to use |
| `temperature` | `number` | `0.7` | Sampling temperature (0–1) |

## Supported Models

| Model | Description |
|-------|-------------|
| `command-r-plus` | Most capable, optimized for RAG |
| `command-r` | Balanced performance |
| `command` | Fast and cost-effective |

## API

### `CohereAdapter`

```typescript
const adapter = new CohereAdapter(config)

adapter.chat(messages: ChatMessage[])   // Promise<ChatResponse>
adapter.stream(messages: ChatMessage[]) // AsyncIterable<StreamEvent>
adapter.embed(text: string)             // Promise<number[]>
```

Implements: `LLMAdapter`, `StreamingLLMAdapter`

## Related Packages

- [`@orka-js/core`](../core) — Core types and `LLMAdapter` interface
- [`@orka-js/openai`](../openai) — OpenAI adapter
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/collector
Description: Trace collector for OrkaJS - re-exports @orka-js/devtools for backward compatibility
Latest version: 1.5.3

# @orka-js/collector

Backward-compatible alias for `@orka-js/devtools` — trace collection for OrkaJS agents.

> **Note:** This package re-exports everything from [`@orka-js/devtools`](../devtools). For new projects, import from `@orka-js/devtools` directly. `@orka-js/collector` will continue to work but the `collector` function alias is deprecated and will be removed in v4.0.

## Installation

```bash
npm install @orka-js/collector
```

## Quick Start

```typescript
import { devtools, trace, withTrace, Trace } from '@orka-js/collector';

// Start the local dashboard
const { tracer, stop } = await devtools({ source: 'local', port: 3001 });

// Trace any async work
const runId = trace.start('agent', 'my-agent', { query: 'Hello' });
const result = await myAgent.run('Hello');
trace.end(runId, result);

await stop();
```

The `collector` export is also available as a direct alias for `devtools`:

```typescript
import { collector } from '@orka-js/collector';

// Identical to calling devtools()
const { tracer, stop } = await collector({ source: 'local' });
```

## API

All exports are re-exported from `@orka-js/devtools`. Refer to the [`@orka-js/devtools` README](../devtools/README.md) for the complete API reference, including:

- `devtools(config?)` — start DevTools (local dashboard or remote agent/viewer)
- `collector` — alias for `devtools` *(deprecated, use `devtools` instead)*
- `trace` — manual tracing helpers (`trace.start`, `trace.end`, `trace.error`, `trace.session`, `trace.wrap`)
- `withTrace(fn, options?)` — wrap a function with automatic tracing
- `@Trace(options?)` — decorator for class methods
- `TraceCollector`, `getCollector()`, `resetCollector()` — low-level collector
- `createDevToolsHook()`, `createTracerWithDevTools()` — observability integration
- `OpenTelemetryExporter`, `createOTLPExporter()` — OTLP export
- `ReplayDebugger`, `createReplayDebugger()` — trace replay and comparison
- `DevToolsServer`, `RemoteAgent`, `RemoteViewer` — server components

## Migrating to `@orka-js/devtools`

Replace the import and remove the `collector` alias:

```diff
- import { collector, trace } from '@orka-js/collector';
- const { tracer, stop } = await collector({ source: 'local' });
+ import { devtools, trace } from '@orka-js/devtools';
+ const { tracer, stop } = await devtools({ source: 'local' });
```

Everything else — `trace`, `withTrace`, `@Trace`, `TraceCollector`, etc. — is identical between the two packages.

## Related Packages

- [`@orka-js/devtools`](../devtools) — The package this is an alias for (prefer this for new projects)
- [`@orka-js/core`](../core) — Core types
- [`@orka-js/observability`](../observability) — `Tracer` and hooks
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/core
Description: Core types, interfaces and classes for OrkaJS - TypeScript LLM framework
Author: Orka Team
Latest version: 1.5.1

# @orka-js/core

Core types, interfaces, and utilities for the OrkaJS ecosystem — the foundation every package builds on.

## Installation

```bash
npm install @orka-js/core
```

## Quick Start

```typescript
import { Orka, createOrka } from '@orka-js/core'
import { OpenAIAdapter } from '@orka-js/openai'

const orka = createOrka({
  llm: new OpenAIAdapter({ apiKey: process.env.OPENAI_API_KEY! }),
})

const response = await orka.chat([
  { role: 'user', content: 'Hello!' }
])
console.log(response.content)
```

## RAG with Knowledge

```typescript
import { Orka, Knowledge } from '@orka-js/core'

const knowledge = new Knowledge({ orka })

await knowledge.ingest([
  { id: 'doc-1', content: 'OrkaJS is a TypeScript AI framework.' }
])

const results = await knowledge.query('What is OrkaJS?', 3)
```

## PII Guard (RGPD)

```typescript
import { PIIGuard, detectPII, redactPII } from '@orka-js/core'

const guard = new PIIGuard()
const detected = guard.detect('My email is john@example.com')
// [{ type: 'email', value: 'john@example.com', start: 12, end: 28 }]

const safe = redactPII('Call me at +1-555-1234')
// 'Call me at [PHONE]'
```

## Streaming

```typescript
import { consumeStream, parseSSEStream } from '@orka-js/core'

const stream = await llm.stream(messages)
const full = await consumeStream(stream)

// SSE from HTTP response
const events = parseSSEStream(response.body!)
for await (const event of events) {
  console.log(event)
}
```

## Callbacks

```typescript
import { CallbackManager } from '@orka-js/core'

const callbacks = new CallbackManager({
  onStart: (run) => console.log('Started', run.id),
  onEnd: (run) => console.log('Done in', run.duration, 'ms'),
  onError: (run, err) => console.error('Error', err),
  onToken: (token) => process.stdout.write(token),
})
```

## Key Exports

| Export | Description |
|--------|-------------|
| `Orka` | Main entry point class |
| `createOrka(config)` | Factory function |
| `Knowledge` | Document ingestion and RAG |
| `LLMAdapter` | Interface for custom LLM adapters |
| `VectorDBAdapter` | Interface for custom vector DB adapters |
| `PIIGuard` | PII detection and redaction |
| `detectPII(text)` | Standalone PII detection |
| `redactPII(text)` | Standalone PII redaction |
| `CallbackManager` | Lifecycle hooks |
| `consumeStream(stream)` | Collect full stream output |
| `parseSSEStream(body)` | Parse SSE streams |
| `chunkDocument(doc, opts)` | Split documents into chunks |
| `generateId()` | Generate unique IDs |
| `OrkaError`, `OrkaErrorCode` | Typed error classes |

## Related Packages

- [`orkajs`](../orkajs) — Full bundle with all adapters
- [`@orka-js/openai`](../openai) — OpenAI adapter
- [`@orka-js/anthropic`](../anthropic) — Anthropic adapter
- [`@orka-js/agent`](../agent) — Agent system
npm package: @orka-js/durable
Description: Durable, resumable, and scheduled agents for OrkaJS
Author: OrkaJS Team
Latest version: 1.0.1

# @orka-js/durable

Durable, resumable, and scheduled agents for OrkaJS — checkpoint persistence, retry, and cron scheduling.

## Installation

```bash
npm install @orka-js/durable @orka-js/core
```

## Quick Start

```typescript
import { DurableAgent, MemoryDurableStore } from '@orka-js/durable'
import { ReActAgent } from '@orka-js/agent'

const store = new MemoryDurableStore()
const agent = new ReActAgent({ orka, tools })
const durable = new DurableAgent(agent, store)

// Start a job — returns a jobId
const { jobId } = await durable.run('Analyze the quarterly report')
console.log('Job:', jobId)

// Check job status
const job = await durable.getJob(jobId)
console.log(job.status) // 'completed', 'running', 'paused', 'failed'
console.log(job.output)
```

## Pause and Resume

```typescript
// Pause a running job
await durable.pause(jobId)

// Resume it later (picks up from last checkpoint)
await durable.resume(jobId)
```

## Redis Store (Production)

```typescript
import { DurableAgent, RedisDurableStore } from '@orka-js/durable'

const store = new RedisDurableStore({
  url: process.env.REDIS_URL!,
})

const durable = new DurableAgent(agent, store, {
  retryOnFailure: true,
  maxRetries: 3,
})
```

## Cron Scheduling

```typescript
const durable = new DurableAgent(agent, store, {
  schedule: '0 9 * * *', // every day at 9am
})

// Start the scheduled job
await durable.startSchedule('Generate daily report')
```

## List All Jobs

```typescript
const jobs = await durable.listJobs()
jobs.forEach(job => {
  console.log(`${job.id}: ${job.status} — ${job.createdAt}`)
})
```

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `retryOnFailure` | `boolean` | `false` | Auto-retry failed jobs |
| `maxRetries` | `number` | `3` | Maximum retry attempts |
| `schedule` | `string` | — | Cron expression for scheduling |

## Job Status

| Status | Description |
|--------|-------------|
| `pending` | Queued, not started |
| `running` | Currently executing |
| `paused` | Manually paused |
| `completed` | Finished successfully |
| `failed` | Encountered an error |

## Related Packages

- [`@orka-js/agent`](../agent) — Agent implementations
- [`@orka-js/core`](../core) — Core types
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/express
Description: Express.js middleware for OrkaJS agents — expose agents as HTTP endpoints with SSE streaming
Author: OrkaJS Team
Latest version: 1.0.1

# @orka-js/express

Express.js middleware for OrkaJS — serve agents as REST APIs with SSE streaming in minutes.

## Installation

```bash
npm install @orka-js/express @orka-js/core express
```

## Quick Start

```typescript
import express from 'express'
import { orkaMiddleware } from '@orka-js/express'
import { Orka } from '@orka-js/core'
import { OpenAIAdapter } from '@orka-js/openai'
import { ReActAgent } from '@orka-js/agent'

const app = express()
app.use(express.json())

const orka = new Orka({
  llm: new OpenAIAdapter({ apiKey: process.env.OPENAI_API_KEY! }),
})

const agent = new ReActAgent({ orka, tools: [] })

app.use(orkaMiddleware({
  orka,
  agents: [{ name: 'assistant', agent }],
  prefix: '/ai', // default
}))

app.listen(3000)
```

## Auto-generated Routes

| Route | Description |
|-------|-------------|
| `GET /ai` | List all registered agents |
| `GET /ai/:name` | Get agent info |
| `POST /ai/:name` | Run agent, returns JSON |
| `POST /ai/:name/stream` | Run agent with SSE streaming |

## Calling the API

```bash
# Standard request
curl -X POST http://localhost:3000/ai/assistant \
  -H "Content-Type: application/json" \
  -d '{"input": "What is the weather in Paris?"}'

# Streaming (Server-Sent Events)
curl -X POST http://localhost:3000/ai/assistant/stream \
  -H "Content-Type: application/json" \
  -d '{"input": "Tell me a story"}'
```

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `orka` | `Orka` | — | OrkaJS instance (required) |
| `agents` | `AgentConfig[]` | — | Agents to expose (required) |
| `prefix` | `string` | `'/ai'` | URL prefix for all routes |

## Types

```typescript
interface AgentRunRequest {
  input: string
  context?: Record<string, unknown>
}

interface AgentRunResponse {
  output: string
  tokens?: number
  duration?: number
}
```

## Related Packages

- [`@orka-js/core`](../core) — Core types
- [`@orka-js/agent`](../agent) — Agent implementations
- [`@orka-js/hono`](../hono) — Edge-compatible alternative
- [`@orka-js/nestjs`](../nestjs) — NestJS integration
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/google
Description: Google AI (Gemini) adapter for OrkaJS
Author: Orka AI
Latest version: 1.0.6

# @orka-js/google

Google Gemini adapter for OrkaJS — Gemini 1.5 Pro/Flash, embeddings, and streaming.

## Installation

```bash
npm install @orka-js/google
```

## Quick Start

```typescript
import { GoogleAdapter } from '@orka-js/google'
import { Orka } from '@orka-js/core'

const llm = new GoogleAdapter({
  apiKey: process.env.GOOGLE_API_KEY!,
  model: 'gemini-1.5-pro',
})

const orka = new Orka({ llm })

const response = await orka.chat([
  { role: 'user', content: 'Hello!' }
])
console.log(response.content)
```

## Streaming

```typescript
const stream = await llm.stream([
  { role: 'user', content: 'Explain neural networks' }
])

for await (const chunk of stream) {
  process.stdout.write(chunk.delta ?? '')
}
```

## Embeddings

```typescript
const vector = await llm.embed('Hello world')
// Returns: number[]
```

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `apiKey` | `string` | — | Google AI API key (required) |
| `model` | `string` | `'gemini-1.5-flash'` | Model to use |
| `temperature` | `number` | `0.7` | Sampling temperature (0–1) |
| `maxTokens` | `number` | — | Max tokens in response |

## Supported Models

| Model | Description |
|-------|-------------|
| `gemini-1.5-pro` | Most capable, 1M context window |
| `gemini-1.5-flash` | Fast and efficient |

**Embeddings:** `text-embedding-004`

## API

### `GoogleAdapter`

```typescript
const adapter = new GoogleAdapter(config)

adapter.chat(messages: ChatMessage[])   // Promise<ChatResponse>
adapter.stream(messages: ChatMessage[]) // AsyncIterable<StreamEvent>
adapter.embed(text: string)             // Promise<number[]>
```

Implements: `LLMAdapter`, `StreamingLLMAdapter`

## Related Packages

- [`@orka-js/core`](../core) — Core types and `LLMAdapter` interface
- [`@orka-js/openai`](../openai) — OpenAI adapter
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/graph
Description: Graph-based workflows for OrkaJS - nodes, edges, conditions, parallel
Author: Orka Team
Latest version: 1.4.1

# @orka-js/graph

Graph-based workflow engine for OrkaJS — conditional branching, parallel execution, and LangGraph-compatible state graphs.

## Installation

```bash
npm install @orka-js/graph @orka-js/core
```

## Quick Start

```typescript
import { GraphWorkflow, actionNode, conditionNode, edge, startNode, endNode } from '@orka-js/graph'
import { Orka } from '@orka-js/core'

const orka = new Orka({ llm })

const workflow = new GraphWorkflow({
  orka,
  nodes: [
    startNode(),
    actionNode('classify', async (ctx) => {
      const category = await classify(ctx.input)
      return { ...ctx, category }
    }),
    conditionNode('route', (ctx) => ctx.category === 'technical' ? 'tech' : 'general'),
    actionNode('tech', async (ctx) => ({ ...ctx, output: await techAgent.run(ctx.input) })),
    actionNode('general', async (ctx) => ({ ...ctx, output: await generalAgent.run(ctx.input) })),
    endNode(),
  ],
  edges: [
    edge('start', 'classify'),
    edge('classify', 'route'),
    edge('route', 'tech'),
    edge('route', 'general'),
    edge('tech', 'end'),
    edge('general', 'end'),
  ],
})

const result = await workflow.run('How do I set up a Redis cache?')
```

## Parallel Execution

```typescript
import { parallelNode } from '@orka-js/graph'

parallelNode('fetch-all', [
  actionNode('fetch-web', webSearchNode),
  actionNode('fetch-db', databaseNode),
  actionNode('fetch-cache', cacheNode),
])
```

## LangGraph-Compatible State Graph

```typescript
import { StateGraph, MemoryCheckpointStore } from '@orka-js/graph'

const graph = new StateGraph({
  channels: { messages: { value: (a, b) => a.concat(b) } },
  checkpointStore: new MemoryCheckpointStore(),
})

graph.addNode('agent', agentNode)
graph.addNode('tools', toolNode)
graph.addEdge('agent', 'tools')
graph.setEntryPoint('agent')

const result = await graph.invoke({ messages: [userMessage] })
```

## Checkpoint Stores

| Store | Description |
|-------|-------------|
| `MemoryCheckpointStore` | In-memory (dev/testing) |
| `PostgresCheckpointStore` | PostgreSQL-backed persistence |
| `RedisCheckpointStore` | Redis-backed persistence |

## Node Helpers

| Helper | Description |
|--------|-------------|
| `startNode()` | Entry point |
| `endNode()` | Exit point |
| `actionNode(name, fn)` | Execute an async function |
| `conditionNode(name, fn)` | Branch based on condition |
| `parallelNode(name, nodes)` | Run nodes in parallel |
| `llmNode(name, config)` | LLM call node |
| `retrieveNode(name, config)` | Vector retrieval node |

## Related Packages

- [`@orka-js/workflow`](../workflow) — Sequential multi-step workflows
- [`@orka-js/agent`](../agent) — Agent implementations
- [`@orka-js/core`](../core) — Core types
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/hono
Description: Hono middleware for OrkaJS agents — edge-compatible AI agent HTTP endpoints
Author: OrkaJS Team
Latest version: 1.0.2

# @orka-js/hono

Hono middleware for OrkaJS agents — edge-compatible (Cloudflare Workers, Deno, Bun, Node.js).

## Installation

```bash
npm install @orka-js/hono @orka-js/core hono
```

## Quick Start

```typescript
import { Hono } from 'hono'
import { orkaHono } from '@orka-js/hono'
import { Orka } from '@orka-js/core'
import { OpenAIAdapter } from '@orka-js/openai'
import { ReActAgent } from '@orka-js/agent'

const orka = new Orka({
  llm: new OpenAIAdapter({ apiKey: process.env.OPENAI_API_KEY! }),
})

const agent = new ReActAgent({ orka, tools: [] })

const app = new Hono()
app.route('/ai', orkaHono({
  orka,
  agents: [{ name: 'assistant', agent }],
}))

export default app
```

## Cloudflare Workers

```typescript
// src/index.ts
import { Hono } from 'hono'
import { orkaHono } from '@orka-js/hono'

const app = new Hono<{ Bindings: Env }>()

app.route('/ai', orkaHono({
  orka: (c) => new Orka({ llm: new OpenAIAdapter({ apiKey: c.env.OPENAI_API_KEY }) }),
  agents: [{ name: 'assistant', agent: myAgent }],
}))

export default app
```

## Auto-generated Routes

| Route | Description |
|-------|-------------|
| `GET /ai` | List all registered agents |
| `GET /ai/:name` | Get agent info |
| `POST /ai/:name` | Run agent, returns JSON |
| `POST /ai/:name/stream` | Run agent with SSE streaming |

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `orka` | `Orka` | — | OrkaJS instance (required) |
| `agents` | `AgentConfig[]` | — | Agents to expose (required) |
| `prefix` | `string` | `'/ai'` | URL prefix for routes |

## Related Packages

- [`@orka-js/core`](../core) — Core types
- [`@orka-js/agent`](../agent) — Agent implementations
- [`@orka-js/express`](../express) — Express.js alternative
- [`@orka-js/nestjs`](../nestjs) — NestJS integration
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/memory
Description: In-memory vector store adapter for OrkaJS
Author: Orka Team
Latest version: 1.0.8

# @orka-js/memory

In-memory vector database adapter for OrkaJS — ideal for development, testing, and small datasets.

## Installation

```bash
npm install @orka-js/memory
```

## Quick Start

```typescript
import { MemoryVectorAdapter } from '@orka-js/memory'
import { Orka } from '@orka-js/core'

const vectorDB = new MemoryVectorAdapter()

const orka = new Orka({ llm, vectorDB })

await orka.knowledge.ingest([
  { id: 'doc-1', content: 'Hello world' },
  { id: 'doc-2', content: 'Goodbye world' },
])

const results = await orka.knowledge.query('hello', 2)
```

## Direct Usage

```typescript
const adapter = new MemoryVectorAdapter({ similarity: 'cosine' })

await adapter.createCollection('docs', 3)
await adapter.upsert('docs', [
  { id: '1', vector: [0.1, 0.2, 0.3], metadata: { text: 'foo' } },
  { id: '2', vector: [0.4, 0.5, 0.6], metadata: { text: 'bar' } },
])

const results = await adapter.search('docs', [0.1, 0.2, 0.3], 1)
const stats = await adapter.getCollectionStats('docs')
// { count: 2, dimension: 3 }
```

> **Note:** Data is stored in process memory only and is not persisted across restarts.

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `similarity` | `'cosine' \| 'euclidean' \| 'dotProduct'` | `'cosine'` | Similarity metric for vector search |

## API

### `MemoryVectorAdapter`

Also exported as `MemoryVectorDBAdapter` (alias).

```typescript
adapter.createCollection(name, dimension)     // Promise<void>
adapter.upsert(collection, docs)              // Promise<void>
adapter.search(collection, vector, topK)      // Promise<SearchResult[]>
adapter.delete(collection, ids)               // Promise<void>
adapter.getCollectionStats(name)              // Promise<{ count, dimension }>
```

Implements: `VectorDBAdapter`

## Related Packages

- [`@orka-js/core`](../core) — `VectorDBAdapter` interface
- [`@orka-js/qdrant`](../qdrant) — Qdrant for production use
- [`@orka-js/pgvector`](../pgvector) — PostgreSQL adapter
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/mistral
Description: Mistral adapter for OrkaJS
Author: Orka Team
Latest version: 1.1.6

# @orka-js/mistral

Mistral AI adapter for OrkaJS — Mistral Large, Codestral, embeddings, and streaming.

## Installation

```bash
npm install @orka-js/mistral
```

## Quick Start

```typescript
import { MistralAdapter } from '@orka-js/mistral'
import { Orka } from '@orka-js/core'

const llm = new MistralAdapter({
  apiKey: process.env.MISTRAL_API_KEY!,
  model: 'mistral-large-latest',
})

const orka = new Orka({ llm })

const response = await orka.chat([
  { role: 'user', content: 'Hello!' }
])
console.log(response.content)
```

## Streaming

```typescript
const stream = await llm.stream([
  { role: 'user', content: 'Explain quantum computing' }
])

for await (const chunk of stream) {
  process.stdout.write(chunk.delta ?? '')
}
```

## Embeddings

```typescript
const vector = await llm.embed('Hello world')
// Returns: number[]
```

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `apiKey` | `string` | — | Mistral API key (required) |
| `model` | `string` | `'mistral-large-latest'` | Model to use |
| `temperature` | `number` | `0.7` | Sampling temperature |
| `maxTokens` | `number` | — | Max tokens in response |

## Supported Models

| Model | Description |
|-------|-------------|
| `mistral-large-latest` | Most powerful Mistral model |
| `mistral-medium` | Balanced performance |
| `mistral-small` | Fast and cost-effective |
| `open-mistral-7b` | Open-source 7B model |
| `open-mixtral-8x7b` | Mixture-of-experts model |
| `codestral` | Code-specialized model |

**Embeddings:** `mistral-embed`

## API

### `MistralAdapter`

```typescript
const adapter = new MistralAdapter(config)

adapter.chat(messages: ChatMessage[])   // Promise<ChatResponse>
adapter.stream(messages: ChatMessage[]) // AsyncIterable<StreamEvent>
adapter.embed(text: string)             // Promise<number[]>
```

Implements: `LLMAdapter`, `StreamingLLMAdapter`

## Related Packages

- [`@orka-js/core`](../core) — Core types and `LLMAdapter` interface
- [`@orka-js/openai`](../openai) — OpenAI adapter
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/nestjs
Description: NestJS integration for OrkaJS agents — DI, modules, SSE streaming, guards, pipes, CQRS, microservices
Author: OrkaJS Team
Latest version: 2.0.2

# @orka-js/nestjs

Native NestJS integration for OrkaJS — DI, decorators, guards, CQRS, and microservices support.

## Installation

```bash
npm install @orka-js/nestjs @orka-js/core
```

## Quick Start

```typescript
// app.module.ts
import { OrkaModule } from '@orka-js/nestjs'
import { OpenAIAdapter } from '@orka-js/openai'

@Module({
  imports: [
    OrkaModule.forRoot({
      llm: new OpenAIAdapter({ apiKey: process.env.OPENAI_API_KEY! }),
    }),
  ],
})
export class AppModule {}
```

## Registering Agents

```typescript
import { Injectable } from '@nestjs/common'
import { OrkaAgent, InjectAgent } from '@orka-js/nestjs'
import { ReActAgent } from '@orka-js/agent'

@OrkaAgent('support', {
  systemPrompt: 'You are a helpful support agent.',
  tools: [myTool],
})
@Injectable()
export class SupportAgentService {
  constructor(@InjectAgent('support') private readonly agent: ReActAgent) {}

  async answer(question: string) {
    return this.agent.run(question)
  }
}
```

## Auto-generated REST Controller

```typescript
import { createOrkaController } from '@orka-js/nestjs'

// Generates GET /agents/support, POST /agents/support, POST /agents/support/stream
@Controller('agents')
export class AgentController extends createOrkaController('support') {}
```

## Semantic Guard

```typescript
import { OrkaSemanticGuard } from '@orka-js/nestjs'
import { UseGuards } from '@nestjs/common'

@UseGuards(OrkaSemanticGuard({ policy: 'Only allow questions about our products' }))
@Post('ask')
async ask(@Body() dto: AskDto) { /* ... */ }
```

## Async Configuration

```typescript
OrkaModule.forRootAsync({
  imports: [ConfigModule],
  useFactory: (config: ConfigService) => ({
    llm: new OpenAIAdapter({ apiKey: config.get('OPENAI_API_KEY') }),
  }),
  inject: [ConfigService],
})
```

## CQRS Support

```typescript
import { OrkaQueryHandler, AgentQueryHandler } from '@orka-js/nestjs'

@AgentQueryHandler(SearchQuery, 'search-agent')
export class SearchQueryHandler extends OrkaQueryHandler<SearchQuery> {
  async execute(query: SearchQuery) {
    return this.agent.run(query.term)
  }
}
```

## Key Exports

| Export | Description |
|--------|-------------|
| `OrkaModule` | NestJS dynamic module |
| `@OrkaAgent(name, config)` | Register an agent |
| `@InjectAgent(name)` | Inject an agent |
| `@InjectAgentClient(name)` | Inject a remote agent client |
| `OrkaSemanticGuard` | LLM-powered HTTP guard |
| `AgentValidationPipe` | NLP → DTO transformation |
| `createOrkaController(name)` | Auto-generate REST controller |
| `OrkaQueryHandler` / `OrkaCommandHandler` | CQRS handlers |
| `AgentClient`, `OrkaClientModule` | Microservice client |

## Related Packages

- [`@orka-js/core`](../core) — Core types
- [`@orka-js/agent`](../agent) — Agent implementations
- [`@orka-js/express`](../express) — Express middleware
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/observability
Description: Observability for OrkaJS - tracing, logging, hooks
Author: Orka Team
Latest version: 1.0.9

# @orka-js/observability

Lightweight observability and tracing utilities for OrkaJS agents.

## Installation

```bash
npm install @orka-js/observability
```

## Quick Start

```typescript
import { Tracer } from '@orka-js/observability'
import { Orka } from '@orka-js/core'

const tracer = new Tracer({
  onEvent: (event) => {
    console.log(`[${event.type}] ${event.name}`, event.data)
  },
})

const orka = new Orka({
  llm,
  callbacks: {
    onStart: (run) => tracer.start(run),
    onEnd: (run) => tracer.end(run),
    onError: (run, err) => tracer.error(run, err),
    onToken: (token) => tracer.token(token),
  },
})
```

## Log Levels

```typescript
import { Tracer, LogLevel } from '@orka-js/observability'

const tracer = new Tracer({
  level: LogLevel.DEBUG,
  onEvent: (event) => {
    if (event.level >= LogLevel.WARN) {
      alertingService.send(event)
    }
  },
})
```

## Trace Hooks

```typescript
import { ObservabilityHook } from '@orka-js/observability'

const hook: ObservabilityHook = {
  onStart: (trace) => { /* ... */ },
  onEnd: (trace) => { /* ... */ },
  onError: (trace, error) => { /* ... */ },
  onToken: (token, traceId) => { /* ... */ },
  onToolCall: (tool, args, traceId) => { /* ... */ },
}
```

## API

### `Tracer`

```typescript
new Tracer({ onEvent?, level? })

tracer.start(run)           // Begin trace
tracer.end(run)             // End trace
tracer.error(run, err)      // Record error
tracer.token(token)         // Record token
```

### Types

| Type | Description |
|------|-------------|
| `Trace` | Full trace object with id, name, events, duration |
| `TraceEvent` | Individual event within a trace |
| `ObservabilityHook` | Hook interface for trace lifecycle |
| `LogLevel` | `DEBUG \| INFO \| WARN \| ERROR` |

## Related Packages

- [`@orka-js/core`](../core) — `CallbackManager` for lifecycle hooks
- [`@orka-js/otel`](../otel) — OpenTelemetry exporter
- [`@orka-js/devtools`](../devtools) — Full DevTools UI
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/ollama
Description: Ollama adapter for OrkaJS
Author: Orka Team
Latest version: 1.1.6

# @orka-js/ollama

Ollama adapter for OrkaJS — run local models (Llama 3, Mistral, etc.) with zero API costs and full privacy.

## Installation

```bash
npm install @orka-js/ollama
```

Requires [Ollama](https://ollama.com) running locally:

```bash
# Install and start Ollama
ollama serve
ollama pull llama3.2
```

## Quick Start

```typescript
import { OllamaAdapter } from '@orka-js/ollama'
import { Orka } from '@orka-js/core'

const llm = new OllamaAdapter({
  model: 'llama3.2',
  // baseUrl defaults to http://localhost:11434
})

const orka = new Orka({ llm })

const response = await orka.chat([
  { role: 'user', content: 'Hello!' }
])
console.log(response.content)
```

## Streaming

```typescript
const stream = await llm.stream([
  { role: 'user', content: 'Write a poem about the sea' }
])

for await (const chunk of stream) {
  process.stdout.write(chunk.delta ?? '')
}
```

## Embeddings

```typescript
// Requires a model with embedding support (e.g. nomic-embed-text)
const vector = await llm.embed('Hello world')
```

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `model` | `string` | `'llama3.2'` | Local model name |
| `baseUrl` | `string` | `'http://localhost:11434'` | Ollama server URL |
| `temperature` | `number` | `0.7` | Sampling temperature |
| `maxTokens` | `number` | — | Max tokens in response |

## Popular Models

```bash
ollama pull llama3.2        # Meta Llama 3.2
ollama pull mistral         # Mistral 7B
ollama pull codellama       # Code-specialized Llama
ollama pull nomic-embed-text # Embeddings model
```

## API

### `OllamaAdapter`

```typescript
const adapter = new OllamaAdapter(config)

adapter.chat(messages: ChatMessage[])   // Promise<ChatResponse>
adapter.stream(messages: ChatMessage[]) // AsyncIterable<StreamEvent>
adapter.embed(text: string)             // Promise<number[]>
```

Implements: `LLMAdapter`, `StreamingLLMAdapter`

> **Cost:** $0 — all computation runs locally.

## Related Packages

- [`@orka-js/core`](../core) — Core types and `LLMAdapter` interface
- [`@orka-js/openai`](../openai) — OpenAI adapter
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/openai
Description: OpenAI adapter for OrkaJS
Author: Orka Team
Latest version: 1.3.1

# @orka-js/openai

OpenAI adapter for OrkaJS — GPT-4o, GPT-4 Turbo, o1, o3-mini, embeddings, Whisper transcription, and TTS.

## Installation

```bash
npm install @orka-js/openai
```

## Quick Start

```typescript
import { OpenAIAdapter } from '@orka-js/openai'
import { Orka } from '@orka-js/core'

const llm = new OpenAIAdapter({
  apiKey: process.env.OPENAI_API_KEY!,
  model: 'gpt-4o',
})

const orka = new Orka({ llm })

const response = await orka.chat([
  { role: 'user', content: 'Hello!' }
])
console.log(response.content)
```

## Streaming

```typescript
const stream = await llm.stream([
  { role: 'user', content: 'Tell me a story' }
])

for await (const chunk of stream) {
  process.stdout.write(chunk.delta ?? '')
}
```

## Embeddings

```typescript
const vector = await llm.embed('Hello world')
// Returns: number[]
```

## Audio

```typescript
import { OpenAIAdapter } from '@orka-js/openai'

const llm = new OpenAIAdapter({ apiKey: process.env.OPENAI_API_KEY! })

// Speech-to-text (Whisper)
const transcript = await llm.transcribe(audioBuffer, { language: 'en' })
console.log(transcript.text)

// Text-to-speech
const audio = await llm.textToSpeech('Hello world', { voice: 'alloy' })
```

## Configuration

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `apiKey` | `string` | — | OpenAI API key (required) |
| `model` | `string` | `'gpt-4o'` | Chat model |
| `temperature` | `number` | `0.7` | Sampling temperature (0–2) |
| `maxTokens` | `number` | — | Max tokens in response |
| `baseURL` | `string` | — | Custom API base URL |

## Supported Models

| Model | Description |
|-------|-------------|
| `gpt-4o` | Most capable, multimodal |
| `gpt-4o-mini` | Fast and affordable |
| `gpt-4-turbo` | GPT-4 with 128k context |
| `gpt-3.5-turbo` | Cost-effective |
| `o1` | Advanced reasoning |
| `o1-mini` | Compact reasoning |
| `o3-mini` | Latest reasoning model |

**Embeddings:** `text-embedding-3-small`, `text-embedding-3-large`

## API

### `OpenAIAdapter`

```typescript
const adapter = new OpenAIAdapter(config)

adapter.chat(messages: ChatMessage[])     // Promise<ChatResponse>
adapter.stream(messages: ChatMessage[])   // AsyncIterable<StreamEvent>
adapter.embed(text: string)               // Promise<number[]>
adapter.transcribe(audio, options?)       // Promise<TranscriptionResult>
adapter.textToSpeech(text, options?)      // Promise<Buffer>
```

Implements: `LLMAdapter`, `StreamingLLMAdapter`, `AudioAdapter`

## Related Packages

- [`@orka-js/core`](../core) — Core types and `LLMAdapter` interface
- [`@orka-js/anthropic`](../anthropic) — Anthropic / Claude adapter
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/orchestration
Description: Multi-model orchestration for OrkaJS - router, consensus, race, load-balancer
Author: Orka Team
Latest version: 1.1.1

# @orka-js/orchestration

Multi-model orchestration for OrkaJS — routing, consensus, racing, and load balancing across LLMs.

## Installation

```bash
npm install @orka-js/orchestration @orka-js/core
```

## Router — Route to the Right Model

```typescript
import { RouterLLM } from '@orka-js/orchestration'

const router = new RouterLLM({
  routes: [
    {
      condition: (messages) => messages.some(m => m.content.includes('code')),
      llm: new OpenAIAdapter({ model: 'gpt-4o' }),
    },
    {
      condition: (messages) => messages[0].content.length > 2000,
      llm: new AnthropicAdapter({ model: 'claude-sonnet-4-6' }),
    },
  ],
  defaultLLM: new OpenAIAdapter({ model: 'gpt-4o-mini' }),
})

const response = await router.chat(messages)
```

## Consensus — Aggregate Multiple Models

```typescript
import { ConsensusLLM } from '@orka-js/orchestration'

const consensus = new ConsensusLLM({
  llms: [openai, anthropic, mistral],
  strategy: 'majority', // or 'best'
})

// Queries all 3 models, returns majority answer
const response = await consensus.chat(messages)
```

## Race — Use the Fastest Response

```typescript
import { RaceLLM } from '@orka-js/orchestration'

const race = new RaceLLM({
  llms: [openai, anthropic, ollama],
})

// Returns the first response that arrives
const response = await race.chat(messages)
```

## Load Balancer — Distribute Requests

```typescript
import { LoadBalancerLLM } from '@orka-js/orchestration'

const lb = new LoadBalancerLLM({
  llms: [openai1, openai2, openai3],
  strategy: 'round-robin', // or 'random'
})

// Distributes calls evenly across instances
const response = await lb.chat(messages)
```

## API

All classes implement `LLMAdapter` and can be used anywhere an LLM is expected:

```typescript
router.chat(messages)    // Promise<ChatResponse>
router.stream(messages)  // AsyncIterable<StreamEvent>
```

## Related Packages

- [`@orka-js/resilience`](../resilience) — Retry and fallback patterns
- [`@orka-js/cache`](../cache) — LLM response caching
- [`@orka-js/core`](../core) — `LLMAdapter` interface
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/otel
Description: OpenTelemetry integration for OrkaJS — OTLP exporter + W3C TraceContext propagation
Author: Orka Team
Latest version: 0.2.1

# @orka-js/otel

OpenTelemetry exporter for OrkaJS — send agent traces to Jaeger, Tempo, Datadog, or any OTLP-compatible backend.

## Installation

```bash
npm install @orka-js/otel
```

## Quick Start

```typescript
import { createOtelExporter } from '@orka-js/otel'
import { Orka } from '@orka-js/core'

const exporter = createOtelExporter({
  endpoint: 'http://localhost:4318/v1/traces',
  serviceName: 'my-ai-app',
})

const orka = new Orka({
  llm,
  callbacks: {
    onStart: (run) => exporter.startSpan(run),
    onEnd: (run) => exporter.endSpan(run),
    onError: (run, err) => exporter.recordError(run, err),
  },
})
```

## With Headers (Datadog / Grafana Cloud)

```typescript
const exporter = createOtelExporter({
  endpoint: 'https://otlp.datadoghq.com/v1/traces',
  serviceName: 'my-ai-app',
  headers: {
    'DD-API-KEY': process.env.DD_API_KEY!,
  },
})
```

## W3C Trace Context Propagation

```typescript
import { traceContextPropagator } from '@orka-js/otel'

// Inject trace context into outgoing HTTP headers
const headers = {}
traceContextPropagator.inject(context, headers)

// Extract trace context from incoming HTTP headers
const ctx = traceContextPropagator.extract(headers)
```

## Configuration

| Option | Type | Description |
|--------|------|-------------|
| `endpoint` | `string` | OTLP HTTP endpoint (required) |
| `serviceName` | `string` | Service name for spans (required) |
| `headers` | `Record<string, string>` | Additional request headers |

## API

### `OtelExporter` / `createOtelExporter(config)`

```typescript
exporter.startSpan(run)           // Start a new span
exporter.endSpan(run)             // End a span
exporter.recordError(run, error)  // Record an exception
exporter.flush()                  // Force flush pending spans
```

### `W3CTraceContextPropagator`

```typescript
propagator.inject(context, carrier)   // Inject trace context into headers
propagator.extract(carrier)           // Extract trace context from headers
```

## Related Packages

- [`@orka-js/observability`](../observability) — Lightweight built-in tracer
- [`@orka-js/devtools`](../devtools) — Local DevTools UI
- [`@orka-js/core`](../core) — `CallbackManager` for lifecycle hooks
- [`orkajs`](../orkajs) — Full bundle
npm package: @orka-js/pgvector
Description: pgvector adapter for OrkaJS — works with PostgreSQL and Supabase
Author: Orka Team
Latest version: 0.2.1

# @orka-js/pgvector

PostgreSQL pgvector adapter for OrkaJS — vector search inside your existing Postgres database.

## Installation

```bash
npm install @orka-js/pgvector
```

Enable the pgvector extension in your PostgreSQL database:

```sql
CREATE EXTENSION IF NOT EXISTS vector;
```

## Quick Start

```typescript
import { PgVectorAdapter } from '@orka-js/pgvector'
import { Orka } from '@orka-js/core'

const vectorDB = new PgVectorAdapter({
  connectionString: process.env.DATABASE_URL!,
  dimension: 1536,
})

const orka = new Orka({ llm, vectorDB })

await orka.knowledge.ingest([
  { id: 'doc-1', content: 'Hello world' }
])
const results = await orka.knowledge.query('hello', 5)
```

## Direct Usage

```typescript
const adapter = new PgVectorAdapter({
  connectionString: 'postgresql://user:pass@localhost:5432/mydb',
  tableName: 'embeddings',
})

await adapter.createCollection('documents', 1536)
await adapter.upsert('documents', [
  { id: 'doc-1', vector: [...], metadata: { text: 'Hello world' } }
])
const results = await adapter.search('documents', queryVector, 5)
await adapter.delete('documents', ['doc-1'])
```

## Configuration

| Option | Type | Description |
|--------|------|-------------|
| `connectionString` | `string` | PostgreSQL connection string (required) |
| `tableName` | `string` | Default table name |
| `dimension` | `number` | Default vector dimension |

## Requirements

- PostgreSQL 13+
- [pgvector](https://github.com/pgvector/pgvector) extension enabled

## API

### `PgVectorAdapter`

```typescript
adapter.createCollection(name, dimension)           // Promise<void> — creates a table
adapter.deleteCollection(name)                      // Promise<void> — drops the table
adapter.upsert(collection, docs)                    // Promise<void>
adapter.search(collection, vector, topK, filter?)   // Promise<SearchResult[]>
adapter.delete(collection, ids)                     // Promise<void>
```

Implements: `VectorDBAdapter`

## Related Packages

- [`@orka-js/core`](../core) — `VectorDBAdapter` interface
- [`@orka-js/qdrant`](../qdrant) — Dedicated vector DB
- [`@orka-js/memory`](../memory) — In-memory adapter for dev/testing
- [`orkajs`](../orkajs) — Full bundle