@vainplex/openclaw-membrane 0.3.5 → 0.3.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.6] — 2026-03-04
4
+
5
+ ### Fixed
6
+ - **Agent-scoped memory retrieval.** Membrane now passes `agentId` from hook context to retrieval queries. Each agent only retrieves its own memories instead of seeing all agents' conversations. Prevents cross-agent memory injection in multi-agent setups. `actor_id` is set to `openclaw-{agentId}` and `scopes` filters by agent.
7
+
3
8
  ## [0.3.5] — 2026-03-04
4
9
 
5
10
  ### Fixed
package/dist/index.js CHANGED
@@ -41,14 +41,14 @@ export function validateConfig(raw) {
41
41
  return result;
42
42
  }
43
43
  // --- Retrieve helper ---
44
- async function retrieveMemories(client, query, config, fetchLimit) {
44
+ async function retrieveMemories(client, query, config, fetchLimit, agentId = 'main') {
45
45
  const request = {
46
46
  task_descriptor: query.substring(0, 500),
47
47
  trust: {
48
48
  max_sensitivity: config.retrieve_max_sensitivity,
49
49
  authenticated: true,
50
- actor_id: 'openclaw-main',
51
- scopes: [],
50
+ actor_id: `openclaw-${agentId}`,
51
+ scopes: [agentId],
52
52
  },
53
53
  memory_types: [],
54
54
  min_salience: config.retrieve_min_salience,
@@ -90,12 +90,12 @@ async function handleSearch(client, config, logger, params) {
90
90
  }
91
91
  }
92
92
  // --- Context hook handler ---
93
- async function handleContextInjection(client, config, logger, prompt) {
93
+ async function handleContextInjection(client, config, logger, prompt, agentId = 'main') {
94
94
  if (!prompt || prompt.length < 5)
95
95
  return undefined;
96
96
  try {
97
97
  const fetchLimit = Math.max(config.retrieve_limit * 10, 50);
98
- const result = await retrieveMemories(client, prompt, config, fetchLimit);
98
+ const result = await retrieveMemories(client, prompt, config, fetchLimit, agentId);
99
99
  if (!result?.records?.length)
100
100
  return undefined;
101
101
  const parsed = parseMembraneRecords(result.records, logger);
@@ -209,9 +209,11 @@ const plugin = {
209
209
  });
210
210
  // Context hook: auto-inject Membrane memories before agent starts
211
211
  if (config.retrieve_enabled) {
212
- api.on('before_agent_start', (event) => {
212
+ api.on('before_agent_start', (event, ctx) => {
213
213
  const e = event;
214
- return handleContextInjection(client, config, logger, e.prompt || e.message || '');
214
+ const hookCtx = ctx;
215
+ const agentId = hookCtx?.agentId || 'main';
216
+ return handleContextInjection(client, config, logger, e.prompt || e.message || '', agentId);
215
217
  });
216
218
  }
217
219
  // Shutdown: flush buffer, close client
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vainplex/openclaw-membrane",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "type": "module",
5
5
  "description": "Membrane gRPC bridge for OpenClaw — episodic memory ingestion, search tool, and auto-context injection via Membrane sidecar",
6
6
  "main": "dist/index.js",