@nowledge/openclaw-nowledge-mem 0.8.24 → 0.8.25
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/CHANGELOG.md +6 -0
- package/CLAUDE.md +5 -5
- package/README.md +10 -8
- package/SKILL.md +1 -1
- package/openclaw.plugin.json +5 -5
- package/package.json +1 -1
- package/skills/memory-guide/SKILL.md +3 -3
- package/src/client.js +32 -2
- package/src/context-engine.js +13 -9
- package/src/corpus-supplement.js +1 -1
- package/src/hooks/recall.js +10 -6
- package/src/tools/context.js +14 -17
- package/src/tools/status.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to the Nowledge Mem OpenClaw plugin will be documented in th
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## [0.8.25] - 2026-06-06
|
|
8
|
+
|
|
9
|
+
### Improved
|
|
10
|
+
|
|
11
|
+
- `nowledge_mem_context`, `sessionContext`, and Context Engine prompt injection now load Context Bundle when available, then fall back to Working Memory for older `nmem` clients. OpenClaw can receive owner identity, AI Identity, active space, active rules, and current priorities through the existing context surface without a tool-name change.
|
|
12
|
+
|
|
7
13
|
## [0.8.24] - 2026-05-15
|
|
8
14
|
|
|
9
15
|
### Fixed
|
package/CLAUDE.md
CHANGED
|
@@ -44,7 +44,7 @@ src/
|
|
|
44
44
|
memory-search.js - OpenClaw compat; multi-signal; bi-temporal; relevance_reason; sourceThreadId
|
|
45
45
|
memory-get.js - OpenClaw compat; supports MEMORY.md alias; sourceThreadId
|
|
46
46
|
save.js - structured capture: unit_type, labels, temporal, importance; pre-save dedup check
|
|
47
|
-
context.js -
|
|
47
|
+
context.js - startup context read + Working Memory section-level patch
|
|
48
48
|
connections.js - graph exploration: edge types, relationship strength, provenance
|
|
49
49
|
timeline.js - activity feed: daily grouping, event_type filter, memoryId hints
|
|
50
50
|
forget.js - memory deletion by ID or search
|
|
@@ -66,7 +66,7 @@ When `corpusSupplement: true`, the plugin registers a `MemoryCorpusSupplement` v
|
|
|
66
66
|
|
|
67
67
|
1. **Recall**: When memory-core's `memory_search` runs, it fans out to all registered corpus supplements. Our supplement calls `client.search()` and maps results to `MemoryCorpusSearchResult` format.
|
|
68
68
|
2. **Dreaming**: Recalled Nowledge Mem content accumulates frequency, relevance, and diversity scores in memory-core's short-term recall store. High-scoring content is promoted to `MEMORY.md` during deep-phase dreaming.
|
|
69
|
-
3. **Dedup**: When active, the recall hook and CE `assemble()` skip their own search-based recall (memories section only).
|
|
69
|
+
3. **Dedup**: When active, the recall hook and CE `assemble()` skip their own search-based recall (memories section only). Startup context injection continues as before.
|
|
70
70
|
|
|
71
71
|
### When to enable
|
|
72
72
|
|
|
@@ -132,7 +132,7 @@ When `contextEngine` points elsewhere (or is absent), hooks handle everything. N
|
|
|
132
132
|
|
|
133
133
|
### Nowledge Mem Native (differentiators)
|
|
134
134
|
- `nowledge_mem_save` - structured capture: `unit_type`, `labels[]`, `event_start`, `event_end`, `temporal_context`, `importance`. All fields wired to CLI and API.
|
|
135
|
-
- `nowledge_mem_context` -
|
|
135
|
+
- `nowledge_mem_context` - startup context. Read-only by default: Context Bundle when available, Working Memory fallback on older `nmem` clients. Also supports Working Memory section-level patch via `patch_section` + `patch_content`/`patch_append` params (uses `nmem wm patch` client-side read-modify-write).
|
|
136
136
|
- `nowledge_mem_connections` - graph exploration. Edges JOIN-ed to nodes by type: CRYSTALLIZED_FROM (crystal → source memories), EVOLVES (with sub-relations: supersedes/enriches/confirms/challenges), SOURCED_FROM (document provenance), MENTIONS (entities). Each connection shows strength % and memoryId.
|
|
137
137
|
- `nowledge_mem_timeline` - activity feed via `nmem f`. Groups by day. `event_type` filter. Exact date range via `date_from`/`date_to` (YYYY-MM-DD). Entries include `(id: <memoryId>)` for chaining to connections.
|
|
138
138
|
- `nowledge_mem_forget` - delete by ID or fuzzy query.
|
|
@@ -151,7 +151,7 @@ When `contextEngine` points elsewhere (or is absent), hooks handle everything. N
|
|
|
151
151
|
## Hook Surface
|
|
152
152
|
|
|
153
153
|
- `before_prompt_build` (always-on) - directive behavioral guidance in system-prompt space: tells agent to search before answering questions about prior work/decisions/preferences, and to save decisions/learnings proactively. Explicitly notes semantic search (not file paths) to counter OpenClaw's hardcoded memory section. Adjusts when sessionContext is on to avoid redundant searches.
|
|
154
|
-
- `before_prompt_build` (sessionContext) - session context: Working Memory + `searchRich()` memories with `relevanceReason`. Note: does NOT inject thread snippets — threads are available via `memory_search` tool and `nowledge_mem_thread_fetch`.
|
|
154
|
+
- `before_prompt_build` (sessionContext) - session context: Context Bundle / Working Memory + `searchRich()` memories with `relevanceReason`. Note: does NOT inject thread snippets — threads are available via `memory_search` tool and `nowledge_mem_thread_fetch`.
|
|
155
155
|
- `agent_end` - thread capture + LLM triage/distillation (requires `sessionDigest: true`)
|
|
156
156
|
- `after_compaction` - thread append
|
|
157
157
|
- `before_reset` - thread append
|
|
@@ -170,7 +170,7 @@ Ambient space: choose one real lane through plugin config `space` or `spaceTempl
|
|
|
170
170
|
|
|
171
171
|
| Key | Type | Default | Env Var | Description |
|
|
172
172
|
|-----|------|---------|---------|-------------|
|
|
173
|
-
| `sessionContext` | boolean | `false` | `NMEM_SESSION_CONTEXT` | Inject Working Memory + relevant memories at prompt time |
|
|
173
|
+
| `sessionContext` | boolean | `false` | `NMEM_SESSION_CONTEXT` | Inject Context Bundle / Working Memory + relevant memories at prompt time |
|
|
174
174
|
| `sessionDigest` | boolean | `true` | `NMEM_SESSION_DIGEST` | Thread capture + LLM distillation at session end |
|
|
175
175
|
| `digestMinInterval` | integer 0-86400 | `300` | `NMEM_DIGEST_MIN_INTERVAL` | Minimum seconds between session digests |
|
|
176
176
|
| `maxContextResults` | integer 1-20 | `5` | `NMEM_MAX_CONTEXT_RESULTS` | How many memories to inject at prompt time |
|
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ If you manage config manually, or you want to verify what the installer selected
|
|
|
83
83
|
}
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
By default the agent gets 10 tools on demand, a behavioral skill that teaches it when to search and save, a short always-on system hint, and end-of-session capture. Working Memory injection is optional and controlled by `sessionContext`.
|
|
86
|
+
By default the agent gets 10 tools on demand, a behavioral skill that teaches it when to search and save, a short always-on system hint, and end-of-session capture. Context Bundle / Working Memory injection is optional and controlled by `sessionContext`.
|
|
87
87
|
|
|
88
88
|
### Remote mode
|
|
89
89
|
|
|
@@ -117,7 +117,7 @@ The OpenClaw plugin settings can own that lane directly:
|
|
|
117
117
|
}
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
Use `space` when one OpenClaw profile belongs to one stable lane. Use `spaceTemplate` only when your launcher or host environment already sets a trustworthy variable that identifies the lane. If your OpenClaw runtime does not expose per-
|
|
120
|
+
Use `space` when one OpenClaw profile belongs to one stable lane. Use `spaceTemplate` only when your launcher or host environment already sets a trustworthy variable that identifies the lane. If your OpenClaw runtime does not expose per-AI Identity to plugins, do not fake it. Use one profile/process per lane or stay on `Default`.
|
|
121
121
|
|
|
122
122
|
If you are running OpenClaw from a launcher or script with no richer config surface, you can still set one session-wide fallback lane with:
|
|
123
123
|
|
|
@@ -127,6 +127,8 @@ NMEM_SPACE="Research Agent"
|
|
|
127
127
|
|
|
128
128
|
Nowledge Mem's CLI-backed Working Memory, memory search/save, and the plugin's API-backed thread/feed fallbacks will then stay in that lane together. There is no second OpenClaw-only vault setting; the shared Mem boundary is still one hidden space key, but humans and agents should normally work with the space name instead.
|
|
129
129
|
|
|
130
|
+
For multi-agent orchestrators, set `NMEM_AGENT_ID=<agent-slug>` per spawned OpenClaw worker. Add `NMEM_SPACE` only when that run should override the AI Identity's default space. `NMEM_HOST_AGENT_ID` is for advanced host-id aliases. Context Bundle will use the stable identity while keeping `source_app=openclaw` for provenance. Keep these as launcher environment variables instead of plugin config keys so OpenClaw's strict config validation remains stable.
|
|
131
|
+
|
|
130
132
|
Shared spaces, default retrieval, and agent guidance still live in Mem's own space profile. OpenClaw chooses the lane and preserves it across transports; it should not duplicate the profile semantics.
|
|
131
133
|
|
|
132
134
|
### Configure via WebUI of OpenClaw
|
|
@@ -145,7 +147,7 @@ flowchart TD
|
|
|
145
147
|
A["User sends message"] --> B["before_prompt_build hook"]
|
|
146
148
|
|
|
147
149
|
B --> C["Behavioral guidance(cacheable system hint)"]
|
|
148
|
-
B -.->|"sessionContext: true"| D["Working Memory +relevant memories (~1-2 KB)"]
|
|
150
|
+
B -.->|"sessionContext: true"| D["Context Bundle / Working Memory +relevant memories (~1-2 KB)"]
|
|
149
151
|
|
|
150
152
|
C --> E["Agent processes message(10 tools available)"]
|
|
151
153
|
D --> E
|
|
@@ -172,7 +174,7 @@ The behavioral skill and always-on hook nudge the agent to **search before answe
|
|
|
172
174
|
| Decision made, insight learned | `nowledge_mem_save` | Structured save with `unit_type`, `labels`, `event_start`, `importance`. |
|
|
173
175
|
| "What was I doing last week?" | `nowledge_mem_timeline` | Activity feed grouped by day. Supports exact date ranges. |
|
|
174
176
|
| "How is X connected to Y?" | `nowledge_mem_connections` | Graph walk: edges, entities, EVOLVES chains, document provenance. |
|
|
175
|
-
| Need today's focus/priorities | `nowledge_mem_context` | Read Working Memory
|
|
177
|
+
| Need startup context or today's focus/priorities | `nowledge_mem_context` | Read Context Bundle when available, with Working Memory fallback. Supports Working Memory section-level patch. |
|
|
176
178
|
| Memory has `sourceThreadId` | `nowledge_mem_thread_fetch` | Fetch full source conversation. Pagination via `offset` + `limit`. |
|
|
177
179
|
| "Find our discussion about X" | `nowledge_mem_thread_search` | Search past conversations by keyword. Returns matched snippets. |
|
|
178
180
|
| "Forget X" | `nowledge_mem_forget` | Delete by ID or search query. |
|
|
@@ -241,7 +243,7 @@ When OpenClaw's memory-core is the primary memory slot and Nowledge Mem runs alo
|
|
|
241
243
|
- Every time memory-core runs `memory_search`, it also searches Nowledge Mem's knowledge graph via the supplement.
|
|
242
244
|
- Recalled Nowledge Mem content accumulates frequency and relevance scores in memory-core's short-term store.
|
|
243
245
|
- High-scoring content is promoted to `MEMORY.md` during deep-phase dreaming (daily, 3 AM).
|
|
244
|
-
- The plugin's own search-based recall is automatically disabled to avoid duplicates.
|
|
246
|
+
- The plugin's own search-based recall is automatically disabled to avoid duplicates. Startup context injection continues as before.
|
|
245
247
|
|
|
246
248
|
**When to enable:** When memory-core is the memory slot and you want your cross-tool knowledge graph to participate in OpenClaw's native dreaming cycle. Most users have Nowledge Mem as the memory slot directly, so this defaults to `false`.
|
|
247
249
|
|
|
@@ -306,7 +308,7 @@ temporal_context: past
|
|
|
306
308
|
|
|
307
309
|
Eight memory types: `fact`, `preference`, `decision`, `plan`, `procedure`, `learning`, `context`, `event`. Each becomes a typed node in the knowledge graph. Labels enable filtering in `memory_search`. `event_start` records *when* something happened, not just when you saved it, powering bi-temporal search.
|
|
308
310
|
|
|
309
|
-
**nowledge_mem_context** - Read
|
|
311
|
+
**nowledge_mem_context** - Read startup context. On current Nowledge Mem installs this is Context Bundle: owner identity, AI Identity, active space, active rules, Working Memory, and KFS paths. Older `nmem` clients fall back to today's Working Memory. Patch mode still edits Working Memory sections.
|
|
310
312
|
|
|
311
313
|
**nowledge_mem_connections** - Explore the knowledge graph around a topic or memory. Returns connected memories, EVOLVES version chains (how understanding has grown), related entities, and source document provenance (which files or URLs knowledge was extracted from).
|
|
312
314
|
|
|
@@ -360,7 +362,7 @@ The plugin supports three modes. Choose based on how much you want to guarantee
|
|
|
360
362
|
| Mode | Config | Behavior | Tradeoff |
|
|
361
363
|
|------|--------|----------|----------|
|
|
362
364
|
| **Default** (recommended) | `sessionContext: false, sessionDigest: true` | Agent calls 10 tools on demand. A short system hint stays on. Conversations captured + distilled at session end. | Lowest overhead. Agent decides when to search, usually smart, occasionally forgets. |
|
|
363
|
-
| **Session context** | `sessionContext: true` | Working Memory + relevant memories injected at prompt time, plus all 10 tools still available. | Higher per-turn context cost. Guarantees context is present from the first turn. |
|
|
365
|
+
| **Session context** | `sessionContext: true` | Context Bundle / Working Memory + relevant memories injected at prompt time, plus all 10 tools still available. | Higher per-turn context cost. Guarantees context is present from the first turn. |
|
|
364
366
|
| **Minimal** | `sessionDigest: false` | Tool-only, no automatic capture. | Small overhead from the always-on hint only. Use when you handle memory manually. |
|
|
365
367
|
|
|
366
368
|
**Which mode should you use?**
|
|
@@ -438,7 +440,7 @@ OpenClaw does not currently have a separate user-owned instruction file in this
|
|
|
438
440
|
|
|
439
441
|
| Key | Type | Default | Description |
|
|
440
442
|
|-----|------|---------|-------------|
|
|
441
|
-
| `sessionContext` | boolean | `false` | Inject Working Memory + relevant memories at prompt time |
|
|
443
|
+
| `sessionContext` | boolean | `false` | Inject Context Bundle / Working Memory + relevant memories at prompt time |
|
|
442
444
|
| `sessionDigest` | boolean | `true` | Thread capture + LLM distillation at session end |
|
|
443
445
|
| `digestMinInterval` | integer | `300` | Minimum seconds between session digests for the same thread (0-86400) |
|
|
444
446
|
| `maxContextResults` | integer | `5` | Max memories to inject at prompt time (1-20, only used when sessionContext is enabled) |
|
package/SKILL.md
CHANGED
|
@@ -74,7 +74,7 @@ nmem --version
|
|
|
74
74
|
If this fails:
|
|
75
75
|
|
|
76
76
|
- For users with the desktop app, direct them to **Settings > Preferences > Developer Tools > Install CLI**
|
|
77
|
-
- Otherwise suggest `pip install nmem-cli`
|
|
77
|
+
- Otherwise suggest `pip install nmem-cli`, or on Arch Linux `yay -S nmem-cli` / `paru -S nmem-cli`
|
|
78
78
|
|
|
79
79
|
### Step 2 — Verify the Backend Before Plugin Setup
|
|
80
80
|
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "openclaw-nowledge-mem",
|
|
3
3
|
"name": "Nowledge Mem",
|
|
4
|
-
"description": "Cross-tool knowledge graph memory for OpenClaw with
|
|
5
|
-
"version": "0.8.
|
|
4
|
+
"description": "Cross-tool knowledge graph memory for OpenClaw with startup context, graph search, and session distillation.",
|
|
5
|
+
"version": "0.8.25",
|
|
6
6
|
"kind": ["memory", "context-engine"],
|
|
7
7
|
"skills": [
|
|
8
8
|
"skills/memory-guide"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"uiHints": {
|
|
11
11
|
"sessionContext": {
|
|
12
12
|
"label": "Session context injection",
|
|
13
|
-
"help": "Inject Working Memory and relevant memories at prompt time. Off by default; the agent can call memory_search on demand instead."
|
|
13
|
+
"help": "Inject Context Bundle / Working Memory and relevant memories at prompt time. Off by default; the agent can call memory_search on demand instead."
|
|
14
14
|
},
|
|
15
15
|
"sessionDigest": {
|
|
16
16
|
"label": "Session digest at end",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"corpusSupplement": {
|
|
44
44
|
"label": "Register as corpus supplement",
|
|
45
|
-
"help": "Make Nowledge Mem searchable through memory-core's recall pipeline and dreaming promotion. Enable when memory-core is your memory slot and you want cross-tool knowledge to participate in OpenClaw's native recall and dreaming. When enabled, the plugin's own search-based recall is skipped to avoid duplicates (
|
|
45
|
+
"help": "Make Nowledge Mem searchable through memory-core's recall pipeline and dreaming promotion. Enable when memory-core is your memory slot and you want cross-tool knowledge to participate in OpenClaw's native recall and dreaming. When enabled, the plugin's own search-based recall is skipped to avoid duplicates (startup context injection continues)."
|
|
46
46
|
},
|
|
47
47
|
"corpusMaxResults": {
|
|
48
48
|
"label": "Corpus supplement max results",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"sessionContext": {
|
|
81
81
|
"type": "boolean",
|
|
82
82
|
"default": false,
|
|
83
|
-
"description": "Inject Working Memory and recalled memories at prompt time. Off by default; the agent queries memory on demand via tools."
|
|
83
|
+
"description": "Inject Context Bundle / Working Memory and recalled memories at prompt time. Off by default; the agent queries memory on demand via tools."
|
|
84
84
|
},
|
|
85
85
|
"sessionDigest": {
|
|
86
86
|
"type": "boolean",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nowledge/openclaw-nowledge-mem",
|
|
3
3
|
"displayName": "Nowledge Mem for OpenClaw",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.25",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Nowledge Mem memory plugin for OpenClaw, local-first personal knowledge base",
|
|
7
7
|
"author": {
|
|
@@ -31,7 +31,7 @@ Bi-temporal filters narrow results by time:
|
|
|
31
31
|
|
|
32
32
|
## Save (nowledge_mem_save)
|
|
33
33
|
|
|
34
|
-
Save proactively when the conversation produces a
|
|
34
|
+
Save proactively when the conversation produces a durable fact, preference, decision, plan, procedure, learning, event, or important context. Do not wait to be asked.
|
|
35
35
|
|
|
36
36
|
Structure saves:
|
|
37
37
|
|
|
@@ -54,9 +54,9 @@ Browse recent activity grouped by day. Filter by `event_type` or exact `date_fro
|
|
|
54
54
|
|
|
55
55
|
Find past conversations by keyword, then progressively fetch messages. Threads span all sources: this tool, other AI tools, browser capture, imports.
|
|
56
56
|
|
|
57
|
-
##
|
|
57
|
+
## Startup Context (nowledge_mem_context)
|
|
58
58
|
|
|
59
|
-
Read
|
|
59
|
+
Read Context Bundle when identity, active space, active rules, or current priorities matter. Older `nmem` clients fall back to the user's Working Memory briefing. Patch a specific Working Memory section with `patch_section` + `patch_content`/`patch_append` when the conversation updates a priority or resolves a flag.
|
|
60
60
|
|
|
61
61
|
## Important
|
|
62
62
|
|
package/src/client.js
CHANGED
|
@@ -690,12 +690,42 @@ export class NowledgeMemClient {
|
|
|
690
690
|
const data = await this.execJson(["--json", "wm", "read"], 15_000);
|
|
691
691
|
const content = String(data.content ?? "").trim();
|
|
692
692
|
const exists = Boolean(data.exists);
|
|
693
|
-
return {
|
|
693
|
+
return {
|
|
694
|
+
content,
|
|
695
|
+
available: exists && content.length > 0,
|
|
696
|
+
source: "working-memory",
|
|
697
|
+
};
|
|
694
698
|
} catch {
|
|
695
|
-
return { content: "", available: false };
|
|
699
|
+
return { content: "", available: false, source: "working-memory" };
|
|
696
700
|
}
|
|
697
701
|
}
|
|
698
702
|
|
|
703
|
+
async readContextBundle() {
|
|
704
|
+
try {
|
|
705
|
+
const data = await this.execJson(
|
|
706
|
+
["--json", "context", "--source-app", "openclaw"],
|
|
707
|
+
15_000,
|
|
708
|
+
);
|
|
709
|
+
const content = String(
|
|
710
|
+
data.rendered_markdown ?? data.markdown ?? data.content ?? "",
|
|
711
|
+
).trim();
|
|
712
|
+
return {
|
|
713
|
+
content,
|
|
714
|
+
available: content.length > 0,
|
|
715
|
+
source: "context-bundle",
|
|
716
|
+
raw: data,
|
|
717
|
+
};
|
|
718
|
+
} catch {
|
|
719
|
+
return { content: "", available: false, source: "context-bundle" };
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
async readStartupContext() {
|
|
724
|
+
const bundle = await this.readContextBundle();
|
|
725
|
+
if (bundle.available) return bundle;
|
|
726
|
+
return this.readWorkingMemory();
|
|
727
|
+
}
|
|
728
|
+
|
|
699
729
|
/**
|
|
700
730
|
* Patch a single section of Working Memory without touching the rest.
|
|
701
731
|
* Uses `nmem wm patch` (CLI v0.4.1+) — client-side read-modify-write.
|
package/src/context-engine.js
CHANGED
|
@@ -183,24 +183,24 @@ export function createNowledgeMemContextEngineFactory(
|
|
|
183
183
|
info: {
|
|
184
184
|
id: "nowledge-mem",
|
|
185
185
|
name: "Nowledge Mem",
|
|
186
|
-
version: "0.8.
|
|
186
|
+
version: "0.8.25",
|
|
187
187
|
ownsCompaction: false,
|
|
188
188
|
},
|
|
189
189
|
|
|
190
190
|
// ------------------------------------------------------------------
|
|
191
|
-
// bootstrap — pre-warm
|
|
191
|
+
// bootstrap — pre-warm startup context for first assemble()
|
|
192
192
|
// ------------------------------------------------------------------
|
|
193
193
|
async bootstrap({ sessionId, sessionKey }) {
|
|
194
194
|
const key = sessionKey || sessionId;
|
|
195
195
|
try {
|
|
196
|
-
const wm = await client.
|
|
196
|
+
const wm = await client.readStartupContext();
|
|
197
197
|
const state = getSessionState(key);
|
|
198
198
|
state.wm = wm;
|
|
199
199
|
state.lastWmFetch = Date.now();
|
|
200
|
-
logger.debug?.(`ce: bootstrap —
|
|
200
|
+
logger.debug?.(`ce: bootstrap — startup context loaded for ${key}`);
|
|
201
201
|
return { bootstrapped: true };
|
|
202
202
|
} catch (err) {
|
|
203
|
-
logger.warn(`ce: bootstrap —
|
|
203
|
+
logger.warn(`ce: bootstrap — startup context read failed: ${err}`);
|
|
204
204
|
return { bootstrapped: false, reason: String(err) };
|
|
205
205
|
}
|
|
206
206
|
},
|
|
@@ -232,19 +232,23 @@ export function createNowledgeMemContextEngineFactory(
|
|
|
232
232
|
cfg.sessionContext ? SESSION_CONTEXT_GUIDANCE : BASE_GUIDANCE,
|
|
233
233
|
);
|
|
234
234
|
|
|
235
|
-
// 2.
|
|
235
|
+
// 2. Startup context (refresh if stale)
|
|
236
236
|
try {
|
|
237
237
|
if (!state.wm || Date.now() - state.lastWmFetch > WM_CACHE_TTL_MS) {
|
|
238
|
-
state.wm = await client.
|
|
238
|
+
state.wm = await client.readStartupContext();
|
|
239
239
|
state.lastWmFetch = Date.now();
|
|
240
240
|
}
|
|
241
241
|
if (state.wm?.available) {
|
|
242
|
+
const tag =
|
|
243
|
+
state.wm.source === "context-bundle"
|
|
244
|
+
? "nowledge-context-bundle"
|
|
245
|
+
: "working-memory";
|
|
242
246
|
sections.push(
|
|
243
|
-
|
|
247
|
+
`<${tag}>\n${escapeForPrompt(state.wm.content)}\n</${tag}>`,
|
|
244
248
|
);
|
|
245
249
|
}
|
|
246
250
|
} catch (err) {
|
|
247
|
-
logger.debug?.(`ce: assemble —
|
|
251
|
+
logger.debug?.(`ce: assemble — startup context read failed: ${err}`);
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
// 3. Recalled memories (when sessionContext enabled)
|
package/src/corpus-supplement.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Enable via config: `corpusSupplement: true`
|
|
11
11
|
*
|
|
12
12
|
* Designed to coexist with the plugin's own tools and hooks:
|
|
13
|
-
* -
|
|
13
|
+
* - Startup context injection: still handled by the recall hook / CE
|
|
14
14
|
* - Search-based recall: handled by this supplement when active, by hooks/CE when not
|
|
15
15
|
*
|
|
16
16
|
* Error handling: both search() and get() catch all errors and return [] / null.
|
package/src/hooks/recall.js
CHANGED
|
@@ -193,17 +193,21 @@ export function buildRecallHandler(client, cfg, logger, runtime = {}) {
|
|
|
193
193
|
|
|
194
194
|
const sections = [];
|
|
195
195
|
|
|
196
|
-
// 1.
|
|
197
|
-
// Always injected regardless of search query (
|
|
196
|
+
// 1. Startup context — identity/guidance plus daily context when available.
|
|
197
|
+
// Always injected regardless of search query (it is independent of user message).
|
|
198
198
|
try {
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
199
|
+
const startupContext = await client.readStartupContext();
|
|
200
|
+
if (startupContext.available) {
|
|
201
|
+
const tag =
|
|
202
|
+
startupContext.source === "context-bundle"
|
|
203
|
+
? "nowledge-context-bundle"
|
|
204
|
+
: "working-memory";
|
|
201
205
|
sections.push(
|
|
202
|
-
|
|
206
|
+
`<${tag}>\n${escapeForPrompt(startupContext.content)}\n</${tag}>`,
|
|
203
207
|
);
|
|
204
208
|
}
|
|
205
209
|
} catch (err) {
|
|
206
|
-
logger.error(`recall:
|
|
210
|
+
logger.error(`recall: startup context read failed: ${err}`);
|
|
207
211
|
}
|
|
208
212
|
|
|
209
213
|
// 2. Relevant memories — enriched with scoring signals and labels.
|
package/src/tools/context.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* nowledge_mem_context — read
|
|
2
|
+
* nowledge_mem_context — read startup context.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* updated throughout the day as events occur.
|
|
4
|
+
* Read mode prefers Context Bundle: owner identity, AI Identity, active
|
|
5
|
+
* space, active rules, Working Memory, and KFS paths. Older nmem clients
|
|
6
|
+
* fall back to Working Memory.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
* It's a living document that reflects what matters TODAY.
|
|
8
|
+
* Patch mode still edits Working Memory sections only.
|
|
11
9
|
*/
|
|
12
10
|
export function createContextTool(client, logger) {
|
|
13
11
|
return {
|
|
14
12
|
name: "nowledge_mem_context",
|
|
15
13
|
description:
|
|
16
|
-
"Read
|
|
17
|
-
"
|
|
18
|
-
"READ MODE (default): Call with no parameters to understand what the user is currently focused on. " +
|
|
14
|
+
"Read the user's startup context, or patch Working Memory sections. " +
|
|
15
|
+
"READ MODE (default): Call with no parameters to load Context Bundle when available: owner identity, AI Identity, active space, active rules, Working Memory, and KFS paths. Older nmem clients fall back to Working Memory. " +
|
|
19
16
|
"PATCH MODE: Supply patch_section to update just one section without overwriting the rest. " +
|
|
20
17
|
"Use patch_content to replace the section body, or patch_append to add text to it. " +
|
|
21
18
|
"Example: patch_section='## Notes', patch_append='New note: ...' to add a note without losing existing content. " +
|
|
22
|
-
"Note: Working Memory is regenerated by the Knowledge Agent each morning. " +
|
|
19
|
+
"Note: patch mode edits Working Memory, which is regenerated by the Knowledge Agent each morning. " +
|
|
23
20
|
"To see what happened recently by date, use nowledge_mem_timeline instead.",
|
|
24
21
|
parameters: {
|
|
25
22
|
type: "object",
|
|
@@ -100,22 +97,22 @@ export function createContextTool(client, logger) {
|
|
|
100
97
|
|
|
101
98
|
// — READ MODE —
|
|
102
99
|
try {
|
|
103
|
-
const
|
|
100
|
+
const context = await client.readStartupContext();
|
|
104
101
|
|
|
105
|
-
if (!
|
|
102
|
+
if (!context.available) {
|
|
106
103
|
return {
|
|
107
104
|
content: [
|
|
108
105
|
{
|
|
109
106
|
type: "text",
|
|
110
|
-
text: "
|
|
107
|
+
text: "Startup context is not available yet. Ensure Nowledge Mem is running. Context Bundle requires a recent nmem CLI; older clients fall back to Working Memory generated by Background Intelligence.",
|
|
111
108
|
},
|
|
112
109
|
],
|
|
113
110
|
};
|
|
114
111
|
}
|
|
115
112
|
|
|
116
113
|
return {
|
|
117
|
-
content: [{ type: "text", text:
|
|
118
|
-
details: { available: true },
|
|
114
|
+
content: [{ type: "text", text: context.content }],
|
|
115
|
+
details: { available: true, source: context.source },
|
|
119
116
|
};
|
|
120
117
|
} catch (err) {
|
|
121
118
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -124,7 +121,7 @@ export function createContextTool(client, logger) {
|
|
|
124
121
|
content: [
|
|
125
122
|
{
|
|
126
123
|
type: "text",
|
|
127
|
-
text: `Failed to read
|
|
124
|
+
text: `Failed to read startup context: ${msg}`,
|
|
128
125
|
},
|
|
129
126
|
],
|
|
130
127
|
};
|
package/src/tools/status.js
CHANGED
|
@@ -108,11 +108,11 @@ export function createStatusTool(client, _logger, cfg, runtimeInfo = {}) {
|
|
|
108
108
|
);
|
|
109
109
|
if (cfg.sessionContext) {
|
|
110
110
|
lines.push(
|
|
111
|
-
" Fallback active: Nowledge Mem still injects
|
|
111
|
+
" Fallback active: Nowledge Mem still injects startup context and uses its own recall path.",
|
|
112
112
|
);
|
|
113
113
|
} else {
|
|
114
114
|
lines.push(
|
|
115
|
-
" Fallback: Nowledge Mem tools remain available. Enable sessionContext for prompt-time
|
|
115
|
+
" Fallback: Nowledge Mem tools remain available. Enable sessionContext for prompt-time startup context and recall.",
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
if (corpusSupplementRegistrationError) {
|