memoryrouter-codex 1.2.0 → 1.2.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/README.md +1 -1
- package/package.json +1 -1
- package/runtime/hook.cjs +4 -10
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ MemoryRouter's Reflection Hierarchy consolidates raw memories into higher-tier r
|
|
|
149
149
|
- **CLI:** `memoryrouter-codex reflect [--tier 1|2] [--batches N|all] [--max-tokens N] [--dry-run]`. The loop checks out a batch of unconsolidated memories under a 15 minute server lease, runs Codex itself headlessly (`codex exec`, you pay your own inference) with server-authored instructions, and commits the resulting reflection entries. It keeps no local state: if anything dies mid-loop, the lease expires server-side and the memories return to the pool, so re-running always resumes from the oldest unconsolidated memory. `--dry-run` prints the checkout and prompt and deliberately lets the lease expire (this bills one checkout).
|
|
150
150
|
- **Local stdio MCP:** `memory_consolidate` (checkout, returns memory texts plus the server's reflection instructions) and `memory_commit_reflections` (submit entries for the batch, idempotent on replay). The model never sees memory row IDs; it works with bare texts and one opaque `cb_` batch id.
|
|
151
151
|
|
|
152
|
-
`memory_search` accepts optional `tiers` (subset of `[1, 2, 3]`: raw, reflections, high-level reflections) and `importance` (integer 1 to 10 minimum threshold; only reflections carry ratings). `memory_status` reports the current reflection debt. When the server reports that consolidation is
|
|
152
|
+
`memory_search` accepts optional `tiers` (subset of `[1, 2, 3]`: raw, reflections, high-level reflections) and `importance` (integer 1 to 10 minimum threshold; only reflections carry ratings). `memory_status` reports the current reflection debt. When the server reports that consolidation is suggested, hook-injected context appends a one-line suggestion on every injection until the debt is consolidated.
|
|
153
153
|
|
|
154
154
|
Reflection prompts are always server-authored. This package never writes its own consolidation instructions and refuses to reflect if the server response carries none. See https://docs.memoryrouter.ai/reflections for endpoint semantics, lease rules, and billing.
|
|
155
155
|
|
package/package.json
CHANGED
package/runtime/hook.cjs
CHANGED
|
@@ -36,8 +36,6 @@ function emitContext(eventName, context) {
|
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const NUDGE_SUPPRESS_MS = 24 * 60 * 60 * 1000;
|
|
40
|
-
|
|
41
39
|
function estimateDebtTokens(reflection) {
|
|
42
40
|
const raw = reflection?.unconsolidated?.raw?.est_tokens || 0;
|
|
43
41
|
const tier2 = reflection?.unconsolidated?.tier2?.est_tokens || 0;
|
|
@@ -45,19 +43,15 @@ function estimateDebtTokens(reflection) {
|
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
// Debt nudge rules (reflection-connectors-spec.md, section d):
|
|
48
|
-
// only when a context is being emitted anyway,
|
|
49
|
-
//
|
|
50
|
-
//
|
|
46
|
+
// only when a context is being emitted anyway, and counted inside the
|
|
47
|
+
// existing context char cap so it can never push memory content out.
|
|
48
|
+
// Fires on every run with a non-null suggestion.
|
|
51
49
|
function maybeAppendNudge(context, reflection, sessionId, hookContext) {
|
|
52
50
|
if (!context || !reflection || !reflection.suggestion || !sessionId) return context;
|
|
53
|
-
const state = loadSessionState(sessionId, hookContext.env);
|
|
54
|
-
if (state.lastNudgeAt && Date.now() - Date.parse(state.lastNudgeAt) < NUDGE_SUPPRESS_MS) return context;
|
|
55
51
|
const tokens = estimateDebtTokens(reflection);
|
|
56
|
-
const nudge = `\n\n[MemoryRouter] Consolidation
|
|
52
|
+
const nudge = `\n\n[MemoryRouter] Consolidation suggested: ${Math.round(tokens / 1000)}k unconsolidated tokens. Run: memoryrouter-codex reflect`;
|
|
57
53
|
const maxChars = Number(hookContext.config?.contextChars || 12000);
|
|
58
54
|
if (context.length + nudge.length > maxChars) return context;
|
|
59
|
-
state.lastNudgeAt = new Date().toISOString();
|
|
60
|
-
saveSessionState(sessionId, state, hookContext.env);
|
|
61
55
|
return context + nudge;
|
|
62
56
|
}
|
|
63
57
|
|