Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<h1 align="center">Membase Plugin for OpenClaw</h1>

[![Membase banner](https://github.com/user-attachments/assets/19393af8-7af0-4e8f-9967-b5c9d8119d83)](https://membase.so/?utm_source=github&utm_medium=openclaw-membase)

<p align="center">
Persistent long-term memory for OpenClaw using hybrid vector search and a knowledge graph.
</p>
Expand All @@ -20,7 +18,7 @@

Give your [OpenClaw](https://openclaw.ai/) agent persistent memory that survives across sessions. Membase uses hybrid vector search + knowledge graph to remember not just text, but entities, relationships, and facts.

> **Free to start** Sign up at [app.membase.so](https://app.membase.so) and connect in under a minute.
> **Free to start** - Sign up at [app.membase.so](https://app.membase.so) and connect in under a minute.

## Install

Expand Down Expand Up @@ -77,7 +75,7 @@ The agent uses these tools autonomously during conversations:

| Tool | Description |
| --- | --- |
| `membase_search` | Search memories by semantic similarity. Supports date filtering (`date_from`, `date_to`, `timezone`) and source filtering (`sources` integrations, AI clients including `codex`/`hermes`, imports, `notion`, and other sources). Returns episode bundles with related facts and relevance scores. |
| `membase_search` | Search memories by semantic similarity. Supports date filtering (`date_from`, `date_to`, `timezone`) and source filtering (`sources` - integrations, AI clients including `codex`/`hermes`, imports, `notion`, and other sources). Returns episode bundles with related facts and relevance scores. |
| `membase_get_current_date` | Return runtime local and UTC time before converting relative dates into `date_from`/`date_to`. |
| `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). |
Expand All @@ -87,10 +85,14 @@ The agent uses these tools autonomously during conversations:
| `membase_update_wiki` | Update title/content/Project for an existing wiki document. Set Project to `null` to move to Basic. Reports the returned destination. |
| `membase_delete_wiki` | Delete a wiki document with confirmation flow. |

## Example Workflows

- [Remember reviewed public X/Twitter signals from TweetClaw](./examples/tweetclaw-x-memory.md) - gather public X context with TweetClaw, then store reviewed summaries and source URLs in Membase Wiki.

## CLI Commands

```bash
openclaw membase login # OAuth login (PKCE) opens browser
openclaw membase login # OAuth login (PKCE) - opens browser
openclaw membase logout # Remove stored tokens
openclaw membase search <query> # Search memories
openclaw membase search <query> -s slack,gmail # Filter by source
Expand Down Expand Up @@ -175,14 +177,14 @@ bun run build

## Contributing

Contributions welcome see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
Contributions welcome - see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.

## Links

- [Membase](https://membase.so/?utm_source=github&utm_medium=openclaw-membase) Website
- [Dashboard](https://app.membase.so) Manage your memories
- [Docs](https://docs.membase.so) Full documentation
- [OpenClaw](https://openclaw.ai/) AI agent framework
- [Membase](https://membase.so/?utm_source=github&utm_medium=openclaw-membase) - Website
- [Dashboard](https://app.membase.so) - Manage your memories
- [Docs](https://docs.membase.so) - Full documentation
- [OpenClaw](https://openclaw.ai/) - AI agent framework

## License

Expand Down
63 changes: 63 additions & 0 deletions examples/tweetclaw-x-memory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Remember Reviewed X/Twitter Signals From TweetClaw

Use this workflow when the same OpenClaw workspace needs structured public X/Twitter data and persistent memory. TweetClaw gathers the public source material, then Membase stores reviewed summaries, source URLs, and follow-up decisions.

## Install The Plugins

```bash
openclaw plugins install clawhub:@xquik/tweetclaw
openclaw plugins install @membase/openclaw-membase
openclaw config set tools.alsoAllow '["explore", "tweetclaw", "openclaw-membase"]'
```

Keep credentials in the plugin that owns them:

- TweetClaw keeps `XQUIK_API_KEY` in its OpenClaw plugin configuration. Never
paste the key into chats, prompts, logs, or memory.
- Membase keeps OAuth tokens in its `tokenFile`, outside the plugin directory.
- Do not store API keys, OAuth tokens, direct message contents, or raw private account exports in memory.

## Capture Public Signals

Use TweetClaw's free `explore` tool to identify the right endpoint, then use
the optional `tweetclaw` tool for public X/Twitter source material:

- Search tweets or search tweet replies for a launch, incident, competitor, keyword, or support topic.
- Monitor tweets and webhooks for recurring public mentions.
- Export public follower context or run user lookup when the audience or author matters.
- Record giveaway draw results with the source tweet URL and draw criteria.
- Use post tweets or post tweet replies only after the OpenClaw user approves the visible action.

## Store A Reviewed Wiki Document

After reviewing the TweetClaw result, use `membase_add_wiki` to store a compact
document in a Project such as `X Research`. Include:

- Source: `tweetclaw`
- Capture date
- Tweet URL or tweet ID
- Author handle when relevant
- Short summary
- Sentiment or category if useful
- Next action or decision

Example memory content:

```text
Source: TweetClaw
Captured: YYYY-MM-DD
Topic: billing launch feedback
Source URLs: https://x.com/example/status/123
Summary: Users asked whether annual plans include API credits.
Decision: Update the launch FAQ before the next announcement.
```

## Recall Later

Use `membase_search_wiki` to recover the reviewed X/Twitter context without
fetching every source again. `autoWikiRecall` can inject relevant Wiki context
automatically. Keep each document durable and compact: store facts, source URLs,
and decisions, not full timelines or private data.

Xquik is an independent third-party service. Not affiliated with X Corp.
"Twitter" and "X" are trademarks of X Corp.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"overrides": {
"tar": "7.5.16"
},
"description": "Membase plugin for OpenClaw persistent long-term memory for AI agents",
"description": "Membase plugin for OpenClaw - persistent long-term memory for AI agents",
"files": [
"dist/",
"src/client.ts",
Expand All @@ -33,6 +33,7 @@
"src/utils.ts",
"src/wiki-project.ts",
"skills/",
"examples/",
"index.ts",
"openclaw.plugin.json"
],
Expand Down
10 changes: 10 additions & 0 deletions src/hooks/capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ const pendingDocumentBuffers = new Map<
const silenceTimers = new Map<string, ReturnType<typeof setTimeout>>();
let flushSequence = 0;

export function clearCaptureState(): void {
for (const timer of silenceTimers.values()) {
clearTimeout(timer);
}
messageBuffers.clear();
pendingDocumentBuffers.clear();
silenceTimers.clear();
flushSequence = 0;
}

function getChannelKey(event: Record<string, unknown>): string {
// Prefer the top-level sessionKey from newer OpenClaw event payloads.
// Fall back to the legacy session object shape, then to "default".
Expand Down
7 changes: 6 additions & 1 deletion src/membase-tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
resolveTokenFilePath,
} from "./config";
import { formatBundles, formatWikiDocument } from "./format";
import { flushAllBuffers, registerCaptureHook } from "./hooks/capture";
import {
clearCaptureState,
flushAllBuffers,
registerCaptureHook,
} from "./hooks/capture";
import { registerAddWikiTool } from "./tools/add-wiki";
import {
buildCurrentDateText,
Expand All @@ -23,6 +27,7 @@ const originalFetch = globalThis.fetch;

afterEach(() => {
globalThis.fetch = originalFetch;
clearCaptureState();
});

function makeApi(): { api: OpenClawPluginApi; tools: ToolDefinition[] } {
Expand Down
11 changes: 8 additions & 3 deletions src/tools/add-wiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ export function registerAddWikiTool(
return await toolResponse(`Add wiki failed: ${projectInput.error}`);
}
if (looksSensitive(params.content)) {
return await toolResponse(
"Add wiki failed: content appears to contain secrets or private credentials. Redact it before saving.",
);
return {
content: [
{
type: "text" as const,
text: "Add wiki failed: content appears to contain secrets or private credentials. Redact it before saving.",
},
],
};
}
const doc = await client.createWikiDocument(
params.title,
Expand Down
11 changes: 8 additions & 3 deletions src/tools/update-wiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ export function registerUpdateWikiTool(
typeof params.content === "string" &&
looksSensitive(params.content)
) {
return await toolResponse(
"Update wiki failed: content appears to contain secrets or private credentials. Redact it before saving.",
);
return {
content: [
{
type: "text" as const,
text: "Update wiki failed: content appears to contain secrets or private credentials. Redact it before saving.",
},
],
};
}

const updates: Parameters<MembaseClient["updateWikiDocument"]>[1] = {
Expand Down