kongbrain 0.1.1 → 0.1.2
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 +6 -5
- package/package.json +1 -1
- package/src/context-engine.ts +1 -1
- package/src/index.ts +2 -2
- package/src/memory-daemon.ts +5 -2
- package/src/reflection.ts +1 -1
package/README.md
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
+
[](https://www.npmjs.com/package/kongbrain)
|
|
7
8
|
[](https://github.com/42U/kongbrain)
|
|
8
|
-
[](https://opensource.org/licenses/MIT)
|
|
9
10
|
[](https://nodejs.org)
|
|
10
11
|
[](https://surrealdb.com)
|
|
11
12
|
[](https://github.com/openclaw/openclaw)
|
|
@@ -270,7 +271,7 @@ Triggers at session end when metrics indicate problems:
|
|
|
270
271
|
| Steering candidates | any detected |
|
|
271
272
|
| Context waste | > 0.5% of context window |
|
|
272
273
|
|
|
273
|
-
|
|
274
|
+
The LLM generates a 2-4 sentence reflection: root cause, error pattern, what to do differently. Stored with importance 7.0, deduped at 0.85 cosine similarity.
|
|
274
275
|
|
|
275
276
|
</details>
|
|
276
277
|
|
|
@@ -297,7 +298,7 @@ Context Injection ─ Vector search -> graph expand -> 6-signal scoring -> budge
|
|
|
297
298
|
| Scores: similarity, recency, importance, access, neighbor, utility
|
|
298
299
|
| Budget: 21% of context window reserved for retrieval
|
|
299
300
|
v
|
|
300
|
-
Agent Loop ────────
|
|
301
|
+
Agent Loop ──────── LLM + tool execution
|
|
301
302
|
| Planning gate: announces plan before touching tools
|
|
302
303
|
| Smart truncation: preserves tail of large tool outputs
|
|
303
304
|
v
|
|
@@ -307,7 +308,7 @@ Turn Storage ────── Every message embedded + stored + linked via gra
|
|
|
307
308
|
Quality Eval ────── Measures retrieval utilization (text overlap, trigrams, unigrams)
|
|
308
309
|
| Tracks tool success, context waste, feeds ACAN training
|
|
309
310
|
v
|
|
310
|
-
Memory Daemon ───── Worker thread extracts 9 knowledge types via
|
|
311
|
+
Memory Daemon ───── Worker thread extracts 9 knowledge types via LLM:
|
|
311
312
|
| causal chains, monologues, concepts, corrections,
|
|
312
313
|
| preferences, artifacts, decisions, skills, resolved memories
|
|
313
314
|
v
|
|
@@ -323,7 +324,7 @@ At session start, a wake-up briefing is synthesized from the handoff, recent mon
|
|
|
323
324
|
<details>
|
|
324
325
|
<summary><strong>Memory Daemon</strong>: background knowledge extraction</summary>
|
|
325
326
|
|
|
326
|
-
A worker thread running throughout the session. Batches turns every ~12K tokens, calls
|
|
327
|
+
A worker thread running throughout the session. Batches turns every ~12K tokens, calls the configured LLM to extract:
|
|
327
328
|
|
|
328
329
|
- **Causal chains**: trigger/outcome sequences with success/confidence
|
|
329
330
|
- **Monologue traces**: thinking blocks that reveal problem-solving approach
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kongbrain",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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/context-engine.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -92,7 +92,7 @@ async function runSessionCleanup(
|
|
|
92
92
|
.catch(e => { swallow.warn("cleanup:soulGraduation", e); return null; });
|
|
93
93
|
endOps.push(graduationPromise);
|
|
94
94
|
|
|
95
|
-
// The session-end
|
|
95
|
+
// The session-end LLM call is critical and needs the full 45s.
|
|
96
96
|
await Promise.race([
|
|
97
97
|
Promise.allSettled(endOps),
|
|
98
98
|
new Promise(resolve => setTimeout(resolve, 45_000)),
|
|
@@ -391,7 +391,7 @@ export default definePluginEntry({
|
|
|
391
391
|
});
|
|
392
392
|
|
|
393
393
|
// OpenClaw's session_end is fire-and-forget and doesn't fire on CLI exit.
|
|
394
|
-
// Register a process exit handler to ensure the critical
|
|
394
|
+
// Register a process exit handler to ensure the critical extraction
|
|
395
395
|
// completes even when the user exits with Ctrl+D or /exit.
|
|
396
396
|
// Clean up previous listeners first (register() can be called multiple times).
|
|
397
397
|
if (registeredExitHandler) {
|
package/src/memory-daemon.ts
CHANGED
|
@@ -185,8 +185,11 @@ async function processExtraction(msg: DaemonMessage & { type: "turn_batch" }): P
|
|
|
185
185
|
const systemPrompt = buildSystemPrompt(thinking.length > 0, retrievedMemories.length > 0, priorState);
|
|
186
186
|
|
|
187
187
|
const { completeSimple, getModel } = await import("@mariozechner/pi-ai");
|
|
188
|
-
const provider = config.llmProvider
|
|
189
|
-
const modelId = config.llmModel
|
|
188
|
+
const provider = config.llmProvider;
|
|
189
|
+
const modelId = config.llmModel;
|
|
190
|
+
if (!provider || !modelId) {
|
|
191
|
+
throw new Error("Memory daemon requires llmProvider and llmModel from host config");
|
|
192
|
+
}
|
|
190
193
|
// getModel is heavily typed for known providers; cast needed for runtime-configured values
|
|
191
194
|
const model = (getModel as any)(provider, modelId);
|
|
192
195
|
|
package/src/reflection.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* At session end, reviews own performance: tool failures, runaway detections,
|
|
5
5
|
* low retrieval utilization, wasted tokens. If problems exceeded thresholds,
|
|
6
|
-
* generates a structured reflection via
|
|
6
|
+
* generates a structured reflection via the configured LLM, stored as high-importance memory.
|
|
7
7
|
* Retrieved when similar situations arise in future sessions.
|
|
8
8
|
*
|
|
9
9
|
* Ported from kongbrain — takes SurrealStore/EmbeddingService as params.
|