@totalreclaw/mcp-server 3.3.0 → 3.5.0

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.
Files changed (152) hide show
  1. package/README.md +61 -2
  2. package/SKILL.md +1 -1
  3. package/dist/claims-helper.d.ts +1 -1
  4. package/dist/claims-helper.d.ts.map +1 -1
  5. package/dist/claims-helper.js +31 -31
  6. package/dist/claims-helper.js.map +1 -1
  7. package/dist/cli/setup.d.ts +10 -0
  8. package/dist/cli/setup.d.ts.map +1 -1
  9. package/dist/cli/setup.js +15 -5
  10. package/dist/cli/setup.js.map +1 -1
  11. package/dist/consolidation.d.ts +3 -5
  12. package/dist/consolidation.d.ts.map +1 -1
  13. package/dist/consolidation.js +47 -122
  14. package/dist/consolidation.js.map +1 -1
  15. package/dist/contradiction-sync.d.ts +2 -2
  16. package/dist/contradiction-sync.d.ts.map +1 -1
  17. package/dist/contradiction-sync.js +17 -16
  18. package/dist/contradiction-sync.js.map +1 -1
  19. package/dist/dispatch.d.ts +95 -0
  20. package/dist/dispatch.d.ts.map +1 -0
  21. package/dist/dispatch.js +191 -0
  22. package/dist/dispatch.js.map +1 -0
  23. package/dist/embedding-codec.d.ts +81 -0
  24. package/dist/embedding-codec.d.ts.map +1 -0
  25. package/dist/embedding-codec.js +223 -0
  26. package/dist/embedding-codec.js.map +1 -0
  27. package/dist/extraction/extractor.d.ts +1 -0
  28. package/dist/extraction/extractor.d.ts.map +1 -1
  29. package/dist/extraction/extractor.js +15 -15
  30. package/dist/extraction/extractor.js.map +1 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +484 -767
  33. package/dist/index.js.map +1 -1
  34. package/dist/pair-remote-client.d.ts +41 -0
  35. package/dist/pair-remote-client.d.ts.map +1 -1
  36. package/dist/pair-remote-client.js +130 -32
  37. package/dist/pair-remote-client.js.map +1 -1
  38. package/dist/prompts.d.ts +3 -4
  39. package/dist/prompts.d.ts.map +1 -1
  40. package/dist/prompts.js +3 -9
  41. package/dist/prompts.js.map +1 -1
  42. package/dist/server-setup.d.ts +35 -0
  43. package/dist/server-setup.d.ts.map +1 -0
  44. package/dist/server-setup.js +102 -0
  45. package/dist/server-setup.js.map +1 -0
  46. package/dist/subgraph/bundle.d.ts +129 -0
  47. package/dist/subgraph/bundle.d.ts.map +1 -0
  48. package/dist/subgraph/bundle.js +232 -0
  49. package/dist/subgraph/bundle.js.map +1 -0
  50. package/dist/subgraph/chain-config.d.ts +128 -0
  51. package/dist/subgraph/chain-config.d.ts.map +1 -0
  52. package/dist/subgraph/chain-config.js +135 -0
  53. package/dist/subgraph/chain-config.js.map +1 -0
  54. package/dist/subgraph/credentials.d.ts +83 -0
  55. package/dist/subgraph/credentials.d.ts.map +1 -0
  56. package/dist/subgraph/credentials.js +210 -0
  57. package/dist/subgraph/credentials.js.map +1 -0
  58. package/dist/subgraph/search.js +13 -13
  59. package/dist/subgraph/search.js.map +1 -1
  60. package/dist/subgraph/store.d.ts +39 -2
  61. package/dist/subgraph/store.d.ts.map +1 -1
  62. package/dist/subgraph/store.js +48 -13
  63. package/dist/subgraph/store.js.map +1 -1
  64. package/dist/tools/account.d.ts +5 -2
  65. package/dist/tools/account.d.ts.map +1 -1
  66. package/dist/tools/account.js +17 -4
  67. package/dist/tools/account.js.map +1 -1
  68. package/dist/tools/consolidate.d.ts +2 -2
  69. package/dist/tools/consolidate.d.ts.map +1 -1
  70. package/dist/tools/consolidate.js +2 -1
  71. package/dist/tools/consolidate.js.map +1 -1
  72. package/dist/tools/debrief.d.ts +2 -2
  73. package/dist/tools/debrief.d.ts.map +1 -1
  74. package/dist/tools/debrief.js +2 -1
  75. package/dist/tools/debrief.js.map +1 -1
  76. package/dist/tools/export.d.ts +2 -2
  77. package/dist/tools/export.d.ts.map +1 -1
  78. package/dist/tools/export.js +2 -1
  79. package/dist/tools/export.js.map +1 -1
  80. package/dist/tools/forget.d.ts +8 -2
  81. package/dist/tools/forget.d.ts.map +1 -1
  82. package/dist/tools/forget.js +14 -7
  83. package/dist/tools/forget.js.map +1 -1
  84. package/dist/tools/helpers.d.ts +40 -0
  85. package/dist/tools/helpers.d.ts.map +1 -0
  86. package/dist/tools/helpers.js +64 -0
  87. package/dist/tools/helpers.js.map +1 -0
  88. package/dist/tools/import-batch.d.ts +2 -1
  89. package/dist/tools/import-batch.d.ts.map +1 -1
  90. package/dist/tools/import-batch.js +1 -1
  91. package/dist/tools/import-batch.js.map +1 -1
  92. package/dist/tools/import-from.d.ts +2 -2
  93. package/dist/tools/import-from.d.ts.map +1 -1
  94. package/dist/tools/import-from.js +2 -1
  95. package/dist/tools/import-from.js.map +1 -1
  96. package/dist/tools/import.d.ts +2 -2
  97. package/dist/tools/import.d.ts.map +1 -1
  98. package/dist/tools/import.js +4 -3
  99. package/dist/tools/import.js.map +1 -1
  100. package/dist/tools/index.d.ts +2 -2
  101. package/dist/tools/index.d.ts.map +1 -1
  102. package/dist/tools/index.js +7 -9
  103. package/dist/tools/index.js.map +1 -1
  104. package/dist/tools/pair.d.ts +2 -1
  105. package/dist/tools/pair.d.ts.map +1 -1
  106. package/dist/tools/pair.js +67 -4
  107. package/dist/tools/pair.js.map +1 -1
  108. package/dist/tools/pin.d.ts +10 -7
  109. package/dist/tools/pin.d.ts.map +1 -1
  110. package/dist/tools/pin.js +43 -49
  111. package/dist/tools/pin.js.map +1 -1
  112. package/dist/tools/recall.d.ts +2 -2
  113. package/dist/tools/recall.d.ts.map +1 -1
  114. package/dist/tools/recall.js +22 -47
  115. package/dist/tools/recall.js.map +1 -1
  116. package/dist/tools/remember.d.ts +2 -2
  117. package/dist/tools/remember.d.ts.map +1 -1
  118. package/dist/tools/remember.js +30 -48
  119. package/dist/tools/remember.js.map +1 -1
  120. package/dist/tools/retype.d.ts +6 -1
  121. package/dist/tools/retype.d.ts.map +1 -1
  122. package/dist/tools/retype.js +37 -33
  123. package/dist/tools/retype.js.map +1 -1
  124. package/dist/tools/set-scope.d.ts +6 -1
  125. package/dist/tools/set-scope.d.ts.map +1 -1
  126. package/dist/tools/set-scope.js +14 -10
  127. package/dist/tools/set-scope.js.map +1 -1
  128. package/dist/tools/status.d.ts +2 -1
  129. package/dist/tools/status.d.ts.map +1 -1
  130. package/dist/tools/status.js +14 -12
  131. package/dist/tools/status.js.map +1 -1
  132. package/dist/tools/support.d.ts +5 -3
  133. package/dist/tools/support.d.ts.map +1 -1
  134. package/dist/tools/support.js +9 -8
  135. package/dist/tools/support.js.map +1 -1
  136. package/dist/tools/types.d.ts +38 -0
  137. package/dist/tools/types.d.ts.map +1 -0
  138. package/dist/tools/types.js +17 -0
  139. package/dist/tools/types.js.map +1 -0
  140. package/dist/tools/upgrade.d.ts +2 -1
  141. package/dist/tools/upgrade.d.ts.map +1 -1
  142. package/dist/tools/upgrade.js +6 -4
  143. package/dist/tools/upgrade.js.map +1 -1
  144. package/package.json +3 -4
  145. package/dist/subgraph/index.d.ts +0 -7
  146. package/dist/subgraph/index.d.ts.map +0 -1
  147. package/dist/subgraph/index.js +0 -23
  148. package/dist/subgraph/index.js.map +0 -1
  149. package/dist/tools/migrate.d.ts +0 -88
  150. package/dist/tools/migrate.d.ts.map +0 -1
  151. package/dist/tools/migrate.js +0 -273
  152. package/dist/tools/migrate.js.map +0 -1
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ /**
3
+ * Single tool-dispatch table for the TotalReclaw MCP server.
4
+ *
5
+ * The server serves two storage-mode pipelines — self-hosted (`http`) and
6
+ * managed service (`subgraph`) — that used to live in two parallel `switch`
7
+ * statements plus per-tool glue duplicated across both. This module collapses
8
+ * that into one data-driven router:
9
+ *
10
+ * - `TOOL_MANIFEST` is the mode-independent tool list returned by ListTools.
11
+ * - `SUBGRAPH_POLICY` / `HTTP_POLICY` capture the per-(tool, mode)
12
+ * cross-cutting behaviour (quota-error trapping + memory-context cache
13
+ * invalidation) as data instead of copy-pasted `try`/`catch` arms.
14
+ * - `createCallToolHandler` is the router. The concrete handlers are injected
15
+ * as pre-bound "bundles" (name → handler) so this module stays free of the
16
+ * crypto/subgraph weight and is unit-testable with fakes.
17
+ *
18
+ * Routing order is preserved verbatim from the original entry point:
19
+ * 1. `totalreclaw_setup` → removed-tool envelope (phrase-safety, 3.2.1).
20
+ * 2. `totalreclaw_support` → available in every mode (incl. unconfigured).
21
+ * 3. `totalreclaw_pair` → available in every mode (incl. unconfigured).
22
+ * 4. unconfigured mode → not-configured envelope for everything else.
23
+ * 5. resolve the mode bundle, look up the handler, apply the policy, and
24
+ * wrap the whole thing in the shared quota → auth → generic error funnel.
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.HTTP_POLICY = exports.SUBGRAPH_POLICY = exports.TOOL_MANIFEST = void 0;
28
+ exports.setupRemovedResponse = setupRemovedResponse;
29
+ exports.notConfiguredResponse = notConfiguredResponse;
30
+ exports.unknownToolResponse = unknownToolResponse;
31
+ exports.genericErrorResponse = genericErrorResponse;
32
+ exports.createCallToolHandler = createCallToolHandler;
33
+ const index_js_1 = require("./tools/index.js");
34
+ const pin_js_1 = require("./tools/pin.js");
35
+ const retype_js_1 = require("./tools/retype.js");
36
+ const set_scope_js_1 = require("./tools/set-scope.js");
37
+ /**
38
+ * The tool list advertised by ListTools. Identical in both storage modes —
39
+ * mode gating happens at dispatch time (an unsupported tool returns a
40
+ * mode-specific error envelope), not in the manifest.
41
+ */
42
+ exports.TOOL_MANIFEST = [
43
+ index_js_1.rememberToolDefinition,
44
+ index_js_1.recallToolDefinition,
45
+ index_js_1.forgetToolDefinition,
46
+ index_js_1.exportToolDefinition,
47
+ index_js_1.importToolDefinition,
48
+ index_js_1.importFromToolDefinition,
49
+ index_js_1.importBatchToolDefinition,
50
+ index_js_1.consolidateToolDefinition,
51
+ index_js_1.statusToolDefinition,
52
+ index_js_1.upgradeToolDefinition,
53
+ index_js_1.debriefToolDefinition,
54
+ index_js_1.supportToolDefinition,
55
+ index_js_1.accountToolDefinition,
56
+ pin_js_1.pinToolDefinition,
57
+ pin_js_1.unpinToolDefinition,
58
+ retype_js_1.retypeToolDefinition,
59
+ set_scope_js_1.setScopeToolDefinition,
60
+ index_js_1.pairToolDefinition,
61
+ // The tool definitions declare `inputSchema.type` as `string` rather than the
62
+ // literal `"object"` the SDK's `Tool` type wants; the widening is harmless at
63
+ // runtime (they are all `"object"`). The cast keeps ListTools strongly typed.
64
+ ];
65
+ /** Per-tool policy in managed-service (subgraph) mode. */
66
+ exports.SUBGRAPH_POLICY = {
67
+ totalreclaw_remember: { quotaGuard: true, invalidateCache: true },
68
+ totalreclaw_forget: { invalidateCache: true },
69
+ totalreclaw_debrief: { quotaGuard: true, invalidateCache: true },
70
+ totalreclaw_pin: { quotaGuard: true, invalidateCache: true },
71
+ totalreclaw_unpin: { quotaGuard: true, invalidateCache: true },
72
+ totalreclaw_retype: { quotaGuard: true, invalidateCache: true },
73
+ totalreclaw_set_scope: { quotaGuard: true, invalidateCache: true },
74
+ };
75
+ /** Per-tool policy in self-hosted (HTTP) mode. */
76
+ exports.HTTP_POLICY = {
77
+ totalreclaw_remember: { quotaGuard: true },
78
+ totalreclaw_forget: { invalidateCache: true },
79
+ totalreclaw_consolidate: { invalidateCache: true },
80
+ totalreclaw_debrief: { quotaGuard: true },
81
+ };
82
+ /** Response for the removed `totalreclaw_setup` tool (phrase-safety, 3.2.1). */
83
+ function setupRemovedResponse() {
84
+ return {
85
+ content: [{
86
+ type: 'text',
87
+ text: JSON.stringify({
88
+ error: 'tool_removed',
89
+ message: 'The totalreclaw_setup tool was removed in @totalreclaw/mcp-server@3.2.1 ' +
90
+ 'for phrase-safety. Follow the URL-driven install flow at ' +
91
+ 'https://github.com/p-diogo/totalreclaw/blob/main/docs/guides/claude-code-setup.md. ' +
92
+ 'The user sources their recovery phrase out-of-band (OpenClaw or Hermes ' +
93
+ 'browser pair flow, or an offline BIP-39 generator) and pastes it directly ' +
94
+ 'into TOTALRECLAW_RECOVERY_PHRASE in the MCP host config — never into chat.',
95
+ }),
96
+ }],
97
+ isError: true,
98
+ };
99
+ }
100
+ /** Response when a tool is called before the server is configured. */
101
+ function notConfiguredResponse() {
102
+ return {
103
+ content: [{
104
+ type: 'text',
105
+ text: JSON.stringify({
106
+ error: 'not_configured',
107
+ message: 'TotalReclaw is not configured yet. Follow the URL-driven install flow ' +
108
+ 'at https://github.com/p-diogo/totalreclaw/blob/main/docs/guides/claude-code-setup.md — ' +
109
+ 'the user pastes their recovery phrase directly into the MCP host config (TOTALRECLAW_RECOVERY_PHRASE), ' +
110
+ 'never into chat.',
111
+ }),
112
+ }],
113
+ isError: true,
114
+ };
115
+ }
116
+ /** Response for a tool name with no handler in the active mode. */
117
+ function unknownToolResponse(name) {
118
+ return {
119
+ content: [{ type: 'text', text: JSON.stringify({ error: `Unknown tool: ${name}` }) }],
120
+ isError: true,
121
+ };
122
+ }
123
+ /** Response for an uncaught handler error that is neither quota nor auth. */
124
+ function genericErrorResponse(error) {
125
+ return {
126
+ content: [{
127
+ type: 'text',
128
+ text: JSON.stringify({ error: error instanceof Error ? error.message : 'Unknown error' }),
129
+ }],
130
+ isError: true,
131
+ };
132
+ }
133
+ /**
134
+ * Build the CallTool router. Returns `(name, args) => Promise<ToolResponse>`
135
+ * — the single entry point the server's CallTool handler delegates to.
136
+ */
137
+ function createCallToolHandler(deps) {
138
+ return async function dispatchTool(name, args) {
139
+ // 1. Removed setup tool — structured error, never surfaces a phrase.
140
+ if (name === 'totalreclaw_setup')
141
+ return setupRemovedResponse();
142
+ // 2 + 3. Support and pair are reachable in every mode, including
143
+ // unconfigured (pair is the MCP-only onboarding entry point).
144
+ if (name === 'totalreclaw_support')
145
+ return deps.handleSupport(args);
146
+ if (name === 'totalreclaw_pair')
147
+ return deps.handlePair(args);
148
+ // 4. Unconfigured: everything else returns setup guidance.
149
+ const mode = deps.getMode();
150
+ if (mode === 'unconfigured')
151
+ return notConfiguredResponse();
152
+ // 5. Configured dispatch, wrapped in the shared quota → auth → generic funnel.
153
+ try {
154
+ // Mode-independent tools (status / upgrade / account) route first — they
155
+ // hit the relay directly and must not depend on the self-hosted client.
156
+ const commonHandler = deps.common[name];
157
+ if (commonHandler)
158
+ return await commonHandler(args);
159
+ const bundle = await deps.resolveBundle(mode);
160
+ const handler = bundle[name];
161
+ if (!handler)
162
+ return unknownToolResponse(name);
163
+ const policy = (mode === 'subgraph' ? exports.SUBGRAPH_POLICY : exports.HTTP_POLICY)[name] ?? {};
164
+ if (policy.quotaGuard) {
165
+ try {
166
+ const result = await handler(args);
167
+ if (policy.invalidateCache)
168
+ deps.onMutate();
169
+ return result;
170
+ }
171
+ catch (error) {
172
+ if (deps.isQuotaExceededError(error))
173
+ return deps.quotaExceededResponse();
174
+ throw error;
175
+ }
176
+ }
177
+ const result = await handler(args);
178
+ if (policy.invalidateCache)
179
+ deps.onMutate();
180
+ return result;
181
+ }
182
+ catch (error) {
183
+ if (deps.isQuotaExceededError(error))
184
+ return deps.quotaExceededResponse();
185
+ if (deps.isAuthError(error))
186
+ return deps.authHintResponse();
187
+ return genericErrorResponse(error);
188
+ }
189
+ };
190
+ }
191
+ //# sourceMappingURL=dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AA2HH,oDAiBC;AAGD,sDAeC;AAGD,kDAKC;AAGD,oDAQC;AAMD,sDAiDC;AApOD,+CAe0B;AAC1B,2CAAwE;AACxE,iDAAyD;AACzD,uDAA8D;AAI9D;;;;GAIG;AACU,QAAA,aAAa,GAAG;IAC3B,iCAAsB;IACtB,+BAAoB;IACpB,+BAAoB;IACpB,+BAAoB;IACpB,+BAAoB;IACpB,mCAAwB;IACxB,oCAAyB;IACzB,oCAAyB;IACzB,+BAAoB;IACpB,gCAAqB;IACrB,gCAAqB;IACrB,gCAAqB;IACrB,gCAAqB;IACrB,0BAAiB;IACjB,4BAAmB;IACnB,gCAAoB;IACpB,qCAAsB;IACtB,6BAAkB;IAClB,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AAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC1E,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC5D,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Universal embedding codec — cross-client format parity (internal#479 Part B).
3
+ *
4
+ * MCP-side mirror of `skill/plugin/embedding/embedding-codec.ts`. The pure
5
+ * packing/unpacking of the *pre-encryption* embedding payload; the
6
+ * XChaCha20-Poly1305 wrapping stays in `subgraph/crypto.ts`
7
+ * (`encrypt` / `decrypt`).
8
+ *
9
+ * # The parity bug (#479)
10
+ *
11
+ * Three clients wrote three different pre-encryption payloads:
12
+ * - Hermes / canonical core: base64(little-endian f16) — 1280 B for 640-d.
13
+ * - TS plugin (legacy): `JSON.stringify(number[])` — a JSON array.
14
+ * - Old Python / MCP: base64(little-endian f32) — 2560 B for 640-d.
15
+ *
16
+ * Each client only read its OWN format, so in a mixed-client vault a foreign
17
+ * fact's embedding decrypted to garbage and that fact silently degraded to
18
+ * word-index-only matching. The READ side below fixes that: one UNIVERSAL
19
+ * decoder, preferring `@totalreclaw/core.decodeEmbeddingUniversal` when the
20
+ * installed core exposes it, else a local fallback implementing the exact
21
+ * dispatch of core's `decode_embedding_universal`
22
+ * (rust/totalreclaw-core/src/embedding_codec.rs):
23
+ * - payload beginning with `[` → JSON float array;
24
+ * - else base64-decode → `len == EMBEDDING_DIMS*2` → f16 upcast to f32;
25
+ * - else `len % 4 == 0` → LE f32;
26
+ * - else → throw. Never a silently wrong-length vector.
27
+ *
28
+ * WRITE: {@link encodeEmbeddingPayload} delegates to
29
+ * `@totalreclaw/core.encodeEmbeddingCanonical` when present (canonical f16,
30
+ * fail-closed on NaN/±inf/overflow — the throw aborts the store). When the
31
+ * installed core predates the codec it keeps the legacy f32-binary packing the
32
+ * MCP server has always used (see `index.ts` `encryptEmbedding`). f32→f16
33
+ * rounding is NOT reimplemented here — it stays in core; writes flip to
34
+ * canonical automatically when the core dep bumps.
35
+ */
36
+ /** Production embedding dimensionality. Mirrors core's `EMBEDDING_DIMS`. */
37
+ export declare const EMBEDDING_DIMS = 640;
38
+ /**
39
+ * The core binding shape this module prefers. Both ship in `@totalreclaw/core`
40
+ * once the embedding codec lands; older cores omit them and we fall back to the
41
+ * local implementation. Structural (no `instanceof`) so a stale type
42
+ * declaration never blocks the build — same style as `consolidation.ts`.
43
+ */
44
+ export interface CoreEmbeddingCodec {
45
+ /** Pack a vector into the canonical pre-encryption payload. Throws on
46
+ * non-finite / f16-overflow inputs (fail-closed). */
47
+ encodeEmbeddingCanonical(embedding: number[]): string;
48
+ /** Decode any payload (canonical or legacy) into a vector. */
49
+ decodeEmbeddingUniversal(payload: string): number[] | Float32Array;
50
+ }
51
+ export declare function decodeEmbeddingLocal(payload: string): number[];
52
+ /**
53
+ * Decode with an explicit core binding (injection seam). When `core` is
54
+ * non-null it is preferred (byte-exact parity with core); otherwise the local
55
+ * decoder runs. Production code calls {@link decodeEmbeddingUniversal}.
56
+ */
57
+ export declare function decodeEmbeddingWithCore(payload: string, core: CoreEmbeddingCodec | null): number[];
58
+ /**
59
+ * Decode any embedding payload, preferring the installed `@totalreclaw/core`
60
+ * binding when it exposes `decodeEmbeddingUniversal`, else the local fallback.
61
+ */
62
+ export declare function decodeEmbeddingUniversal(payload: string): number[];
63
+ /**
64
+ * Encode a vector into the pre-encryption payload, with an explicit core
65
+ * binding (injection seam). When `core` is present this delegates to
66
+ * `core.encodeEmbeddingCanonical` (fail-closed on NaN/±inf/overflow — the
67
+ * throw intentionally aborts the store). When `core` is null it returns the
68
+ * marker `'__legacy-f32:use-mcp-packing__'`; the MCP `encryptEmbedding` helper
69
+ * then packs the legacy f32 binary itself (its historical write). The f32→f16
70
+ * rounding is deliberately left to core, never reimplemented here.
71
+ */
72
+ export declare const LEGACY_F32_MARKER = "__totalreclaw-legacy-f32-packing__";
73
+ export declare function encodeEmbeddingPayloadWithCore(embedding: number[], core: CoreEmbeddingCodec | null): string;
74
+ /**
75
+ * Encode a vector into the pre-encryption payload, preferring canonical f16 via
76
+ * `@totalreclaw/core.encodeEmbeddingCanonical` when the installed core exposes
77
+ * it, else the legacy-f32 marker (the MCP helper packs f32 itself). Writes flip
78
+ * to canonical automatically when the core dependency bumps past the codec.
79
+ */
80
+ export declare function encodeEmbeddingPayload(embedding: number[]): string;
81
+ //# sourceMappingURL=embedding-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedding-codec.d.ts","sourceRoot":"","sources":["../src/embedding-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;yDACqD;IACrD,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACtD,8DAA8D;IAC9D,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,YAAY,CAAC;CACpE;AAoGD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAkD9D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,kBAAkB,GAAG,IAAI,GAC9B,MAAM,EAAE,CAGV;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAElE;AAMD;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,uCAAuC,CAAC;AAEtE,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,EAAE,EACnB,IAAI,EAAE,kBAAkB,GAAG,IAAI,GAC9B,MAAM,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAElE"}
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ /**
3
+ * Universal embedding codec — cross-client format parity (internal#479 Part B).
4
+ *
5
+ * MCP-side mirror of `skill/plugin/embedding/embedding-codec.ts`. The pure
6
+ * packing/unpacking of the *pre-encryption* embedding payload; the
7
+ * XChaCha20-Poly1305 wrapping stays in `subgraph/crypto.ts`
8
+ * (`encrypt` / `decrypt`).
9
+ *
10
+ * # The parity bug (#479)
11
+ *
12
+ * Three clients wrote three different pre-encryption payloads:
13
+ * - Hermes / canonical core: base64(little-endian f16) — 1280 B for 640-d.
14
+ * - TS plugin (legacy): `JSON.stringify(number[])` — a JSON array.
15
+ * - Old Python / MCP: base64(little-endian f32) — 2560 B for 640-d.
16
+ *
17
+ * Each client only read its OWN format, so in a mixed-client vault a foreign
18
+ * fact's embedding decrypted to garbage and that fact silently degraded to
19
+ * word-index-only matching. The READ side below fixes that: one UNIVERSAL
20
+ * decoder, preferring `@totalreclaw/core.decodeEmbeddingUniversal` when the
21
+ * installed core exposes it, else a local fallback implementing the exact
22
+ * dispatch of core's `decode_embedding_universal`
23
+ * (rust/totalreclaw-core/src/embedding_codec.rs):
24
+ * - payload beginning with `[` → JSON float array;
25
+ * - else base64-decode → `len == EMBEDDING_DIMS*2` → f16 upcast to f32;
26
+ * - else `len % 4 == 0` → LE f32;
27
+ * - else → throw. Never a silently wrong-length vector.
28
+ *
29
+ * WRITE: {@link encodeEmbeddingPayload} delegates to
30
+ * `@totalreclaw/core.encodeEmbeddingCanonical` when present (canonical f16,
31
+ * fail-closed on NaN/±inf/overflow — the throw aborts the store). When the
32
+ * installed core predates the codec it keeps the legacy f32-binary packing the
33
+ * MCP server has always used (see `index.ts` `encryptEmbedding`). f32→f16
34
+ * rounding is NOT reimplemented here — it stays in core; writes flip to
35
+ * canonical automatically when the core dep bumps.
36
+ */
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.LEGACY_F32_MARKER = exports.EMBEDDING_DIMS = void 0;
39
+ exports.decodeEmbeddingLocal = decodeEmbeddingLocal;
40
+ exports.decodeEmbeddingWithCore = decodeEmbeddingWithCore;
41
+ exports.decodeEmbeddingUniversal = decodeEmbeddingUniversal;
42
+ exports.encodeEmbeddingPayloadWithCore = encodeEmbeddingPayloadWithCore;
43
+ exports.encodeEmbeddingPayload = encodeEmbeddingPayload;
44
+ /** Production embedding dimensionality. Mirrors core's `EMBEDDING_DIMS`. */
45
+ exports.EMBEDDING_DIMS = 640;
46
+ // MCP uses bare `require('@totalreclaw/core')` (see consolidation.ts,
47
+ // contradiction-sync.ts) — match that pattern rather than `createRequire`.
48
+ let _coreCodec;
49
+ /**
50
+ * Probe the installed `@totalreclaw/core` for the embedding codec. Returns the
51
+ * binding when BOTH functions are present, `null` when either is missing (or
52
+ * the module cannot be loaded), and caches the result. The require is wrapped
53
+ * so a partial install of the dependency tree does not crash module init.
54
+ */
55
+ function resolveCoreCodec() {
56
+ if (_coreCodec !== undefined)
57
+ return _coreCodec;
58
+ try {
59
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
60
+ const core = require('@totalreclaw/core');
61
+ if (typeof core.encodeEmbeddingCanonical === 'function' &&
62
+ typeof core.decodeEmbeddingUniversal === 'function') {
63
+ _coreCodec = core;
64
+ return _coreCodec;
65
+ }
66
+ }
67
+ catch {
68
+ // Core not installed / unloadable — fall back to the local decoder.
69
+ }
70
+ _coreCodec = null;
71
+ return _coreCodec;
72
+ }
73
+ // ---------------------------------------------------------------------------
74
+ // f16 → f32 upcast (exact bit math)
75
+ // ---------------------------------------------------------------------------
76
+ const _f32View = new DataView(new ArrayBuffer(4));
77
+ /**
78
+ * Convert one IEEE-754 binary16 (little-endian bytes `lo`,`hi`) into a JS
79
+ * number, widening to f32 first. Mirrors Rust `half::f16::to_f32` exactly:
80
+ * sign/exponent/mantissa widening, subnormals normalized, inf/NaN preserved.
81
+ * Every f32 is exactly representable as a JS number (f64), so this is
82
+ * bit-exact with core's `f16.to_f32()` exposed to JS.
83
+ */
84
+ function f16LeBytesToNumber(lo, hi) {
85
+ const half = lo | (hi << 8); // little-endian u16
86
+ const sign = (half & 0x8000) << 16; // sign bit moved to f32 position
87
+ const exp = (half & 0x7c00) >> 10; // 5-bit exponent
88
+ const mant = half & 0x03ff; // 10-bit mantissa
89
+ let bits;
90
+ if (exp === 0) {
91
+ if (mant === 0) {
92
+ bits = sign; // signed zero
93
+ }
94
+ else {
95
+ // Subnormal f16: normalize into a normal f32.
96
+ let m = mant;
97
+ let e = -14;
98
+ while ((m & 0x0400) === 0) {
99
+ m <<= 1;
100
+ e -= 1;
101
+ }
102
+ m &= 0x03ff; // drop the implicit leading 1
103
+ e += 127; // rebias to f32
104
+ bits = sign | (e << 23) | (m << 13);
105
+ }
106
+ }
107
+ else if (exp === 31) {
108
+ // Inf or NaN — preserve payload bits in the f32 mantissa.
109
+ bits = sign | 0x7f800000 | (mant << 13);
110
+ }
111
+ else {
112
+ bits = sign | ((exp + 112) << 23) | (mant << 13); // normal: rebias 15→127
113
+ }
114
+ _f32View.setUint32(0, bits >>> 0, true);
115
+ return _f32View.getFloat32(0, true);
116
+ }
117
+ // ---------------------------------------------------------------------------
118
+ // READ — local universal decoder (the actual parity fix)
119
+ // ---------------------------------------------------------------------------
120
+ /**
121
+ * Decode any pre-encryption embedding payload — canonical f16, legacy JSON, or
122
+ * legacy f32 binary — into a `number[]`, using ONLY local computation (no core
123
+ * binding). Dispatch matches core's `decode_embedding_universal` exactly. See
124
+ * the file header for the dispatch table. Throws on malformed JSON, invalid
125
+ * base64, or an uninterpretable byte length.
126
+ */
127
+ // Strict base64 validation (coordinator review): Buffer.from(s, 'base64') is
128
+ // silently LAX — it skips invalid characters and never throws, so a corrupted
129
+ // or foreign payload could decode to a plausible-length buffer of garbage
130
+ // floats instead of erroring. Core (Rust) and Python both REJECT invalid
131
+ // base64; the local fallback must match that contract. Standard alphabet,
132
+ // padded, whole-string.
133
+ // Note: this validates alphabet + padding shape but not trailing-bit
134
+ // canonicality (core's Rust engine also rejects non-zero trailing bits in
135
+ // the final block) — slightly more lenient in the SAFE direction only; no
136
+ // real encoder emits non-canonical trailing bits.
137
+ const BASE64_STRICT = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
138
+ function decodeEmbeddingLocal(payload) {
139
+ const trimmed = payload.trim();
140
+ // Legacy TS plugin format: a decrypted payload beginning with '[' is a JSON
141
+ // float array (the historical JSON.stringify(vec) write).
142
+ if (trimmed.startsWith('[')) {
143
+ let parsed;
144
+ try {
145
+ parsed = JSON.parse(trimmed);
146
+ }
147
+ catch (e) {
148
+ throw new Error(`invalid JSON embedding array: ${e instanceof Error ? e.message : String(e)}`);
149
+ }
150
+ if (!Array.isArray(parsed) || !parsed.every((v) => typeof v === 'number')) {
151
+ throw new Error('JSON embedding payload is not an array of numbers');
152
+ }
153
+ return parsed;
154
+ }
155
+ if (!BASE64_STRICT.test(trimmed)) {
156
+ throw new Error('base64 decode failed: payload contains non-base64 characters');
157
+ }
158
+ const buf = Buffer.from(trimmed, 'base64');
159
+ if (buf.length === exports.EMBEDDING_DIMS * 2) {
160
+ // Canonical f16 payload (640 * 2 bytes).
161
+ const out = new Array(exports.EMBEDDING_DIMS);
162
+ for (let i = 0; i < exports.EMBEDDING_DIMS; i++) {
163
+ out[i] = f16LeBytesToNumber(buf[i * 2], buf[i * 2 + 1]);
164
+ }
165
+ return out;
166
+ }
167
+ if (buf.length % 4 === 0) {
168
+ // Legacy f32 binary payload (old Python '<Nf' / the MCP write), OR any
169
+ // non-640-d vector packed as f32. 0 bytes → empty vector.
170
+ const count = buf.length / 4;
171
+ const out = new Array(count);
172
+ for (let i = 0; i < count; i++) {
173
+ out[i] = buf.readFloatLE(i * 4);
174
+ }
175
+ return out;
176
+ }
177
+ throw new Error(`decoded embedding buffer has length ${buf.length} (expected ${exports.EMBEDDING_DIMS * 2} for f16, or a multiple of 4 for f32)`);
178
+ }
179
+ /**
180
+ * Decode with an explicit core binding (injection seam). When `core` is
181
+ * non-null it is preferred (byte-exact parity with core); otherwise the local
182
+ * decoder runs. Production code calls {@link decodeEmbeddingUniversal}.
183
+ */
184
+ function decodeEmbeddingWithCore(payload, core) {
185
+ if (core)
186
+ return Array.from(core.decodeEmbeddingUniversal(payload));
187
+ return decodeEmbeddingLocal(payload);
188
+ }
189
+ /**
190
+ * Decode any embedding payload, preferring the installed `@totalreclaw/core`
191
+ * binding when it exposes `decodeEmbeddingUniversal`, else the local fallback.
192
+ */
193
+ function decodeEmbeddingUniversal(payload) {
194
+ return decodeEmbeddingWithCore(payload, resolveCoreCodec());
195
+ }
196
+ // ---------------------------------------------------------------------------
197
+ // WRITE — canonical f16 (core-binding only) or legacy f32 fallback
198
+ // ---------------------------------------------------------------------------
199
+ /**
200
+ * Encode a vector into the pre-encryption payload, with an explicit core
201
+ * binding (injection seam). When `core` is present this delegates to
202
+ * `core.encodeEmbeddingCanonical` (fail-closed on NaN/±inf/overflow — the
203
+ * throw intentionally aborts the store). When `core` is null it returns the
204
+ * marker `'__legacy-f32:use-mcp-packing__'`; the MCP `encryptEmbedding` helper
205
+ * then packs the legacy f32 binary itself (its historical write). The f32→f16
206
+ * rounding is deliberately left to core, never reimplemented here.
207
+ */
208
+ exports.LEGACY_F32_MARKER = '__totalreclaw-legacy-f32-packing__';
209
+ function encodeEmbeddingPayloadWithCore(embedding, core) {
210
+ if (core)
211
+ return core.encodeEmbeddingCanonical(embedding);
212
+ return exports.LEGACY_F32_MARKER;
213
+ }
214
+ /**
215
+ * Encode a vector into the pre-encryption payload, preferring canonical f16 via
216
+ * `@totalreclaw/core.encodeEmbeddingCanonical` when the installed core exposes
217
+ * it, else the legacy-f32 marker (the MCP helper packs f32 itself). Writes flip
218
+ * to canonical automatically when the core dependency bumps past the codec.
219
+ */
220
+ function encodeEmbeddingPayload(embedding) {
221
+ return encodeEmbeddingPayloadWithCore(embedding, resolveCoreCodec());
222
+ }
223
+ //# sourceMappingURL=embedding-codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedding-codec.js","sourceRoot":"","sources":["../src/embedding-codec.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;AAqHH,oDAkDC;AAOD,0DAMC;AAMD,4DAEC;AAiBD,wEAMC;AAQD,wDAEC;AA3ND,4EAA4E;AAC/D,QAAA,cAAc,GAAG,GAAG,CAAC;AAgBlC,sEAAsE;AACtE,2EAA2E;AAC3E,IAAI,UAAiD,CAAC;AAEtD;;;;;GAKG;AACH,SAAS,gBAAgB;IACvB,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC;IAChD,IAAI,CAAC;QACH,iEAAiE;QACjE,MAAM,IAAI,GAAG,OAAO,CAAC,mBAAmB,CAA4B,CAAC;QACrE,IACE,OAAO,IAAI,CAAC,wBAAwB,KAAK,UAAU;YACnD,OAAO,IAAI,CAAC,wBAAwB,KAAK,UAAU,EACnD,CAAC;YACD,UAAU,GAAG,IAAqC,CAAC;YACnD,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,oEAAoE;IACtE,CAAC;IACD,UAAU,GAAG,IAAI,CAAC;IAClB,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,8EAA8E;AAC9E,oCAAoC;AACpC,8EAA8E;AAE9E,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAElD;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,EAAU,EAAE,EAAU;IAChD,MAAM,IAAI,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAA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,CAAC,OAAO,CAAC,CAAC,CAAC;IACpE,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,OAAe;IACtD,OAAO,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,8EAA8E;AAC9E,mEAAmE;AACnE,8EAA8E;AAE9E;;;;;;;;GAQG;AACU,QAAA,iBAAiB,GAAG,oCAAoC,CAAC;AAEtE,SAAgB,8BAA8B,CAC5C,SAAmB,EACnB,IAA+B;IAE/B,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAC1D,OAAO,yBAAiB,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,SAAmB;IACxD,OAAO,8BAA8B,CAAC,SAAS,EAAE,gBAAgB,EAAE,CAAC,CAAC;AACvE,CAAC"}
@@ -129,6 +129,7 @@ export declare function normalizeConfidence(raw: unknown): number;
129
129
  export interface ExtractorLogger {
130
130
  info?: (msg: string) => void;
131
131
  warn?: (msg: string) => void;
132
+ debug?: (msg: string) => void;
132
133
  }
133
134
  /**
134
135
  * Compute a lexical importance bump (0-2) for a single fact based on signals
@@ -1 +1 @@
1
- {"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../src/extraction/extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEpE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEzF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CA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AE,MAAM,GAAG,MAAM,EACrB,gBAAgB,CAAC,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EACtD,cAAc,CAAC,EAAE,MAAM,EACvB,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,aAAa,EAAE,CAAC,CAiG1B"}
@@ -492,14 +492,14 @@ function parseFactsResponseForCompaction(response, logger) {
492
492
  }
493
493
  }
494
494
  if (recoveryUsed === 'bracket-scan') {
495
- logger?.info?.(`parseFactsResponseForCompaction: recovered JSON via bracket-scan fallback`);
495
+ logger?.debug?.(`parseFactsResponseForCompaction: recovered JSON via bracket-scan fallback`);
496
496
  }
497
497
  if (!parsed || typeof parsed !== 'object') {
498
498
  logger?.warn?.(`parseFactsResponseForCompaction: could not parse LLM output as JSON object. Preview: ${JSON.stringify(originalPreview)}`);
499
499
  return [];
500
500
  }
501
- const obj = parsed;
502
- const rawFacts = Array.isArray(obj.facts) ? obj.facts : null;
501
+ const parsedObj = parsed;
502
+ const rawFacts = Array.isArray(parsedObj.facts) ? parsedObj.facts : null;
503
503
  // Legacy v0 compaction output (bare JSON array) — best-effort parse.
504
504
  const rawArray = rawFacts ?? (Array.isArray(parsed) ? parsed : null);
505
505
  if (!rawArray) {
@@ -632,7 +632,7 @@ async function extractFactsForCompaction(rawMessages, existingMemories, logger)
632
632
  logger?.info?.('extractFactsForCompaction: chatCompletion returned null/empty response');
633
633
  return [];
634
634
  }
635
- logger?.info?.(`extractFactsForCompaction: LLM returned ${response.length} chars; handing to parseFactsResponseForCompaction`);
635
+ logger?.debug?.(`extractFactsForCompaction: LLM returned ${response.length} chars; handing to parseFactsResponseForCompaction`);
636
636
  let facts = parseFactsResponseForCompaction(response, logger);
637
637
  // v1 provenance filter (tag-don't-drop). Uses importance >= 5 floor because
638
638
  // the filter's own floor is 5 in lax mode, matching compaction semantics.
@@ -648,7 +648,7 @@ async function extractFactsForCompaction(rawMessages, existingMemories, logger)
648
648
  const oldImportance = f.importance;
649
649
  const effectiveBump = f.importance >= 8 ? Math.min(bump, 1) : bump;
650
650
  f.importance = Math.min(10, f.importance + effectiveBump);
651
- logger?.info?.(`extractFactsForCompaction: lexical bump +${bump} for "${f.text.slice(0, 60)}..." (${oldImportance} → ${f.importance})`);
651
+ logger?.debug?.(`extractFactsForCompaction: lexical bump +${bump} for "${f.text.slice(0, 60)}..." (${oldImportance} → ${f.importance})`);
652
652
  }
653
653
  }
654
654
  return facts;
@@ -917,7 +917,7 @@ function parseMergedResponseV1(response, logger) {
917
917
  }
918
918
  }
919
919
  if (recoveryUsed === 'bracket-scan') {
920
- logger?.info?.(`parseFactsResponse: recovered JSON via bracket-scan fallback`);
920
+ logger?.debug?.(`parseFactsResponse: recovered JSON via bracket-scan fallback`);
921
921
  }
922
922
  if (!parsed || typeof parsed !== 'object') {
923
923
  logger?.warn?.(`parseFactsResponse: could not parse LLM output as JSON. Preview: ${JSON.stringify(originalPreview)}`);
@@ -927,25 +927,25 @@ function parseMergedResponseV1(response, logger) {
927
927
  // a bare JSON array of fact objects (legacy / test fixture shape). The
928
928
  // bare array is wrapped as { topics: [], facts: [...] } so the downstream
929
929
  // logic stays uniform. A single fact object (no wrapper) is also wrapped.
930
- let obj;
930
+ let parsedObj;
931
931
  if (Array.isArray(parsed)) {
932
- obj = { topics: [], facts: parsed };
932
+ parsedObj = { topics: [], facts: parsed };
933
933
  }
934
934
  else if (typeof parsed.facts === 'undefined' &&
935
935
  typeof parsed.text === 'string') {
936
936
  // Single fact object, not a merged wrapper.
937
- obj = { topics: [], facts: [parsed] };
937
+ parsedObj = { topics: [], facts: [parsed] };
938
938
  }
939
939
  else {
940
- obj = parsed;
940
+ parsedObj = parsed;
941
941
  }
942
- const rawTopics = obj.topics;
942
+ const rawTopics = parsedObj.topics;
943
943
  const topics = Array.isArray(rawTopics)
944
944
  ? rawTopics
945
945
  .filter((t) => typeof t === 'string' && t.length > 0)
946
946
  .slice(0, 3)
947
947
  : [];
948
- const rawFacts = obj.facts;
948
+ const rawFacts = parsedObj.facts;
949
949
  if (!Array.isArray(rawFacts))
950
950
  return { topics, facts: [] };
951
951
  const validActions = ['ADD', 'UPDATE', 'DELETE', 'NOOP'];
@@ -1231,10 +1231,10 @@ async function extractFacts(rawMessages, mode, existingMemories, profileContext,
1231
1231
  logger?.info?.('extractFacts: chatCompletion returned null/empty response');
1232
1232
  return [];
1233
1233
  }
1234
- logger?.info?.(`extractFacts: LLM returned ${response.length} chars; parsing merged response`);
1234
+ logger?.debug?.(`extractFacts: LLM returned ${response.length} chars; parsing merged response`);
1235
1235
  const { topics, facts: rawFacts } = parseMergedResponseV1(response, logger);
1236
1236
  if (topics.length > 0) {
1237
- logger?.info?.(`extractFacts: topics = ${JSON.stringify(topics)}`);
1237
+ logger?.debug?.(`extractFacts: topics = ${JSON.stringify(topics)}`);
1238
1238
  }
1239
1239
  // Provenance filter (tag-don't-drop)
1240
1240
  let facts = applyProvenanceFilterLax(rawFacts, conversationText);
@@ -1249,7 +1249,7 @@ async function extractFacts(rawMessages, mode, existingMemories, profileContext,
1249
1249
  const oldImportance = f.importance;
1250
1250
  const effectiveBump = f.importance >= 8 ? Math.min(bump, 1) : bump;
1251
1251
  f.importance = Math.min(10, f.importance + effectiveBump);
1252
- logger?.info?.(`extractFacts: lexical bump +${bump} for "${f.text.slice(0, 60)}..." (${oldImportance} → ${f.importance})`);
1252
+ logger?.debug?.(`extractFacts: lexical bump +${bump} for "${f.text.slice(0, 60)}..." (${oldImportance} → ${f.importance})`);
1253
1253
  }
1254
1254
  }
1255
1255
  return facts;