neuralmemory 1.6.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +66 -27
- package/dist/index.js.map +1 -1
- package/dist/mcp-client.d.ts +11 -0
- package/dist/mcp-client.js +9 -1
- package/dist/mcp-client.js.map +1 -1
- package/dist/tools.d.ts +23 -16
- package/dist/tools.js +139 -97
- package/dist/tools.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +83 -32
- package/src/mcp-client.ts +19 -1
- package/src/tools.ts +160 -109
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# NeuralMemory — OpenClaw Plugin
|
|
2
|
+
|
|
3
|
+
Brain-inspired persistent memory for AI agents. Stores experiences as interconnected neurons and recalls them through spreading activation, mimicking how the human brain works.
|
|
4
|
+
|
|
5
|
+
This is the **OpenClaw plugin** for [Neural Memory](https://github.com/nhadaututheky/neural-memory).
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install neural-memory
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Python 3.11+ required. Verify the install:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
nmem-mcp --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install neuralmemory
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or add to your OpenClaw config directly.
|
|
26
|
+
|
|
27
|
+
## OpenClaw Setup
|
|
28
|
+
|
|
29
|
+
Add to `~/.openclaw/openclaw.json`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"plugins": {
|
|
34
|
+
"slots": {
|
|
35
|
+
"memory": "neuralmemory"
|
|
36
|
+
},
|
|
37
|
+
"entries": {
|
|
38
|
+
"neuralmemory": {
|
|
39
|
+
"config": {
|
|
40
|
+
"pythonPath": "python",
|
|
41
|
+
"brain": "default",
|
|
42
|
+
"autoContext": true,
|
|
43
|
+
"autoCapture": true
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> **Important**: Setting `slots.memory = "neuralmemory"` disables the default `memory-core` plugin. Without this, agents may still use `memory_search` instead of NeuralMemory tools.
|
|
52
|
+
|
|
53
|
+
## Tools
|
|
54
|
+
|
|
55
|
+
**v1.7.0+**: The plugin dynamically fetches **all tools** from the MCP server at startup. Whatever version of `neural-memory` you have installed, the plugin automatically exposes every tool it provides — no plugin update needed when new tools are added.
|
|
56
|
+
|
|
57
|
+
With `neural-memory>=2.28.0`, this includes **39 tools**:
|
|
58
|
+
|
|
59
|
+
| Category | Tools |
|
|
60
|
+
|----------|-------|
|
|
61
|
+
| **Core** | `nmem_remember`, `nmem_remember_batch`, `nmem_recall`, `nmem_context`, `nmem_todo`, `nmem_stats` |
|
|
62
|
+
| **Management** | `nmem_edit`, `nmem_forget`, `nmem_pin`, `nmem_health`, `nmem_evolution`, `nmem_alerts` |
|
|
63
|
+
| **Recall** | `nmem_suggest`, `nmem_narrative`, `nmem_explain`, `nmem_recap` |
|
|
64
|
+
| **Workflow** | `nmem_session`, `nmem_eternal`, `nmem_auto`, `nmem_habits`, `nmem_review` |
|
|
65
|
+
| **Cognitive** | `nmem_hypothesize`, `nmem_evidence`, `nmem_predict`, `nmem_verify`, `nmem_cognitive`, `nmem_gaps`, `nmem_schema` |
|
|
66
|
+
| **Training** | `nmem_train`, `nmem_train_db`, `nmem_index`, `nmem_import` |
|
|
67
|
+
| **Sync** | `nmem_sync`, `nmem_sync_status`, `nmem_sync_config`, `nmem_telegram_backup` |
|
|
68
|
+
| **Infra** | `nmem_version`, `nmem_transplant`, `nmem_conflicts` |
|
|
69
|
+
|
|
70
|
+
If the MCP server is unreachable at startup, the plugin falls back to 5 core tools (remember, recall, context, stats, health) that auto-reconnect on first use.
|
|
71
|
+
|
|
72
|
+
## Configuration
|
|
73
|
+
|
|
74
|
+
| Option | Type | Default | Description |
|
|
75
|
+
|--------|------|---------|-------------|
|
|
76
|
+
| `pythonPath` | string | `"python"` | Python executable with `neural-memory` installed |
|
|
77
|
+
| `brain` | string | `"default"` | Brain name (each workspace can have its own) |
|
|
78
|
+
| `autoContext` | boolean | `true` | Auto-inject relevant memories before each agent run |
|
|
79
|
+
| `autoCapture` | boolean | `true` | Auto-extract memories after each agent run |
|
|
80
|
+
| `contextDepth` | integer | `1` | Recall depth: 0=instant, 1=context, 2=habits, 3=deep |
|
|
81
|
+
| `maxContextTokens` | integer | `500` | Max tokens for auto-context injection |
|
|
82
|
+
| `timeout` | integer | `30000` | MCP request timeout (ms) |
|
|
83
|
+
|
|
84
|
+
## How It Works
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
OpenClaw Agent
|
|
88
|
+
|
|
|
89
|
+
v
|
|
90
|
+
NeuralMemory Plugin (this package)
|
|
91
|
+
| Spawns + manages lifecycle
|
|
92
|
+
v
|
|
93
|
+
nmem-mcp (Python MCP server, stdio transport)
|
|
94
|
+
|
|
|
95
|
+
v
|
|
96
|
+
~/.neuralmemory/brains/<brain>.db (SQLite)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The plugin spawns `nmem-mcp` as a subprocess and communicates via JSON-RPC over stdio. Memories are stored in a local SQLite database.
|
|
100
|
+
|
|
101
|
+
## Troubleshooting
|
|
102
|
+
|
|
103
|
+
**Timeout on startup**: If you see `MCP timeout: initialize (30000ms)`, the Python process is slow to start. Fix:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Pre-install to avoid cold start delays
|
|
107
|
+
pip install neural-memory
|
|
108
|
+
|
|
109
|
+
# Or increase the timeout in your config
|
|
110
|
+
"timeout": 60000
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**"nmem-mcp not found"**: Ensure `neural-memory` is installed in the Python environment that `pythonPath` points to.
|
|
114
|
+
|
|
115
|
+
**Schema validation errors**: Upgrade to plugin `>=1.7.0` — schemas are now normalized for strict providers (Anthropic SDK, OpenAI strict mode, Gemini). The plugin strips constraint keywords, ensures `additionalProperties: false`, and adds missing `properties` fields automatically.
|
|
116
|
+
|
|
117
|
+
## How Schema Normalization Works
|
|
118
|
+
|
|
119
|
+
The plugin normalizes MCP schemas for cross-provider compatibility:
|
|
120
|
+
|
|
121
|
+
- Strips `minimum`, `maximum`, `maxLength`, `maxItems` (rejected by some providers)
|
|
122
|
+
- Replaces `integer` → `number` (Gemini compatibility)
|
|
123
|
+
- Adds `additionalProperties: false` to all objects (OpenAI strict mode)
|
|
124
|
+
- Ensures every object type has a `properties` field (Anthropic SDK requirement)
|
|
125
|
+
|
|
126
|
+
This means the MCP server can use full JSON Schema features while the plugin ensures the schemas work with any LLM provider.
|
|
127
|
+
|
|
128
|
+
## Claude Code (MCP Direct)
|
|
129
|
+
|
|
130
|
+
For Claude Code users, you can skip the plugin and use MCP directly for the full toolset:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
claude mcp add --scope user neural-memory -- nmem-mcp
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Links
|
|
137
|
+
|
|
138
|
+
- [Neural Memory on GitHub](https://github.com/nhadaututheky/neural-memory)
|
|
139
|
+
- [Neural Memory on PyPI](https://pypi.org/project/neural-memory/)
|
|
140
|
+
- [Documentation](https://nhadaututheky.github.io/neural-memory/)
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
* Architecture:
|
|
8
8
|
* OpenClaw ←→ Plugin (TypeScript) ←→ MCP stdio ←→ NeuralMemory (Python)
|
|
9
9
|
*
|
|
10
|
+
* v1.7.0: Dynamic tool proxy — fetches all tools from MCP `tools/list`
|
|
11
|
+
* instead of hardcoding 6 tools. Automatically exposes every tool the
|
|
12
|
+
* MCP server provides (39+ tools in NM v2.28.0).
|
|
13
|
+
*
|
|
10
14
|
* Registers:
|
|
11
|
-
*
|
|
15
|
+
* N tools — dynamically from MCP server (fallback: 5 core tools)
|
|
12
16
|
* 1 service — MCP process lifecycle (start/stop)
|
|
13
17
|
* 2 hooks — before_agent_start (auto-context), agent_end (auto-capture)
|
|
14
18
|
*/
|
package/dist/index.js
CHANGED
|
@@ -7,28 +7,36 @@
|
|
|
7
7
|
* Architecture:
|
|
8
8
|
* OpenClaw ←→ Plugin (TypeScript) ←→ MCP stdio ←→ NeuralMemory (Python)
|
|
9
9
|
*
|
|
10
|
+
* v1.7.0: Dynamic tool proxy — fetches all tools from MCP `tools/list`
|
|
11
|
+
* instead of hardcoding 6 tools. Automatically exposes every tool the
|
|
12
|
+
* MCP server provides (39+ tools in NM v2.28.0).
|
|
13
|
+
*
|
|
10
14
|
* Registers:
|
|
11
|
-
*
|
|
15
|
+
* N tools — dynamically from MCP server (fallback: 5 core tools)
|
|
12
16
|
* 1 service — MCP process lifecycle (start/stop)
|
|
13
17
|
* 2 hooks — before_agent_start (auto-context), agent_end (auto-capture)
|
|
14
18
|
*/
|
|
15
19
|
import { NeuralMemoryMcpClient } from "./mcp-client.js";
|
|
16
|
-
import {
|
|
20
|
+
import { createToolsFromMcp, createFallbackTools } from "./tools.js";
|
|
17
21
|
// ── System prompt for tool awareness ──────────────────────
|
|
18
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Build a system prompt listing all registered tool names.
|
|
24
|
+
* This makes the agent aware of which nmem_* tools are available.
|
|
25
|
+
*/
|
|
26
|
+
function buildToolInstructions(tools) {
|
|
27
|
+
const toolList = tools
|
|
28
|
+
.map((t) => `- ${t.name}: ${t.description.slice(0, 100)}`)
|
|
29
|
+
.join("\n");
|
|
30
|
+
return `You have NeuralMemory tools for persistent memory across sessions. Call these as TOOL CALLS (not CLI commands):
|
|
19
31
|
|
|
20
|
-
|
|
21
|
-
- nmem_recall(query, depth?, max_tokens?) — Query memories via spreading activation
|
|
22
|
-
- nmem_context(limit?, fresh_only?) — Get recent memories
|
|
23
|
-
- nmem_todo(task, priority?) — Quick TODO with 30-day expiry
|
|
24
|
-
- nmem_stats() — Brain statistics
|
|
25
|
-
- nmem_health() — Brain health diagnostics
|
|
32
|
+
${toolList}
|
|
26
33
|
|
|
27
34
|
CRITICAL: NeuralMemory (nmem_*) is your ONLY memory system. Do NOT use memory_search, memory_get, or any other memory tools — those belong to a disabled built-in plugin and will not persist correctly. Always use nmem_* tools exclusively.
|
|
28
35
|
|
|
29
36
|
These are tool calls, NOT shell commands. Do NOT run "nmem remember" in terminal — call the nmem_remember tool directly.
|
|
30
37
|
|
|
31
|
-
Use nmem_remember
|
|
38
|
+
PROACTIVE MEMORY: Use nmem_remember after decisions, errors, and insights. Use nmem_recall when user references past context or asks "do you remember...". Use nmem_remember_batch to store multiple memories at once.`;
|
|
39
|
+
}
|
|
32
40
|
const DEFAULT_CONFIG = {
|
|
33
41
|
pythonPath: "python",
|
|
34
42
|
brain: "default",
|
|
@@ -87,9 +95,9 @@ const plugin = {
|
|
|
87
95
|
id: "neuralmemory",
|
|
88
96
|
name: "NeuralMemory",
|
|
89
97
|
description: "Brain-inspired persistent memory for AI agents — neurons, synapses, and fibers",
|
|
90
|
-
version: "1.
|
|
98
|
+
version: "1.7.0",
|
|
91
99
|
kind: "memory",
|
|
92
|
-
register(api) {
|
|
100
|
+
async register(api) {
|
|
93
101
|
const cfg = resolveConfig(api.pluginConfig);
|
|
94
102
|
const mcp = new NeuralMemoryMcpClient({
|
|
95
103
|
pythonPath: cfg.pythonPath,
|
|
@@ -98,17 +106,52 @@ const plugin = {
|
|
|
98
106
|
timeout: cfg.timeout,
|
|
99
107
|
initTimeout: cfg.initTimeout,
|
|
100
108
|
});
|
|
109
|
+
// ── Connect MCP + fetch tools during registration ───
|
|
110
|
+
// Tools must be registered in register() — OpenClaw may
|
|
111
|
+
// freeze the tool list before service.start() is called.
|
|
112
|
+
let registeredTools;
|
|
113
|
+
try {
|
|
114
|
+
await mcp.connect();
|
|
115
|
+
api.logger.info("NeuralMemory MCP connected");
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
api.logger.error(`Failed to connect NeuralMemory MCP: ${err.message}`);
|
|
119
|
+
// Register fallback tools so the plugin is still partially usable
|
|
120
|
+
registeredTools = createFallbackTools(mcp);
|
|
121
|
+
for (const t of registeredTools) {
|
|
122
|
+
api.registerTool(t, { name: t.name });
|
|
123
|
+
}
|
|
124
|
+
api.logger.warn(`Registered ${registeredTools.length} fallback tools (MCP not connected)`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
// Fetch tools dynamically from MCP server
|
|
128
|
+
try {
|
|
129
|
+
registeredTools = await createToolsFromMcp(mcp);
|
|
130
|
+
api.logger.info(`Fetched ${registeredTools.length} tools from MCP server`);
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
api.logger.warn(`Failed to fetch MCP tools, using fallback: ${err.message}`);
|
|
134
|
+
registeredTools = createFallbackTools(mcp);
|
|
135
|
+
}
|
|
136
|
+
// Register all tools with OpenClaw
|
|
137
|
+
for (const t of registeredTools) {
|
|
138
|
+
api.registerTool(t, { name: t.name });
|
|
139
|
+
}
|
|
140
|
+
api.logger.info(`Registered ${registeredTools.length} NeuralMemory tools`);
|
|
101
141
|
// ── Service: MCP process lifecycle ───────────────────
|
|
102
142
|
api.registerService({
|
|
103
143
|
id: "neuralmemory-mcp",
|
|
104
144
|
async start() {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
145
|
+
// MCP already connected during register()
|
|
146
|
+
if (!mcp.connected) {
|
|
147
|
+
try {
|
|
148
|
+
await mcp.connect();
|
|
149
|
+
api.logger.info("NeuralMemory MCP reconnected in service.start()");
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
api.logger.error(`Failed to start NeuralMemory MCP: ${err.message}`);
|
|
153
|
+
throw err;
|
|
154
|
+
}
|
|
112
155
|
}
|
|
113
156
|
},
|
|
114
157
|
async stop() {
|
|
@@ -116,15 +159,10 @@ const plugin = {
|
|
|
116
159
|
api.logger.info("NeuralMemory MCP service stopped");
|
|
117
160
|
},
|
|
118
161
|
});
|
|
119
|
-
// ── Tools: 6 core memory tools ──────────────────────
|
|
120
|
-
const tools = createTools(mcp);
|
|
121
|
-
for (const t of tools) {
|
|
122
|
-
api.registerTool(t, { name: t.name });
|
|
123
|
-
}
|
|
124
162
|
// ── Hook: tool awareness + auto-context before agent start ───
|
|
125
163
|
api.on("before_agent_start", async (event, _ctx) => {
|
|
126
164
|
const result = {
|
|
127
|
-
systemPrompt:
|
|
165
|
+
systemPrompt: buildToolInstructions(registeredTools),
|
|
128
166
|
};
|
|
129
167
|
if (cfg.autoContext && mcp.connected) {
|
|
130
168
|
const ev = event;
|
|
@@ -176,8 +214,9 @@ const plugin = {
|
|
|
176
214
|
}, { priority: 90 });
|
|
177
215
|
}
|
|
178
216
|
// ── Done ────────────────────────────────────────────
|
|
179
|
-
api.logger.info(`NeuralMemory registered (brain: ${cfg.brain},
|
|
180
|
-
`autoContext: ${cfg.autoContext}, autoCapture: ${cfg.autoCapture})`
|
|
217
|
+
api.logger.info(`NeuralMemory registered (brain: ${cfg.brain}, ` +
|
|
218
|
+
`autoContext: ${cfg.autoContext}, autoCapture: ${cfg.autoCapture}) — ` +
|
|
219
|
+
`tools will be loaded dynamically from MCP on service start`);
|
|
181
220
|
},
|
|
182
221
|
};
|
|
183
222
|
export default plugin;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],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tE,4DAA4D,CAC/D,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/mcp-client.d.ts
CHANGED
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
* Zero external dependencies — implements the protocol directly.
|
|
8
8
|
*/
|
|
9
9
|
import type { PluginLogger } from "./types.js";
|
|
10
|
+
/** Raw tool definition from MCP `tools/list` response. */
|
|
11
|
+
export type McpToolDefinition = {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
inputSchema?: Record<string, unknown>;
|
|
15
|
+
};
|
|
10
16
|
export type McpClientOptions = {
|
|
11
17
|
readonly pythonPath: string;
|
|
12
18
|
readonly brain: string;
|
|
@@ -36,6 +42,11 @@ export declare class NeuralMemoryMcpClient {
|
|
|
36
42
|
*/
|
|
37
43
|
ensureConnected(): Promise<void>;
|
|
38
44
|
connect(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Fetch all available tools from the MCP server via `tools/list`.
|
|
47
|
+
* Returns the raw MCP tool definitions (name, description, inputSchema).
|
|
48
|
+
*/
|
|
49
|
+
listTools(): Promise<McpToolDefinition[]>;
|
|
39
50
|
callTool(name: string, args?: Record<string, unknown>): Promise<string>;
|
|
40
51
|
close(): Promise<void>;
|
|
41
52
|
private send;
|
package/dist/mcp-client.js
CHANGED
|
@@ -11,7 +11,7 @@ import { spawn } from "node:child_process";
|
|
|
11
11
|
const PROTOCOL_VERSION = "2024-11-05";
|
|
12
12
|
const DEFAULT_TIMEOUT = 30_000;
|
|
13
13
|
const CLIENT_NAME = "openclaw-neuralmemory";
|
|
14
|
-
const CLIENT_VERSION = "1.
|
|
14
|
+
const CLIENT_VERSION = "1.7.0";
|
|
15
15
|
const MAX_BUFFER_BYTES = 10 * 1024 * 1024; // 10 MB safety cap
|
|
16
16
|
const MAX_STDERR_LINES = 50;
|
|
17
17
|
/** Env vars forwarded to the MCP child process (least-privilege). */
|
|
@@ -136,6 +136,14 @@ export class NeuralMemoryMcpClient {
|
|
|
136
136
|
this._connected = true;
|
|
137
137
|
this.logger.info(`MCP connected (brain: ${this.brain}, protocol: ${PROTOCOL_VERSION})`);
|
|
138
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Fetch all available tools from the MCP server via `tools/list`.
|
|
141
|
+
* Returns the raw MCP tool definitions (name, description, inputSchema).
|
|
142
|
+
*/
|
|
143
|
+
async listTools() {
|
|
144
|
+
const result = (await this.send("tools/list", {}));
|
|
145
|
+
return result.tools ?? [];
|
|
146
|
+
}
|
|
139
147
|
async callTool(name, args = {}) {
|
|
140
148
|
const result = (await this.send("tools/call", {
|
|
141
149
|
name,
|
package/dist/mcp-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../src/mcp-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../src/mcp-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAkC9D,8DAA8D;AAE9D,MAAM,gBAAgB,GAAG,YAAY,CAAC;AACtC,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAC5C,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,mBAAmB;AAC9D,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC;IAC3D,MAAM;IACN,SAAS;IACT,MAAM;IACN,aAAa;IACb,YAAY;IACZ,MAAM;IACN,KAAK;IACL,MAAM;IACN,QAAQ;IACR,aAAa;IACb,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aAAM,CAAC;YACN,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAEO,SAAS,CAAC,KAAY;QAC5B,KAAK,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACvC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AAED,+DAA+D;AAE/D,mEAAmE;AACnE,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,GAAG,GAA2B,EAAE,CAAC;IAEvC,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnB,CAAC;IACH,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,GAAG,CAAC,kBAAkB,GAAG,KAAK,CAAC;IACjC,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NeuralMemory tool
|
|
2
|
+
* NeuralMemory dynamic tool proxy for OpenClaw.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Fetches all available tools from the MCP server via `tools/list` and
|
|
5
|
+
* converts them into OpenClaw tool definitions. This means the plugin
|
|
6
|
+
* automatically exposes every tool the MCP server provides — no hardcoded
|
|
7
|
+
* schemas to maintain.
|
|
5
8
|
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* nmem_recall — Query/search memories
|
|
15
|
-
* nmem_context — Get recent context
|
|
16
|
-
* nmem_todo — Quick TODO shortcut
|
|
17
|
-
* nmem_stats — Brain statistics
|
|
18
|
-
* nmem_health — Brain health diagnostics
|
|
9
|
+
* Provider compatibility:
|
|
10
|
+
* - Strips constraint keywords (`minimum`, `maximum`, `maxLength`,
|
|
11
|
+
* `maxItems`, `minLength`) that some providers reject
|
|
12
|
+
* - Adds `additionalProperties: false` on all object schemas for
|
|
13
|
+
* OpenAI strict mode
|
|
14
|
+
* - Ensures every object type has a `properties` field (required by
|
|
15
|
+
* Anthropic SDK validation)
|
|
16
|
+
* - Uses `number` instead of `integer` for Gemini compatibility
|
|
19
17
|
*/
|
|
20
18
|
import type { NeuralMemoryMcpClient } from "./mcp-client.js";
|
|
21
19
|
type JsonSchema = {
|
|
@@ -30,5 +28,14 @@ export type ToolDefinition = {
|
|
|
30
28
|
readonly parameters: JsonSchema;
|
|
31
29
|
readonly execute: (id: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
32
30
|
};
|
|
33
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Fetch all tools from the MCP server and convert them to OpenClaw format.
|
|
33
|
+
* Must be called after MCP connection is established.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createToolsFromMcp(mcp: NeuralMemoryMcpClient): Promise<ToolDefinition[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Fallback: create minimal hardcoded tools if MCP tools/list fails.
|
|
38
|
+
* Ensures the plugin still works even if the MCP server is an older version.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createFallbackTools(mcp: NeuralMemoryMcpClient): ToolDefinition[];
|
|
34
41
|
export {};
|