docs: update README for OpenClaw with AI install guide
This commit is contained in:
190
README_EN.md
190
README_EN.md
@ -1,16 +1,61 @@
|
||||
# TrulyMEM - WaterFlow Adapter
|
||||
# TrulyMEM - OpenClaw Adapter
|
||||
|
||||
Give AI true long-term memory capability - WaterFlow framework adapter version
|
||||
Give AI true long-term memory capability - OpenClaw framework adapter version
|
||||
|
||||
[中文版本](./README.md)
|
||||
|
||||
---
|
||||
|
||||
## 🤖 AI Self-Installation Guide
|
||||
|
||||
> This section is for AI Agents, guiding them how to self-install this Skill to OpenClaw
|
||||
|
||||
### Installation Steps
|
||||
|
||||
#### Step 1: Locate Skill Directory
|
||||
|
||||
OpenClaw Skill precedence: `/.agents/skills/` > `~/.agents/skills/` > `~/.openclaw/skills/`
|
||||
|
||||
Copy the `skills/` directory to a high-priority location:
|
||||
|
||||
```bash
|
||||
# Method 1: User-level installation (recommended)
|
||||
cp -r skills/ ~/.agents/skills/graph_memory
|
||||
|
||||
# Method 2: System-level installation
|
||||
sudo cp -r skills/ /.agents/skills/graph_memory
|
||||
```
|
||||
|
||||
#### Step 2: Verify Installation
|
||||
|
||||
Invoke Skill in OpenClaw:
|
||||
|
||||
```
|
||||
Remember: I like programming and am learning TypeScript
|
||||
```
|
||||
|
||||
AI should receive a confirmation message.
|
||||
|
||||
#### Step 3: Use the Skill
|
||||
|
||||
After installation, AI can use these commands:
|
||||
|
||||
| Command | Function |
|
||||
|---------|----------|
|
||||
| `commit` | Commit memories |
|
||||
| `recall` | Retrieve memories |
|
||||
| `purge` | Delete memories |
|
||||
| `introspect` | Inspect status |
|
||||
| `persona_update/clear` | Persona management |
|
||||
| `task_create/set_state/delete` | Task management |
|
||||
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
This project ports TrulyMEM's graph memory capability to TypeScript for the WaterFlow framework.
|
||||
This project ports TrulyMEM's graph memory capability to TypeScript for the OpenClaw framework.
|
||||
|
||||
As a built-in module for WaterFlow, it provides graph memory functionality:
|
||||
As an OpenClaw Skill module, it provides graph memory functionality:
|
||||
|
||||
- **recall**: Retrieve memories
|
||||
- **commit**: Commit memories
|
||||
@ -29,45 +74,41 @@ ts/
|
||||
│ ├── graph_memory/ # Graph memory core module
|
||||
│ │ ├── types.ts # Type definitions
|
||||
│ │ ├── graph_database.ts # Graph database
|
||||
│ │ ├── memory_service.ts # Memory service
|
||||
│ │ └── index.ts # Module exports
|
||||
│ │ ├── memory_service.ts # Memory service
|
||||
│ │ └── index.ts # Module exports
|
||||
│ └── tools/
|
||||
│ └── builtin/
|
||||
│ └── graph_memory_tool.ts # Tool implementation
|
||||
│
|
||||
├── bundled-skills/ # Skill definitions
|
||||
│ └── graph_memory/
|
||||
│ ├── SKILL.md # Memory operations
|
||||
│ ├── persona/SKILL.md # Persona management
|
||||
│ └── task/SKILL.md # Task management
|
||||
│
|
||||
├── package.json # Project config
|
||||
└── tsconfig.json # TypeScript config
|
||||
├── package.json # Project config
|
||||
└── tsconfig.json # TypeScript config
|
||||
|
||||
skills/ # OpenClaw Skill definitions
|
||||
└── graph_memory/
|
||||
├── SKILL.md # Memory operations
|
||||
├── persona/SKILL.md # Persona management
|
||||
└── task/SKILL.md # Task management
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage in WaterFlow
|
||||
## Using in OpenClaw
|
||||
|
||||
This module supports two usage methods: **import as module** or **use as Skill**.
|
||||
### Method 1: As Module (for Developer Integration)
|
||||
|
||||
### Method 1: Import as Module (for developer integration)
|
||||
#### Step 1: Copy Source Code
|
||||
|
||||
#### Step 1: Copy source files
|
||||
|
||||
Copy the `ts/` directory to your WaterFlow project, for example:
|
||||
Copy the `ts/` directory to your OpenClaw project:
|
||||
|
||||
```
|
||||
your-waterflow-project/
|
||||
├── src/
|
||||
│ └── runtime/
|
||||
│ └── core/
|
||||
│ └── graph_memory/ # Copy from ts/src/runtime/core/
|
||||
└── ts/ # Or place in project root
|
||||
└── bundled-skills/ # Skill files
|
||||
yourOpenClawProject/
|
||||
└── src/
|
||||
└── runtime/
|
||||
└── core/
|
||||
└── graph_memory/ # Copy from ts/src/runtime/core/
|
||||
```
|
||||
|
||||
#### Step 2: Build TypeScript
|
||||
#### Step 2: Compile TypeScript
|
||||
|
||||
```bash
|
||||
cd ts/
|
||||
@ -75,104 +116,61 @@ npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
Compiled files will be output to `ts/dist/`.
|
||||
Compiled files output to `ts/dist/` directory.
|
||||
|
||||
#### Step 3: Import in your code
|
||||
#### Step 3: Import in Code
|
||||
|
||||
```typescript
|
||||
import { createGraphMemoryTool } from './runtime/core/tools/builtin/graph_memory_tool';
|
||||
|
||||
// Create tool instance, can pass sessionId to distinguish different sessions
|
||||
// Create tool instance
|
||||
const tool = createGraphMemoryTool('my-session-id');
|
||||
|
||||
// Prepare execution context
|
||||
const context = {
|
||||
toolCallId: 'call-123',
|
||||
workingDirectory: '/project',
|
||||
abortController: { signal: {} },
|
||||
config: { timeout: 30000 },
|
||||
logger: {
|
||||
info: console.log,
|
||||
warn: console.warn,
|
||||
error: console.error,
|
||||
debug: console.debug
|
||||
}
|
||||
};
|
||||
|
||||
// Commit memory example
|
||||
const commitResult = await tool.handler({
|
||||
action: 'commit',
|
||||
params: {
|
||||
triplets: [
|
||||
{ subject: 'User', relation: 'likes', object: 'Programming' },
|
||||
{ subject: 'User', relation: 'is learning', object: 'TypeScript' }
|
||||
{ subject: '用户', relation: '喜欢', object: '编程' },
|
||||
{ subject: '用户', relation: '正在学习', object: 'TypeScript' }
|
||||
]
|
||||
}
|
||||
}, context);
|
||||
|
||||
console.log(commitResult);
|
||||
// Output: {"success":true,"data":{"createdEntities":4,"createdRelations":2}}
|
||||
|
||||
// Recall memory example
|
||||
const recallResult = await tool.handler({
|
||||
action: 'recall',
|
||||
params: {
|
||||
queryIntent: 'User Programming'
|
||||
queryIntent: '用户 编程'
|
||||
}
|
||||
}, context);
|
||||
|
||||
console.log(recallResult);
|
||||
// Output: {"success":true,"data":{"entities":[...],"relations":[...],"message":"Found X entities, Y relations"}}
|
||||
```
|
||||
|
||||
### Method 2: Use Skill (recommended for AI Agent)
|
||||
### Method 2: Use Skill (Recommended for AI Agent)
|
||||
|
||||
#### Step 1: Configure Skill source
|
||||
#### Step 1: Place Skill Files
|
||||
|
||||
In your WaterFlow project, find the Skill configuration file and add bundled source pointing to this project's Skill directory:
|
||||
Copy `skills/` directory to OpenClaw's Skill directory:
|
||||
|
||||
```typescript
|
||||
// skill_interface.ts or config file
|
||||
import { DEFAULT_SKILL_LOADER_CONFIG } from './skill_interface';
|
||||
|
||||
const config = {
|
||||
...DEFAULT_SKILL_LOADER_CONFIG,
|
||||
sources: {
|
||||
...DEFAULT_SKILL_LOADER_CONFIG.sources,
|
||||
bundled: './ts/bundled-skills' // Point to this project's Skill directory
|
||||
},
|
||||
enabledSources: ['project', 'bundled']
|
||||
};
|
||||
```bash
|
||||
cp -r skills/ ~/.agents/skills/graph_memory
|
||||
```
|
||||
|
||||
#### Step 2: Call Skill via Agent
|
||||
#### Step 2: Invoke Skill
|
||||
|
||||
In your Agent or Workflow, call Skill via Tool:
|
||||
Use directly in OpenClaw:
|
||||
|
||||
```
|
||||
Use skill:graph_memory for:
|
||||
|
||||
1. Commit memory: I like programming, learning TypeScript
|
||||
2. Recall memory: Find memories related to me and programming
|
||||
```
|
||||
|
||||
Or call via code:
|
||||
|
||||
```typescript
|
||||
// Call via SkillTool
|
||||
const skillResult = await skillTool.handler({
|
||||
skill: 'graph_memory',
|
||||
args: 'recall - queryIntent: "User learning"'
|
||||
}, context);
|
||||
Use graph_memory to remember: I like programming and am learning TypeScript
|
||||
```
|
||||
|
||||
#### Available Skills
|
||||
|
||||
| Skill Name | Function | Use Case |
|
||||
|------------|----------|----------|
|
||||
| `graph_memory` | Memory CRUD | Read/Write/Delete memories |
|
||||
| `graph_memory_persona` | Persona management | Set AI role/personality |
|
||||
| `graph_memory_task` | Task management | Create/update long-term tasks |
|
||||
| `graph_memory` | Memory CRUD | Read/write/delete memories |
|
||||
| `graph_memory_persona` | Persona management | Set AI persona |
|
||||
| `graph_memory_task` | Task management | Create/update tasks |
|
||||
|
||||
---
|
||||
|
||||
@ -195,7 +193,7 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
| `persona_update` | Update persona | `attributes`, `mode` |
|
||||
| `persona_clear` | Clear persona | `confirm` |
|
||||
| `task_create` | Create task | `task_id`, `description`, `info_nodes` |
|
||||
| `task_set_state` | Set state | `task_id`, `state` |
|
||||
| `task_set_state` | Set task state | `task_id`, `state` |
|
||||
| `task_delete` | Delete task | `task_id` |
|
||||
|
||||
---
|
||||
@ -209,8 +207,8 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
"action": "commit",
|
||||
"params": {
|
||||
"triplets": [
|
||||
{ "subject": "User", "relation": "likes", "object": "TypeScript" },
|
||||
{ "subject": "User", "relation": "is learning", "object": "WaterFlow" }
|
||||
{ "subject": "用户", "relation": "喜欢", "object": "TypeScript" },
|
||||
{ "subject": "用户", "relation": "正在学习", "object": "OpenClaw" }
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -222,7 +220,7 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
{
|
||||
"action": "recall",
|
||||
"params": {
|
||||
"queryIntent": "User learning"
|
||||
"queryIntent": "用户 学习"
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -233,9 +231,9 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
{
|
||||
"action": "task_create",
|
||||
"params": {
|
||||
"task_id": "Task_LearnTypeScript",
|
||||
"description": "Learn TypeScript and complete project",
|
||||
"info_nodes": ["Documentation", "Tutorial"]
|
||||
"task_id": "Task_学习TypeScript",
|
||||
"description": "学习 TypeScript 并完成项目",
|
||||
"info_nodes": ["文档链接", "教程链接"]
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -244,4 +242,4 @@ const tool = new GraphMemoryTool(sessionId?: string);
|
||||
|
||||
## License
|
||||
|
||||
[GNU General Public License v3.0 (GPLv3)](LICENSE)
|
||||
[GNU General Public License v3.0 (GPLv3)](LICENSE)
|
||||
Reference in New Issue
Block a user