@mingxy/cerebro 1.6.9 → 1.7.1
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/package.json +1 -1
- package/src/index.ts +4 -18
- package/src/tui.tsx +6 -4
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -32,8 +32,9 @@ export function setAutoStoreEnabled(sessionId: string, enabled: boolean): void {
|
|
|
32
32
|
autoStoreSessions.set(sessionId, enabled);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// Bridge for TUI plugin
|
|
36
|
-
(
|
|
35
|
+
// Bridge for TUI plugin: expose the Map directly so TUI can query with its own sessionID
|
|
36
|
+
// (tool sessionId and TUI sessionID may differ in format)
|
|
37
|
+
(globalThis as any).__cerebro_autoStoreMap = autoStoreSessions;
|
|
37
38
|
|
|
38
39
|
function showToast(tui: any, title: string, message?: string, variant: string = "info", duration: number = 5000) {
|
|
39
40
|
if (!tui) return;
|
|
@@ -116,25 +117,10 @@ const OmemPlugin: Plugin = async (input) => {
|
|
|
116
117
|
config: async (cfg: any) => {
|
|
117
118
|
cfg.command ??= {};
|
|
118
119
|
cfg.command["memory-toggle"] = {
|
|
119
|
-
template: "
|
|
120
|
+
template: "Use the memory_toggle tool with state='$ARGUMENTS' to toggle Cerebro auto-store for this session. You MUST call the memory_toggle tool, do not just acknowledge.",
|
|
120
121
|
description: "Toggle Cerebro auto-store ON or OFF for current session",
|
|
121
122
|
};
|
|
122
123
|
},
|
|
123
|
-
"command.execute.before": async (input: { command: string; sessionID: string; arguments: string }, output: { parts: any[] }) => {
|
|
124
|
-
if (input.command !== "memory-toggle") return;
|
|
125
|
-
const arg = input.arguments.trim().toLowerCase();
|
|
126
|
-
const sessionId = input.sessionID;
|
|
127
|
-
if (arg === "off") {
|
|
128
|
-
setAutoStoreEnabled(sessionId, false);
|
|
129
|
-
output.parts = [{ type: "text", text: "⏸️ Cerebro auto-store: OFF — manual memory_store still works" }];
|
|
130
|
-
} else if (arg === "on") {
|
|
131
|
-
setAutoStoreEnabled(sessionId, true);
|
|
132
|
-
output.parts = [{ type: "text", text: "✅ Cerebro auto-store: ON" }];
|
|
133
|
-
} else {
|
|
134
|
-
const current = isAutoStoreEnabled(sessionId);
|
|
135
|
-
output.parts = [{ type: "text", text: `Cerebro auto-store: ${current ? "✅ ON" : "⏸️ OFF"}\nUsage: /memory-toggle on | off` }];
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
124
|
"experimental.chat.system.transform": async (input: any, output: any) => {
|
|
139
125
|
if (input.sessionID) currentSessionId = input.sessionID;
|
|
140
126
|
return recallHook(input, output);
|
package/src/tui.tsx
CHANGED
|
@@ -13,24 +13,26 @@ function SidebarContentView(props: {
|
|
|
13
13
|
const [autoStore, setAutoStore] = createSignal(true);
|
|
14
14
|
const theme = () => props.api.theme.current;
|
|
15
15
|
|
|
16
|
+
const readAutoStore = () => (globalThis as any).__cerebro_autoStoreMap?.get(props.sessionID) ?? true;
|
|
17
|
+
|
|
16
18
|
const unsubscribers = [
|
|
17
19
|
props.api.event.on("session.updated", () => {
|
|
18
|
-
setAutoStore(
|
|
20
|
+
setAutoStore(readAutoStore());
|
|
19
21
|
}),
|
|
20
22
|
props.api.event.on("tui.session.select", (event) => {
|
|
21
23
|
if (event.properties?.sessionID === props.sessionID) {
|
|
22
|
-
setAutoStore(
|
|
24
|
+
setAutoStore(readAutoStore());
|
|
23
25
|
}
|
|
24
26
|
}),
|
|
25
27
|
];
|
|
26
28
|
|
|
27
29
|
createEffect(() => {
|
|
28
30
|
props.sessionID;
|
|
29
|
-
setAutoStore(
|
|
31
|
+
setAutoStore(readAutoStore());
|
|
30
32
|
});
|
|
31
33
|
|
|
32
34
|
const interval = setInterval(() => {
|
|
33
|
-
setAutoStore(
|
|
35
|
+
setAutoStore(readAutoStore());
|
|
34
36
|
}, 2000);
|
|
35
37
|
|
|
36
38
|
onCleanup(() => {
|