kongbrain 0.1.3 → 0.1.4

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 CHANGED
@@ -88,7 +88,7 @@ Add to your OpenClaw config (`~/.openclaw/openclaw.json`):
88
88
  ### 5. Talk to your ape
89
89
 
90
90
  ```bash
91
- openclaw
91
+ openclaw tui
92
92
  ```
93
93
 
94
94
  That's it. KongBrain uses whatever LLM provider and model you already have configured in OpenClaw (Anthropic, OpenAI, Google, Ollama, whatever). No separate API keys needed for the brain itself.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kongbrain",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Graph-backed persistent memory engine for OpenClaw. Replaces the default context window with SurrealDB + vector embeddings that learn across sessions.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -337,16 +337,18 @@ export default definePluginEntry({
337
337
  return new KongBrainContextEngine(state);
338
338
  });
339
339
 
340
- // ── Hook handlers ──────────────────────────────────────────────────
340
+ // ── Hook handlers (register once — register() may be called multiple times) ──
341
341
 
342
- api.on("before_prompt_build", createBeforePromptBuildHandler(globalState));
343
- api.on("before_tool_call", createBeforeToolCallHandler(globalState));
344
- api.on("after_tool_call", createAfterToolCallHandler(globalState));
345
- api.on("llm_output", createLlmOutputHandler(globalState));
342
+ if (!registered) {
343
+ api.on("before_prompt_build", createBeforePromptBuildHandler(globalState));
344
+ api.on("before_tool_call", createBeforeToolCallHandler(globalState));
345
+ api.on("after_tool_call", createAfterToolCallHandler(globalState));
346
+ api.on("llm_output", createLlmOutputHandler(globalState));
347
+ }
346
348
 
347
- // ── Session lifecycle ──────────────────────────────────────────────
349
+ // ── Session lifecycle (also register once) ─────────────────────────
348
350
 
349
- api.on("session_start", async (event) => {
351
+ if (!registered) api.on("session_start", async (event) => {
350
352
  if (!globalState) return;
351
353
  const sessionKey = event.sessionKey ?? event.sessionId;
352
354
  const session = globalState.getOrCreateSession(sessionKey, event.sessionId);
@@ -420,7 +422,7 @@ export default definePluginEntry({
420
422
  .catch(e => swallow.warn("index:deferredCleanup", e));
421
423
  });
422
424
 
423
- api.on("session_end", async (event) => {
425
+ if (!registered) api.on("session_end", async (event) => {
424
426
  if (!globalState) return;
425
427
  const sessionKey = event.sessionKey ?? event.sessionId;
426
428
  const session = globalState.getSession(sessionKey);