@memorilabs/openclaw-memori 0.0.5 → 0.0.6-beta

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.
Files changed (45) hide show
  1. package/README.md +123 -96
  2. package/dist/cli/commands.d.ts +2 -0
  3. package/dist/cli/commands.js +143 -0
  4. package/dist/cli/config-file.d.ts +8 -0
  5. package/dist/cli/config-file.js +64 -0
  6. package/dist/constants.d.ts +12 -1
  7. package/dist/constants.js +12 -1
  8. package/dist/handlers/augmentation.d.ts +4 -0
  9. package/dist/handlers/augmentation.js +150 -45
  10. package/dist/index.js +13 -4
  11. package/dist/sanitizer.d.ts +1 -0
  12. package/dist/sanitizer.js +10 -2
  13. package/dist/tools/index.d.ts +4 -0
  14. package/dist/tools/index.js +16 -0
  15. package/dist/tools/memori-compaction.d.ts +35 -0
  16. package/dist/tools/memori-compaction.js +119 -0
  17. package/dist/tools/memori-feedback.d.ts +25 -0
  18. package/dist/tools/memori-feedback.js +40 -0
  19. package/dist/tools/memori-quota.d.ts +17 -0
  20. package/dist/tools/memori-quota.js +55 -0
  21. package/dist/tools/memori-recall-summary.d.ts +39 -0
  22. package/dist/tools/memori-recall-summary.js +58 -0
  23. package/dist/tools/memori-recall.d.ts +51 -0
  24. package/dist/tools/memori-recall.js +123 -0
  25. package/dist/tools/memori-signup.d.ts +25 -0
  26. package/dist/tools/memori-signup.js +72 -0
  27. package/dist/tools/types.d.ts +8 -0
  28. package/dist/tools/types.js +1 -0
  29. package/dist/types.d.ts +19 -1
  30. package/dist/utils/context.d.ts +4 -2
  31. package/dist/utils/context.js +4 -2
  32. package/dist/utils/index.d.ts +2 -1
  33. package/dist/utils/index.js +2 -1
  34. package/dist/utils/memori-client.d.ts +11 -0
  35. package/dist/utils/memori-client.js +20 -2
  36. package/dist/utils/skills-loader.d.ts +6 -0
  37. package/dist/utils/skills-loader.js +14 -0
  38. package/dist/version.d.ts +1 -1
  39. package/dist/version.js +1 -1
  40. package/openclaw.plugin.json +22 -2
  41. package/package.json +3 -2
  42. package/skills/clawhub/SKILL.md +221 -0
  43. package/skills/memori/SKILL.md +355 -0
  44. package/dist/handlers/recall.d.ts +0 -5
  45. package/dist/handlers/recall.js +0 -34
@@ -0,0 +1,221 @@
1
+ ---
2
+ name: memori
3
+ id: '@memorilabs/openclaw-memori'
4
+ description: Agent-native memory for OpenClaw that structures memory from agent trace, execution history, decisions, tool calls, and conversations into durable long-term memory primitives.
5
+ license: Apache-2.0
6
+ homepage: https://github.com/MemoriLabs/Memori
7
+ repository: https://github.com/MemoriLabs/Memori.git
8
+ compatibility:
9
+ - openclaw
10
+ metadata:
11
+ openclaw:
12
+ requires:
13
+ env:
14
+ - MEMORI_API_KEY
15
+ - ENTITY_ID
16
+ - PROJECT_ID
17
+ bins:
18
+ - memori
19
+ primaryEnv: MEMORI_API_KEY
20
+ externalServices:
21
+ - https://api.memorilabs.ai
22
+ ---
23
+
24
+ # Memori - Structured Long-term Memory for OpenClaw
25
+
26
+ Give your OpenClaw agents persistent, structured memory derived from agent execution, tool usage, workflow history, and conversations. Memori integrates seamlessly in the background via lifecycle hooks and provides agents with the tools to retrieve context when it is relevant.
27
+
28
+ ## Core Workflow
29
+
30
+ Memori operates on two parallel tracks through standard OpenClaw lifecycle hooks:
31
+
32
+ ### 1. Advanced Augmentation (automatic)
33
+
34
+ After each interaction, Memori converts raw session data into structured, reusable memories asynchronously.
35
+
36
+ - Transforms raw agent sessions into structured memory units
37
+ - Captures the agent's actions, reasoning, tool usage, responses, corrections, and failures
38
+ - Organizes into classes to enable efficient retrieval
39
+ - Generates embeddings for semantic retrieval
40
+ - Updates structured memory and the knowledge graph
41
+
42
+ This is how structured memory is continuously built and updated over time. It runs after the agent responds and does not impact latency.
43
+
44
+ ### 2. Agent-Controlled-Intelligent Recall
45
+
46
+ Recall is explicit and initiated by the agent.
47
+
48
+ Memori separates memory creation from memory recall:
49
+
50
+ - Creation is automatic (advanced augmentation)
51
+ - Recall is intentional (agent-controlled)
52
+
53
+ Agents decide:
54
+
55
+ - When to recall
56
+ - What scope to recall from
57
+ - How much history to include
58
+
59
+ To maintain an efficient context window, Memori equips the agent with specific tools to retrieve history when required for the conversation:
60
+
61
+ 1. **`memori_recall`**: Searches the structured memory graph for specific facts, constraints, and prior decisions.
62
+ 2. **`memori_recall_summary`**: Retrieves structured daily briefs and rolling summaries of prior sessions.
63
+ 3. **`memori_compaction`**: Retrieves structured post-compaction brief to continue task without interruption.
64
+ 4. **`memori_feedback`**: Reports on memory quality to improve extraction accuracy.
65
+
66
+ ## Installation
67
+
68
+ ```bash
69
+ openclaw plugins install @memorilabs/openclaw-memori
70
+ ```
71
+
72
+ ## Configuration
73
+
74
+ Add to your `~/.openclaw/openclaw.json` or use the `openclaw memori init` CLI command to set up your workspace:
75
+
76
+ ```bash
77
+ openclaw memori init \
78
+ --api-key "YOUR_MEMORI_API_KEY" \
79
+ --entity-id "your-entity-id" \
80
+ --project-id "your-project-id"
81
+ ```
82
+
83
+ Alternatively, configure it directly via JSON:
84
+
85
+ ```json
86
+ {
87
+ "plugins": {
88
+ "entries": {
89
+ "openclaw-memori": {
90
+ "enabled": true,
91
+ "config": {
92
+ "apiKey": "${MEMORI_API_KEY}",
93
+ "entityId": "openclaw-user",
94
+ "projectId": "default-project"
95
+ }
96
+ }
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### Configuration Options
103
+
104
+ - **apiKey** (required): Your Memori API key from [memorilabs.ai](https://app.memorilabs.ai/signup)
105
+ - **entityId** (required): Unique identifier for this user's memories
106
+ - **projectId** (required): Scopes all memories to a specific project or workspace
107
+
108
+ ## Agentic Tool Guidelines
109
+
110
+ When this plugin is active, the agent is equipped with tools to manage long-term context. The agent should use its discretion to call these tools when helpful:
111
+
112
+ - **Contextual Recall**: The agent can run a `memori_recall` search to retrieve relevant details if context is missing regarding user preferences.
113
+ - **Summaries**: The agent can utilize the `memori_recall_summary` tool to construct a brief if a user requests a recap.
114
+ - **Account Creation**: If a user explicitly asks to create an account, the agent can use the `memori_signup` tool to initiate the process by asking for an email address. Keys are never returned in the chat. The system securely emails the credentials to the user, who must then manually configure them to activate the plugin.
115
+ - **Quota Monitoring**: The agent can use the `memori_quota` tool to check the user's current memory usage and storage limits to communicate quota status or gracefully degrade behavior if limits are reached.
116
+ - **Date Defaults**: If the agent chooses to search memory, providing specific start/end dates is recommended to keep context windows efficient. Omitting dates will search all available history.
117
+
118
+ ## Verification
119
+
120
+ Check that the plugin is working and securely connected:
121
+
122
+ ```bash
123
+ # Verify plugin is securely connected to the API
124
+ openclaw memori status --check
125
+
126
+ # Check for Memori logs in gateway output
127
+ openclaw gateway logs --filter "[Memori]"
128
+ ```
129
+
130
+ ## Quota Management
131
+
132
+ Check your current API quota:
133
+
134
+ ```bash
135
+ memori quota
136
+ ```
137
+
138
+ **Example output:**
139
+
140
+ ```
141
+ __ __ _
142
+ | \/ | ___ _ __ ___ ___ _ __(_)
143
+ | |\/| |/ _ \ '_ ` _ \ / _ \| '__| |
144
+ | | | | __/ | | | | | (_) | | | |
145
+ |_| |_|\___|_| |_| |_|\___/|_| |_|
146
+ perfectam memoriam
147
+ memorilabs.ai
148
+
149
+ + Maximum # of Memories: 100
150
+ + Current # of Memories: 0
151
+
152
+ + You are not currently over quota.
153
+ ```
154
+
155
+ Use this to monitor usage and upgrade if needed.
156
+
157
+ ## Performance
158
+
159
+ - **Automatic deduplication** prevents memory bloat
160
+ - **Agent-controlled retrieval** ensures token usage remains targeted, compact, and actionable
161
+ - **Semantic ranking** ensures relevant memories surface first
162
+
163
+ ## Privacy, Consent & Data Handling
164
+
165
+ **Explicit Opt-In Required:** Memori requires the user to explicitly configure an API key (`MEMORI_API_KEY`) and an `entityId`. **No data is captured or transmitted unless these credentials are actively provided by the user.**
166
+
167
+ - ✅ Conversations are securely transmitted to the Memori backend (`https://api.memorilabs.ai`) only when the plugin is fully configured by the user.
168
+ - ✅ Data is encrypted in transit and at rest.
169
+ - ✅ Users control their data scope via their specific `projectId` and `entityId`.
170
+ - ✅ The backend automatically filters sensitive data (API keys, passwords, secrets) prior to storage.
171
+
172
+ For details: [Memori Privacy Policy](https://memorilabs.ai/privacy)
173
+
174
+ ## Memory Persistence
175
+
176
+ Memories persist safely across:
177
+
178
+ - Session restarts
179
+ - Gateway restarts
180
+ - System reboots
181
+ - OpenClaw upgrades
182
+
183
+ All storage is handled by the Memori backend and is scoped safely alongside your local `MEMORY.md` file without overwriting it.
184
+
185
+ ## Troubleshooting
186
+
187
+ **Plugin not loading:**
188
+
189
+ - Verify `enabled: true` in openclaw.json
190
+ - Check API key: `echo $MEMORI_API_KEY`
191
+ - Restart gateway: `openclaw gateway restart`
192
+
193
+ **No memories captured:**
194
+
195
+ - Check gateway logs for `[Memori]` errors
196
+ - Verify API endpoint reachable
197
+ - Test API key: `memori quota`
198
+
199
+ **Memories not recalled:**
200
+
201
+ - Did the agent utilize the retrieval tool? Check your gateway logs for `memori_recall` tool execution. If it didn't use the tool, you can prompt it to search its memory.
202
+ - Ensure `entityId` and `projectId` are consistent across sessions.
203
+ - Verify memories exist: `memori quota` shows count > 0.
204
+
205
+ **Quota exceeded:**
206
+
207
+ - Run `memori quota` to check usage
208
+ - Upgrade at [memorilabs.ai](https://app.memorilabs.ai/)
209
+ - Or clear old memories via dashboard
210
+
211
+ ## Learn More
212
+
213
+ - **npm Package**: https://www.npmjs.com/package/@memorilabs/openclaw-memori
214
+ - **GitHub**: https://github.com/MemoriLabs/Memori
215
+ - **Documentation**: https://memorilabs.ai/docs/memori-cloud/openclaw/overview/
216
+ - **API Dashboard**: https://app.memorilabs.ai/
217
+ - **Support**: [GitHub Issues](https://github.com/MemoriLabs/Memori/issues)
218
+
219
+ ## Notes
220
+
221
+ This skill informs the agent about the Memori plugin. The plugin must be installed separately via npm. Once installed, memory capture happens in the background, and the agent is empowered to explicitly query its memories when needed.
@@ -0,0 +1,355 @@
1
+ # Memori skills file
2
+
3
+ You have access to Memori, agent-native memory infrastructure: an LLM-agnostic layer that structures memory from not just natural language, but also from agent trace that comes from execution.
4
+
5
+ Memori automatically captures and structures memory from conversation and execution trace — including the agent's actions, tool results, decisions, and outcomes — and allows you to retrieve it on demand. Use it to maintain continuity across sessions, preserve decisions and constraints, and help the agent understand what it actually did so the next time it completes a task, it is more accurate and efficient.
6
+
7
+ ---
8
+
9
+ ## Core instruction
10
+
11
+ At the start of a session, you should check the `SKILL.md` file
12
+
13
+ Use it to understand:
14
+
15
+ - Available capabilities
16
+ - Tooling and integrations
17
+ - Expected behaviors and constraints
18
+
19
+ Treat `SKILL.md` as a source of truth for what you can do before taking action.
20
+
21
+ ---
22
+
23
+ ## When to use Memori
24
+
25
+ Use Memori when:
26
+
27
+ - The task depends on prior context
28
+ - The user refers to previous sessions or decisions
29
+ - You need known constraints, preferences, or patterns
30
+ - You are starting a session and need current state
31
+ - You want to understand what has already been done
32
+
33
+ ---
34
+
35
+ ## When not to use Memori
36
+
37
+ Do not use Memori when:
38
+
39
+ - The task is fully self-contained
40
+ - The answer depends only on the current prompt
41
+ - No historical context is required
42
+ - The query is simple or one-off
43
+
44
+ Avoid unnecessary recall.
45
+
46
+ ---
47
+
48
+ ## Recall behavior
49
+
50
+ Recall is **agent-controlled and intentional**.
51
+
52
+ Prefer targeted recall over broad queries.
53
+
54
+ ### Supported parameters (recall only)
55
+
56
+ - `entityId` → user, agent, or system context
57
+ - `projectId` → project or workspace context
58
+ - `sessionId` → specific session
59
+ - `dateStart` / `dateEnd` → time-bounded recall
60
+ - `source` → type of memory (must be paired with `signal` from the allowed combinations below)
61
+ - `signal` → how the memory was derived (must be paired with `source` from the allowed combinations below)
62
+
63
+ > Note: If a `sessionId` is provided, a `projectId` must also be provided.
64
+ > All timestamps are stored in **UTC**.
65
+
66
+ ### Allowed source + signal combinations
67
+
68
+ `source` and `signal` are not independent. They must be set together (or both omitted). Only the following `(source, signal)` pairs are valid:
69
+
70
+ - `source=constraint`, `signal=discovery`
71
+ - `source=decision`, `signal=commit`
72
+ - `source=fact`, `signal=verification`
73
+ - `source=execution`, `signal=failure`
74
+ - `source=instruction`, `signal=discovery`
75
+ - `source=insight`, `signal=inference`
76
+ - `source=status`, `signal=update`
77
+ - `source=strategy`, `signal=pattern`
78
+ - `source=task`, `signal=result`
79
+
80
+ Any combination of `source` and `signal` not in this list is invalid and must not be sent to `memori_recall`.
81
+
82
+ Use one of the allowed `(source, signal)` pairs to prioritize high-signal memory when possible; never set `source` or `signal` independently.
83
+
84
+ ### Default behavior (recall)
85
+
86
+ - No date range → **all-time memory**
87
+ - Use time bounds when narrowing results is necessary
88
+
89
+ ### Best practices
90
+
91
+ - Start narrow (entity + project)
92
+ - Add time bounds only when needed
93
+ - Use an allowed `(source, signal)` pair to refine results (never set them independently)
94
+ - Expand scope only if needed
95
+ - Do not recall on every turn
96
+
97
+ ---
98
+
99
+ ## Summary behavior
100
+
101
+ Summaries are used for **state awareness**, not precise retrieval.
102
+
103
+ Use:
104
+
105
+ - `memori_recall_summary`
106
+
107
+ ### Supported parameters (summaries)
108
+
109
+ - `projectId`
110
+ - `sessionId`
111
+ - `dateStart`
112
+ - `dateEnd`
113
+
114
+ > Summaries do **not** support `source` or `signal`.
115
+
116
+ ### Default behavior (summaries)
117
+
118
+ - No date range → **last 24 hours**
119
+
120
+ ---
121
+
122
+ ## Daily brief behavior
123
+
124
+ At the start of a meaningful session, retrieve a structured summary.
125
+
126
+ Use the daily brief to understand:
127
+
128
+ - Current state
129
+ - Prior decisions
130
+ - Constraints
131
+ - Open work
132
+
133
+ ### Expected daily brief structure
134
+
135
+ - Today at a glance
136
+ - Top 3 next actions
137
+ - Top 3 risks
138
+ - Verify before acting
139
+ - Recent decisions
140
+ - Mission stack
141
+ - Hard constraints
142
+ - Current status
143
+ - Open loops
144
+ - Known failures and anti-patterns
145
+ - Staleness warnings
146
+
147
+ Treat this as the working state of the system.
148
+
149
+ ---
150
+
151
+ ## Typical workflow
152
+
153
+ 1. Start of session → retrieve summary
154
+ 2. During task → use targeted recall
155
+ 3. When memory is missing or incorrect → send feedback
156
+ 4. When limits are reached → degrade gracefully
157
+
158
+ ---
159
+
160
+ ## Post-compaction brief behavior
161
+
162
+ Post-compaction briefs are used to restore working state after context compaction.
163
+
164
+ Use them when:
165
+
166
+ - The agent resumes after compaction
167
+ - A long-running workflow has lost conversational detail
168
+ - The agent needs to continue operational work without replaying the full prior session
169
+ - The agent needs durable state, standing instructions, environment details, open loops, or the next expected action
170
+
171
+ Post-compaction briefs are not a replacement for precise memory retrieval.
172
+
173
+ ### Use:
174
+
175
+ memori_compaction
176
+
177
+ Supported parameters (post-compaction briefs)
178
+
179
+ projectId (required)
180
+ sessionId (optional)
181
+
182
+ Post-compaction briefs do not support source or signal.
183
+
184
+ ### Default behavior (post-compaction briefs)
185
+
186
+ Retrieve the most recent relevant post-compaction brief for the project or session.
187
+
188
+ Expected post-compaction brief structure
189
+
190
+ - Meta
191
+ - Environment
192
+ - Standing orders
193
+ - State
194
+ - Active tasks
195
+ - Open loops
196
+ - Pending results
197
+ - Timeline
198
+ - Workspace changes
199
+ - Continuation
200
+ - Last action
201
+ - Next expected action
202
+
203
+ ### How to use a post-compaction brief
204
+
205
+ Treat the post-compaction brief as the agent's resume state.
206
+
207
+ Use it to understand:
208
+
209
+ - What environment the agent was operating in
210
+ - Which standing orders must continue to be followed
211
+ - Which tasks are active
212
+ - Which issues remain unresolved
213
+ - What happened across the prior session window
214
+ - What files, workspace state, or external systems may have changed
215
+ - What the agent did last
216
+ - What the agent should do next
217
+
218
+ ### Important behavior
219
+
220
+ The post-compaction brief should guide continuation, not override explicit user instructions.
221
+
222
+ Before acting on operational details, verify any state that may have changed since compaction.
223
+
224
+ Pay special attention to:
225
+
226
+ - Standing orders
227
+ - Hard constraints
228
+ - Alerting rules
229
+ - Expected response formats
230
+ - Open loops
231
+ - Staleness warnings
232
+ - Next expected action
233
+
234
+ If the post-compaction brief contains a required output format, follow it exactly unless the user gives a newer instruction.
235
+
236
+ ---
237
+
238
+ ## Safety and correctness
239
+
240
+ - Do not invent memory
241
+ - Do not assume memory is correct if it conflicts with the user
242
+ - Verify before acting when needed
243
+ - Treat recent instructions as higher priority than recalled memory
244
+
245
+ ---
246
+
247
+ ## Memori system guidance
248
+
249
+ This section defines how you should interact with Memori beyond basic recall.
250
+
251
+ ---
252
+
253
+ ### 1. Feedback (`memori_feedback`)
254
+
255
+ You are equipped with the `memori_feedback` tool to improve memory quality over time.
256
+
257
+ You may send feedback at any time, and should do so at the end of a session when appropriate.
258
+
259
+ Feedback should be sent when:
260
+
261
+ - Recall results are irrelevant or missing key context
262
+ - Important decisions or constraints were not captured
263
+ - Memory quality degrades across sessions
264
+ - Something works particularly well and should be reinforced
265
+
266
+ Examples:
267
+
268
+ - "Send feedback that recall missed a pricing constraint."
269
+ - "Tell Memori the daily brief was accurate."
270
+ - "Submit a bug report: you didn't remember my preferred language."
271
+
272
+ #### Purpose
273
+
274
+ Feedback improves:
275
+
276
+ - Memory extraction quality
277
+ - Recall relevance
278
+ - Summary accuracy
279
+
280
+ ---
281
+
282
+ ### 2. Updates
283
+
284
+ Memori evolves over time (new features, improved recall, better summaries).
285
+
286
+ When updates are exposed:
287
+
288
+ - Check for updates via system message or tool
289
+ - Adapt behavior to use new capabilities
290
+
291
+ When an update is detected:
292
+
293
+ - Prefer newer recall patterns when available
294
+ - Use improved summaries or classification outputs
295
+ - Continue operating normally if no changes are required
296
+
297
+ ---
298
+
299
+ ### 3. Account Creation and Onboarding (`memori_signup`)
300
+
301
+ You are equipped with the `memori_signup` tool to securely create an account and provision an API key for the user via the Memori CLI.
302
+
303
+ Use this tool when:
304
+
305
+ - The user explicitly asks to sign up, create an account, or get an API key for Memori.
306
+ - You encounter an error indicating a missing `MEMORI_API_KEY` and the user provides their email address to get one.
307
+
308
+ #### Behavior:
309
+
310
+ - **Email Required:** If the user asks to sign up but **does not** provide an email address, you MUST ask them for their email first. Do not attempt to guess or hallucinate an email.
311
+ - **Execution:** Once they provide an email, run `memori_signup` with that email.
312
+ - **Follow-up:** The tool will trigger the underlying CLI and return a success or error message. Relay that message to the user, remind them to check their inbox for the API key, and instruct them to add it to their configuration (`~/.openclaw/openclaw.json` or `.env` file).
313
+ - **Troubleshooting Errors:** If the tool fails with a `Permission denied`, `EACCES`, or `command not found` error, do not ask the user for permission to troubleshoot. Instead, immediately tell them that their CLI installation is broken or missing, and explicitly instruct them to run `npm install -g @memorilabs/memori` in their terminal to fix it.
314
+
315
+ ---
316
+
317
+ ### 4. Quota Awareness and Upgrades (`memori_quota`)
318
+
319
+ You are equipped with the `memori_quota` tool to check the user's current memory usage and limits via the Memori CLI.
320
+
321
+ Use this tool when:
322
+
323
+ - The user explicitly asks about their quota, usage, storage, or how many memories they have left.
324
+ - You encounter errors suggesting memory limits have been reached and want to confirm before degrading behavior.
325
+
326
+ #### Behavior:
327
+
328
+ - **No Parameters Required:** Simply invoke `memori_quota` — it requires no arguments.
329
+ - **Execution:** The tool runs the underlying CLI and returns the user's current usage and quota.
330
+ - **Follow-up:** Relay the result clearly to the user. If they are near or at their limit, explain the impact and suggest an upgrade.
331
+ - **Troubleshooting Errors:** If the tool fails with a `Permission denied`, `EACCES`, or `command not found` error, do not ask the user for permission to troubleshoot. Instead, immediately tell them that their CLI installation is broken or missing, and explicitly instruct them to run `npm install -g @memorilabs/memori` in their terminal to fix it.
332
+
333
+ #### When limits are reached or nearing:
334
+
335
+ #### a. Degrade gracefully
336
+
337
+ - Reduce recall scope (shorter time ranges)
338
+ - Prioritize high-signal memory (decisions, constraints, key facts)
339
+ - Avoid unnecessary or repeated recall calls
340
+
341
+ #### b. Inform the human/operator
342
+
343
+ Clearly communicate when limits impact performance.
344
+
345
+ Example:
346
+
347
+ > "Memory limits have been reached. I can continue with limited recall, or you can upgrade to restore full functionality."
348
+
349
+ #### c. Suggest upgrades appropriately
350
+
351
+ - Only prompt when performance is affected
352
+ - Avoid repetitive or disruptive messaging
353
+ - Keep messaging neutral and helpful
354
+
355
+ ---
@@ -1,5 +0,0 @@
1
- import { OpenClawEvent, OpenClawContext, MemoriPluginConfig } from '../types.js';
2
- import { MemoriLogger } from '../utils/index.js';
3
- export declare function handleRecall(event: OpenClawEvent, ctx: OpenClawContext, config: MemoriPluginConfig, logger: MemoriLogger): Promise<{
4
- prependContext: string;
5
- } | undefined>;
@@ -1,34 +0,0 @@
1
- import { cleanText, isSystemMessage } from '../sanitizer.js';
2
- import { RECALL_CONFIG } from '../constants.js';
3
- import { extractContext, initializeMemoriClient } from '../utils/index.js';
4
- export async function handleRecall(event, ctx, config, logger) {
5
- logger.section('RECALL HOOK START');
6
- try {
7
- const context = extractContext(event, ctx, config.entityId);
8
- const promptText = cleanText(event.prompt);
9
- if (!promptText ||
10
- promptText.length < RECALL_CONFIG.MIN_PROMPT_LENGTH ||
11
- isSystemMessage(promptText)) {
12
- logger.info('Prompt too short or is a system message. Aborting recall.');
13
- return undefined;
14
- }
15
- const memoriClient = initializeMemoriClient(config.apiKey, context);
16
- logger.info('Executing SDK Recall...');
17
- const recallText = await memoriClient.recall(promptText);
18
- const hookReturn = recallText ? { prependContext: recallText } : undefined;
19
- if (hookReturn) {
20
- logger.info('Successfully injected memory context.');
21
- }
22
- else {
23
- logger.info('No relevant memories found.');
24
- }
25
- return hookReturn;
26
- }
27
- catch (err) {
28
- logger.error(`Recall failed: ${err instanceof Error ? err.message : String(err)}`);
29
- return undefined;
30
- }
31
- finally {
32
- logger.endSection('RECALL HOOK END');
33
- }
34
- }