@mingxy/cerebro 2.3.3 → 2.3.5
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 +2 -2
- package/src/client.ts +412 -403
- package/src/config.ts +277 -275
- package/src/hooks.ts +1040 -1019
- package/src/index.ts +229 -229
- package/src/tools.ts +455 -455
- package/web/assets/{index-DM_NPfgX.js → index-zOJZZn-i.js} +4 -4
- package/web/icons.svg +24 -24
- package/web/index.html +14 -14
- package/src/client.test.ts +0 -373
- package/src/config.test.ts +0 -405
- package/src/hooks-tier1.test.ts +0 -220
- package/src/hooks-tier2.test.ts +0 -275
- package/src/hooks-tier3.test.ts +0 -461
- package/src/index.test.ts +0 -190
- package/src/keywords.test.ts +0 -283
- package/src/logger.test.ts +0 -640
- package/src/privacy.test.ts +0 -128
- package/src/tags.test.ts +0 -86
- package/src/tools.test.ts +0 -508
- package/src/updater.test.ts +0 -380
- package/src/web-server.test.ts +0 -740
package/src/index.ts
CHANGED
|
@@ -1,230 +1,230 @@
|
|
|
1
|
-
import type { Plugin } from "@opencode-ai/plugin";
|
|
2
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join, dirname } from "node:path";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { CerebroClient } from "./client.js";
|
|
7
|
-
import { chatMessageRecallHook, autocontinueHook, compactingHook, sessionIdleHook, sessionMessages, firstMessages, timeMemorySystemHook } from "./hooks.js";
|
|
8
|
-
import { detectSaveKeyword, detectRecallKeyword, KEYWORD_NUDGE, RECALL_NUDGE } from "./keywords.js";
|
|
9
|
-
import { getUserTag, getProjectTag } from "./tags.js";
|
|
10
|
-
import { buildTools } from "./tools.js";
|
|
11
|
-
import { logInfo, logDebug, logError, setOpencodeClient } from "./logger.js";
|
|
12
|
-
import { loadPluginConfig, resolveAgentPolicy } from "./config.js";
|
|
13
|
-
import { checkAndUpdate } from "./updater.js";
|
|
14
|
-
import { startWebServer, stopWebServer, type WebServerHandle } from "./web-server.js";
|
|
15
|
-
|
|
16
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
-
const __dirname = dirname(__filename);
|
|
18
|
-
|
|
19
|
-
let pluginVersion = "unknown";
|
|
20
|
-
try {
|
|
21
|
-
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
22
|
-
if (pkg?.version && typeof pkg.version === "string") {
|
|
23
|
-
pluginVersion = pkg.version;
|
|
24
|
-
}
|
|
25
|
-
} catch {}
|
|
26
|
-
|
|
27
|
-
// Per-session auto-store toggle: sessionId → enabled (default: true = auto-store on)
|
|
28
|
-
const autoStoreSessions = new Map<string, boolean>();
|
|
29
|
-
|
|
30
|
-
function getStateFilePath(sessionId: string): string {
|
|
31
|
-
return join(tmpdir(), `cerebro_autostore_${sessionId}.json`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function isAutoStoreEnabled(sessionId: string | undefined): boolean {
|
|
35
|
-
if (!sessionId) return true;
|
|
36
|
-
const cached = autoStoreSessions.get(sessionId);
|
|
37
|
-
if (cached !== undefined) return cached;
|
|
38
|
-
// Fallback: read from persisted file (survives restart)
|
|
39
|
-
try {
|
|
40
|
-
const data = JSON.parse(readFileSync(getStateFilePath(sessionId), "utf-8"));
|
|
41
|
-
const enabled = data.enabled ?? true;
|
|
42
|
-
autoStoreSessions.set(sessionId, enabled); // cache for next time
|
|
43
|
-
return enabled;
|
|
44
|
-
} catch {
|
|
45
|
-
return true; // file doesn't exist → default ON
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function setAutoStoreEnabled(sessionId: string, enabled: boolean): void {
|
|
50
|
-
autoStoreSessions.set(sessionId, enabled);
|
|
51
|
-
try {
|
|
52
|
-
writeFileSync(getStateFilePath(sessionId), JSON.stringify({ enabled }));
|
|
53
|
-
} catch {}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
(globalThis as any).__cerebro_autoStoreMap = autoStoreSessions;
|
|
57
|
-
|
|
58
|
-
const OmemPlugin: Plugin = async (input) => {
|
|
59
|
-
// Normalize to git root: worktree=git root, directory=cwd.
|
|
60
|
-
// project_path must be git root so parent/child dirs share memories.
|
|
61
|
-
const { directory: _directory, worktree, client } = input;
|
|
62
|
-
// opencode 在非git目录启动时给 worktree="/"(global project,见 opencode 源码
|
|
63
|
-
// database-migration.test.ts:448 `SELECT worktree FROM project WHERE id='global' → '/'`)。
|
|
64
|
-
// 这种情况直接用 `/` 会让服务端 SQL `LIKE '/%'` 命中所有绝对路径记忆,污染注入。
|
|
65
|
-
// fallback 到 cwd(_directory),让前缀匹配只命中 cwd 子树。
|
|
66
|
-
const isWorktreeValid = worktree && worktree !== "/" && worktree !== "." && worktree !== "";
|
|
67
|
-
const directory = isWorktreeValid ? worktree! : _directory;
|
|
68
|
-
const tui = (client as any)?.tui;
|
|
69
|
-
|
|
70
|
-
// Load overrides from opencode.json plugin_config
|
|
71
|
-
let overrides: Record<string, unknown> = {};
|
|
72
|
-
try {
|
|
73
|
-
const ocCfg = JSON.parse(readFileSync(join(directory, "opencode.json"), "utf-8"));
|
|
74
|
-
const pc = ocCfg?.plugin_config?.["@mingxy/cerebro"];
|
|
75
|
-
if (pc) overrides = pc;
|
|
76
|
-
} catch {}
|
|
77
|
-
|
|
78
|
-
const config = loadPluginConfig(overrides as any);
|
|
79
|
-
|
|
80
|
-
setOpencodeClient(client);
|
|
81
|
-
|
|
82
|
-
const cerebroClient = new CerebroClient(config.connection.apiUrl, config.connection.apiKey, config);
|
|
83
|
-
|
|
84
|
-
let connectionStatus: "success" | "error" = "success";
|
|
85
|
-
let statusMessage = "";
|
|
86
|
-
try {
|
|
87
|
-
await cerebroClient.getStats();
|
|
88
|
-
logInfo(`Connected to ${config.connection.apiUrl}`);
|
|
89
|
-
} catch (err) {
|
|
90
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
91
|
-
logError(`Connection failed: ${errMsg}`);
|
|
92
|
-
connectionStatus = "error";
|
|
93
|
-
if (errMsg.includes("[cerebro]")) {
|
|
94
|
-
statusMessage = errMsg.replace(/^\[cerebro]\s*/, "").substring(0, 150);
|
|
95
|
-
} else {
|
|
96
|
-
statusMessage = `Unable to reach ${config.connection.apiUrl}`;
|
|
97
|
-
}
|
|
1
|
+
import type { Plugin } from "@opencode-ai/plugin";
|
|
2
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join, dirname } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { CerebroClient } from "./client.js";
|
|
7
|
+
import { chatMessageRecallHook, autocontinueHook, compactingHook, sessionIdleHook, sessionMessages, firstMessages, timeMemorySystemHook } from "./hooks.js";
|
|
8
|
+
import { detectSaveKeyword, detectRecallKeyword, KEYWORD_NUDGE, RECALL_NUDGE } from "./keywords.js";
|
|
9
|
+
import { getUserTag, getProjectTag } from "./tags.js";
|
|
10
|
+
import { buildTools } from "./tools.js";
|
|
11
|
+
import { logInfo, logDebug, logError, setOpencodeClient } from "./logger.js";
|
|
12
|
+
import { loadPluginConfig, resolveAgentPolicy } from "./config.js";
|
|
13
|
+
import { checkAndUpdate } from "./updater.js";
|
|
14
|
+
import { startWebServer, stopWebServer, type WebServerHandle } from "./web-server.js";
|
|
15
|
+
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = dirname(__filename);
|
|
18
|
+
|
|
19
|
+
let pluginVersion = "unknown";
|
|
20
|
+
try {
|
|
21
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
22
|
+
if (pkg?.version && typeof pkg.version === "string") {
|
|
23
|
+
pluginVersion = pkg.version;
|
|
98
24
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
"
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
25
|
+
} catch {}
|
|
26
|
+
|
|
27
|
+
// Per-session auto-store toggle: sessionId → enabled (default: true = auto-store on)
|
|
28
|
+
const autoStoreSessions = new Map<string, boolean>();
|
|
29
|
+
|
|
30
|
+
function getStateFilePath(sessionId: string): string {
|
|
31
|
+
return join(tmpdir(), `cerebro_autostore_${sessionId}.json`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function isAutoStoreEnabled(sessionId: string | undefined): boolean {
|
|
35
|
+
if (!sessionId) return true;
|
|
36
|
+
const cached = autoStoreSessions.get(sessionId);
|
|
37
|
+
if (cached !== undefined) return cached;
|
|
38
|
+
// Fallback: read from persisted file (survives restart)
|
|
39
|
+
try {
|
|
40
|
+
const data = JSON.parse(readFileSync(getStateFilePath(sessionId), "utf-8"));
|
|
41
|
+
const enabled = data.enabled ?? true;
|
|
42
|
+
autoStoreSessions.set(sessionId, enabled); // cache for next time
|
|
43
|
+
return enabled;
|
|
44
|
+
} catch {
|
|
45
|
+
return true; // file doesn't exist → default ON
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function setAutoStoreEnabled(sessionId: string, enabled: boolean): void {
|
|
50
|
+
autoStoreSessions.set(sessionId, enabled);
|
|
51
|
+
try {
|
|
52
|
+
writeFileSync(getStateFilePath(sessionId), JSON.stringify({ enabled }));
|
|
53
|
+
} catch {}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
(globalThis as any).__cerebro_autoStoreMap = autoStoreSessions;
|
|
57
|
+
|
|
58
|
+
const OmemPlugin: Plugin = async (input) => {
|
|
59
|
+
// Normalize to git root: worktree=git root, directory=cwd.
|
|
60
|
+
// project_path must be git root so parent/child dirs share memories.
|
|
61
|
+
const { directory: _directory, worktree, client } = input;
|
|
62
|
+
// opencode 在非git目录启动时给 worktree="/"(global project,见 opencode 源码
|
|
63
|
+
// database-migration.test.ts:448 `SELECT worktree FROM project WHERE id='global' → '/'`)。
|
|
64
|
+
// 这种情况直接用 `/` 会让服务端 SQL `LIKE '/%'` 命中所有绝对路径记忆,污染注入。
|
|
65
|
+
// fallback 到 cwd(_directory),让前缀匹配只命中 cwd 子树。
|
|
66
|
+
const isWorktreeValid = worktree && worktree !== "/" && worktree !== "." && worktree !== "";
|
|
67
|
+
const directory = isWorktreeValid ? worktree! : _directory;
|
|
68
|
+
const tui = (client as any)?.tui;
|
|
69
|
+
|
|
70
|
+
// Load overrides from opencode.json plugin_config
|
|
71
|
+
let overrides: Record<string, unknown> = {};
|
|
72
|
+
try {
|
|
73
|
+
const ocCfg = JSON.parse(readFileSync(join(directory, "opencode.json"), "utf-8"));
|
|
74
|
+
const pc = ocCfg?.plugin_config?.["@mingxy/cerebro"];
|
|
75
|
+
if (pc) overrides = pc;
|
|
76
|
+
} catch {}
|
|
77
|
+
|
|
78
|
+
const config = loadPluginConfig(overrides as any);
|
|
79
|
+
|
|
80
|
+
setOpencodeClient(client);
|
|
81
|
+
|
|
82
|
+
const cerebroClient = new CerebroClient(config.connection.apiUrl, config.connection.apiKey, config);
|
|
83
|
+
|
|
84
|
+
let connectionStatus: "success" | "error" = "success";
|
|
85
|
+
let statusMessage = "";
|
|
86
|
+
try {
|
|
87
|
+
await cerebroClient.getStats();
|
|
88
|
+
logInfo(`Connected to ${config.connection.apiUrl}`);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
91
|
+
logError(`Connection failed: ${errMsg}`);
|
|
92
|
+
connectionStatus = "error";
|
|
93
|
+
if (errMsg.includes("[cerebro]")) {
|
|
94
|
+
statusMessage = errMsg.replace(/^\[cerebro]\s*/, "").substring(0, 150);
|
|
95
|
+
} else {
|
|
96
|
+
statusMessage = `Unable to reach ${config.connection.apiUrl}`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const email = process.env.GIT_AUTHOR_EMAIL || process.env.USER || "unknown";
|
|
101
|
+
const cwd = directory || process.cwd();
|
|
102
|
+
const containerTags = [getUserTag(email), getProjectTag(cwd)];
|
|
103
|
+
const agentId = process.env.OMEM_AGENT_ID || "opencode";
|
|
104
|
+
|
|
105
|
+
let mainSessionId: string | undefined;
|
|
106
|
+
let mainSessionLocked = false;
|
|
107
|
+
let cachedAgentName: string | undefined;
|
|
108
|
+
|
|
109
|
+
const chatMessageRecall = chatMessageRecallHook(cerebroClient, containerTags, tui, config, () => cachedAgentName || agentId, directory);
|
|
110
|
+
|
|
111
|
+
let webServer: WebServerHandle | null = null;
|
|
112
|
+
const webEnabled = config.web?.enabled !== false;
|
|
113
|
+
let webPort: number | undefined;
|
|
114
|
+
if (webEnabled) {
|
|
115
|
+
try {
|
|
116
|
+
webServer = await startWebServer({
|
|
117
|
+
apiUrl: config.connection.apiUrl,
|
|
118
|
+
port: config.web?.port,
|
|
119
|
+
});
|
|
120
|
+
if (webServer) {
|
|
121
|
+
const addr = webServer.address();
|
|
122
|
+
webPort = typeof addr === "object" && addr ? addr.port : config.web?.port || 5212;
|
|
123
|
+
logInfo(`Web UI available at http://localhost:${webPort}`);
|
|
124
|
+
}
|
|
125
|
+
} catch (err) {
|
|
126
|
+
logError(`Web server start failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const startupToast = connectionStatus === "error"
|
|
131
|
+
? { variant: "error" as const, title: `🧠 Cerebro v${pluginVersion} · Connection Failed`, message: statusMessage }
|
|
132
|
+
: webPort
|
|
133
|
+
? { variant: "success" as const, title: `🧠 Cerebro Connected · v${pluginVersion}`, message: `🌐 Open in browser http://localhost:${webPort}` }
|
|
134
|
+
: { variant: "success" as const, title: `🧠 Cerebro Connected · v${pluginVersion}`, message: "No web server" };
|
|
135
|
+
|
|
136
|
+
// Direct toast — same pattern as opencode-acp (client.tui.showToast, fire-and-forget, 5s delay)
|
|
137
|
+
setTimeout(() => {
|
|
138
|
+
(client as any)?.tui?.showToast({
|
|
139
|
+
body: {
|
|
140
|
+
title: startupToast.title,
|
|
141
|
+
message: startupToast.message,
|
|
142
|
+
variant: startupToast.variant,
|
|
143
|
+
duration: 7000,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}, 5000);
|
|
147
|
+
|
|
148
|
+
// Auto-update check (fire-and-forget, non-blocking)
|
|
149
|
+
checkAndUpdate(tui, pluginVersion).catch(() => {});
|
|
150
|
+
|
|
151
|
+
const shutdown = async () => {
|
|
152
|
+
try {
|
|
153
|
+
if (webServer) {
|
|
154
|
+
await stopWebServer(webServer);
|
|
155
|
+
webServer = null;
|
|
156
|
+
}
|
|
157
|
+
} catch {}
|
|
158
|
+
process.exit(0); // 强制退出,确保 HTTP server 停止
|
|
159
|
+
};
|
|
160
|
+
process.on("SIGTERM", shutdown);
|
|
161
|
+
process.on("SIGINT", shutdown);
|
|
162
|
+
process.on("disconnect", shutdown); // OpenCode 窗口关闭时触发
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
config: async (_cfg: any) => {},
|
|
166
|
+
"chat.message": async (input: any, output: any) => {
|
|
167
|
+
if (input.sessionID && !mainSessionLocked) {
|
|
168
|
+
mainSessionId = input.sessionID;
|
|
169
|
+
mainSessionLocked = true;
|
|
170
|
+
logInfo("mainSessionId locked", { sessionId: input.sessionID });
|
|
171
|
+
}
|
|
172
|
+
await chatMessageRecall(input, output);
|
|
173
|
+
const textContent = output.parts
|
|
174
|
+
.filter((p: any) => p.type === "text" && !(p as any).synthetic)
|
|
175
|
+
.map((p: any) => p.text || (p as any).content || "")
|
|
176
|
+
.join(" ")
|
|
177
|
+
|| (output.message as any).content
|
|
178
|
+
|| "";
|
|
179
|
+
if (!firstMessages.has(input.sessionID)) {
|
|
180
|
+
firstMessages.set(input.sessionID, textContent);
|
|
181
|
+
}
|
|
182
|
+
if (detectSaveKeyword(textContent)) {
|
|
183
|
+
output.parts.push({
|
|
184
|
+
id: `prt_cerebro-save-${Date.now()}`,
|
|
185
|
+
sessionID: input.sessionID,
|
|
186
|
+
messageID: output.message?.id,
|
|
187
|
+
type: "text",
|
|
188
|
+
text: KEYWORD_NUDGE,
|
|
189
|
+
synthetic: true,
|
|
190
|
+
} as any);
|
|
191
|
+
logDebug("save keyword detected, nudge pushed", { sessionId: input.sessionID });
|
|
192
|
+
}
|
|
193
|
+
if (detectRecallKeyword(textContent)) {
|
|
194
|
+
output.parts.push({
|
|
195
|
+
id: `prt_cerebro-recall-${Date.now()}`,
|
|
196
|
+
sessionID: input.sessionID,
|
|
197
|
+
messageID: output.message?.id,
|
|
198
|
+
type: "text",
|
|
199
|
+
text: RECALL_NUDGE,
|
|
200
|
+
synthetic: true,
|
|
201
|
+
} as any);
|
|
202
|
+
logDebug("recall keyword detected, nudge pushed", { sessionId: input.sessionID });
|
|
203
|
+
}
|
|
204
|
+
const policy = resolveAgentPolicy(agentId, config);
|
|
205
|
+
if (policy !== "none") {
|
|
206
|
+
if (!sessionMessages.has(input.sessionID)) {
|
|
207
|
+
sessionMessages.set(input.sessionID, []);
|
|
208
|
+
}
|
|
209
|
+
sessionMessages.get(input.sessionID)!.push({ role: "user", content: textContent });
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"experimental.session.compacting": compactingHook(cerebroClient, containerTags, tui, config.ingest.ingestMode, isAutoStoreEnabled, () => mainSessionId, client, config, agentId, directory),
|
|
213
|
+
"experimental.compaction.autocontinue": autocontinueHook(cerebroClient, containerTags, tui, config.ingest.ingestMode, isAutoStoreEnabled, () => mainSessionId, client, config, agentId, directory),
|
|
214
|
+
tool: buildTools(cerebroClient, containerTags, { agentId, getSessionId: () => mainSessionId, getAgentName: () => cachedAgentName || agentId, getProjectPath: () => directory, config }),
|
|
215
|
+
event: sessionIdleHook(cerebroClient, containerTags, tui, client, config.ingest.ingestMode, config.ingest.autoCaptureThreshold, () => mainSessionId, isAutoStoreEnabled, agentId, config, (name: string) => { cachedAgentName = name; }, directory),
|
|
216
|
+
"shell.env": async (_input: any, output: any) => {
|
|
217
|
+
if (directory) {
|
|
218
|
+
output.env.OMEM_PROJECT_DIR = directory;
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
"experimental.chat.system.transform": timeMemorySystemHook(),
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export { OmemPlugin };
|
|
226
|
+
|
|
227
|
+
export default {
|
|
228
|
+
id: "ourmem",
|
|
229
|
+
server: OmemPlugin,
|
|
230
|
+
};
|