@@ -6,6 +6,37 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"
66import type { SupermemoryClient } from "../client.ts"
77import { log } from "../logger.ts"
88
9+ const SUPERMEMORY_TOOL_NAMES = [
10+ "supermemory_store" ,
11+ "supermemory_search" ,
12+ "supermemory_forget" ,
13+ "supermemory_profile" ,
14+ ]
15+
16+ function appendUniqueStrings ( value : unknown , entries : string [ ] ) : string [ ] {
17+ const current = Array . isArray ( value )
18+ ? value . filter ( ( item ) : item is string => typeof item === "string" )
19+ : [ ]
20+ return Array . from ( new Set ( [ ...current , ...entries ] ) )
21+ }
22+
23+ function ensureSupermemoryToolsAllowed ( config : Record < string , unknown > ) : void {
24+ if (
25+ ! config . tools ||
26+ typeof config . tools !== "object" ||
27+ Array . isArray ( config . tools )
28+ ) {
29+ config . tools = { }
30+ }
31+
32+ const tools = config . tools as Record < string , unknown >
33+ tools . alsoAllow = appendUniqueStrings ( tools . alsoAllow , SUPERMEMORY_TOOL_NAMES )
34+
35+ if ( Array . isArray ( tools . allow ) ) {
36+ tools . allow = appendUniqueStrings ( tools . allow , SUPERMEMORY_TOOL_NAMES )
37+ }
38+ }
39+
940export function registerCli (
1041 api : OpenClawPluginApi ,
1142 client ?: SupermemoryClient ,
@@ -58,11 +89,16 @@ export function registerCli(
5889 if ( ! config . plugins ) config . plugins = { }
5990 const plugins = config . plugins as Record < string , unknown >
6091 if ( ! plugins . entries ) plugins . entries = { }
92+ if ( ! plugins . slots ) plugins . slots = { }
93+ ensureSupermemoryToolsAllowed ( config )
6194 const entries = plugins . entries as Record < string , unknown >
95+ const slots = plugins . slots as Record < string , unknown >
96+ slots . memory = "openclaw-supermemory"
6297
6398 entries [ "openclaw-supermemory" ] = {
6499 enabled : true ,
65100 hooks : {
101+ allowPromptInjection : true ,
66102 allowConversationAccess : true ,
67103 } ,
68104 config : {
@@ -78,7 +114,7 @@ export function registerCli(
78114
79115 console . log ( "\n✓ API key saved to ~/.openclaw/openclaw.json" )
80116 console . log (
81- " Restart OpenClaw to apply changes: openclaw gateway --force \n" ,
117+ " Restart OpenClaw to apply changes: openclaw gateway restart \n" ,
82118 )
83119 } )
84120
@@ -280,7 +316,11 @@ export function registerCli(
280316 if ( ! config . plugins ) config . plugins = { }
281317 const plugins = config . plugins as Record < string , unknown >
282318 if ( ! plugins . entries ) plugins . entries = { }
319+ if ( ! plugins . slots ) plugins . slots = { }
320+ ensureSupermemoryToolsAllowed ( config )
283321 const entries = plugins . entries as Record < string , unknown >
322+ const slots = plugins . slots as Record < string , unknown >
323+ slots . memory = "openclaw-supermemory"
284324
285325 const pluginConfig : Record < string , unknown > = {
286326 apiKey : apiKey . trim ( ) ,
@@ -314,6 +354,7 @@ export function registerCli(
314354 entries [ "openclaw-supermemory" ] = {
315355 enabled : true ,
316356 hooks : {
357+ allowPromptInjection : true ,
317358 allowConversationAccess : true ,
318359 } ,
319360 config : pluginConfig ,
@@ -358,7 +399,7 @@ export function registerCli(
358399 ` Routing instructions: "${ customContainerInstructions . trim ( ) . slice ( 0 , 50 ) } ${ customContainerInstructions . length > 50 ? "..." : "" } "` ,
359400 )
360401 }
361- console . log ( "\nRestart OpenClaw to apply: openclaw gateway --force \n" )
402+ console . log ( "\nRestart OpenClaw to apply: openclaw gateway restart \n" )
362403 } )
363404
364405 cmd
0 commit comments