OpenClaw Plugin Entry Point for TencentDB Agent Memory: Location and Architecture
The OpenClaw plugin entry point for TencentDB Agent Memory is located at MemoryCore/openclaw-plugin/index.ts, which serves as the main module loaded by the OpenClaw runtime to initialize the memory client, register capture/recall hooks, and expose memory management tools.
The TencentCloud/TencentDB-Agent-Memory repository provides a persistent memory layer for AI agents, and its OpenClaw integration allows seamless memory access via a dedicated plugin entry point. Understanding the exact file locations and initialization sequence is essential for developers extending, debugging, or manually installing the memory plugin.
Where to Find the OpenClaw Plugin Entry Point
Main Entry Point: MemoryCore/openclaw-plugin/index.ts
This TypeScript file is the primary module that OpenClaw executes when loading the plugin. It instantiates the MemoryClient from the @tencentdb-agent-memory/memory-sdk-ts-v2 SDK and wires the capture/recall lifecycle hooks that enable automatic memory persistence and retrieval.
Plugin Manifest: MemoryCore/openclaw-plugin/openclaw.plugin.json
Located in the same directory, this JSON manifest declares the plugin ID (memory-tencentdb-client), specifies the entry point path, and defines default configuration parameters. OpenClaw reads this manifest to determine how to bootstrap the plugin and what default settings to write to ~/.openclaw/openclaw.json during installation.
Installation Script: MemoryCore/scripts/install-openclaw-plugin.sh
This shell script automates the build and registration process. It executes npm install, compiles the TypeScript sources, and runs openclaw plugins install -l . to register the plugin with the local OpenClaw CLI, ensuring the entry point is properly linked to the runtime.
Architectural Flow: How the Plugin Integrates with OpenClaw
The integration follows a four-stage initialization sequence defined in the source code:
-
Plugin Loading: OpenClaw reads the manifest at [
openclaw.plugin.json](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/openclaw.plugin.json) and executes [index.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/index.ts). -
Client Initialization: The script creates a MemoryClient pointing to the MemoryCore gateway at
http://127.0.0.1:8420by default. -
Hook Registration: The plugin registers two critical hooks:
capture: InvokesaddConversation()after each turn to persist dialogue to L0 storage ([capture.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/src/hooks/capture.ts)).recall: CallssearchAtomic()andreadCore()before prompt construction to inject relevant context ([recall.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/src/hooks/recall.ts)).
-
Tool Exposure: Three built-in tools become available to the LLM:
tdai_memory_searchfor L1 structured memory retrieval ([memory-search.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/src/tools/memory-search.ts))tdai_conversation_searchfor L0 raw conversation queries ([conversation-search.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/src/tools/conversation-search.ts))tdai_read_cosfor reading scene-block or persona files via COS STS ([read-cos.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/src/tools/read-cos.ts))
Key Source Files and Implementation Details
The complete plugin architecture is distributed across the following modules:
- [
MemoryCore/openclaw-plugin/index.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/index.ts) — Main entry point that orchestrates client creation and registration. - [
MemoryCore/openclaw-plugin/openclaw.plugin.json](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/openclaw.plugin.json) — Manifest defining plugin metadata, entry path, and default configuration. - [
MemoryCore/openclaw-plugin/src/hooks/capture.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/src/hooks/capture.ts) — Implements the capture hook that persists conversation turns to L0 storage usingaddConversation(). - [
MemoryCore/openclaw-plugin/src/hooks/recall.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/src/hooks/recall.ts) — Implements the recall hook that searches memory viasearchAtomic()andreadCore()before injecting context into prompts. - [
MemoryCore/openclaw-plugin/src/tools/memory-search.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/src/tools/memory-search.ts) — L1 memory search tool implementation exposingtdai_memory_search. - [
MemoryCore/openclaw-plugin/src/tools/conversation-search.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/src/tools/conversation-search.ts) — L0 conversation search tool implementation exposingtdai_conversation_search. - [
MemoryCore/openclaw-plugin/src/tools/read-cos.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/src/tools/read-cos.ts) — COS file reader using STS temporary credentials, implementingtdai_read_cos. - [
MemoryCore/scripts/install-openclaw-plugin.sh](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/scripts/install-openclaw-plugin.sh) — Automated installation script that builds and registers the plugin.
Configuration and Usage Examples
To install the plugin using the automated script:
cd MemoryCore
bash scripts/install-openclaw-plugin.sh
This script compiles the TypeScript sources and registers the plugin with your local OpenClaw installation.
For manual configuration without the script, add the following configuration object to your ~/.openclaw/openclaw.json:
{
"plugins": {
"slots": { "memory": "memory-tencentdb-client" },
"entries": {
"memory-tencentdb-client": {
"enabled": true,
"hooks": {
"allowPromptInjection": true,
"allowConversationAccess": true
},
"config": {
"server": {
"url": "http://127.0.0.1:8420",
"apiKey": "local",
"instanceId": "default",
"teamId": "default",
"agentId": "default",
"userId": "default"
}
}
}
}
}
}
When interacting with the LLM, invoke memory tools using the following JSON structure:
{
"type": "toolCall",
"id": "tool-01",
"name": "tdai_memory_search",
"arguments": {
"query": "project status update",
"limit": 3,
"type": "episodic"
}
}
Summary
- The OpenClaw plugin entry point is [
MemoryCore/openclaw-plugin/index.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/index.ts), loaded via the manifest at [openclaw.plugin.json](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/openclaw.plugin.json). - The plugin initializes a MemoryClient connecting to the gateway at
http://127.0.0.1:8420and registers lifecycle hooks for automatic memory capture and recall. - Capture hooks persist conversation turns to L0 storage using
addConversation(), while recall hooks retrieve context viasearchAtomic()andreadCore(). - Three tools—
tdai_memory_search,tdai_conversation_search, andtdai_read_cos—expose memory operations directly to the LLM. - Use [
MemoryCore/scripts/install-openclaw-plugin.sh](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/scripts/install-openclaw-plugin.sh) to automate build, installation, and configuration.
Frequently Asked Questions
What is the exact file path for the OpenClaw plugin entry point in TencentDB Agent Memory?
The entry point is located at [MemoryCore/openclaw-plugin/index.ts](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/feat/server_team/MemoryCore/openclaw-plugin/index.ts) in the TencentCloud/TencentDB-Agent-Memory repository. This file exports the plugin initialization logic that OpenClaw executes when loading the memory-tencentdb-client plugin.
How does the OpenClaw plugin connect to the TencentDB Agent Memory gateway?
The plugin creates a MemoryClient instance from the @tencentdb-agent-memory/memory-sdk-ts-v2 SDK during initialization in index.ts. This client is configured to communicate with the MemoryCore gateway at http://127.0.0.1:8420 by default, handling all subsequent memory operations.
Which hooks does the OpenClaw plugin register for memory management?
The plugin registers two primary hooks. The capture hook calls addConversation() after each dialogue turn to write to L0 storage, while the recall hook executes searchAtomic() and readCore() before prompt generation to inject relevant historical context into the conversation.
Can I install the OpenClaw plugin without using the provided shell script?
Yes, you can manually install the plugin by running npm install and npm run build in the MemoryCore/openclaw-plugin directory, then executing openclaw plugins install -l . to register it locally. You must also manually add the plugin configuration to your ~/.openclaw/openclaw.json file following the schema shown in the configuration example.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →