### Clone Repository and Install Dependencies Source: https://github.com/aristoapp/openclaw-membase/blob/main/CONTRIBUTING.md Use these commands to clone the repository and install project dependencies using Bun. ```bash git clone https://github.com/aristoapp/openclaw-membase.git cd openclaw-membase bun install ``` -------------------------------- ### Install Membase Plugin Source: https://github.com/aristoapp/openclaw-membase/blob/main/README.md Install the Membase plugin for OpenClaw using the provided command. Restart OpenClaw after installation. ```bash openclaw plugins install @membase/openclaw-membase ``` -------------------------------- ### Clone and Install OpenClaw Membase Source: https://github.com/aristoapp/openclaw-membase/blob/main/README.md Set up the development environment by cloning the repository, installing dependencies, and running type checks, linting, and build processes. ```bash git clone https://github.com/aristoapp/openclaw-membase.git cd openclaw-membase bun install bun run check-types bun run lint bun run build ``` -------------------------------- ### Install Membase Plugin for OpenClaw Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Install the Membase plugin using the OpenClaw plugin manager. Remember to restart OpenClaw and authenticate afterwards. ```bash openclaw plugins install @membase/openclaw-membase # Restart OpenClaw after installation # Then authenticate with OAuth openclaw membase login ``` -------------------------------- ### Setup Membase Login Source: https://github.com/aristoapp/openclaw-membase/blob/main/README.md Log in to Membase using OAuth authentication. This command opens a browser for authentication, and tokens are saved automatically. ```bash openclaw membase login ``` -------------------------------- ### Get User Profile Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Retrieve the user's profile settings from Membase, including display name, role, interests, and instructions. ```typescript const profile = await client.getProfile(); console.log(`User: ${profile.display_name}`); console.log(`Role: ${profile.role}`); console.log(`Interests: ${profile.interests}`); console.log(`Instructions: ${profile.instructions}`); ``` -------------------------------- ### Get User Profile Memory Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Fetch the user's profile memory node from the knowledge graph. Returns the memory node if found, otherwise null. ```typescript const profileMemory = await client.getUserProfileMemory(); if (profileMemory) { console.log(`Profile UUID: ${profileMemory.episode.uuid}`); console.log(`Profile: ${profileMemory.episode.summary}`); } ``` -------------------------------- ### Retrieve User Profile and Related Memories Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Fetches the user's profile information and associated memories. Ideal for initializing session context at the start of a new session. ```typescript // Get user profile with related memories const profile = await membase_profile({}); // Response includes: // - User profile (display_name, role, interests, instructions) // - Related memories from knowledge graph // - User profile memory node ``` -------------------------------- ### membase_profile Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Retrieve the user's profile and related memories for session context. Best used at the start of new sessions for an overview of the user. ```APIDOC ## membase_profile ### Description Retrieve the user's profile and related memories for session context. Best used at the start of new sessions for an overview of the user. ### Method GET ### Endpoint /membase/profile ### Parameters No parameters are required for this endpoint. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **profile** (object) - Contains user profile information. - **display_name** (string) - The user's display name. - **role** (string) - The user's role. - **interests** (array of strings) - User's interests. - **instructions** (string) - Specific instructions for the user. - **related_memories** (array) - Memories related to the user's profile. - **profile_memory_node** (object) - The knowledge graph node representing the user's profile. #### Response Example ```json { "profile": { "display_name": "Jane Doe", "role": "Software Engineer", "interests": ["AI", "Machine Learning"], "instructions": "Focus on efficiency and scalability." }, "related_memories": [ { "id": "uuid-related-1", "content": "Worked on project X." } ], "profile_memory_node": { "id": "uuid-profile-node" } } ``` ``` -------------------------------- ### Initialize MembaseClient Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Create a new MembaseClient instance for direct API interaction. Requires API URL, authentication tokens, and optional configuration like debug mode and token refresh callbacks. ```typescript import { MembaseClient } from "./client"; const client = new MembaseClient( "https://api.membase.so", // API URL { accessToken: "your-access-token", refreshToken: "your-refresh-token", clientId: "your-client-id" }, { debug: true, timeoutMs: 15000, onTokenRefresh: (tokens) => { console.log("Tokens refreshed:", tokens.accessToken.slice(0, 10) + "..."); // Persist new tokens } } ); // Check authentication status if (client.isAuthenticated()) { console.log("Client ready for API calls"); } ``` -------------------------------- ### MembaseClient Constructor Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Initializes a new MembaseClient instance for interacting with the Membase backend. Requires API URL and authentication tokens. ```APIDOC ## MembaseClient Constructor ### Description Create a new MembaseClient instance for direct API interaction with the Membase backend. ### Request Example ```typescript import { MembaseClient } from "./client"; const client = new MembaseClient( "https://api.membase.so", // API URL { accessToken: "your-access-token", refreshToken: "your-refresh-token", clientId: "your-client-id" }, { debug: true, timeoutMs: 15000, onTokenRefresh: (tokens) => { console.log("Tokens refreshed:", tokens.accessToken.slice(0, 10) + "..."); // Persist new tokens } } ); // Check authentication status if (client.isAuthenticated()) { console.log("Client ready for API calls"); } ``` ``` -------------------------------- ### Add Wiki Document via CLI Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Create new wiki documents for storing factual knowledge. Documents can include content, be assigned to specific collections, and optionally be summarized. ```bash # Add a basic wiki document openclaw membase wiki-add "Project Setup Guide" --content "# Setup\n\nInstall dependencies with npm install" # Add to specific collection openclaw membase wiki-add "API Reference" --content "## Endpoints\n\n- GET /users" --collection-id api-docs # Add with automatic summarization openclaw membase wiki-add "Meeting Notes" --content "Long meeting content..." --summarize ``` -------------------------------- ### MembaseClient.createWikiDocument Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Creates a new wiki document, with options for specifying a collection and enabling summarization. ```APIDOC ## MembaseClient.createWikiDocument ### Description Create a new wiki document with optional collection and summarization. ### Method `client.createWikiDocument(title: string, content: string, collection?: string, summarize?: boolean): Promise ### Parameters #### Request Body - **title** (string) - Required - The title of the wiki document. - **content** (string) - Required - The content of the wiki document. - **collection** (string) - Optional - The collection to place the document in. - **summarize** (boolean) - Optional - Whether to automatically summarize the content. ### Response #### Success Response (200) - **title** (string) - The title of the created document. - **id** (string) - The unique identifier of the created document. ### Request Example ```typescript const doc = await client.createWikiDocument( "Deployment Checklist", // title "# Pre-deployment\n- Run tests\n- Review PR\n\n# Deployment\n- Deploy to staging\n- Smoke test", // content "devops", // collection (optional) true // summarize (optional) ); console.log(`Created: ${doc.title} (${doc.id})`); ``` ``` -------------------------------- ### Search Membase Wiki via CLI Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Search the Membase knowledge wiki for factual references. Results can be limited and filtered by collection. ```bash # Search wiki documents openclaw membase wiki-search "API authentication" # Limit results openclaw membase wiki-search "deployment" --limit 5 # Filter by collection openclaw membase wiki-search "configuration" --collection-id work-docs ``` -------------------------------- ### Create Wiki Document Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Create a new wiki document with optional collection and summarization. Logs the title and ID of the created document. ```typescript const doc = await client.createWikiDocument( "Deployment Checklist", // title "# Pre-deployment\n- Run tests\n- Review PR\n\n# Deployment\n- Deploy to staging\n- Smoke test", // content "devops", // collection (optional) true // summarize (optional) ); console.log(`Created: ${doc.title} (${doc.id})`); ``` -------------------------------- ### Run Type Checks and Linting Source: https://github.com/aristoapp/openclaw-membase/blob/main/CONTRIBUTING.md Execute these commands to ensure code quality and type correctness before committing changes. ```bash bun run check-types ``` ```bash bun run lint ``` -------------------------------- ### Configure OpenClaw Membase Plugin Source: https://github.com/aristoapp/openclaw-membase/blob/main/README.md Manually configure the plugin by adding 'openclaw-membase' to 'tools.alsoAllow' and specifying plugin-specific settings. This ensures the AI can access memory tools and customizes recall behavior. ```json { "tools": { "profile": "coding", "alsoAllow": ["openclaw-membase"] }, "plugins": { "entries": { "openclaw-membase": { "enabled": true, "config": { "autoRecall": true, "autoWikiRecall": false, "autoCapture": true, "maxRecallChars": 4000 } } } } } ``` -------------------------------- ### MembaseClient.ingest Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Stores content to memory, with optional parameters for display summary and project categorization. ```APIDOC ## MembaseClient.ingest ### Description Store content to memory with optional display summary and project categorization. ### Method `client.ingest(content: string, options?: { displaySummary?: string; project?: string }): Promise<{ status: string }> ### Parameters #### Request Body - **content** (string) - Required - The content to ingest. - **options** (object) - Optional - Additional options. - **displaySummary** (string) - Optional - A summary to display for the ingested content. - **project** (string) - Optional - The project to categorize the content under. ### Request Example ```typescript const result = await client.ingest( "User completed the React certification course on March 1st, 2026.", { displaySummary: "React certification completed", project: "learning" } ); console.log(`Ingestion status: ${result.status}`); ``` ``` -------------------------------- ### Authenticate with Membase CLI Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Authenticate with Membase using the CLI. The standard command initiates an OAuth 2.0 PKCE flow opening a browser. Custom API URLs and callback ports can be specified. ```bash # Standard login (opens browser automatically) openclaw membase login # Custom API URL for self-hosted instances openclaw membase login --api-url https://custom.membase.example.com # Specify callback port if default (8765) is in use openclaw membase login --port 9000 ``` -------------------------------- ### Search Membase Memories via CLI Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Perform semantic searches on stored memories using the CLI. Results can be limited and filtered by source. ```bash # Basic semantic search openclaw membase search "project deadlines" # Search with result limit openclaw membase search "meetings" --limit 20 # Filter by specific sources openclaw membase search "team updates" --sources slack,gmail ``` -------------------------------- ### Update Wiki Document via CLI Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Update existing wiki documents by modifying their title, content, or collection using the document ID. ```bash # Update document title openclaw membase wiki-update abc123 --title "Updated Project Guide" # Update document content openclaw membase wiki-update abc123 --content "# New Content\n\nUpdated information" # Move to different collection openclaw membase wiki-update abc123 --collection api-reference ``` -------------------------------- ### Membase CLI Commands Source: https://github.com/aristoapp/openclaw-membase/blob/main/README.md Common CLI commands for interacting with Membase, including login, logout, searching memories and wiki documents, and managing wiki content. ```bash openclaw membase login # OAuth login (PKCE) — opens browser ``` ```bash openclaw membase logout # Remove stored tokens ``` ```bash openclaw membase search # Search memories ``` ```bash openclaw membase search -s slack,gmail # Filter by source ``` ```bash openclaw membase wiki-search # Search wiki documents ``` ```bash openclaw membase wiki-add "" --content "<markdown>" # Add wiki doc ``` ```bash openclaw membase wiki-update <docId> --title "<new title>" # Update wiki doc ``` ```bash openclaw membase wiki-delete <docId> # Delete wiki doc ``` ```bash openclaw membase status # Check API connectivity ``` -------------------------------- ### Check Membase API Status via CLI Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Verify the connectivity status of the Membase API using the status command. ```bash # Verify API connection openclaw membase status ``` -------------------------------- ### Configure Membase Plugin in OpenClaw Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Configure the Membase plugin settings either through OpenClaw's plugin settings interface or by directly editing the `~/.openclaw/openclaw.json` configuration file. This JSON defines plugin enablement, API URL, token file location, and various recall/capture settings. ```json { "tools": { "profile": "coding", "alsoAllow": ["openclaw-membase"] }, "plugins": { "entries": { "openclaw-membase": { "enabled": true, "config": { "apiUrl": "https://api.membase.so", "tokenFile": "~/.openclaw/credentials/openclaw-membase.json", "autoRecall": true, "autoWikiRecall": false, "autoCapture": true, "maxRecallChars": 4000, "debug": false } } } } } ``` -------------------------------- ### Membase AI Tools Source: https://github.com/aristoapp/openclaw-membase/blob/main/README.md Overview of AI tools provided by the Membase plugin for interacting with memory and wiki documents. These tools can be used autonomously by the agent. ```markdown | Tool | Description | | --- | --- | | `membase_search` | Search memories by semantic similarity. Supports date filtering (`date_from`, `date_to`, `timezone`) and source filtering (`sources` — e.g. `['slack', 'gmail']`). Returns episode bundles with related facts and relevance scores. | | `membase_store` | Save important information to long-term memory. Proactively stores preferences, goals, and context. | | `membase_forget` | Delete a memory. Shows matches first, then deletes after user confirmation (two-step). | | `membase_profile` | Retrieve user profile and related memories for session context. | | `membase_search_wiki` | Search wiki documents for factual references and stable knowledge. | | `membase_add_wiki` | Create a wiki document from markdown content. | | `membase_update_wiki` | Update title/content/collection of an existing wiki document. | | `membase_delete_wiki` | Delete a wiki document with confirmation flow. | ``` -------------------------------- ### Handle MembaseApiError Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Demonstrates how to catch and handle MembaseApiError, checking the status code for specific actions like re-authentication or rate limit handling. ```typescript import { MembaseApiError } from "./types"; try { const result = await client.search("test query"); } catch (error) { if (error instanceof MembaseApiError) { console.error(`API Error: ${error.message}`); console.error(`Status: ${error.status}`); console.error(`Body: ${error.body}`); if (error.status === 401) { console.log("Re-authentication required. Run 'openclaw membase login'"); } else if (error.status === 429) { console.log("Rate limited. Please wait before retrying."); } } else { console.error("Unexpected error:", error); } } ``` -------------------------------- ### Hooks System Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Documentation for the Hooks System, including Auto-Recall and Auto-Capture hooks. ```APIDOC ## Hooks System ### Auto-Recall Hook The recall hook automatically injects relevant memories before each AI turn, searching both episodic memories and wiki documents based on the user's message. **Configuration Options:** - `autoRecall` (boolean): Enable memory recall. - `autoWikiRecall` (boolean): Enable wiki recall. - `maxRecallChars` (number): Context budget (500-16000). **Functionality:** 1. Extracts the user's last message. 2. Skips casual chat and short messages. 3. Searches memories (limit: 10) and wiki (limit: 5) in parallel. 4. Formats results within character budget. 5. Injects as prependContext to the AI turn. ### Auto-Capture Hook The capture hook automatically buffers conversation messages and flushes them to Membase for entity extraction after periods of silence or buffer limits. **Behavior:** - Buffers user messages from each conversation. - Filters out heartbeat/operational messages. - Flushes after 5 minutes of silence. - Flushes when buffer reaches 20 messages. - Minimum 2 messages required to flush. **Manual Flush:** `flushAllBuffers(client, logger)` can be used to manually trigger a flush, typically on shutdown. ``` -------------------------------- ### MembaseClient.getProfile Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Retrieves the user's profile settings from Membase. ```APIDOC ## MembaseClient.getProfile ### Description Retrieve the user's profile settings from Membase. ### Method `client.getProfile(): Promise<UserProfile> ### Response #### Success Response (200) - **display_name** (string) - The user's display name. - **role** (string) - The user's role. - **interests** (string[]) - A list of the user's interests. - **instructions** (string) - Special instructions for the user. ### Request Example ```typescript const profile = await client.getProfile(); console.log(`User: ${profile.display_name}`); console.log(`Role: ${profile.role}`); console.log(`Interests: ${profile.interests}`); console.log(`Instructions: ${profile.instructions}`); ``` ``` -------------------------------- ### membase_search_wiki Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Search the user's knowledge wiki using hybrid semantic and keyword matching. Use for factual knowledge, references, and stable documentation rather than personal context. ```APIDOC ## membase_search_wiki ### Description Search the user's knowledge wiki using hybrid semantic and keyword matching. Use for factual knowledge, references, and stable documentation rather than personal context. ### Method POST ### Endpoint /membase/search_wiki ### Parameters #### Request Body - **query** (string) - Required - The search query string. An empty query fetches recent documents. - **collection** (string) - Optional - Filter search results by a specific wiki collection. - **limit** (integer) - Optional - The maximum number of results to return. ### Request Example ```json { "query": "authentication flow", "limit": 10 } ``` ### Response #### Success Response (200) - **results** (array) - An array of wiki documents matching the query. - **title** (string) - The title of the wiki document. - **content** (string) - The content of the wiki document. - **collection** (string) - The collection the document belongs to. - **timestamp** (string) - The timestamp of the document. #### Response Example ```json { "results": [ { "title": "API Authentication Flow", "content": "# Authentication Flow\n\nDetails about the authentication process...", "collection": "api-reference", "timestamp": "2023-10-26T12:00:00Z" } ] } ``` ``` -------------------------------- ### membase_add_wiki Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Add documents to the user's wiki knowledge base for storing factual documents and references. Supports markdown content with wikilinks. ```APIDOC ## membase_add_wiki ### Description Add documents to the user's wiki knowledge base for storing factual documents and references. Supports markdown content with wikilinks. ### Method POST ### Endpoint /membase/add_wiki ### Parameters #### Request Body - **title** (string) - Required - The title of the wiki document. - **content** (string) - Required - The markdown content of the wiki document. - **collection** (string) - Optional - The collection to categorize this document under. - **summarize** (boolean) - Optional - If true, the system will attempt to auto-generate a summary. ### Request Example ```json { "title": "API Authentication Guide", "content": "# Authentication\n\nUse Bearer tokens for API access.\n\n## Getting a Token\n\nCall POST /auth/login with credentials.", "summarize": true } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the newly created wiki document. - **title** (string) - The title of the created document. - **collection** (string) - The collection the document was added to. #### Response Example ```json { "id": "uuid-wiki-doc-123", "title": "API Authentication Guide", "collection": "documentation" } ``` ``` -------------------------------- ### MembaseClient.searchWiki Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Searches wiki documents, with an option to filter by collection. ```APIDOC ## MembaseClient.searchWiki ### Description Search wiki documents with optional collection filtering. ### Method `client.searchWiki(query: string, limit?: number, collection?: string): Promise<WikiSearchResult> ### Parameters #### Query Parameters - **query** (string) - Required - The search query. - **limit** (number) - Optional - The maximum number of results to return. - **collection** (string) - Optional - The collection to search within. ### Response #### Success Response (200) - **documents** (array) - A list of matching wiki documents. - **title** (string) - The title of the document. - **id** (string) - The unique identifier of the document. - **collection_name** (string) - The name of the collection the document belongs to. - **similarity** (number) - The similarity score of the document to the query. ### Request Example ```typescript const wikiResult = await client.searchWiki( "deployment guide", // query 10, // limit "devops" // collection ); for (const doc of wikiResult.documents) { console.log(`${doc.title} (${doc.id})`); console.log(` Collection: ${doc.collection_name}`); console.log(` Similarity: ${doc.similarity}`); } ``` ``` -------------------------------- ### MembaseClient.search Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Searches memories using semantic similarity, with options for date and source filtering. ```APIDOC ## MembaseClient.search ### Description Search memories with semantic similarity, date filtering, and source filtering. ### Method `client.search(query: string, limit?: number, offset?: number, dateFrom?: string, dateTo?: string, timezone?: string, sources?: string[], project?: string): Promise<SearchBundle[]> ### Parameters #### Query Parameters - **query** (string) - Required - The search query. - **limit** (number) - Optional - The maximum number of results to return. - **offset** (number) - Optional - The number of results to skip. - **dateFrom** (string) - Optional - Filter results from this date (ISO 8601 format). - **dateTo** (string) - Optional - Filter results up to this date (ISO 8601 format). - **timezone** (string) - Optional - The timezone for date filtering. - **sources** (string[]) - Optional - Filter results by source (e.g., ["slack", "gmail"]). - **project** (string) - Optional - Filter results by project. ### Request Example ```typescript const bundles = await client.search( "meeting notes", // query 20, // limit 0, // offset "2026-01-01", // dateFrom (ISO 8601) "2026-03-31", // dateTo (ISO 8601) "America/New_York", // timezone ["slack", "gmail"], // sources filter "work-project" // project filter ); // Process results for (const bundle of bundles) { console.log(`Memory: ${bundle.episode.name}`); console.log(` Summary: ${bundle.episode.summary}`); console.log(` Score: ${bundle.relevance_score}`); for (const edge of bundle.edges) { console.log(` Fact: ${edge.fact}`); } } ``` ``` -------------------------------- ### MembaseClient.getUserProfileMemory Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Fetches the user's profile memory node from the knowledge graph. ```APIDOC ## MembaseClient.getUserProfileMemory ### Description Fetch the user's profile memory node from the knowledge graph. ### Method `client.getUserProfileMemory(): Promise<SearchBundle | null> ### Response #### Success Response (200) - **episode** (object) - The memory episode details. - **uuid** (string) - The unique identifier for the memory episode. - **summary** (string) - A summary of the memory episode. ### Request Example ```typescript const profileMemory = await client.getUserProfileMemory(); if (profileMemory) { console.log(`Profile UUID: ${profileMemory.episode.uuid}`); console.log(`Profile: ${profileMemory.episode.summary}`); } ``` ``` -------------------------------- ### Add Documents to Wiki Knowledge Base Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Stores factual documents and references in the user's wiki. Supports markdown content, wikilinks, collection categorization, and automatic summarization. ```typescript // Create a basic wiki document const newDoc = await membase_add_wiki({ title: "API Authentication Guide", content: "# Authentication\n\nUse Bearer tokens for API access.\n\n## Getting a Token\n\nCall POST /auth/login with credentials." }); ``` ```typescript // Create with collection categorization const categorizedDoc = await membase_add_wiki({ title: "Database Schema", content: "# Users Table\n\n| Column | Type |\n|--------|------|\n| id | UUID |\n| email | VARCHAR |", collection: "technical-docs" }); ``` ```typescript // Create with automatic summarization const summarizedDoc = await membase_add_wiki({ title: "Meeting Notes 2024-03-15", content: "# Product Planning Meeting\n\nLong detailed meeting notes...", summarize: true }); ``` -------------------------------- ### Delete Wiki Document via CLI Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Delete wiki documents from Membase by providing their unique document ID. ```bash # Delete a specific wiki document openclaw membase wiki-delete abc123 ``` -------------------------------- ### Perform Semantic Search on Memories Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Use for general semantic search. Supports filtering by date range, source, and project, as well as pagination. ```typescript const result = await membase_search({ query: "user preferences for dark mode", limit: 20 }); ``` ```typescript const scheduleResult = await membase_search({ query: "", // Empty query for broad date retrieval date_from: "2026-02-02", date_to: "2026-02-19T23:59:59", timezone: "Asia/Seoul", limit: 30 }); ``` ```typescript const slackMemories = await membase_search({ query: "team meeting", sources: ["slack", "gmail"], limit: 10 }); ``` ```typescript const projectMemories = await membase_search({ query: "deployment steps", project: "backend-api", limit: 15 }); ``` ```typescript const nextPage = await membase_search({ query: "coding patterns", limit: 10, offset: 10 }); ``` -------------------------------- ### Search User Knowledge Wiki Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Performs hybrid semantic and keyword matching searches on the user's wiki. Suitable for factual knowledge and documentation, not personal context. ```typescript // Search wiki by topic const wikiResult = await membase_search_wiki({ query: "authentication flow", limit: 10 }); ``` ```typescript // Search within specific collection const apiDocs = await membase_search_wiki({ query: "REST endpoints", collection: "api-reference", limit: 5 }); ``` ```typescript // Fetch recent wiki documents const recentDocs = await membase_search_wiki({ query: "", // Empty query fetches recent limit: 10 }); ``` -------------------------------- ### Error Handling Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Details on the custom MembaseApiError class for handling API-related errors. ```APIDOC ## Error Handling ### MembaseApiError Custom error class for API-related errors with status code and response body information. **Properties:** - `message` (string): The error message. - `status` (number): The HTTP status code of the error response. - `body` (any): The response body from the API. **Common Status Codes:** - `401`: Re-authentication required. Run 'openclaw membase login'. - `429`: Rate limited. Please wait before retrying. ``` -------------------------------- ### MembasePluginConfig Type Definition Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Defines the configuration options for the Membase plugin, including API URL, authentication details, and settings for recall and capture hooks. ```typescript interface MembasePluginConfig { apiUrl: string; // Membase API URL clientId: string; // OAuth client ID tokenFile: string; // Path to token cache file accessToken: string; // Current access token refreshToken: string; // Current refresh token autoRecall: boolean; // Enable auto-recall hook autoWikiRecall: boolean; // Enable wiki recall autoCapture: boolean; // Enable auto-capture hook maxRecallChars: number; // Context budget (500-16000) debug: boolean; // Enable debug logging } ``` -------------------------------- ### Update Wiki Document Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Update an existing wiki document's title, content, or collection. Use membase_search_wiki first to find the document ID. ```typescript // Update document title const updated = await membase_update_wiki({ doc_id: "doc-abc123", title: "Updated API Guide v2" }); ``` ```typescript // Update document content const contentUpdate = await membase_update_wiki({ doc_id: "doc-abc123", content: "# Revised Content\n\nNew documentation..." }); ``` ```typescript // Move to different collection const moveDoc = await membase_update_wiki({ doc_id: "doc-abc123", collection: "archived-docs" }); ``` ```typescript // Update multiple fields const fullUpdate = await membase_update_wiki({ doc_id: "doc-abc123", title: "Complete API Reference", content: "# Full Documentation\n\n...", collection: "api-docs" }); ``` -------------------------------- ### Type Definitions Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Defines the primary data structures used by the Membase API. ```APIDOC ## Type Definitions ### EpisodeBundle The primary response type for memory searches containing an episode with related knowledge graph data. **Properties:** - `episode` (object): Details of the episode. - `uuid` (string): Unique identifier for the episode. - `name` (string): Name of the episode. - `labels` (string[]): Optional labels associated with the episode. - `summary` (string | null): Summary of the episode. - `source` (string | null): Source of the episode data. - `created_at` (string | null): Timestamp of creation. - `valid_at` (string | null): Timestamp of validity. - `attributes` (Record<string, unknown>): Optional attributes. - `relevance_score` (number | null): Relevance score of the episode. - `nodes` (NodeResponse[]): Related nodes in the knowledge graph. - `edges` (object[]): Related edges in the knowledge graph. - `uuid` (string): Unique identifier for the edge. - `name` (string): Name of the edge. - `fact` (string | null): Factual information associated with the edge. - `source_node_uuid` (string): UUID of the source node. - `target_node_uuid` (string): UUID of the target node. - `created_at` (string | null): Timestamp of creation. ### WikiSearchDocument Response type for wiki document searches with similarity scoring. **Properties:** - `id` (string): Unique identifier for the wiki document. - `title` (string): Title of the wiki document. - `content` (string): Content of the wiki document. - `metadata` (Record<string, unknown>): Metadata associated with the document. - `source` (string): Source of the document. - `collection_id` (string | null): ID of the collection the document belongs to. - `collection_name` (string | null): Name of the collection. - `similarity` (number | null): Similarity score. - `created_at` (string | null): Timestamp of creation. - `updated_at` (string | null): Timestamp of last update. ### MembasePluginConfig Configuration options for the Membase plugin. **Properties:** - `apiUrl` (string): Membase API URL. - `clientId` (string): OAuth client ID. - `tokenFile` (string): Path to token cache file. - `accessToken` (string): Current access token. - `refreshToken` (string): Current refresh token. - `autoRecall` (boolean): Enable auto-recall hook. - `autoWikiRecall` (boolean): Enable wiki recall. - `autoCapture` (boolean): Enable auto-capture hook. - `maxRecallChars` (number): Context budget (500-16000). - `debug` (boolean): Enable debug logging. ``` -------------------------------- ### membase_store Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Store important information to long-term memory that persists across sessions. Use for explicit save requests and proactive storage of durable user context like preferences, goals, and ongoing projects. ```APIDOC ## membase_store ### Description Store important information to long-term memory that persists across sessions. Use for explicit save requests and proactive storage of durable user context like preferences, goals, and ongoing projects. ### Method POST ### Endpoint /membase/store ### Parameters #### Request Body - **content** (string) - Required - The main content of the memory to store. - **display_summary** (string) - Optional - A brief summary or title for the memory. - **project** (string) - Optional - The project to associate this memory with. ### Request Example ```json { "content": "User prefers TypeScript over JavaScript for all new projects", "display_summary": "Programming language preference" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the stored memory. #### Response Example ```json { "id": "uuid-generated-by-system" } ``` ``` -------------------------------- ### Ingest Content to Memory Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Store content to memory with optional display summary and project categorization. The result indicates the ingestion status. ```typescript const result = await client.ingest( "User completed the React certification course on March 1st, 2026.", { displaySummary: "React certification completed", project: "learning" } ); console.log(`Ingestion status: ${result.status}`); ``` -------------------------------- ### Update Wiki Document Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Updates an existing wiki document with new title, content, or collection. Requires the document ID. ```typescript const updated = await client.updateWikiDocument( "doc-abc123", { title: "Updated Deployment Guide", content: "# New Content\n\nRevised steps...", collection: "archived" } ); console.log(`Updated: ${updated.title}`); ``` -------------------------------- ### Delete Memories with Confirmation Source: https://context7.com/aristoapp/openclaw-membase/llms.txt A two-step process to delete memories. The first step searches for memories to delete, and the second step, requiring confirmation and a UUID, performs the deletion. ```typescript // Step 1: Search for memories to delete const searchResult = await membase_forget({ query: "outdated project deadline" }); // Returns matching memories with UUIDs for user selection ``` ```typescript // Step 2: Delete after user confirms const deleteResult = await membase_forget({ query: "outdated project deadline", uuid: "550e8400-e29b-41d4-a716-446655440000", confirm: true }); ``` -------------------------------- ### membase_update_wiki Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Updates an existing wiki document's title, content, or collection. It's recommended to use membase_search_wiki first to obtain the document ID. ```APIDOC ## membase_update_wiki ### Description Update an existing wiki document's title, content, or collection. Use membase_search_wiki first to find the document ID. ### Request Example ```typescript // Update document title const updated = await membase_update_wiki({ doc_id: "doc-abc123", title: "Updated API Guide v2" }); // Update document content const contentUpdate = await membase_update_wiki({ doc_id: "doc-abc123", content: "# Revised Content\n\nNew documentation..." }); // Move to different collection const moveDoc = await membase_update_wiki({ doc_id: "doc-abc123", collection: "archived-docs" }); // Update multiple fields const fullUpdate = await membase_update_wiki({ doc_id: "doc-abc123", title: "Complete API Reference", content: "# Full Documentation\n\n...", collection: "api-docs" }); ``` ``` -------------------------------- ### membase_search Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Search stored memories by semantic similarity with support for date filtering, source filtering, and pagination. Returns episode-centric bundles containing memories with related nodes and edges from the knowledge graph. ```APIDOC ## membase_search ### Description Search stored memories by semantic similarity with support for date filtering, source filtering, and pagination. Returns episode-centric bundles containing memories with related nodes and edges from the knowledge graph. ### Method POST ### Endpoint /membase/search ### Parameters #### Request Body - **query** (string) - Required - The search query string. - **date_from** (string) - Optional - The start date for filtering (ISO 8601 format). - **date_to** (string) - Optional - The end date for filtering (ISO 8601 format). - **timezone** (string) - Optional - The timezone for date filtering (e.g., "Asia/Seoul"). - **sources** (array of strings) - Optional - Filter memories by source (e.g., ["slack", "gmail"]). - **project** (string) - Optional - Filter memories by project name. - **limit** (integer) - Optional - The maximum number of results to return. - **offset** (integer) - Optional - The number of results to skip for pagination. ### Request Example ```json { "query": "user preferences for dark mode", "limit": 20 } ``` ### Response #### Success Response (200) - **results** (array) - An array of memory bundles. - **results[].memories** (array) - Memories within the bundle. - **results[].nodes** (array) - Related knowledge graph nodes. - **results[].edges** (array) - Related knowledge graph edges. #### Response Example ```json { "results": [ { "memories": [ { "id": "uuid-1", "content": "User prefers dark mode.", "timestamp": "2023-10-27T10:00:00Z" } ], "nodes": [], "edges": [] } ] } ``` ``` -------------------------------- ### Register Auto-Recall Hook Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Registers the auto-recall hook to automatically inject relevant memories before each AI turn. Configuration options control recall behavior and context budget. ```typescript import { registerRecallHook } from "./hooks/recall"; // Configuration options const config = { autoRecall: true, // Enable memory recall autoWikiRecall: true, // Enable wiki recall maxRecallChars: 4000 // Context budget (500-16000) }; // Register the hook (done automatically by plugin) registerRecallHook(api, client, config); ``` -------------------------------- ### Store Information in Long-Term Memory Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Use to save explicit user requests or proactive context like preferences, goals, and projects. Supports categorization by project. ```typescript const result = await membase_store({ content: "User prefers TypeScript over JavaScript for all new projects", display_summary: "Programming language preference" }); ``` ```typescript const projectMemory = await membase_store({ content: "The backend API uses PostgreSQL with Prisma ORM. Connection pooling is configured for 10 max connections.", display_summary: "Backend database configuration", project: "backend-api" }); ``` ```typescript const backgroundResult = await membase_store({ content: "User is a senior software engineer at TechCorp, specializing in distributed systems and cloud architecture. Started role in March 2024.", display_summary: "Professional background" }); ``` -------------------------------- ### Update Wiki Document Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Updates the properties of an existing wiki document. You can modify its title, content, and collection. ```APIDOC ## POST /wiki/documents/{id} ### Description Update an existing wiki document's properties. ### Method POST ### Endpoint /wiki/documents/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the wiki document to update. #### Request Body - **title** (string) - Optional - The new title for the wiki document. - **content** (string) - Optional - The new content for the wiki document. - **collection** (string) - Optional - The new collection to which the wiki document belongs. ### Request Example ```json { "title": "Updated Deployment Guide", "content": "# New Content\n\nRevised steps...", "collection": "archived" } ``` ### Response #### Success Response (200) - **title** (string) - The updated title of the wiki document. #### Response Example ```json { "title": "Updated Deployment Guide" } ``` ``` -------------------------------- ### Search Wiki Documents Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Search wiki documents with optional collection filtering. Displays the title, ID, collection name, and similarity score for each document found. ```typescript const wikiResult = await client.searchWiki( "deployment guide", // query 10, // limit "devops" // collection ); for (const doc of wikiResult.documents) { console.log(`${doc.title} (${doc.id})`); console.log(` Collection: ${doc.collection_name}`); console.log(` Similarity: ${doc.similarity}`); } ``` -------------------------------- ### Delete Wiki Document Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Delete wiki documents using a two-step confirmation flow. Search for documents first, then confirm deletion. ```typescript // Step 1: Search for documents to delete const searchResult = await membase_delete_wiki({ query: "outdated documentation" }); // Returns matching documents with IDs ``` ```typescript // Step 2: Delete after confirmation const deleteResult = await membase_delete_wiki({ query: "outdated documentation", doc_id: "doc-xyz789", confirm: true }); ``` ```typescript // Search within collection before deleting const collectionSearch = await membase_delete_wiki({ query: "old API docs", collection_id: "archived" }); ``` -------------------------------- ### membase_delete_wiki Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Deletes wiki documents through a two-step confirmation process, similar to memory deletion. ```APIDOC ## membase_delete_wiki ### Description Delete wiki documents using a two-step confirmation flow similar to memory deletion. ### Request Example ```typescript // Step 1: Search for documents to delete const searchResult = await membase_delete_wiki({ query: "outdated documentation" }); // Returns matching documents with IDs // Step 2: Delete after confirmation const deleteResult = await membase_delete_wiki({ query: "outdated documentation", doc_id: "doc-xyz789", confirm: true }); // Search within collection before deleting const collectionSearch = await membase_delete_wiki({ query: "old API docs", collection_id: "archived" }); ``` ``` -------------------------------- ### Logout from Membase CLI Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Disconnect from Membase and clear stored OAuth tokens by executing the logout command. ```bash # Clear credentials and disconnect openclaw membase logout ``` -------------------------------- ### EpisodeBundle Type Definition Source: https://context7.com/aristoapp/openclaw-membase/llms.txt Defines the structure of the EpisodeBundle, which is the primary response type for memory searches. It includes episode details, relevance scores, and related knowledge graph nodes and edges. ```typescript interface EpisodeBundle { episode: { uuid: string; name: string; labels?: string[]; summary: string | null; source: string | null; created_at: string | null; valid_at?: string | null; attributes?: Record<string, unknown>; }; relevance_score?: number | null; nodes?: NodeResponse[]; edges: { uuid: string; name: string; fact: string | null; source_node_uuid?: string; target_node_uuid?: string; created_at: string | null; }[]; } ```