@facthouse/mcp 0.26.0 → 0.27.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.
Files changed (66) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +611 -611
  3. package/dist/cli/inspect-html.js +460 -460
  4. package/dist/cli/inspect-intelligence.js +70 -70
  5. package/dist/cli/inspect-payload.js +39 -39
  6. package/dist/cli/inspect-theme.js +18 -18
  7. package/dist/cli/spend-dashboard.js +4 -4
  8. package/dist/cli/stats-html.js +674 -674
  9. package/dist/cli/web.js +89 -89
  10. package/dist/db/consolidation-lock.js +2 -2
  11. package/dist/db/consolidations.js +15 -15
  12. package/dist/db/embeddings.js +10 -10
  13. package/dist/db/entities.js +26 -26
  14. package/dist/db/extract-watermarks.js +79 -79
  15. package/dist/db/facts.js +39 -39
  16. package/dist/db/inferences.js +8 -8
  17. package/dist/db/intelligence-runs.js +5 -5
  18. package/dist/db/postgres-schema.js +323 -323
  19. package/dist/db/prune.js +17 -17
  20. package/dist/db/schema.js +530 -530
  21. package/dist/db/session-facts.js +26 -26
  22. package/dist/db/sessions.js +10 -10
  23. package/dist/db/sources.js +1 -1
  24. package/dist/db/stats.js +10 -10
  25. package/dist/db/watermarks.js +7 -7
  26. package/dist/intelligence/consolidate.js +35 -35
  27. package/dist/intelligence/extract-prompt.js +26 -26
  28. package/dist/intelligence/token-budget.d.ts +2 -0
  29. package/dist/intelligence/token-budget.d.ts.map +1 -1
  30. package/dist/intelligence/token-budget.js +1 -1
  31. package/dist/intelligence/token-budget.js.map +1 -1
  32. package/dist/search/episodes.js +14 -14
  33. package/dist/search/key-facts.js +3 -3
  34. package/dist/tools/fact-manager.js +3 -3
  35. package/dist/tools/read-tools.js +4 -4
  36. package/package.json +62 -62
  37. package/dist/cli/log-event.d.ts +0 -55
  38. package/dist/cli/log-event.d.ts.map +0 -1
  39. package/dist/cli/log-event.js +0 -149
  40. package/dist/cli/log-event.js.map +0 -1
  41. package/dist/db/scheduler-signal.d.ts +0 -20
  42. package/dist/db/scheduler-signal.d.ts.map +0 -1
  43. package/dist/db/scheduler-signal.js +0 -32
  44. package/dist/db/scheduler-signal.js.map +0 -1
  45. package/dist/schemas/starter-vocabulary.d.ts +0 -34
  46. package/dist/schemas/starter-vocabulary.d.ts.map +0 -1
  47. package/dist/schemas/starter-vocabulary.js +0 -91
  48. package/dist/schemas/starter-vocabulary.js.map +0 -1
  49. package/dist/search/profile.d.ts +0 -31
  50. package/dist/search/profile.d.ts.map +0 -1
  51. package/dist/search/profile.js +0 -43
  52. package/dist/search/profile.js.map +0 -1
  53. package/dist/sources/jsonl-ingest.d.ts +0 -58
  54. package/dist/sources/jsonl-ingest.d.ts.map +0 -1
  55. package/dist/sources/jsonl-ingest.js +0 -195
  56. package/dist/sources/jsonl-ingest.js.map +0 -1
  57. package/dist/sources/pull.d.ts +0 -85
  58. package/dist/sources/pull.d.ts.map +0 -1
  59. package/dist/sources/pull.js +0 -145
  60. package/dist/sources/pull.js.map +0 -1
  61. package/dist/types.d.ts +0 -115
  62. package/dist/types.d.ts.map +0 -1
  63. package/dist/types.js +0 -6
  64. package/dist/types.js.map +0 -1
  65. package/dist/warnings.d.ts.map +0 -1
  66. package/dist/warnings.js.map +0 -1
@@ -1,58 +0,0 @@
1
- /**
2
- * Shared JSONL tail: watermark, fingerprint, insert.
3
- *
4
- * Adapters discover files and map lines. This module is the one ingest
5
- * path so a crash cannot duplicate a line, regardless of which client
6
- * wrote the transcript.
7
- */
8
- import type { Db } from "../db/connection.js";
9
- import type { NewSessionEvent } from "../db/sessions.js";
10
- export interface JsonlFilePull {
11
- path: string;
12
- inserted: number;
13
- skipped: number;
14
- }
15
- export type MapTranscriptLine = (raw: string, fallbackSessionId: string, filePath: string, lineNumber: number, sourceTool: string) => NewSessionEvent[];
16
- export interface JsonlIngestOptions {
17
- sourceTool: string;
18
- mapLine: MapTranscriptLine;
19
- }
20
- /**
21
- * Tail one JSONL file into session_events from its watermark. Inserts and the
22
- * watermark update share a transaction so a crash cannot duplicate a line.
23
- */
24
- export declare function ingestJsonlFile(db: Db, filePath: string, opts: JsonlIngestOptions): Promise<JsonlFilePull>;
25
- export declare function isDir(p: string): boolean;
26
- export declare function listJsonl(dir: string): string[];
27
- export declare function sessionIdFromPath(filePath: string): string;
28
- /**
29
- * On-disk group under `home/projects/<group>/`.
30
- * That encoded name is the provenance we store on `sessions.project` —
31
- * not a tenant, and not a decoded filesystem path (encoding is lossy).
32
- */
33
- export declare function encodedProjectGroupFromPath(filePath: string): string | null;
34
- export interface FileFingerprint {
35
- prefix: string;
36
- suffix: string;
37
- size: number;
38
- encoded: string;
39
- }
40
- /** Prefix + suffix + size. Compaction that keeps a stable header still
41
- * changes the tail or the length, so the watermark resets. */
42
- export declare function fileFingerprint(fd: number, size: number): FileFingerprint;
43
- export declare function parseFingerprint(encoded: string): {
44
- prefix: string;
45
- suffix: string;
46
- size: number;
47
- } | null;
48
- /**
49
- * Unchanged file: resume. Append (header still in place, grew, old tail
50
- * still at the previous end): resume. Anything else — including a compacted
51
- * body behind the same header — reset.
52
- *
53
- * Do not compare `current.prefix` to `prev.prefix` when the file is shorter
54
- * than the fingerprint window: that hash covers the whole file, so a one-byte
55
- * append changes the prefix and looks like a rewrite.
56
- */
57
- export declare function shouldResumeFromWatermark(fd: number, stored: string, byteOffset: number, current: FileFingerprint): boolean;
58
- //# sourceMappingURL=jsonl-ingest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonl-ingest.d.ts","sourceRoot":"","sources":["../../src/sources/jsonl-ingest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAcH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAOzD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAA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AAU,EAAE,MAAM,EAClB,OAAO,EAAE,eAAe,GACvB,OAAO,CAYT"}
@@ -1,195 +0,0 @@
1
- /**
2
- * Shared JSONL tail: watermark, fingerprint, insert.
3
- *
4
- * Adapters discover files and map lines. This module is the one ingest
5
- * path so a crash cannot duplicate a line, regardless of which client
6
- * wrote the transcript.
7
- */
8
- import { createHash } from "node:crypto";
9
- import { closeSync, existsSync, fstatSync, openSync, readSync, readdirSync, statSync, } from "node:fs";
10
- import path from "node:path";
11
- import { withTransaction } from "../db/connection.js";
12
- import { ensureSession, insertEvent } from "../db/sessions.js";
13
- import { getWatermark, upsertWatermark } from "../db/watermarks.js";
14
- /** Window hashed at each end of the file. Prefix alone misses a rewrite
15
- * (compaction) that keeps the same header. */
16
- const FINGERPRINT_BYTES = 256;
17
- /**
18
- * Tail one JSONL file into session_events from its watermark. Inserts and the
19
- * watermark update share a transaction so a crash cannot duplicate a line.
20
- */
21
- export async function ingestJsonlFile(db, filePath, opts) {
22
- const abs = path.resolve(filePath);
23
- const fd = openSync(abs, "r");
24
- try {
25
- const size = fstatSync(fd).size;
26
- const current = fileFingerprint(fd, size);
27
- const existing = await getWatermark(db, abs);
28
- const resume = existing &&
29
- existing.byte_offset <= size &&
30
- shouldResumeFromWatermark(fd, existing.fingerprint, existing.byte_offset, current)
31
- ? existing
32
- : null;
33
- const fingerprint = current.encoded;
34
- const startOffset = resume?.byte_offset ?? 0;
35
- const startLine = resume?.line_number ?? 0;
36
- const { lines, endOffset } = readCompleteLines(fd, startOffset, size);
37
- const sessionId = sessionIdFromPath(abs);
38
- const project = encodedProjectGroupFromPath(abs);
39
- if (lines.length === 0 && resume) {
40
- // File unchanged, or only an incomplete last line past the watermark.
41
- // Leave the watermark where it is: a later append that completes the
42
- // line is detected as growth and resumed from this offset.
43
- // Still record the conversation's project so a store that was pulled
44
- // before sessions.project was written gets provenance on the next pull.
45
- await ensureSession(db, {
46
- id: sessionId,
47
- source_tool: opts.sourceTool,
48
- project,
49
- });
50
- return { path: abs, inserted: 0, skipped: 0 };
51
- }
52
- let inserted = 0;
53
- let skipped = 0;
54
- let lineNumber = startLine;
55
- await withTransaction(db, async () => {
56
- const seen = new Set();
57
- for (const line of lines) {
58
- lineNumber += 1;
59
- const mapped = opts.mapLine(line, sessionId, abs, lineNumber, opts.sourceTool);
60
- if (mapped.length === 0) {
61
- skipped += 1;
62
- continue;
63
- }
64
- for (const event of mapped) {
65
- const conversation = event.client_session_id || sessionId;
66
- if (!seen.has(conversation)) {
67
- seen.add(conversation);
68
- await ensureSession(db, {
69
- id: conversation,
70
- source_tool: opts.sourceTool,
71
- project,
72
- });
73
- }
74
- await insertEvent(db, event);
75
- inserted += 1;
76
- }
77
- }
78
- await upsertWatermark(db, {
79
- path: abs,
80
- byte_offset: endOffset,
81
- line_number: lineNumber,
82
- fingerprint,
83
- });
84
- });
85
- return { path: abs, inserted, skipped };
86
- }
87
- finally {
88
- closeSync(fd);
89
- }
90
- }
91
- export function isDir(p) {
92
- try {
93
- return existsSync(p) && statSync(p).isDirectory();
94
- }
95
- catch {
96
- return false;
97
- }
98
- }
99
- export function listJsonl(dir) {
100
- if (!isDir(dir))
101
- return [];
102
- return readdirSync(dir, { withFileTypes: true })
103
- .filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl"))
104
- .map((entry) => path.join(dir, entry.name));
105
- }
106
- export function sessionIdFromPath(filePath) {
107
- return path.basename(filePath, ".jsonl");
108
- }
109
- /**
110
- * On-disk group under `home/projects/<group>/`.
111
- * That encoded name is the provenance we store on `sessions.project` —
112
- * not a tenant, and not a decoded filesystem path (encoding is lossy).
113
- */
114
- export function encodedProjectGroupFromPath(filePath) {
115
- const parts = path.normalize(filePath).split(path.sep);
116
- const i = parts.lastIndexOf("projects");
117
- if (i < 0 || i + 1 >= parts.length)
118
- return null;
119
- return parts[i + 1] || null;
120
- }
121
- function hashWindow(fd, position, length) {
122
- const buf = Buffer.alloc(length);
123
- if (length > 0)
124
- readSync(fd, buf, 0, length, position);
125
- return createHash("sha256").update(buf).digest("hex");
126
- }
127
- /** Prefix + suffix + size. Compaction that keeps a stable header still
128
- * changes the tail or the length, so the watermark resets. */
129
- export function fileFingerprint(fd, size) {
130
- const n = Math.min(FINGERPRINT_BYTES, size);
131
- const prefix = hashWindow(fd, 0, n);
132
- const suffix = hashWindow(fd, Math.max(0, size - n), n);
133
- return { prefix, suffix, size, encoded: `${prefix}:${suffix}:${size}` };
134
- }
135
- export function parseFingerprint(encoded) {
136
- const parts = encoded.split(":");
137
- if (parts.length !== 3)
138
- return null;
139
- const size = Number(parts[2]);
140
- if (!Number.isFinite(size))
141
- return null;
142
- return { prefix: parts[0], suffix: parts[1], size };
143
- }
144
- /**
145
- * Unchanged file: resume. Append (header still in place, grew, old tail
146
- * still at the previous end): resume. Anything else — including a compacted
147
- * body behind the same header — reset.
148
- *
149
- * Do not compare `current.prefix` to `prev.prefix` when the file is shorter
150
- * than the fingerprint window: that hash covers the whole file, so a one-byte
151
- * append changes the prefix and looks like a rewrite.
152
- */
153
- export function shouldResumeFromWatermark(fd, stored, byteOffset, current) {
154
- if (stored === current.encoded && byteOffset <= current.size)
155
- return true;
156
- const prev = parseFingerprint(stored);
157
- if (!prev)
158
- return false;
159
- if (current.size < prev.size || byteOffset > current.size)
160
- return false;
161
- const prefixLen = Math.min(FINGERPRINT_BYTES, prev.size);
162
- if (hashWindow(fd, 0, prefixLen) !== prev.prefix)
163
- return false;
164
- if (current.size === prev.size)
165
- return prev.suffix === current.suffix;
166
- // Grew: only treat as an append if the previous tail is still where it was.
167
- const oldWindow = Math.min(FINGERPRINT_BYTES, prev.size);
168
- const stillThere = hashWindow(fd, Math.max(0, prev.size - oldWindow), oldWindow);
169
- return stillThere === prev.suffix;
170
- }
171
- /**
172
- * Read from `startOffset` to EOF and return only complete lines (those
173
- * terminated by `\\n`). The returned `endOffset` is the byte position after
174
- * the last complete line, so a file still being written is not consumed past
175
- * a partial line.
176
- */
177
- function readCompleteLines(fd, startOffset, size) {
178
- const remaining = size - startOffset;
179
- if (remaining <= 0)
180
- return { lines: [], endOffset: startOffset };
181
- const buf = Buffer.alloc(remaining);
182
- const bytesRead = readSync(fd, buf, 0, remaining, startOffset);
183
- const slice = buf.subarray(0, bytesRead);
184
- const lastNl = slice.lastIndexOf(0x0a);
185
- if (lastNl === -1)
186
- return { lines: [], endOffset: startOffset };
187
- const complete = slice.subarray(0, lastNl + 1);
188
- const text = complete.toString("utf8");
189
- const lines = text.split("\n");
190
- // split() after a trailing newline yields a final empty string — drop it.
191
- if (lines.length > 0 && lines[lines.length - 1] === "")
192
- lines.pop();
193
- return { lines, endOffset: startOffset + complete.length };
194
- }
195
- //# sourceMappingURL=jsonl-ingest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonl-ingest.js","sourceRoot":"","sources":["../../src/sources/jsonl-ingest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEpE;+CAC+C;AAC/C,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAqB9B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,EAAM,EACN,QAAgB,EAChB,IAAwB;IAExB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,EAAE,GAAG,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC;QACH,M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I,GAAG,WAAW,CAAC;IACrC,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IAEjE,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,CAAC,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IAEhE,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,0EAA0E;IAC1E,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IACpE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;AAC7D,CAAC"}
@@ -1,85 +0,0 @@
1
- /**
2
- * Pull named capture sources into session_events.
3
- *
4
- * This is the single entry for client-agnostic capture. `factmem pull`
5
- * is the documented command; the MCP server calls the same function at
6
- * session start and, on a named-source store, again at the start of a
7
- * tool or resource read when the files have grown. Empty `sources` is a
8
- * successful no-op — pull is off, and the heartbeat never walks a client
9
- * home.
10
- */
11
- import type { Db } from "../db/connection.js";
12
- export interface PullResult {
13
- /** How many configured sources were resolved and walked. */
14
- sources: number;
15
- /** Transcript files discovered across those sources. */
16
- files: number;
17
- /** New session_events inserted this run. */
18
- events_inserted: number;
19
- /** Complete lines that could not be mapped honestly (system/meta/empty). */
20
- events_skipped: number;
21
- }
22
- /**
23
- * A first pull of a whole Claude home can insert thousands of events.
24
- * Flushing those at session_start would spawn `claude -p` on the lot.
25
- * Incremental pulls of a handful of new lines still match session_start
26
- * intent and may run extract-then-graduate. Zero inserts keep leftover
27
- * recovery (scheduler.full()).
28
- */
29
- export declare const SESSION_START_FLUSH_MAX_INSERTED = 50;
30
- /** Whether session_start should call scheduler.full() after this pull. */
31
- export declare function shouldFlushAfterSessionStartPull(eventsInserted: number, threshold?: number): boolean;
32
- /**
33
- * Whether the CLI pull should wake a running server with `tick`.
34
- *
35
- * Same band as session_start: a handful of new lines may extract
36
- * (threshold permitting). A first-run backfill above the cap must not.
37
- * Zero inserts send nothing — leftovers are session_start's job.
38
- *
39
- * `tick` is D→I, not I→K: it honours the consolidation threshold so a
40
- * frequent incremental pull does not spawn `claude -p` on every reply.
41
- * A pull with no server listening cannot tick; the CLI then tells the
42
- * user to run `factmem consolidate`.
43
- */
44
- export declare function shouldTickAfterCliPull(eventsInserted: number, threshold?: number): boolean;
45
- /** In-process throttle for MCP-call tails. Not a product timer. */
46
- export declare const PULL_HEARTBEAT_DEBOUNCE_MS = 2000;
47
- export type PullFollowUp = "tick" | "flush" | "none";
48
- /**
49
- * What the CLI does after copying D. `--flush` is compact wake-up
50
- * (graduate, not extract). `--no-tick` copies only. Default still ticks
51
- * a handful of new lines when a server is listening.
52
- */
53
- export declare function pullFollowUp(opts: {
54
- flush: boolean;
55
- noTick: boolean;
56
- eventsInserted: number;
57
- }): PullFollowUp;
58
- export interface PullHeartbeat {
59
- /** Copy new JSONL lines if files grew. Never extracts. */
60
- pullIfGrown(): Promise<PullResult>;
61
- }
62
- export interface PullHeartbeatOpts {
63
- db: Db;
64
- sources: unknown;
65
- debounceMs?: number;
66
- now?: () => number;
67
- /** Override for tests. Production uses `pullSources`. */
68
- pull?: (db: Db, sources: unknown) => Promise<PullResult>;
69
- onPulled?: (result: PullResult) => void;
70
- onError?: (err: Error) => void;
71
- }
72
- /**
73
- * In-process JSONL tail for a live MCP server. Empty `sources` never
74
- * discovers files (so a record store does not open `~/.claude`). A burst
75
- * of tool calls in one turn shares one walk.
76
- */
77
- export declare function createPullHeartbeat(opts: PullHeartbeatOpts): PullHeartbeat;
78
- /**
79
- * Resolve `config.sources` and ingest every new transcript line.
80
- *
81
- * Throws on an unknown kind or a malformed source — a typo must not look
82
- * like "nothing to pull". An empty list returns zeros and inserts nothing.
83
- */
84
- export declare function pullSources(db: Db, sources: unknown): Promise<PullResult>;
85
- //# sourceMappingURL=pull.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/sources/pull.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAU9C,MAAM,WAAW,UAAU;IACzB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAC;CACxB;AAkBD;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,KAAK,CAAC;AAEnD,0EAA0E;AAC1E,wBAAgB,gCAAgC,CAC9C,cAAc,EAAE,MAAM,EACtB,SAAS,GAAE,MAAyC,GACnD,OAAO,CAET;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EACtB,SAAS,GAAE,MAAyC,GACnD,OAAO,CAET;AAED,mEAAmE;AACnE,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,YAAY,CAKf;AASD,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,WAAW,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,EAAE,CAAC;IACP,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,yDAAyD;IACzD,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACzD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAoC1E;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAqB/E"}
@@ -1,145 +0,0 @@
1
- /**
2
- * Pull named capture sources into session_events.
3
- *
4
- * This is the single entry for client-agnostic capture. `factmem pull`
5
- * is the documented command; the MCP server calls the same function at
6
- * session start and, on a named-source store, again at the start of a
7
- * tool or resource read when the files have grown. Empty `sources` is a
8
- * successful no-op — pull is off, and the heartbeat never walks a client
9
- * home.
10
- */
11
- import { storeHasNamedSources } from "../tools/capture-fact-description.js";
12
- import { discoverClaudeCodeFiles, ingestClaudeCodeFile, } from "./claude-code.js";
13
- import { discoverCursorFiles, ingestCursorFile } from "./cursor.js";
14
- import { resolveSources } from "./resolve.js";
15
- const adapters = {
16
- "claude-code": {
17
- discover: discoverClaudeCodeFiles,
18
- ingest: ingestClaudeCodeFile,
19
- },
20
- cursor: {
21
- discover: discoverCursorFiles,
22
- ingest: ingestCursorFile,
23
- },
24
- };
25
- /**
26
- * A first pull of a whole Claude home can insert thousands of events.
27
- * Flushing those at session_start would spawn `claude -p` on the lot.
28
- * Incremental pulls of a handful of new lines still match session_start
29
- * intent and may run extract-then-graduate. Zero inserts keep leftover
30
- * recovery (scheduler.full()).
31
- */
32
- export const SESSION_START_FLUSH_MAX_INSERTED = 50;
33
- /** Whether session_start should call scheduler.full() after this pull. */
34
- export function shouldFlushAfterSessionStartPull(eventsInserted, threshold = SESSION_START_FLUSH_MAX_INSERTED) {
35
- return eventsInserted <= threshold;
36
- }
37
- /**
38
- * Whether the CLI pull should wake a running server with `tick`.
39
- *
40
- * Same band as session_start: a handful of new lines may extract
41
- * (threshold permitting). A first-run backfill above the cap must not.
42
- * Zero inserts send nothing — leftovers are session_start's job.
43
- *
44
- * `tick` is D→I, not I→K: it honours the consolidation threshold so a
45
- * frequent incremental pull does not spawn `claude -p` on every reply.
46
- * A pull with no server listening cannot tick; the CLI then tells the
47
- * user to run `factmem consolidate`.
48
- */
49
- export function shouldTickAfterCliPull(eventsInserted, threshold = SESSION_START_FLUSH_MAX_INSERTED) {
50
- return eventsInserted > 0 && eventsInserted <= threshold;
51
- }
52
- /** In-process throttle for MCP-call tails. Not a product timer. */
53
- export const PULL_HEARTBEAT_DEBOUNCE_MS = 2000;
54
- /**
55
- * What the CLI does after copying D. `--flush` is compact wake-up
56
- * (graduate, not extract). `--no-tick` copies only. Default still ticks
57
- * a handful of new lines when a server is listening.
58
- */
59
- export function pullFollowUp(opts) {
60
- if (opts.flush)
61
- return "flush";
62
- if (opts.noTick)
63
- return "none";
64
- if (shouldTickAfterCliPull(opts.eventsInserted))
65
- return "tick";
66
- return "none";
67
- }
68
- const EMPTY_PULL = {
69
- sources: 0,
70
- files: 0,
71
- events_inserted: 0,
72
- events_skipped: 0,
73
- };
74
- /**
75
- * In-process JSONL tail for a live MCP server. Empty `sources` never
76
- * discovers files (so a record store does not open `~/.claude`). A burst
77
- * of tool calls in one turn shares one walk.
78
- */
79
- export function createPullHeartbeat(opts) {
80
- const debounceMs = opts.debounceMs ?? PULL_HEARTBEAT_DEBOUNCE_MS;
81
- const now = opts.now ?? Date.now;
82
- const pull = opts.pull ?? pullSources;
83
- let lastWalkAt = null;
84
- let inFlight = null;
85
- return {
86
- async pullIfGrown() {
87
- if (!storeHasNamedSources(opts.sources)) {
88
- return { ...EMPTY_PULL };
89
- }
90
- if (inFlight)
91
- return inFlight;
92
- const t = now();
93
- if (lastWalkAt !== null && t - lastWalkAt < debounceMs) {
94
- return { ...EMPTY_PULL };
95
- }
96
- inFlight = (async () => {
97
- try {
98
- const result = await pull(opts.db, opts.sources);
99
- if (result.events_inserted > 0)
100
- opts.onPulled?.(result);
101
- return result;
102
- }
103
- catch (err) {
104
- const error = err instanceof Error ? err : new Error(String(err));
105
- opts.onError?.(error);
106
- return { ...EMPTY_PULL };
107
- }
108
- finally {
109
- // Stamp after the walk so a slow ingest does not expire the
110
- // debounce before it has finished.
111
- lastWalkAt = now();
112
- inFlight = null;
113
- }
114
- })();
115
- return inFlight;
116
- },
117
- };
118
- }
119
- /**
120
- * Resolve `config.sources` and ingest every new transcript line.
121
- *
122
- * Throws on an unknown kind or a malformed source — a typo must not look
123
- * like "nothing to pull". An empty list returns zeros and inserts nothing.
124
- */
125
- export async function pullSources(db, sources) {
126
- const resolved = resolveSources(sources);
127
- const result = {
128
- sources: resolved.length,
129
- files: 0,
130
- events_inserted: 0,
131
- events_skipped: 0,
132
- };
133
- for (const source of resolved) {
134
- const adapter = adapters[source.kind];
135
- const files = adapter.discover(source);
136
- result.files += files.length;
137
- for (const file of files) {
138
- const fileResult = await adapter.ingest(db, file);
139
- result.events_inserted += fileResult.inserted;
140
- result.events_skipped += fileResult.skipped;
141
- }
142
- }
143
- return result;
144
- }
145
- //# sourceMappingURL=pull.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pull.js","sourceRoot":"","sources":["../../src/sources/pull.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,cAAc,EAA8B,MAAM,cAAc,CAAC;AAkB1E,MAAM,QAAQ,GAA6C;IACzD,aAAa,EAAE;QACb,QAAQ,EAAE,uBAAuB;QACjC,MAAM,EAAE,oBAAoB;KAC7B;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,mBAAmB;QAC7B,MAAM,EAAE,gBAAgB;KACzB;CACF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,CAAC;AAEnD,0EAA0E;AAC1E,MAAM,UAAU,gCAAgC,CAC9C,cAAsB,EACtB,YAAoB,gCAAgC;IAEpD,OAAO,cAAc,IAAI,SAAS,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CACpC,cAAsB,EACtB,YAAoB,gCAAgC;IAEpD,OAAO,cAAc,GAAG,CAAC,IAAI,cAAc,IAAI,SAAS,CAAC;AAC3D,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAI/C;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAI5B;IACC,IAAI,IAAI,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IAC/B,IAAI,IAAI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AU,CAAC,QAAQ,CAAC;YAC9C,MAAM,CAAC,cAAc,IAAI,UAAU,CAAC,OAAO,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,115 +0,0 @@
1
- /**
2
- * Core type definitions for OpenMemory.
3
- */
4
- export interface Fact {
5
- id: string;
6
- content: string;
7
- domain: string;
8
- subdomain: string | null;
9
- confidence: number;
10
- importance: number;
11
- source_type: string;
12
- source_tool: string | null;
13
- source_id: string | null;
14
- status: "active" | "superseded" | "rejected";
15
- superseded_by: string | null;
16
- is_latest: boolean;
17
- created_at: string;
18
- valid_from: string | null;
19
- valid_until: string | null;
20
- system_retired_at: string | null;
21
- session_id: string | null;
22
- capture_context: string | null;
23
- access_count: number;
24
- }
25
- export interface Entity {
26
- id: string;
27
- type: string;
28
- name: string;
29
- canonical_name: string | null;
30
- metadata: Record<string, unknown> | null;
31
- created_at: string;
32
- access_count: number;
33
- last_accessed_at: string | null;
34
- }
35
- export interface EntityEdge {
36
- from_entity: string;
37
- to_entity: string;
38
- relationship: string;
39
- strength: number;
40
- metadata: Record<string, unknown> | null;
41
- created_at: string;
42
- last_accessed_at: string | null;
43
- }
44
- export interface Source {
45
- id: string;
46
- type: string;
47
- tool_id: string | null;
48
- timestamp: string;
49
- raw_content: string | null;
50
- metadata: Record<string, unknown> | null;
51
- }
52
- export interface Inference {
53
- id: string;
54
- hypothesis: string;
55
- evidence: string[];
56
- confidence: number;
57
- status: "pending" | "confirmed" | "rejected";
58
- rejection_reason: string | null;
59
- no_reinfer_until: string | null;
60
- created_at: string;
61
- validated_at: string | null;
62
- }
63
- export interface SearchResult {
64
- fact: Fact;
65
- score: number;
66
- entities: Entity[];
67
- source: Source | null;
68
- }
69
- /** Search response with metamemory signals for calling AIs. */
70
- export interface SearchResponse {
71
- results: SearchResult[];
72
- /** Estimated fraction of relevant knowledge surfaced (0.0–1.0). */
73
- coverage_estimate: number;
74
- /** Confidence in result quality based on score distribution (0.0–1.0). */
75
- result_confidence: number;
76
- /** Suggested query refinement when results look thin. */
77
- suggested_refinement: string | null;
78
- }
79
- /** Default importance when not specified by the calling LLM or user config. */
80
- export declare const DEFAULT_IMPORTANCE = 0.5;
81
- /** A domain definition — seed domains ship in config, new ones created at runtime. */
82
- export interface DomainDef {
83
- name: string;
84
- subdomains: string[];
85
- }
86
- /** Temporal mode configuration. */
87
- export type TemporalMode = "simple" | "bitemporal";
88
- export interface TemporalConfig {
89
- mode: TemporalMode;
90
- /** ISO timestamp recorded automatically when switching from simple to bitemporal.
91
- * System-time queries before this date return incomplete results. */
92
- bitemporal_since: string | null;
93
- }
94
- /** Top-level server configuration (loaded from config.json in data dir). */
95
- export interface ServerConfig {
96
- storage: {
97
- provider: "sqlite";
98
- sqlite?: {
99
- path: string;
100
- };
101
- };
102
- temporal: TemporalConfig;
103
- search?: {
104
- embedding_provider: "openai" | "ollama" | null;
105
- };
106
- /** Optional seed domains with suggested subdomains, created on init.
107
- * New domains can also be created at runtime by the calling LLM or server.
108
- * If omitted, the server starts with an empty domains table. */
109
- domains?: DomainDef[];
110
- /** Optional domain importance defaults. When the calling LLM doesn't
111
- * specify importance at capture time, the server uses these.
112
- * Falls back to DEFAULT_IMPORTANCE (0.5) for unconfigured domains. */
113
- importance_defaults?: Record<string, number>;
114
- }
115
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG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ACtE,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,4EAA4E;AAC5E,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE;QACP,QAAQ,EAAE,QAAQ,CAAC;QACnB,MAAM,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;KAC3B,CAAC;IACF,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,CAAC,EAAE;QACP,kBAAkB,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC;KAChD,CAAC;IACF;;qEAEiE;IACjE,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB;;2EAEuE;IACvE,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C"}
package/dist/types.js DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Core type definitions for OpenMemory.
3
- */
4
- /** Default importance when not specified by the calling LLM or user config. */
5
- export const DEFAULT_IMPORTANCE = 0.5;
6
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoFH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"warnings.d.ts","sourceRoot":"","sources":["../src/warnings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"warnings.js","sourceRoot":"","sources":["../src/warnings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,UAAU,GAAG,mCAAmC,CAAC;AAEvD,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAEnD,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC,OAAuB,EAAE,GAAG,IAAe,EAAE,EAAE;IACrE,MAAM,IAAI,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IAC9E,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO;IACtC,8DAA8D;IAC9D,OAAQ,QAAgB,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;AAC7C,CAAC,CAA+B,CAAC"}