npm package: @lakehouse/openclaw-plugin
Description: Lakehouse42 plugin for OpenClaw - enterprise knowledge at your fingertips
Author: Lakehouse42
Latest version: 0.1.0

# @lakehouse/openclaw-plugin

Lakehouse42 plugin for OpenClaw - gives your AI agent access to enterprise knowledge through semantic search, RAG Q&A, and automatic knowledge capture.

## Features

- **Agent Tools**: Search, ask questions, list collections, ingest content
- **Auto-Recall**: Automatically injects relevant knowledge before the agent processes messages
- **Auto-Capture**: Captures important information from conversations to the knowledge base
- **CLI Commands**: Direct interaction with the knowledge base from the command line
- **Gateway Methods**: Programmatic API for custom integrations

## Installation

```bash
# In your OpenClaw extensions directory
cd ~/.openclaw/extensions
npm install @lakehouse/openclaw-plugin
```

Or install globally:

```bash
npm install -g @lakehouse/openclaw-plugin
```

## Configuration

Add the plugin configuration to your `~/.openclaw/config.json5`:

```json5
{
  "plugins": {
    "entries": {
      "knowledge-lakehouse": {
        "enabled": true,
        "config": {
          // Required: Your Lakehouse42 API key
          "apiKey": "lh_your_api_key_here",

          // Optional: API base URL (for self-hosted instances)
          "baseUrl": "https://api.lakehouse42.com",

          // Optional: Organization ID (uses default if omitted)
          "organizationId": "org_xxx",

          // Optional: Default collections to search
          "defaultCollectionIds": ["col_xxx", "col_yyy"],

          // Auto-recall settings
          "autoRecall": {
            "enabled": true,
            "minScore": 0.3,    // Minimum relevance score (0-1)
            "maxResults": 5     // Max results to inject
          },

          // Auto-capture settings
          "autoCapture": {
            "enabled": true,
            "collectionId": "col_xxx",  // Target collection
            "minLength": 20,
            "maxLength": 2000,
            "triggerPatterns": ["remember this", "important:"],
            "excludePatterns": ["password", "secret"]
          },

          // Search settings
          "search": {
            "defaultTopK": 10,
            "rerankEnabled": true
          },

          // Ingest settings
          "ingest": {
            "defaultCollectionId": "col_xxx",
            "sourceApp": "openclaw"
          }
        }
      }
    }
  }
}
```

## Agent Tools

The plugin provides these tools to your OpenClaw agent:

### knowledge_search

Search the enterprise knowledge base using semantic search.

```
Agent: I'll search for information about our refund policy.
[Uses knowledge_search with query: "refund policy"]
```

Parameters:
- `query` (required): Search query
- `collection_ids`: Specific collections to search
- `top_k`: Number of results (default: 10)
- `filters`: Metadata filters

### knowledge_ask

Ask questions and get AI-generated answers with citations.

```
Agent: Let me find out what our SLA terms are.
[Uses knowledge_ask with question: "What are our SLA terms?"]
```

Parameters:
- `question` (required): Question to answer
- `collection_ids`: Specific collections to search
- `include_citations`: Include source citations (default: true)

### knowledge_collections

List available knowledge collections.

```
Agent: I'll check what data sources are available.
[Uses knowledge_collections]
```

### knowledge_ingest

Ingest text content into the knowledge base.

```
Agent: I'll save these meeting notes for future reference.
[Uses knowledge_ingest with content: "...meeting notes..."]
```

Parameters:
- `content` (required): Text content to ingest
- `title`: Document title
- `collection_id`: Target collection
- `metadata`: Additional metadata

### knowledge_save

Quick-save important information from conversations.

```
Agent: I'll save that preference for you.
[Uses knowledge_save with text: "User prefers dark mode"]
```

Parameters:
- `text` (required): Text to save
- `importance`: low, medium, or high
- `tags`: Categorization tags

## Auto-Recall

When enabled, the plugin automatically:

1. Takes the user's message
2. Searches the knowledge base for relevant content
3. Injects matching results as context before the agent processes

This runs **alongside** OpenClaw's built-in memory system, not replacing it. Your agent gets both personal memory (LanceDB) and enterprise knowledge (Lakehouse42).

Example injected context:

```xml
<enterprise-knowledge query="refund policy" results="3">
  <result rank="1" relevance="92%" source="Customer Policy Guide">
    Refunds are processed within 5-7 business days...
  </result>
  ...
</enterprise-knowledge>
```

## Auto-Capture

When enabled, the plugin automatically captures important information from conversations:

- **Decisions**: "We decided to use React for the frontend"
- **Preferences**: "I prefer the dark theme"
- **Facts**: "The API rate limit is 1000 requests/minute"
- **Instructions**: "Always verify email before sending"

Content is filtered by:
- Length (min/max configurable)
- Importance level detection
- Trigger/exclude patterns
- Category detection

## CLI Commands

```bash
# Search the knowledge base
openclaw lakehouse search "refund policy"
openclaw lakehouse search "deployment process" -n 5 -c col_xxx

# Ask a question
openclaw lakehouse ask "What is our vacation policy?"
openclaw lakehouse ask "How do I deploy to production?" --no-citations

# List collections
openclaw lakehouse collections

# Ingest content
openclaw lakehouse ingest --text "Meeting notes from today..." --collection col_xxx --title "Team Meeting 2024-01-15"

# Check status
openclaw lakehouse status
```

## Gateway Methods

For programmatic access from other plugins or custom code:

```typescript
// Search
const results = await gateway.call("lakehouse.search", {
  query: "deployment process",
  topK: 5,
});

// Ask question
const answer = await gateway.call("lakehouse.ask", {
  question: "What is our SLA?",
  includeCitations: true,
});

// Ingest content
const doc = await gateway.call("lakehouse.ingest", {
  content: "Important information...",
  title: "Meeting Notes",
  collectionId: "col_xxx",
});

// List collections
const collections = await gateway.call("lakehouse.collections");
```

## How It Works

```
┌─────────────────────────────────────────────────────────┐
│                       OpenClaw                          │
├─────────────────────────────────────────────────────────┤
│  User Message                                           │
│       │                                                 │
│       ▼                                                 │
│  ┌─────────────────┐    ┌──────────────────────────┐   │
│  │  Auto-Recall    │───▶│  Lakehouse42 API │   │
│  │  (before_agent) │◀───│  (search)                │   │
│  └────────┬────────┘    └──────────────────────────┘   │
│           │                                             │
│           ▼ inject context                              │
│  ┌─────────────────┐                                   │
│  │    Agent        │──▶ Tools: knowledge_search,       │
│  │                 │           knowledge_ask, etc.     │
│  └────────┬────────┘                                   │
│           │                                             │
│           ▼                                             │
│  ┌─────────────────┐    ┌──────────────────────────┐   │
│  │  Auto-Capture   │───▶│  Lakehouse42 API │   │
│  │  (agent_end)    │    │  (ingest)                │   │
│  └─────────────────┘    └──────────────────────────┘   │
│                                                         │
│  Response to User                                       │
└─────────────────────────────────────────────────────────┘
```

## Getting an API Key

1. Sign up at [lakehouse42.com](https://lakehouse42.com)
2. Create an organization
3. Go to Settings → API Keys
4. Create a new API key with appropriate permissions
5. Copy the `lh_xxx` key to your config

## License

MIT