@memorilabs/openclaw-memori 0.0.8 → 0.0.10
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 +118 -91
- 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/handlers/augmentation.js +12 -5
- package/dist/index.js +10 -3
- package/dist/sanitizer.d.ts +1 -0
- package/dist/sanitizer.js +10 -2
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +12 -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 +61 -0
- package/dist/tools/memori-recall.js +99 -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 +4 -8
- 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 +15 -2
- package/package.json +3 -2
- package/skills/clawhub/SKILL.md +313 -0
- package/skills/memori/SKILL.md +284 -0
- package/dist/handlers/recall.d.ts +0 -5
- package/dist/handlers/recall.js +0 -34
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRecallClient } from '../utils/memori-client.js';
|
|
2
|
+
export function createMemoriFeedbackTool(deps) {
|
|
3
|
+
const { config, logger } = deps;
|
|
4
|
+
return {
|
|
5
|
+
name: 'memori_feedback',
|
|
6
|
+
label: 'Memori Feedback',
|
|
7
|
+
description: 'CRITICAL: You MUST use this tool immediately whenever the user asks you to send feedback, report a bug, suggest a feature, or complain about Memori. Send feedback directly to the Memori team (positive or negative).',
|
|
8
|
+
parameters: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
content: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'REQUIRED: The feedback message to send.',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
required: ['content'],
|
|
17
|
+
},
|
|
18
|
+
async execute(_toolCallId, params) {
|
|
19
|
+
try {
|
|
20
|
+
logger.info(`memori_feedback sending: ${params.content}`);
|
|
21
|
+
const client = createRecallClient(config.apiKey, config.entityId);
|
|
22
|
+
await client.agentFeedback(params.content);
|
|
23
|
+
const result = { success: true, message: 'Feedback sent successfully.' };
|
|
24
|
+
return {
|
|
25
|
+
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
26
|
+
details: null,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
logger.warn(`memori_feedback failed: ${String(e)}`);
|
|
31
|
+
const errorResult = { error: 'Feedback failed to send.' };
|
|
32
|
+
logger.info(`memori_feedback error result: ${JSON.stringify(errorResult)}`);
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
35
|
+
details: null,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ToolDeps } from './types.js';
|
|
2
|
+
export declare function createMemoriQuotaTool(deps: ToolDeps): {
|
|
3
|
+
name: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {};
|
|
9
|
+
};
|
|
10
|
+
execute(_toolCallId: string): Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
details: null;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
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 createMemoriQuotaTool(deps) {
|
|
7
|
+
const { logger } = deps;
|
|
8
|
+
return {
|
|
9
|
+
name: 'memori_quota',
|
|
10
|
+
label: 'Memori Quota',
|
|
11
|
+
description: 'Retrieves the current memory usage and maximum allowed quota for the user. Use this when the user asks about their limits, storage, or how many memories they have left — or when you encounter errors suggesting memory limits have been reached and want to confirm before degrading behavior.',
|
|
12
|
+
parameters: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {},
|
|
15
|
+
},
|
|
16
|
+
async execute(_toolCallId) {
|
|
17
|
+
try {
|
|
18
|
+
logger.info('memori_quota checking usage...');
|
|
19
|
+
const tmpDir = os.tmpdir();
|
|
20
|
+
await execAsync(`npm install --prefix ${tmpDir} --no-save @memorilabs/memori@0.1.12-beta`);
|
|
21
|
+
const binPath = path.join(tmpDir, 'node_modules', '.bin', 'memori');
|
|
22
|
+
const { stdout } = await execAsync(`${binPath} quota`);
|
|
23
|
+
const result = {
|
|
24
|
+
success: true,
|
|
25
|
+
message: stdout.trim(),
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
29
|
+
details: null,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
logger.warn(`memori_quota CLI failed: ${String(e)}`);
|
|
34
|
+
let output = 'An unexpected error occurred while trying to fetch quota via the CLI.';
|
|
35
|
+
if (typeof e === 'object' && e !== null) {
|
|
36
|
+
const errObj = e;
|
|
37
|
+
const stdout = typeof errObj.stdout === 'string' ? errObj.stdout.trim() : '';
|
|
38
|
+
const stderr = typeof errObj.stderr === 'string' ? errObj.stderr.trim() : '';
|
|
39
|
+
const msg = typeof errObj.message === 'string' ? errObj.message : '';
|
|
40
|
+
output = stdout || stderr || msg || output;
|
|
41
|
+
}
|
|
42
|
+
else if (typeof e === 'string') {
|
|
43
|
+
output = e;
|
|
44
|
+
}
|
|
45
|
+
const errorResult = {
|
|
46
|
+
error: output,
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
50
|
+
details: null,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ToolDeps } from './types.js';
|
|
2
|
+
export declare function createMemoriRecallSummaryTool(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
|
+
};
|
|
26
|
+
};
|
|
27
|
+
execute(_toolCallId: string, params: {
|
|
28
|
+
dateStart?: string;
|
|
29
|
+
dateEnd?: string;
|
|
30
|
+
projectId?: string;
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
content: {
|
|
34
|
+
type: "text";
|
|
35
|
+
text: string;
|
|
36
|
+
}[];
|
|
37
|
+
details: null;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
@@ -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,61 @@
|
|
|
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
|
+
query: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
limit: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
dateStart: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
dateEnd: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
projectId: {
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
sessionId: {
|
|
30
|
+
type: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
signal: {
|
|
34
|
+
type: string;
|
|
35
|
+
description: string;
|
|
36
|
+
enum: string[];
|
|
37
|
+
};
|
|
38
|
+
source: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
enum: string[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
required: string[];
|
|
45
|
+
};
|
|
46
|
+
execute(_toolCallId: string, params: {
|
|
47
|
+
query: string;
|
|
48
|
+
dateStart?: string;
|
|
49
|
+
dateEnd?: string;
|
|
50
|
+
projectId?: string;
|
|
51
|
+
sessionId?: string;
|
|
52
|
+
signal?: string;
|
|
53
|
+
source?: string;
|
|
54
|
+
}): Promise<{
|
|
55
|
+
content: {
|
|
56
|
+
type: "text";
|
|
57
|
+
text: string;
|
|
58
|
+
}[];
|
|
59
|
+
details: null;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
query: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'REQUIRED: The natural language search query to find specific facts (e.g., "What database did we decide to use?", "Ryan\'s dogs"). DO NOT use wildcards like "*" or regex. This is a semantic search, so use real words.',
|
|
14
|
+
},
|
|
15
|
+
limit: {
|
|
16
|
+
type: 'number',
|
|
17
|
+
description: 'Maximum number of memories to return (default: 10)',
|
|
18
|
+
},
|
|
19
|
+
dateStart: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'ISO 8601 (MUST be UTC) date string to filter memories created on or after this time',
|
|
22
|
+
},
|
|
23
|
+
dateEnd: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'ISO 8601 (MUST be UTC) date string to filter memories created on or before this time',
|
|
26
|
+
},
|
|
27
|
+
projectId: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
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.',
|
|
30
|
+
},
|
|
31
|
+
sessionId: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Filter to a specific session. Cannot be used without projectId.',
|
|
34
|
+
},
|
|
35
|
+
signal: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Filter to a specific fact signal. MUST be one of the allowed enum values.',
|
|
38
|
+
enum: [
|
|
39
|
+
'commit',
|
|
40
|
+
'discovery',
|
|
41
|
+
'failure',
|
|
42
|
+
'inference',
|
|
43
|
+
'pattern',
|
|
44
|
+
'result',
|
|
45
|
+
'update',
|
|
46
|
+
'verification',
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
source: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
description: 'Filter to a specific source origin. MUST be one of the allowed enum values.',
|
|
52
|
+
enum: [
|
|
53
|
+
'constraint',
|
|
54
|
+
'decision',
|
|
55
|
+
'execution',
|
|
56
|
+
'fact',
|
|
57
|
+
'insight',
|
|
58
|
+
'instruction',
|
|
59
|
+
'status',
|
|
60
|
+
'strategy',
|
|
61
|
+
'task',
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
// Force the LLM to ALWAYS provide a search query
|
|
66
|
+
required: ['query'],
|
|
67
|
+
},
|
|
68
|
+
async execute(_toolCallId, params) {
|
|
69
|
+
try {
|
|
70
|
+
// If params.projectId is undefined, it falls back to config.projectId.
|
|
71
|
+
// If the LLM intentionally provides one, it overwrites the config.
|
|
72
|
+
const finalParams = { projectId: config.projectId, ...params };
|
|
73
|
+
if (finalParams.sessionId && !finalParams.projectId) {
|
|
74
|
+
const errorResult = { error: 'sessionId cannot be provided without projectId' };
|
|
75
|
+
logger.warn(`memori_recall rejected: ${JSON.stringify(errorResult)}`);
|
|
76
|
+
return {
|
|
77
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
78
|
+
details: null,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
logger.info(`memori_recall params: ${JSON.stringify(finalParams)}`);
|
|
82
|
+
const client = createRecallClient(config.apiKey, config.entityId);
|
|
83
|
+
const result = await client.agentRecall(finalParams);
|
|
84
|
+
return {
|
|
85
|
+
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
86
|
+
details: null,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
logger.warn(`memori_recall failed: ${String(e)}`);
|
|
91
|
+
const errorResult = { error: 'Recall failed' };
|
|
92
|
+
return {
|
|
93
|
+
content: [{ type: 'text', text: JSON.stringify(errorResult) }],
|
|
94
|
+
details: null,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -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,6 +1,8 @@
|
|
|
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;
|
|
@@ -44,13 +46,7 @@ export interface ExtractedToolCall {
|
|
|
44
46
|
result: unknown;
|
|
45
47
|
}
|
|
46
48
|
export interface ParsedTurn {
|
|
47
|
-
userMessage:
|
|
48
|
-
|
|
49
|
-
content: string;
|
|
50
|
-
} | null;
|
|
51
|
-
assistantMessage: {
|
|
52
|
-
role: string;
|
|
53
|
-
content: string;
|
|
54
|
-
} | null;
|
|
49
|
+
userMessage: IntegrationMessage | null;
|
|
50
|
+
assistantMessage: IntegrationMessage | null;
|
|
55
51
|
tools: ExtractedToolCall[];
|
|
56
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.10";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = '0.0.
|
|
1
|
+
export const SDK_VERSION = '0.0.10';
|