@memorilabs/openclaw-memori 0.0.14 → 0.0.16

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/dist/index.js CHANGED
@@ -24,9 +24,10 @@ const memoriPlugin = {
24
24
  }
25
25
  logger.info(`\n=== ${PLUGIN_CONFIG.LOG_PREFIX} INITIALIZING PLUGIN ===`);
26
26
  logger.info(`${PLUGIN_CONFIG.LOG_PREFIX} Tracking Entity ID: ${config.entityId}`);
27
- if (skillsContent) {
28
- api.on('before_prompt_build', () => ({ appendSystemContext: skillsContent }));
29
- }
27
+ const configContext = `Memori plugin configuration: projectId="${config.projectId}", entityId="${config.entityId}"`;
28
+ api.on('before_prompt_build', () => ({
29
+ appendSystemContext: [skillsContent, configContext].filter(Boolean).join('\n\n'),
30
+ }));
30
31
  api.on('agent_end', (event, ctx) => handleAugmentation(event, ctx, config, logger));
31
32
  registerAuthenticatedTools({ api, config, logger });
32
33
  },
@@ -3,6 +3,7 @@ import { createMemoriQuotaTool } from './memori-quota.js';
3
3
  import { createMemoriRecallTool } from './memori-recall.js';
4
4
  import { createMemoriRecallSummaryTool } from './memori-recall-summary.js';
5
5
  import { createMemoriFeedbackTool } from './memori-feedback.js';
6
+ import { createMemoriCompactionTool } from './memori-compaction.js';
6
7
  export function registerUtilityTools(deps) {
7
8
  deps.api.registerTool(createMemoriSignupTool(deps));
8
9
  }
@@ -11,4 +12,5 @@ export function registerAuthenticatedTools(deps) {
11
12
  deps.api.registerTool(createMemoriRecallSummaryTool(deps));
12
13
  deps.api.registerTool(createMemoriFeedbackTool(deps));
13
14
  deps.api.registerTool(createMemoriQuotaTool(deps));
15
+ deps.api.registerTool(createMemoriCompactionTool(deps));
14
16
  }
@@ -0,0 +1,35 @@
1
+ import type { ToolDeps } from './types.js';
2
+ export declare function createMemoriCompactionTool(deps: ToolDeps): {
3
+ name: string;
4
+ label: string;
5
+ description: string;
6
+ parameters: {
7
+ type: string;
8
+ required: string[];
9
+ properties: {
10
+ projectId: {
11
+ type: string;
12
+ description: string;
13
+ };
14
+ sessionId: {
15
+ type: string;
16
+ description: string;
17
+ };
18
+ numMessages: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ };
23
+ };
24
+ execute(_toolCallId: string, params: {
25
+ projectId?: string;
26
+ sessionId?: string;
27
+ numMessages?: number;
28
+ }): Promise<{
29
+ content: {
30
+ type: "text";
31
+ text: string;
32
+ }[];
33
+ details: null;
34
+ }>;
35
+ };
@@ -0,0 +1,119 @@
1
+ import { QuotaExceededError } from '@memorilabs/memori';
2
+ import { createRecallClient } from '../utils/memori-client.js';
3
+ export function createMemoriCompactionTool(deps) {
4
+ const { config, logger } = deps;
5
+ return {
6
+ name: 'memori_compaction',
7
+ label: 'Compact Agent Memory',
8
+ description: `Use this tool to restore working state after context compaction. Returns a structured snapshot of the agent's long-term memory to enable continuation without replaying the full prior session.
9
+
10
+ WHEN TO USE:
11
+ - The agent resumes after compaction
12
+ - A long-running workflow has lost conversational detail
13
+ - The agent needs to continue operational work without replaying the full prior session
14
+ - The agent needs durable state, standing instructions, environment details, open loops, or the next expected action
15
+
16
+ WHEN NOT TO USE:
17
+ - Do NOT call this on every turn — it costs 100 memory credits per execution
18
+ - Do NOT use this for targeted memory search — use memori_recall for that instead
19
+ - Do NOT call this if the agent is starting a brand-new task with no prior context
20
+ - Compaction is not a replacement for precise memory retrieval
21
+
22
+ The compaction result returns:
23
+ - **environment**: environment variable context captured during prior sessions
24
+ - **standing_orders**: persistent instructions the agent must continue to follow
25
+ - **state**: active_tasks (work in progress), open_loops (unresolved threads), pending_results
26
+ - **timeline**: a chronological narrative of agent activity (when available)
27
+ - **workspace_changes**: recent file or system changes made by the agent
28
+ - **continuation**: last_action (what the agent did last) and next_expected_action (what it should do next)
29
+ - **messages**: a tail of recent conversation messages for continuity
30
+
31
+ HOW TO USE THE RESULT:
32
+ Treat the compaction result as the agent's resume state — use it to understand what environment the agent was operating in, which standing orders must continue to be followed, which tasks are active, what happened across the prior session window, and what the agent should do next.
33
+
34
+ The compaction result should guide continuation, not override explicit user instructions. Before acting on operational details, verify any state that may have changed since compaction.
35
+
36
+ Pay special attention to:
37
+ - Standing orders
38
+ - Hard constraints
39
+ - Alerting rules
40
+ - Expected response formats
41
+ - Open loops
42
+ - Staleness warnings
43
+ - Next expected action
44
+
45
+ If the compaction result contains a required output format, follow it exactly unless the user gives a newer instruction.`,
46
+ parameters: {
47
+ type: 'object',
48
+ required: ['projectId'],
49
+ properties: {
50
+ projectId: {
51
+ type: 'string',
52
+ description: 'The project to compact. REQUIRED — always pass the configured project ID. This scopes the compaction to the correct workspace.',
53
+ },
54
+ sessionId: {
55
+ type: 'string',
56
+ description: 'Scope the compaction to a specific agent session. Leave empty to compact across all sessions in the project. Cannot be used without projectId.',
57
+ },
58
+ numMessages: {
59
+ type: 'number',
60
+ description: 'Number of recent conversation messages to include in the result. Defaults to 5. Increase (up to ~20) only if the user explicitly asks for more conversation context.',
61
+ },
62
+ },
63
+ },
64
+ async execute(_toolCallId, params) {
65
+ try {
66
+ // Config projectId is the fallback; an explicit LLM-provided value overrides it.
67
+ const finalParams = { projectId: config.projectId, ...params };
68
+ if (!finalParams.projectId) {
69
+ const errorResult = { error: 'projectId is required but was not configured' };
70
+ logger.warn(`memori_compaction rejected: ${JSON.stringify(errorResult)}`);
71
+ return {
72
+ content: [{ type: 'text', text: JSON.stringify(errorResult) }],
73
+ details: null,
74
+ };
75
+ }
76
+ if (finalParams.sessionId && !finalParams.projectId) {
77
+ const errorResult = { error: 'sessionId cannot be provided without projectId' };
78
+ logger.warn(`memori_compaction rejected: ${JSON.stringify(errorResult)}`);
79
+ return {
80
+ content: [{ type: 'text', text: JSON.stringify(errorResult) }],
81
+ details: null,
82
+ };
83
+ }
84
+ logger.info(`memori_compaction params: ${JSON.stringify(finalParams)}`);
85
+ const client = createRecallClient(config.apiKey, config.entityId);
86
+ const result = await client.agentCompaction(finalParams);
87
+ if (result === null) {
88
+ const errorResult = { error: 'Compaction failed' };
89
+ return {
90
+ content: [{ type: 'text', text: JSON.stringify(errorResult) }],
91
+ details: null,
92
+ };
93
+ }
94
+ return {
95
+ content: [{ type: 'text', text: JSON.stringify(result) }],
96
+ details: null,
97
+ };
98
+ }
99
+ catch (e) {
100
+ if (e instanceof QuotaExceededError) {
101
+ logger.warn('memori_compaction quota exceeded');
102
+ const errorResult = {
103
+ error: 'Quota exceeded: compaction costs 100 memory credits and your organization has exhausted its Recall Execution quota.',
104
+ };
105
+ return {
106
+ content: [{ type: 'text', text: JSON.stringify(errorResult) }],
107
+ details: null,
108
+ };
109
+ }
110
+ logger.warn(`memori_compaction failed: ${String(e)}`);
111
+ const errorResult = { error: 'Compaction failed' };
112
+ return {
113
+ content: [{ type: 'text', text: JSON.stringify(errorResult) }],
114
+ details: null,
115
+ };
116
+ }
117
+ },
118
+ };
119
+ }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.0.14";
1
+ export declare const SDK_VERSION = "0.0.16";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const SDK_VERSION = '0.0.14';
1
+ export const SDK_VERSION = '0.0.16';
@@ -9,6 +9,7 @@
9
9
  "tools": [
10
10
  "memori_recall",
11
11
  "memori_recall_summary",
12
+ "memori_compaction",
12
13
  "memori_feedback",
13
14
  "memori_signup",
14
15
  "memori_quota"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memorilabs/openclaw-memori",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Official MemoriLabs.ai long-term memory plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -67,6 +67,6 @@
67
67
  "@hono/node-server": "^1.19.10"
68
68
  },
69
69
  "dependencies": {
70
- "@memorilabs/memori": "0.1.12-beta"
70
+ "@memorilabs/memori": "^0.1.23-beta"
71
71
  }
72
72
  }
@@ -60,7 +60,8 @@ To maintain an efficient context window, Memori equips the agent with specific t
60
60
 
61
61
  1. **`memori_recall`**: Searches the structured memory graph for specific facts, constraints, and prior decisions.
62
62
  2. **`memori_recall_summary`**: Retrieves structured daily briefs and rolling summaries of prior sessions.
63
- 3. **`memori_feedback`**: Reports on memory quality to improve extraction accuracy.
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.
64
65
 
65
66
  ## Installation
66
67
 
@@ -157,6 +157,84 @@ Treat this as the working state of the system.
157
157
 
158
158
  ---
159
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
+
160
238
  ## Safety and correctness
161
239
 
162
240
  - Do not invent memory