@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.
- package/README.md +123 -96
- package/dist/cli/commands.d.ts +2 -0
- package/dist/cli/commands.js +143 -0
- package/dist/cli/config-file.d.ts +8 -0
- package/dist/cli/config-file.js +64 -0
- package/dist/constants.d.ts +12 -1
- package/dist/constants.js +12 -1
- package/dist/handlers/augmentation.d.ts +4 -0
- package/dist/handlers/augmentation.js +150 -45
- package/dist/index.js +13 -4
- package/dist/sanitizer.d.ts +1 -0
- package/dist/sanitizer.js +10 -2
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.js +16 -0
- package/dist/tools/memori-compaction.d.ts +35 -0
- package/dist/tools/memori-compaction.js +119 -0
- package/dist/tools/memori-feedback.d.ts +25 -0
- package/dist/tools/memori-feedback.js +40 -0
- package/dist/tools/memori-quota.d.ts +17 -0
- package/dist/tools/memori-quota.js +55 -0
- package/dist/tools/memori-recall-summary.d.ts +39 -0
- package/dist/tools/memori-recall-summary.js +58 -0
- package/dist/tools/memori-recall.d.ts +51 -0
- package/dist/tools/memori-recall.js +123 -0
- package/dist/tools/memori-signup.d.ts +25 -0
- package/dist/tools/memori-signup.js +72 -0
- package/dist/tools/types.d.ts +8 -0
- package/dist/tools/types.js +1 -0
- package/dist/types.d.ts +19 -1
- package/dist/utils/context.d.ts +4 -2
- package/dist/utils/context.js +4 -2
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/memori-client.d.ts +11 -0
- package/dist/utils/memori-client.js +20 -2
- package/dist/utils/skills-loader.d.ts +6 -0
- package/dist/utils/skills-loader.js +14 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/openclaw.plugin.json +22 -2
- package/package.json +3 -2
- package/skills/clawhub/SKILL.md +221 -0
- package/skills/memori/SKILL.md +355 -0
- package/dist/handlers/recall.d.ts +0 -5
- package/dist/handlers/recall.js +0 -34
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createRecallClient } from '../utils/memori-client.js';
|
|
2
|
+
export function createMemoriRecallSummaryTool(deps) {
|
|
3
|
+
const { config, logger } = deps;
|
|
4
|
+
return {
|
|
5
|
+
name: 'memori_recall_summary',
|
|
6
|
+
label: 'Recall Memory Summary',
|
|
7
|
+
description: 'CRITICAL: You MUST use this tool BEFORE answering any requests for a summary, status update, daily brief, or high-level overview of a project or past sessions. Fetch summarized views of stored memories from Memori within a specific date range. If no date range is provided, the result defaults to the last 24 hours.',
|
|
8
|
+
parameters: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
dateStart: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'ISO 8601 (MUST be UTC) date string to filter summaries created on or after this time',
|
|
14
|
+
},
|
|
15
|
+
dateEnd: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'ISO 8601 (MUST be UTC) date string to filter summaries created on or before this time',
|
|
18
|
+
},
|
|
19
|
+
projectId: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'CRITICAL: Leave this EMPTY to use the configured default project. ONLY provide a value if the user explicitly asks to search a different project by name.',
|
|
22
|
+
},
|
|
23
|
+
sessionId: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'Filter to a specific session. Cannot be used without projectId.',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
async execute(_toolCallId, params) {
|
|
30
|
+
try {
|
|
31
|
+
const finalParams = { projectId: config.projectId, ...params };
|
|
32
|
+
if (finalParams.sessionId && !finalParams.projectId) {
|
|
33
|
+
const errorResult = { error: 'sessionId cannot be provided without projectId' };
|
|
34
|
+
logger.warn(`memori_recall_summary rejected: ${JSON.stringify(errorResult)}`);
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
37
|
+
details: null,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
logger.info(`memori_recall_summary params: ${JSON.stringify(finalParams)}`);
|
|
41
|
+
const client = createRecallClient(config.apiKey, config.entityId);
|
|
42
|
+
const result = await client.agentRecallSummary(finalParams);
|
|
43
|
+
return {
|
|
44
|
+
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
45
|
+
details: null,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
logger.warn(`memori_recall_summary failed: ${String(e)}`);
|
|
50
|
+
const errorResult = { error: 'Recall summary failed' };
|
|
51
|
+
return {
|
|
52
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
53
|
+
details: null,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ToolDeps } from './types.js';
|
|
2
|
+
export declare function createMemoriRecallTool(deps: ToolDeps): {
|
|
3
|
+
name: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
dateStart: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
dateEnd: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
projectId: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
sessionId: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
signal: {
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
enum: string[];
|
|
29
|
+
};
|
|
30
|
+
source: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
enum: string[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
execute(_toolCallId: string, params: {
|
|
38
|
+
dateStart?: string;
|
|
39
|
+
dateEnd?: string;
|
|
40
|
+
projectId?: string;
|
|
41
|
+
sessionId?: string;
|
|
42
|
+
signal?: string;
|
|
43
|
+
source?: string;
|
|
44
|
+
}): Promise<{
|
|
45
|
+
content: {
|
|
46
|
+
type: "text";
|
|
47
|
+
text: string;
|
|
48
|
+
}[];
|
|
49
|
+
details: null;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { createRecallClient } from '../utils/memori-client.js';
|
|
2
|
+
export function createMemoriRecallTool(deps) {
|
|
3
|
+
const { config, logger } = deps;
|
|
4
|
+
return {
|
|
5
|
+
name: 'memori_recall',
|
|
6
|
+
label: 'Recall Memory',
|
|
7
|
+
description: 'CRITICAL: You MUST use this tool to search for past context BEFORE claiming you do not know the user, their preferences, or past events. Explicitly fetch relevant memories from Memori using filters...',
|
|
8
|
+
parameters: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
dateStart: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'ISO 8601 (MUST be UTC) date string to filter memories created on or after this time',
|
|
14
|
+
},
|
|
15
|
+
dateEnd: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'ISO 8601 (MUST be UTC) date string to filter memories created on or before this time',
|
|
18
|
+
},
|
|
19
|
+
projectId: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'CRITICAL: Leave this EMPTY to use the configured default project. ONLY provide a value if the user explicitly asks to search a different project by name.',
|
|
22
|
+
},
|
|
23
|
+
sessionId: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'Filter to a specific session. Cannot be used without projectId.',
|
|
26
|
+
},
|
|
27
|
+
signal: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'Filter by how the memory was derived. MUST be set together with `source` using one of the allowed (source, signal) pairs — never set independently. Valid pairs: (constraint, discovery), (decision, commit), (fact, verification), (execution, failure), (instruction, discovery), (insight, inference), (status, update), (strategy, pattern), (task, result).',
|
|
30
|
+
enum: [
|
|
31
|
+
'commit',
|
|
32
|
+
'discovery',
|
|
33
|
+
'failure',
|
|
34
|
+
'inference',
|
|
35
|
+
'pattern',
|
|
36
|
+
'result',
|
|
37
|
+
'update',
|
|
38
|
+
'verification',
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
source: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'Filter by memory type. MUST be set together with `signal` using one of the allowed (source, signal) pairs — never set independently. Valid pairs: (constraint, discovery), (decision, commit), (fact, verification), (execution, failure), (instruction, discovery), (insight, inference), (status, update), (strategy, pattern), (task, result).',
|
|
44
|
+
enum: [
|
|
45
|
+
'constraint',
|
|
46
|
+
'decision',
|
|
47
|
+
'execution',
|
|
48
|
+
'fact',
|
|
49
|
+
'insight',
|
|
50
|
+
'instruction',
|
|
51
|
+
'status',
|
|
52
|
+
'strategy',
|
|
53
|
+
'task',
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
async execute(_toolCallId, params) {
|
|
59
|
+
try {
|
|
60
|
+
// If params.projectId is undefined, it falls back to config.projectId.
|
|
61
|
+
// If the LLM intentionally provides one, it overwrites the config.
|
|
62
|
+
const finalParams = { projectId: config.projectId, ...params };
|
|
63
|
+
if (finalParams.sessionId && !finalParams.projectId) {
|
|
64
|
+
const errorResult = { error: 'sessionId cannot be provided without projectId' };
|
|
65
|
+
logger.warn(`memori_recall rejected: ${JSON.stringify(errorResult)}`);
|
|
66
|
+
return {
|
|
67
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
68
|
+
details: null,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const hasSource = finalParams.source != null;
|
|
72
|
+
const hasSignal = finalParams.signal != null;
|
|
73
|
+
if (hasSource !== hasSignal) {
|
|
74
|
+
const errorResult = {
|
|
75
|
+
error: 'source and signal must be provided together or both omitted',
|
|
76
|
+
};
|
|
77
|
+
logger.warn(`memori_recall rejected: ${JSON.stringify(errorResult)}`);
|
|
78
|
+
return {
|
|
79
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
80
|
+
details: null,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const VALID_PAIRS = {
|
|
84
|
+
constraint: 'discovery',
|
|
85
|
+
decision: 'commit',
|
|
86
|
+
fact: 'verification',
|
|
87
|
+
execution: 'failure',
|
|
88
|
+
instruction: 'discovery',
|
|
89
|
+
insight: 'inference',
|
|
90
|
+
status: 'update',
|
|
91
|
+
strategy: 'pattern',
|
|
92
|
+
task: 'result',
|
|
93
|
+
};
|
|
94
|
+
const source = finalParams.source;
|
|
95
|
+
if (hasSource && source != null && VALID_PAIRS[source] !== finalParams.signal) {
|
|
96
|
+
const errorResult = {
|
|
97
|
+
error: `Invalid (source, signal) pair: (${source}, ${finalParams.signal}). Expected signal for source "${source}" is "${VALID_PAIRS[source]}".`,
|
|
98
|
+
};
|
|
99
|
+
logger.warn(`memori_recall rejected: ${JSON.stringify(errorResult)}`);
|
|
100
|
+
return {
|
|
101
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
102
|
+
details: null,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
logger.info(`memori_recall params: ${JSON.stringify(finalParams)}`);
|
|
106
|
+
const client = createRecallClient(config.apiKey, config.entityId);
|
|
107
|
+
const result = await client.agentRecall(finalParams);
|
|
108
|
+
return {
|
|
109
|
+
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
110
|
+
details: null,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
logger.warn(`memori_recall failed: ${String(e)}`);
|
|
115
|
+
const errorResult = { error: 'Recall failed' };
|
|
116
|
+
return {
|
|
117
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
118
|
+
details: null,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ToolDeps } from './types.js';
|
|
2
|
+
export declare function createMemoriSignupTool(deps: ToolDeps): {
|
|
3
|
+
name: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
email: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
required: string[];
|
|
15
|
+
};
|
|
16
|
+
execute(_toolCallId: string, params: {
|
|
17
|
+
email: string;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
content: {
|
|
20
|
+
type: "text";
|
|
21
|
+
text: string;
|
|
22
|
+
}[];
|
|
23
|
+
details: null;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { exec } from 'child_process';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
const execAsync = promisify(exec);
|
|
6
|
+
export function createMemoriSignupTool(deps) {
|
|
7
|
+
const { logger } = deps;
|
|
8
|
+
return {
|
|
9
|
+
name: 'memori_signup',
|
|
10
|
+
label: 'Memori Sign Up',
|
|
11
|
+
description: 'CRITICAL: You MUST use this tool when the user asks to sign up, create an account, or get an API key for Memori — or when you encounter a missing MEMORI_API_KEY error and the user provides their email. If the user has not provided an email address, ask for it first. Do not guess or hallucinate an email.',
|
|
12
|
+
parameters: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
email: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'The email address to send the Memori API key to.',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
required: ['email'],
|
|
21
|
+
},
|
|
22
|
+
async execute(_toolCallId, params) {
|
|
23
|
+
try {
|
|
24
|
+
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
25
|
+
if (!emailRegex.test(params.email)) {
|
|
26
|
+
const errorResult = {
|
|
27
|
+
error: `The email you provided "${params.email}" is not valid. Please provide a standard email address.`,
|
|
28
|
+
};
|
|
29
|
+
logger.warn(`memori_signup rejected email format: ${params.email}`);
|
|
30
|
+
return {
|
|
31
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
32
|
+
details: null,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
logger.info(`memori_signup attempting to sign up: ${params.email}`);
|
|
36
|
+
const tmpDir = os.tmpdir();
|
|
37
|
+
await execAsync(`npm install --prefix ${tmpDir} --no-save @memorilabs/memori@0.1.12-beta`);
|
|
38
|
+
const binPath = path.join(tmpDir, 'node_modules', '.bin', 'memori');
|
|
39
|
+
const { stdout } = await execAsync(`${binPath} sign-up ${params.email}`);
|
|
40
|
+
const result = {
|
|
41
|
+
success: true,
|
|
42
|
+
message: stdout.trim(),
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
46
|
+
details: null,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
logger.warn(`memori_signup CLI failed: ${String(e)}`);
|
|
51
|
+
let output = 'An unexpected error occurred while trying to sign up via the CLI.';
|
|
52
|
+
if (typeof e === 'object' && e !== null) {
|
|
53
|
+
const errObj = e;
|
|
54
|
+
const stdout = typeof errObj.stdout === 'string' ? errObj.stdout.trim() : '';
|
|
55
|
+
const stderr = typeof errObj.stderr === 'string' ? errObj.stderr.trim() : '';
|
|
56
|
+
const msg = typeof errObj.message === 'string' ? errObj.message : '';
|
|
57
|
+
output = stdout || stderr || msg || output;
|
|
58
|
+
}
|
|
59
|
+
else if (typeof e === 'string') {
|
|
60
|
+
output = e;
|
|
61
|
+
}
|
|
62
|
+
const errorResult = {
|
|
63
|
+
error: output,
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
67
|
+
details: null,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk';
|
|
2
|
+
import type { MemoriPluginConfig } from '../types.js';
|
|
3
|
+
import type { MemoriLogger } from '../utils/logger.js';
|
|
4
|
+
export interface ToolDeps {
|
|
5
|
+
api: OpenClawPluginApi;
|
|
6
|
+
config: MemoriPluginConfig;
|
|
7
|
+
logger: MemoriLogger;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
|
+
import { IntegrationMessage } from '@memorilabs/memori/integrations';
|
|
1
2
|
export interface MemoriPluginConfig {
|
|
2
3
|
apiKey: string;
|
|
3
4
|
entityId: string;
|
|
5
|
+
projectId: string;
|
|
4
6
|
}
|
|
5
7
|
export interface OpenClawMessageBlock {
|
|
6
8
|
type?: string;
|
|
7
9
|
text?: string;
|
|
8
10
|
thinking?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
arguments?: unknown;
|
|
9
14
|
[key: string]: unknown;
|
|
10
15
|
}
|
|
11
16
|
export interface OpenClawMessage {
|
|
12
|
-
role:
|
|
17
|
+
role: string;
|
|
13
18
|
content: string | OpenClawMessageBlock[];
|
|
14
19
|
timestamp?: number;
|
|
20
|
+
toolCallId?: string;
|
|
21
|
+
provider?: string;
|
|
22
|
+
model?: string;
|
|
15
23
|
[key: string]: unknown;
|
|
16
24
|
}
|
|
17
25
|
export interface OpenClawEvent {
|
|
@@ -32,3 +40,13 @@ export interface OpenClawContext {
|
|
|
32
40
|
workspaceDir?: string;
|
|
33
41
|
messageProvider?: string;
|
|
34
42
|
}
|
|
43
|
+
export interface ExtractedToolCall {
|
|
44
|
+
name: string;
|
|
45
|
+
args: Record<string, unknown>;
|
|
46
|
+
result: unknown;
|
|
47
|
+
}
|
|
48
|
+
export interface ParsedTurn {
|
|
49
|
+
userMessage: IntegrationMessage | null;
|
|
50
|
+
assistantMessage: IntegrationMessage | null;
|
|
51
|
+
tools: ExtractedToolCall[];
|
|
52
|
+
}
|
package/dist/utils/context.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface ExtractedContext {
|
|
|
6
6
|
entityId: string;
|
|
7
7
|
sessionId: string;
|
|
8
8
|
provider: string;
|
|
9
|
+
projectId: string;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Extracts and normalizes context information from OpenClaw event and context objects.
|
|
@@ -14,7 +15,8 @@ export interface ExtractedContext {
|
|
|
14
15
|
* @param event - OpenClaw event object
|
|
15
16
|
* @param ctx - OpenClaw context object
|
|
16
17
|
* @param configuredEntityId - Hardcoded entity ID from plugin config
|
|
17
|
-
* @
|
|
18
|
+
* @param configuredProjectId - Project ID from plugin config
|
|
19
|
+
* @returns Normalized context with entityId, sessionId, provider, and projectId
|
|
18
20
|
* @throws Error If entityId, sessionId, or provider cannot be determined
|
|
19
21
|
*/
|
|
20
|
-
export declare function extractContext(event: OpenClawEvent, ctx: OpenClawContext, configuredEntityId: string): ExtractedContext;
|
|
22
|
+
export declare function extractContext(event: OpenClawEvent, ctx: OpenClawContext, configuredEntityId: string, configuredProjectId: string): ExtractedContext;
|
package/dist/utils/context.js
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* @param event - OpenClaw event object
|
|
6
6
|
* @param ctx - OpenClaw context object
|
|
7
7
|
* @param configuredEntityId - Hardcoded entity ID from plugin config
|
|
8
|
-
* @
|
|
8
|
+
* @param configuredProjectId - Project ID from plugin config
|
|
9
|
+
* @returns Normalized context with entityId, sessionId, provider, and projectId
|
|
9
10
|
* @throws Error If entityId, sessionId, or provider cannot be determined
|
|
10
11
|
*/
|
|
11
|
-
export function extractContext(event, ctx, configuredEntityId) {
|
|
12
|
+
export function extractContext(event, ctx, configuredEntityId, configuredProjectId) {
|
|
12
13
|
const sessionId = ctx.sessionKey || event.sessionId;
|
|
13
14
|
const provider = ctx.messageProvider || event.messageProvider;
|
|
14
15
|
if (!sessionId) {
|
|
@@ -21,5 +22,6 @@ export function extractContext(event, ctx, configuredEntityId) {
|
|
|
21
22
|
entityId: configuredEntityId,
|
|
22
23
|
sessionId,
|
|
23
24
|
provider,
|
|
25
|
+
projectId: configuredProjectId,
|
|
24
26
|
};
|
|
25
27
|
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { extractContext, type ExtractedContext } from './context.js';
|
|
2
2
|
export { MemoriLogger } from './logger.js';
|
|
3
|
-
export { initializeMemoriClient } from './memori-client.js';
|
|
3
|
+
export { initializeMemoriClient, createRecallClient } from './memori-client.js';
|
|
4
|
+
export { loadSkillsContent } from './skills-loader.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { extractContext } from './context.js';
|
|
2
2
|
export { MemoriLogger } from './logger.js';
|
|
3
|
-
export { initializeMemoriClient } from './memori-client.js';
|
|
3
|
+
export { initializeMemoriClient, createRecallClient } from './memori-client.js';
|
|
4
|
+
export { loadSkillsContent } from './skills-loader.js';
|
|
@@ -8,3 +8,14 @@ import { ExtractedContext } from './context.js';
|
|
|
8
8
|
* @returns Configured OpenClawIntegration instance
|
|
9
9
|
*/
|
|
10
10
|
export declare function initializeMemoriClient(apiKey: string, context: ExtractedContext): OpenClawIntegration;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a minimal Memori client scoped only to an entity, with no session or project
|
|
13
|
+
* context pre-set. Intended for use in tool execute handlers where OpenClaw does not
|
|
14
|
+
* reliably provide session context — callers supply projectId/sessionId as explicit
|
|
15
|
+
* parameters instead.
|
|
16
|
+
*
|
|
17
|
+
* @param apiKey - Memori API key
|
|
18
|
+
* @param entityId - Entity ID for attribution
|
|
19
|
+
* @returns Configured OpenClawIntegration instance
|
|
20
|
+
*/
|
|
21
|
+
export declare function createRecallClient(apiKey: string, entityId: string): OpenClawIntegration;
|
|
@@ -11,7 +11,25 @@ export function initializeMemoriClient(apiKey, context) {
|
|
|
11
11
|
const memori = new Memori();
|
|
12
12
|
memori.config.apiKey = apiKey;
|
|
13
13
|
const openclaw = memori.integrate(OpenClawIntegration);
|
|
14
|
-
openclaw
|
|
15
|
-
|
|
14
|
+
openclaw
|
|
15
|
+
.scope(context.sessionId, context.projectId)
|
|
16
|
+
.attribution(context.entityId, context.provider);
|
|
17
|
+
return openclaw;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a minimal Memori client scoped only to an entity, with no session or project
|
|
21
|
+
* context pre-set. Intended for use in tool execute handlers where OpenClaw does not
|
|
22
|
+
* reliably provide session context — callers supply projectId/sessionId as explicit
|
|
23
|
+
* parameters instead.
|
|
24
|
+
*
|
|
25
|
+
* @param apiKey - Memori API key
|
|
26
|
+
* @param entityId - Entity ID for attribution
|
|
27
|
+
* @returns Configured OpenClawIntegration instance
|
|
28
|
+
*/
|
|
29
|
+
export function createRecallClient(apiKey, entityId) {
|
|
30
|
+
const memori = new Memori();
|
|
31
|
+
memori.config.apiKey = apiKey;
|
|
32
|
+
const openclaw = memori.integrate(OpenClawIntegration);
|
|
33
|
+
openclaw.attribution(entityId);
|
|
16
34
|
return openclaw;
|
|
17
35
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the Memori skills document at plugin registration time.
|
|
3
|
+
* Returns an empty string if the file cannot be read so the plugin
|
|
4
|
+
* degrades gracefully rather than failing to register.
|
|
5
|
+
*/
|
|
6
|
+
export declare function loadSkillsContent(resolvePath: (input: string) => string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
/**
|
|
3
|
+
* Loads the Memori skills document at plugin registration time.
|
|
4
|
+
* Returns an empty string if the file cannot be read so the plugin
|
|
5
|
+
* degrades gracefully rather than failing to register.
|
|
6
|
+
*/
|
|
7
|
+
export function loadSkillsContent(resolvePath) {
|
|
8
|
+
try {
|
|
9
|
+
return readFileSync(resolvePath('skills/memori/SKILL.md'), 'utf-8');
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.0.
|
|
1
|
+
export declare const SDK_VERSION = "0.0.6-beta";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = '0.0.
|
|
1
|
+
export const SDK_VERSION = '0.0.6-beta';
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "openclaw-memori",
|
|
3
3
|
"name": "Memori System",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.13",
|
|
5
5
|
"description": "Hosted memory backend",
|
|
6
6
|
"kind": "memory",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
|
+
"contracts": {
|
|
9
|
+
"tools": [
|
|
10
|
+
"memori_recall",
|
|
11
|
+
"memori_recall_summary",
|
|
12
|
+
"memori_compaction",
|
|
13
|
+
"memori_feedback",
|
|
14
|
+
"memori_signup",
|
|
15
|
+
"memori_quota"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
8
18
|
"uiHints": {
|
|
9
19
|
"apiKey": {
|
|
10
20
|
"label": "Memori API Key",
|
|
@@ -16,6 +26,11 @@
|
|
|
16
26
|
"label": "Entity ID",
|
|
17
27
|
"placeholder": "e.g., your-app-user-id",
|
|
18
28
|
"help": "Required. The unique identifier to attribute these memories to."
|
|
29
|
+
},
|
|
30
|
+
"projectId": {
|
|
31
|
+
"label": "Project ID",
|
|
32
|
+
"placeholder": "e.g., my-project",
|
|
33
|
+
"help": "Required. Scopes all memories to this project."
|
|
19
34
|
}
|
|
20
35
|
},
|
|
21
36
|
"configSchema": {
|
|
@@ -29,7 +44,12 @@
|
|
|
29
44
|
"entityId": {
|
|
30
45
|
"type": "string",
|
|
31
46
|
"title": "Entity ID",
|
|
32
|
-
"description": "Required.
|
|
47
|
+
"description": "Required. The unique identifier to attribute these memories to."
|
|
48
|
+
},
|
|
49
|
+
"projectId": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"title": "Project ID",
|
|
52
|
+
"description": "Required. Scopes all memories to this project."
|
|
33
53
|
}
|
|
34
54
|
},
|
|
35
55
|
"required": []
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memorilabs/openclaw-memori",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6-beta",
|
|
4
4
|
"description": "Official MemoriLabs.ai long-term memory plugin for OpenClaw",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
|
+
"skills",
|
|
10
11
|
"openclaw.plugin.json"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
@@ -66,6 +67,6 @@
|
|
|
66
67
|
"@hono/node-server": "^1.19.10"
|
|
67
68
|
},
|
|
68
69
|
"dependencies": {
|
|
69
|
-
"@memorilabs/memori": "^0.
|
|
70
|
+
"@memorilabs/memori": "^0.1.22-beta"
|
|
70
71
|
}
|
|
71
72
|
}
|