@vortex-os/memory-extended 0.5.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 (181) hide show
  1. package/README.md +244 -0
  2. package/dist/consolidate/index.d.ts +7 -0
  3. package/dist/consolidate/index.d.ts.map +1 -0
  4. package/dist/consolidate/index.js +4 -0
  5. package/dist/consolidate/index.js.map +1 -0
  6. package/dist/consolidate/proposer.d.ts +43 -0
  7. package/dist/consolidate/proposer.d.ts.map +1 -0
  8. package/dist/consolidate/proposer.js +276 -0
  9. package/dist/consolidate/proposer.js.map +1 -0
  10. package/dist/consolidate/query.d.ts +32 -0
  11. package/dist/consolidate/query.d.ts.map +1 -0
  12. package/dist/consolidate/query.js +40 -0
  13. package/dist/consolidate/query.js.map +1 -0
  14. package/dist/consolidate/store.d.ts +21 -0
  15. package/dist/consolidate/store.d.ts.map +1 -0
  16. package/dist/consolidate/store.js +91 -0
  17. package/dist/consolidate/store.js.map +1 -0
  18. package/dist/consolidate/types.d.ts +68 -0
  19. package/dist/consolidate/types.d.ts.map +1 -0
  20. package/dist/consolidate/types.js +2 -0
  21. package/dist/consolidate/types.js.map +1 -0
  22. package/dist/index.d.ts +7 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +7 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/internal/frontmatter.d.ts +6 -0
  27. package/dist/internal/frontmatter.d.ts.map +1 -0
  28. package/dist/internal/frontmatter.js +38 -0
  29. package/dist/internal/frontmatter.js.map +1 -0
  30. package/dist/internal/proactive-curator-helpers.d.ts +171 -0
  31. package/dist/internal/proactive-curator-helpers.d.ts.map +1 -0
  32. package/dist/internal/proactive-curator-helpers.js +162 -0
  33. package/dist/internal/proactive-curator-helpers.js.map +1 -0
  34. package/dist/mcp/document-tools.d.ts +144 -0
  35. package/dist/mcp/document-tools.d.ts.map +1 -0
  36. package/dist/mcp/document-tools.js +319 -0
  37. package/dist/mcp/document-tools.js.map +1 -0
  38. package/dist/mcp/index.d.ts +34 -0
  39. package/dist/mcp/index.d.ts.map +1 -0
  40. package/dist/mcp/index.js +29 -0
  41. package/dist/mcp/index.js.map +1 -0
  42. package/dist/mcp/install.d.ts +72 -0
  43. package/dist/mcp/install.d.ts.map +1 -0
  44. package/dist/mcp/install.js +92 -0
  45. package/dist/mcp/install.js.map +1 -0
  46. package/dist/mcp/memory-tools.d.ts +101 -0
  47. package/dist/mcp/memory-tools.d.ts.map +1 -0
  48. package/dist/mcp/memory-tools.js +105 -0
  49. package/dist/mcp/memory-tools.js.map +1 -0
  50. package/dist/mcp/recall-tool.d.ts +52 -0
  51. package/dist/mcp/recall-tool.d.ts.map +1 -0
  52. package/dist/mcp/recall-tool.js +60 -0
  53. package/dist/mcp/recall-tool.js.map +1 -0
  54. package/dist/mcp/server.d.ts +32 -0
  55. package/dist/mcp/server.d.ts.map +1 -0
  56. package/dist/mcp/server.js +113 -0
  57. package/dist/mcp/server.js.map +1 -0
  58. package/dist/recall/engine.d.ts +38 -0
  59. package/dist/recall/engine.d.ts.map +1 -0
  60. package/dist/recall/engine.js +113 -0
  61. package/dist/recall/engine.js.map +1 -0
  62. package/dist/recall/index.d.ts +22 -0
  63. package/dist/recall/index.d.ts.map +1 -0
  64. package/dist/recall/index.js +20 -0
  65. package/dist/recall/index.js.map +1 -0
  66. package/dist/recall/intent.d.ts +24 -0
  67. package/dist/recall/intent.d.ts.map +1 -0
  68. package/dist/recall/intent.js +95 -0
  69. package/dist/recall/intent.js.map +1 -0
  70. package/dist/recall/render.d.ts +11 -0
  71. package/dist/recall/render.d.ts.map +1 -0
  72. package/dist/recall/render.js +23 -0
  73. package/dist/recall/render.js.map +1 -0
  74. package/dist/recall/types.d.ts +72 -0
  75. package/dist/recall/types.d.ts.map +1 -0
  76. package/dist/recall/types.js +2 -0
  77. package/dist/recall/types.js.map +1 -0
  78. package/dist/sessionArchive/adapters/claude-code.d.ts +3 -0
  79. package/dist/sessionArchive/adapters/claude-code.d.ts.map +1 -0
  80. package/dist/sessionArchive/adapters/claude-code.js +276 -0
  81. package/dist/sessionArchive/adapters/claude-code.js.map +1 -0
  82. package/dist/sessionArchive/adapters/claude-desktop.d.ts +3 -0
  83. package/dist/sessionArchive/adapters/claude-desktop.d.ts.map +1 -0
  84. package/dist/sessionArchive/adapters/claude-desktop.js +234 -0
  85. package/dist/sessionArchive/adapters/claude-desktop.js.map +1 -0
  86. package/dist/sessionArchive/adapters/codex.d.ts +3 -0
  87. package/dist/sessionArchive/adapters/codex.d.ts.map +1 -0
  88. package/dist/sessionArchive/adapters/codex.js +322 -0
  89. package/dist/sessionArchive/adapters/codex.js.map +1 -0
  90. package/dist/sessionArchive/adapters/gemini.d.ts +3 -0
  91. package/dist/sessionArchive/adapters/gemini.d.ts.map +1 -0
  92. package/dist/sessionArchive/adapters/gemini.js +248 -0
  93. package/dist/sessionArchive/adapters/gemini.js.map +1 -0
  94. package/dist/sessionArchive/adapters/index.d.ts +5 -0
  95. package/dist/sessionArchive/adapters/index.d.ts.map +1 -0
  96. package/dist/sessionArchive/adapters/index.js +5 -0
  97. package/dist/sessionArchive/adapters/index.js.map +1 -0
  98. package/dist/sessionArchive/index.d.ts +9 -0
  99. package/dist/sessionArchive/index.d.ts.map +1 -0
  100. package/dist/sessionArchive/index.js +6 -0
  101. package/dist/sessionArchive/index.js.map +1 -0
  102. package/dist/sessionArchive/ingest.d.ts +68 -0
  103. package/dist/sessionArchive/ingest.d.ts.map +1 -0
  104. package/dist/sessionArchive/ingest.js +134 -0
  105. package/dist/sessionArchive/ingest.js.map +1 -0
  106. package/dist/sessionArchive/normalize.d.ts +15 -0
  107. package/dist/sessionArchive/normalize.d.ts.map +1 -0
  108. package/dist/sessionArchive/normalize.js +40 -0
  109. package/dist/sessionArchive/normalize.js.map +1 -0
  110. package/dist/sessionArchive/store.d.ts +118 -0
  111. package/dist/sessionArchive/store.d.ts.map +1 -0
  112. package/dist/sessionArchive/store.js +491 -0
  113. package/dist/sessionArchive/store.js.map +1 -0
  114. package/dist/sessionArchive/types.d.ts +124 -0
  115. package/dist/sessionArchive/types.d.ts.map +1 -0
  116. package/dist/sessionArchive/types.js +24 -0
  117. package/dist/sessionArchive/types.js.map +1 -0
  118. package/dist/sqlite/drift.d.ts +22 -0
  119. package/dist/sqlite/drift.d.ts.map +1 -0
  120. package/dist/sqlite/drift.js +69 -0
  121. package/dist/sqlite/drift.js.map +1 -0
  122. package/dist/sqlite/index.d.ts +22 -0
  123. package/dist/sqlite/index.d.ts.map +1 -0
  124. package/dist/sqlite/index.js +4 -0
  125. package/dist/sqlite/index.js.map +1 -0
  126. package/dist/sqlite/rebuild.d.ts +32 -0
  127. package/dist/sqlite/rebuild.d.ts.map +1 -0
  128. package/dist/sqlite/rebuild.js +80 -0
  129. package/dist/sqlite/rebuild.js.map +1 -0
  130. package/dist/sqlite/schema.d.ts +15 -0
  131. package/dist/sqlite/schema.d.ts.map +1 -0
  132. package/dist/sqlite/schema.js +41 -0
  133. package/dist/sqlite/schema.js.map +1 -0
  134. package/dist/sqlite/store.d.ts +49 -0
  135. package/dist/sqlite/store.d.ts.map +1 -0
  136. package/dist/sqlite/store.js +179 -0
  137. package/dist/sqlite/store.js.map +1 -0
  138. package/dist/sqlite/types.d.ts +57 -0
  139. package/dist/sqlite/types.d.ts.map +1 -0
  140. package/dist/sqlite/types.js +2 -0
  141. package/dist/sqlite/types.js.map +1 -0
  142. package/dist/vector/backend-brute.d.ts +38 -0
  143. package/dist/vector/backend-brute.d.ts.map +1 -0
  144. package/dist/vector/backend-brute.js +112 -0
  145. package/dist/vector/backend-brute.js.map +1 -0
  146. package/dist/vector/embedder.d.ts +59 -0
  147. package/dist/vector/embedder.d.ts.map +1 -0
  148. package/dist/vector/embedder.js +47 -0
  149. package/dist/vector/embedder.js.map +1 -0
  150. package/dist/vector/index.d.ts +24 -0
  151. package/dist/vector/index.d.ts.map +1 -0
  152. package/dist/vector/index.js +7 -0
  153. package/dist/vector/index.js.map +1 -0
  154. package/dist/vector/math.d.ts +21 -0
  155. package/dist/vector/math.d.ts.map +1 -0
  156. package/dist/vector/math.js +34 -0
  157. package/dist/vector/math.js.map +1 -0
  158. package/dist/vector/schema.d.ts +14 -0
  159. package/dist/vector/schema.d.ts.map +1 -0
  160. package/dist/vector/schema.js +24 -0
  161. package/dist/vector/schema.js.map +1 -0
  162. package/dist/vector/segment.d.ts +65 -0
  163. package/dist/vector/segment.d.ts.map +1 -0
  164. package/dist/vector/segment.js +72 -0
  165. package/dist/vector/segment.js.map +1 -0
  166. package/dist/vector/session.d.ts +90 -0
  167. package/dist/vector/session.d.ts.map +1 -0
  168. package/dist/vector/session.js +242 -0
  169. package/dist/vector/session.js.map +1 -0
  170. package/dist/vector/store.d.ts +69 -0
  171. package/dist/vector/store.d.ts.map +1 -0
  172. package/dist/vector/store.js +131 -0
  173. package/dist/vector/store.js.map +1 -0
  174. package/dist/vector/types.d.ts +109 -0
  175. package/dist/vector/types.d.ts.map +1 -0
  176. package/dist/vector/types.js +24 -0
  177. package/dist/vector/types.js.map +1 -0
  178. package/package.json +96 -0
  179. package/scripts/mcp-stdio.mjs +143 -0
  180. package/scripts/rebuild-memory-sqlite.mjs +39 -0
  181. package/scripts/rebuild-memory-vector.mjs +64 -0
@@ -0,0 +1,34 @@
1
+ /**
2
+ * `mcp` namespace — exposes recall to MCP-capable hosts (Claude Desktop,
3
+ * chatbots, other agents).
4
+ * - Slice 1: the `recall` tool, stdio transport (server.ts / recall-tool.ts).
5
+ * - Slice 2: one-line install into the host's config (install.ts) — the bin's
6
+ * `install` subcommand merges our server entry without clobbering others.
7
+ * - Slice 3: read-only companion tools `list_memories` / `get_memory`
8
+ * (memory-tools.ts).
9
+ * - Slice 4: document tools `suggest_document` / `write_document` /
10
+ * `decline_document` (document-tools.ts) — a propose-then-write pair so the
11
+ * only write surface is gated behind an explicit second call. Operational
12
+ * records stay auto-kept; formal knowledge docs are proposed, then written
13
+ * only on acceptance ("auto the plumbing, propose the prose").
14
+ *
15
+ * Packaging: this lives INSIDE memory-extended (not a separate package) so that
16
+ * installing the memory extension also installs its MCP surface — the recall
17
+ * tool is a memory feature, so it ships with memory. The MCP SDK itself is an
18
+ * OPTIONAL dependency, loaded at runtime only when {@link createRecallServer}
19
+ * runs (mirrors the optional `@huggingface/transformers` embedder dependency).
20
+ *
21
+ * Run the stdio server via the `vortex-mcp-recall` bin (scripts/mcp-stdio.mjs);
22
+ * register it with `vortex-mcp-recall install --data-dir <path>`.
23
+ */
24
+ export { createRecallServer } from "./server.js";
25
+ export type { RecallServerOptions } from "./server.js";
26
+ export { RECALL_TOOL_NAME, recallToolDefinition, runRecall } from "./recall-tool.js";
27
+ export type { RunRecallArgs, RunRecallDeps } from "./recall-tool.js";
28
+ export { LIST_MEMORIES_TOOL_NAME, GET_MEMORY_TOOL_NAME, listMemoriesToolDefinition, getMemoryToolDefinition, runListMemories, runGetMemory, } from "./memory-tools.js";
29
+ export type { RunListArgs, RunGetArgs, RunMemoryToolDeps, MemorySummary, ListResult, GetResult, } from "./memory-tools.js";
30
+ export { SUGGEST_DOCUMENT_TOOL_NAME, WRITE_DOCUMENT_TOOL_NAME, DECLINE_DOCUMENT_TOOL_NAME, suggestDocumentToolDefinition, writeDocumentToolDefinition, declineDocumentToolDefinition, runSuggestDocument, runWriteDocument, runDeclineDocument, renderDocumentBody, documentFingerprint, } from "./document-tools.js";
31
+ export type { DocumentArgs, DocumentToolDeps, SuggestResult, WriteResult, DeclineResult, } from "./document-tools.js";
32
+ export { DEFAULT_SERVER_KEY, claudeDesktopConfigPath, buildRecallServerEntry, mergeServerEntry, parseExistingConfig, serializeConfig, } from "./install.js";
33
+ export type { InstallEnv, McpServerEntry, BuildEntryOptions, McpConfig, MergeResult, } from "./install.js";
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrF,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,SAAS,GACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,EAC7B,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,WAAW,GACZ,MAAM,cAAc,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `mcp` namespace — exposes recall to MCP-capable hosts (Claude Desktop,
3
+ * chatbots, other agents).
4
+ * - Slice 1: the `recall` tool, stdio transport (server.ts / recall-tool.ts).
5
+ * - Slice 2: one-line install into the host's config (install.ts) — the bin's
6
+ * `install` subcommand merges our server entry without clobbering others.
7
+ * - Slice 3: read-only companion tools `list_memories` / `get_memory`
8
+ * (memory-tools.ts).
9
+ * - Slice 4: document tools `suggest_document` / `write_document` /
10
+ * `decline_document` (document-tools.ts) — a propose-then-write pair so the
11
+ * only write surface is gated behind an explicit second call. Operational
12
+ * records stay auto-kept; formal knowledge docs are proposed, then written
13
+ * only on acceptance ("auto the plumbing, propose the prose").
14
+ *
15
+ * Packaging: this lives INSIDE memory-extended (not a separate package) so that
16
+ * installing the memory extension also installs its MCP surface — the recall
17
+ * tool is a memory feature, so it ships with memory. The MCP SDK itself is an
18
+ * OPTIONAL dependency, loaded at runtime only when {@link createRecallServer}
19
+ * runs (mirrors the optional `@huggingface/transformers` embedder dependency).
20
+ *
21
+ * Run the stdio server via the `vortex-mcp-recall` bin (scripts/mcp-stdio.mjs);
22
+ * register it with `vortex-mcp-recall install --data-dir <path>`.
23
+ */
24
+ export { createRecallServer } from "./server.js";
25
+ export { RECALL_TOOL_NAME, recallToolDefinition, runRecall } from "./recall-tool.js";
26
+ export { LIST_MEMORIES_TOOL_NAME, GET_MEMORY_TOOL_NAME, listMemoriesToolDefinition, getMemoryToolDefinition, runListMemories, runGetMemory, } from "./memory-tools.js";
27
+ export { SUGGEST_DOCUMENT_TOOL_NAME, WRITE_DOCUMENT_TOOL_NAME, DECLINE_DOCUMENT_TOOL_NAME, suggestDocumentToolDefinition, writeDocumentToolDefinition, declineDocumentToolDefinition, runSuggestDocument, runWriteDocument, runDeclineDocument, renderDocumentBody, documentFingerprint, } from "./document-tools.js";
28
+ export { DEFAULT_SERVER_KEY, claudeDesktopConfigPath, buildRecallServerEntry, mergeServerEntry, parseExistingConfig, serializeConfig, } from "./install.js";
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAErF,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,YAAY,GACb,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,EAC7B,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Install helpers for registering the `vortex-mcp-recall` stdio server in an MCP
3
+ * host's config (slice 2). Everything here is PURE — path resolution, entry
4
+ * construction, and config merging are deterministic and unit-testable. The bin
5
+ * (scripts/mcp-stdio.mjs) does the actual file read/backup/write around them.
6
+ *
7
+ * Design rule: NEVER overwrite the user's whole config. We read the existing
8
+ * config, merge in (or update) only our one server entry under a stable key,
9
+ * and preserve every other server and top-level field untouched.
10
+ */
11
+ export declare const DEFAULT_SERVER_KEY = "vortex-recall";
12
+ export interface InstallEnv {
13
+ readonly platform?: NodeJS.Platform;
14
+ readonly home?: string;
15
+ readonly appData?: string;
16
+ }
17
+ /**
18
+ * Resolve the Claude Desktop config file path per documented OS locations:
19
+ * - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
20
+ * - Windows: %APPDATA%/Claude/claude_desktop_config.json
21
+ * - Linux: ~/.config/Claude/claude_desktop_config.json (unofficial)
22
+ */
23
+ export declare function claudeDesktopConfigPath(env?: InstallEnv): string;
24
+ /** A single MCP server entry as Claude Desktop expects it. */
25
+ export interface McpServerEntry {
26
+ readonly command: string;
27
+ readonly args: readonly string[];
28
+ readonly env?: Readonly<Record<string, string>>;
29
+ }
30
+ export interface BuildEntryOptions {
31
+ /** Absolute path to the instance data dir (passed to the server via --data-dir). */
32
+ readonly dataDir: string;
33
+ /**
34
+ * Launcher command. Default "npx" runs the published bin without a global
35
+ * install; pass "node" + an explicit script path for a local checkout.
36
+ */
37
+ readonly command?: string;
38
+ /** Override the args entirely (advanced; e.g. node + absolute bin path). */
39
+ readonly args?: readonly string[];
40
+ }
41
+ /**
42
+ * Build the server entry that launches `vortex-mcp-recall` with the given data
43
+ * dir. Default form: `npx vortex-mcp-recall --data-dir <dataDir>`.
44
+ */
45
+ export declare function buildRecallServerEntry(options: BuildEntryOptions): McpServerEntry;
46
+ export type McpConfig = {
47
+ mcpServers?: Record<string, McpServerEntry>;
48
+ [key: string]: unknown;
49
+ };
50
+ export interface MergeResult {
51
+ readonly config: McpConfig;
52
+ /** "added" if the key was new, "updated" if it replaced an existing entry. */
53
+ readonly action: "added" | "updated";
54
+ /** Server keys preserved untouched alongside ours (excludes our key). */
55
+ readonly preservedKeys: readonly string[];
56
+ }
57
+ /**
58
+ * Merge our server entry into an existing config object WITHOUT mutating the
59
+ * input. Every other `mcpServers` entry and every other top-level field is
60
+ * carried over verbatim. If our key already exists, it is replaced (idempotent
61
+ * re-install) and `action` is "updated".
62
+ */
63
+ export declare function mergeServerEntry(existing: McpConfig | null | undefined, entry: McpServerEntry, key?: string): MergeResult;
64
+ /**
65
+ * Parse an existing config file's text. Returns `{}` for empty/whitespace
66
+ * content (a fresh install). Throws on malformed JSON so the caller can abort
67
+ * rather than clobber a file the user hand-edited into an invalid state.
68
+ */
69
+ export declare function parseExistingConfig(text: string | null | undefined): McpConfig;
70
+ /** Serialize a config object the way Claude Desktop writes it (2-space, trailing newline). */
71
+ export declare function serializeConfig(config: McpConfig): string;
72
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/mcp/install.ts"],"names":[],"mappings":"AAGA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,MAAM,EAAE,CAAC;CAC3C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,EACtC,KAAK,EAAE,cAAc,EACrB,GAAG,GAAE,MAA2B,GAC/B,WAAW,CAcb;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,CAiB9E;AAED,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAEzD"}
@@ -0,0 +1,92 @@
1
+ import { homedir } from "node:os";
2
+ import { join } from "node:path";
3
+ /**
4
+ * Install helpers for registering the `vortex-mcp-recall` stdio server in an MCP
5
+ * host's config (slice 2). Everything here is PURE — path resolution, entry
6
+ * construction, and config merging are deterministic and unit-testable. The bin
7
+ * (scripts/mcp-stdio.mjs) does the actual file read/backup/write around them.
8
+ *
9
+ * Design rule: NEVER overwrite the user's whole config. We read the existing
10
+ * config, merge in (or update) only our one server entry under a stable key,
11
+ * and preserve every other server and top-level field untouched.
12
+ */
13
+ export const DEFAULT_SERVER_KEY = "vortex-recall";
14
+ /**
15
+ * Resolve the Claude Desktop config file path per documented OS locations:
16
+ * - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
17
+ * - Windows: %APPDATA%/Claude/claude_desktop_config.json
18
+ * - Linux: ~/.config/Claude/claude_desktop_config.json (unofficial)
19
+ */
20
+ export function claudeDesktopConfigPath(env = {}) {
21
+ const platform = env.platform ?? process.platform;
22
+ const home = env.home ?? homedir();
23
+ const file = "claude_desktop_config.json";
24
+ if (platform === "darwin") {
25
+ return join(home, "Library", "Application Support", "Claude", file);
26
+ }
27
+ if (platform === "win32") {
28
+ const appData = env.appData ?? process.env.APPDATA ?? join(home, "AppData", "Roaming");
29
+ return join(appData, "Claude", file);
30
+ }
31
+ return join(home, ".config", "Claude", file);
32
+ }
33
+ /**
34
+ * Build the server entry that launches `vortex-mcp-recall` with the given data
35
+ * dir. Default form: `npx vortex-mcp-recall --data-dir <dataDir>`.
36
+ */
37
+ export function buildRecallServerEntry(options) {
38
+ const dataDir = options.dataDir?.trim();
39
+ if (!dataDir) {
40
+ throw new Error("buildRecallServerEntry: dataDir is required");
41
+ }
42
+ const command = options.command ?? "npx";
43
+ const args = options.args ?? ["vortex-mcp-recall", "--data-dir", dataDir];
44
+ return { command, args };
45
+ }
46
+ /**
47
+ * Merge our server entry into an existing config object WITHOUT mutating the
48
+ * input. Every other `mcpServers` entry and every other top-level field is
49
+ * carried over verbatim. If our key already exists, it is replaced (idempotent
50
+ * re-install) and `action` is "updated".
51
+ */
52
+ export function mergeServerEntry(existing, entry, key = DEFAULT_SERVER_KEY) {
53
+ const base = existing && typeof existing === "object" ? existing : {};
54
+ const existingServers = base.mcpServers && typeof base.mcpServers === "object" ? base.mcpServers : {};
55
+ const action = key in existingServers ? "updated" : "added";
56
+ const preservedKeys = Object.keys(existingServers).filter((k) => k !== key);
57
+ const config = {
58
+ ...base,
59
+ mcpServers: {
60
+ ...existingServers,
61
+ [key]: entry,
62
+ },
63
+ };
64
+ return { config, action, preservedKeys };
65
+ }
66
+ /**
67
+ * Parse an existing config file's text. Returns `{}` for empty/whitespace
68
+ * content (a fresh install). Throws on malformed JSON so the caller can abort
69
+ * rather than clobber a file the user hand-edited into an invalid state.
70
+ */
71
+ export function parseExistingConfig(text) {
72
+ const trimmed = (text ?? "").trim();
73
+ if (trimmed.length === 0) {
74
+ return {};
75
+ }
76
+ let parsed;
77
+ try {
78
+ parsed = JSON.parse(trimmed);
79
+ }
80
+ catch (e) {
81
+ throw new Error(`existing config is not valid JSON — refusing to overwrite. Fix or remove it first. (${e.message})`);
82
+ }
83
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
84
+ throw new Error("existing config is not a JSON object — refusing to overwrite.");
85
+ }
86
+ return parsed;
87
+ }
88
+ /** Serialize a config object the way Claude Desktop writes it (2-space, trailing newline). */
89
+ export function serializeConfig(config) {
90
+ return JSON.stringify(config, null, 2) + "\n";
91
+ }
92
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/mcp/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAQlD;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAkB,EAAE;IAC1D,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IAClD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,4BAA4B,CAAC;IAC1C,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,qBAAqB,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QACvF,OAAO,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC;AAqBD;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA0B;IAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IACxC,IAAI,CAAC,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pC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,uFAAwF,CAAW,CAAC,OAAO,GAAG,CAC/G,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3E,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,MAAmB,CAAC;AAC7B,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;AAChD,CAAC"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Read-only MCP tools alongside `recall` (slice 3): structured listing and
3
+ * full-entry reads over the memory sqlite index. Neither writes — keeping the
4
+ * MCP surface read-only honors "auto the plumbing, propose the prose": memory
5
+ * writes stay a proposal flow, not a directly-callable external tool.
6
+ *
7
+ * Unlike recall, these need no embedder — only the sqlite store — so they are
8
+ * cheap and never trigger a model load.
9
+ */
10
+ export declare const LIST_MEMORIES_TOOL_NAME = "list_memories";
11
+ export declare const GET_MEMORY_TOOL_NAME = "get_memory";
12
+ export declare const listMemoriesToolDefinition: {
13
+ name: string;
14
+ description: string;
15
+ inputSchema: {
16
+ type: "object";
17
+ properties: {
18
+ type: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ tag: {
23
+ type: string;
24
+ description: string;
25
+ };
26
+ privacy: {
27
+ type: string;
28
+ description: string;
29
+ };
30
+ limit: {
31
+ type: string;
32
+ description: string;
33
+ };
34
+ };
35
+ required: never[];
36
+ };
37
+ };
38
+ export declare const getMemoryToolDefinition: {
39
+ name: string;
40
+ description: string;
41
+ inputSchema: {
42
+ type: "object";
43
+ properties: {
44
+ id: {
45
+ type: string;
46
+ description: string;
47
+ };
48
+ };
49
+ required: string[];
50
+ };
51
+ };
52
+ export interface RunListArgs {
53
+ readonly type?: string;
54
+ readonly tag?: string;
55
+ readonly privacy?: string;
56
+ readonly limit?: number;
57
+ }
58
+ export interface RunGetArgs {
59
+ readonly id: string;
60
+ }
61
+ /** Both read tools need only the sqlite index path — no embedder. */
62
+ export interface RunMemoryToolDeps {
63
+ /** Absolute path to <dataDir>/_indexes/memory.sqlite. */
64
+ readonly dbPath: string;
65
+ readonly defaultLimit?: number;
66
+ }
67
+ export interface MemorySummary {
68
+ readonly id: string;
69
+ readonly name: string;
70
+ readonly description: string;
71
+ readonly type: string;
72
+ readonly tags: readonly string[];
73
+ readonly updated: string | null;
74
+ }
75
+ export interface ListResult {
76
+ readonly count: number;
77
+ readonly memories: readonly MemorySummary[];
78
+ }
79
+ export interface GetResult {
80
+ readonly found: boolean;
81
+ readonly memory?: {
82
+ readonly id: string;
83
+ readonly name: string;
84
+ readonly description: string;
85
+ readonly type: string;
86
+ readonly privacy: string;
87
+ readonly created: string | null;
88
+ readonly updated: string | null;
89
+ readonly tags: readonly string[];
90
+ readonly body: string;
91
+ };
92
+ }
93
+ /**
94
+ * List memories, optionally filtered. With no filter, lists all (capped by
95
+ * limit). Opens + closes the sqlite store per call (releases the file lock —
96
+ * matters on Windows).
97
+ */
98
+ export declare function runListMemories(args: RunListArgs, deps: RunMemoryToolDeps): Promise<ListResult>;
99
+ /** Read one memory in full by id. Returns `{ found: false }` for empty id or miss. */
100
+ export declare function runGetMemory(args: RunGetArgs, deps: RunMemoryToolDeps): Promise<GetResult>;
101
+ //# sourceMappingURL=memory-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"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,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;QACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAsBrG;AAED,sFAAsF;AACtF,wBAAsB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CA4BhG"}
@@ -0,0 +1,105 @@
1
+ import { MemorySqliteStore } from "../sqlite/store.js";
2
+ /**
3
+ * Read-only MCP tools alongside `recall` (slice 3): structured listing and
4
+ * full-entry reads over the memory sqlite index. Neither writes — keeping the
5
+ * MCP surface read-only honors "auto the plumbing, propose the prose": memory
6
+ * writes stay a proposal flow, not a directly-callable external tool.
7
+ *
8
+ * Unlike recall, these need no embedder — only the sqlite store — so they are
9
+ * cheap and never trigger a model load.
10
+ */
11
+ export const LIST_MEMORIES_TOOL_NAME = "list_memories";
12
+ export const GET_MEMORY_TOOL_NAME = "get_memory";
13
+ export const listMemoriesToolDefinition = {
14
+ name: LIST_MEMORIES_TOOL_NAME,
15
+ description: "List the user's stored memories, optionally filtered by type, tag, or privacy. " +
16
+ "Returns lightweight summaries (id, name, description, type, tags, updated) WITHOUT " +
17
+ "full bodies — call get_memory for a full entry. Use this to browse what the user has " +
18
+ "stored before recalling or answering.",
19
+ inputSchema: {
20
+ type: "object",
21
+ properties: {
22
+ type: { type: "string", description: "Filter to one memory type (e.g. feedback, project, reference)." },
23
+ tag: { type: "string", description: "Filter to memories carrying this tag." },
24
+ privacy: { type: "string", description: "Filter by privacy level (public, internal, personal)." },
25
+ limit: { type: "number", description: "Max entries to return (default 50)." },
26
+ },
27
+ required: [],
28
+ },
29
+ };
30
+ export const getMemoryToolDefinition = {
31
+ name: GET_MEMORY_TOOL_NAME,
32
+ description: "Read one memory in full by its id (the filename stem, e.g. 'feedback_response_concise'). " +
33
+ "Returns name, description, type, tags, dates, and the full markdown body. Use after " +
34
+ "list_memories or recall surfaces an id you want to read in full.",
35
+ inputSchema: {
36
+ type: "object",
37
+ properties: {
38
+ id: { type: "string", description: "Memory id — the filename stem without the .md extension." },
39
+ },
40
+ required: ["id"],
41
+ },
42
+ };
43
+ /**
44
+ * List memories, optionally filtered. With no filter, lists all (capped by
45
+ * limit). Opens + closes the sqlite store per call (releases the file lock —
46
+ * matters on Windows).
47
+ */
48
+ export async function runListMemories(args, deps) {
49
+ const q = {};
50
+ if (args.type?.trim())
51
+ q.type = [args.type.trim()];
52
+ if (args.tag?.trim())
53
+ q.tags = [args.tag.trim()];
54
+ if (args.privacy?.trim())
55
+ q.privacy = [args.privacy.trim()];
56
+ const limit = args.limit && args.limit > 0 ? args.limit : deps.defaultLimit ?? 50;
57
+ const store = new MemorySqliteStore(deps.dbPath);
58
+ try {
59
+ const rows = Object.keys(q).length > 0 ? store.query(q) : store.listAll();
60
+ const memories = rows.slice(0, limit).map((r) => ({
61
+ id: r.id,
62
+ name: r.name,
63
+ description: r.description,
64
+ type: r.type,
65
+ tags: r.tags,
66
+ updated: r.updated,
67
+ }));
68
+ return { count: memories.length, memories };
69
+ }
70
+ finally {
71
+ store.close();
72
+ }
73
+ }
74
+ /** Read one memory in full by id. Returns `{ found: false }` for empty id or miss. */
75
+ export async function runGetMemory(args, deps) {
76
+ const id = (args.id ?? "").trim();
77
+ if (id.length === 0) {
78
+ return { found: false };
79
+ }
80
+ const store = new MemorySqliteStore(deps.dbPath);
81
+ try {
82
+ const row = store.getById(id);
83
+ if (!row) {
84
+ return { found: false };
85
+ }
86
+ return {
87
+ found: true,
88
+ memory: {
89
+ id: row.id,
90
+ name: row.name,
91
+ description: row.description,
92
+ type: row.type,
93
+ privacy: row.privacy,
94
+ created: row.created,
95
+ updated: row.updated,
96
+ tags: row.tags,
97
+ body: row.body,
98
+ },
99
+ };
100
+ }
101
+ finally {
102
+ store.close();
103
+ }
104
+ }
105
+ //# sourceMappingURL=memory-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-tools.js","sourceRoot":"","sources":["../../src/mcp/memory-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvD;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAC;AACvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EACT,iFAAiF;QACjF,qFAAqF;QACrF,uFAAuF;QACvF,uCAAuC;IACzC,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gEAAgE,EAAE;YACvG,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uCAAuC,EAAE;YAC7E,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uDAAuD,EAAE;YACjG,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qCAAqC,EAAE;SAC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,CAAC,EAAE;gBACV,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,WAAW,EAAE,GAAG,CAAC,WAAW;gBAC5B,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,IAAI,EAAE,GAAG,CAAC,IAAI;aACf;SACF,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,52 @@
1
+ import type { RecallResult } from "../recall/types.js";
2
+ import type { EmbedFn, VectorSource } from "../vector/types.js";
3
+ export declare const RECALL_TOOL_NAME = "recall";
4
+ /**
5
+ * MCP tool descriptor for `recall`, as plain JSON (no MCP SDK types at build
6
+ * time — the SDK is an optional, runtime-resolved dependency). The low-level
7
+ * MCP Server validates the request envelope; arguments are read defensively in
8
+ * {@link runRecall} and the server handler.
9
+ */
10
+ export declare const recallToolDefinition: {
11
+ name: string;
12
+ description: string;
13
+ inputSchema: {
14
+ type: "object";
15
+ properties: {
16
+ query: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ k: {
21
+ type: string;
22
+ description: string;
23
+ };
24
+ source: {
25
+ type: string;
26
+ enum: string[];
27
+ description: string;
28
+ };
29
+ };
30
+ required: string[];
31
+ };
32
+ };
33
+ export interface RunRecallArgs {
34
+ readonly query: string;
35
+ readonly k?: number;
36
+ readonly source?: VectorSource;
37
+ readonly noHardFilter?: boolean;
38
+ }
39
+ export interface RunRecallDeps {
40
+ /** Embedding function — supply a warm embedder once and reuse it across calls. */
41
+ readonly embed: EmbedFn;
42
+ /** Absolute path to the memory SQLite index (e.g. <dataDir>/_indexes/memory.sqlite). */
43
+ readonly dbPath: string;
44
+ readonly defaultK?: number;
45
+ }
46
+ /**
47
+ * Open the recall stores, run a hybrid recall query, and always close the stores
48
+ * (releasing the SQLite file lock — critical on Windows). The embedder is injected,
49
+ * not opened here, so its one-time model load is amortised across the server's life.
50
+ */
51
+ export declare function runRecall(args: RunRecallArgs, deps: RunRecallDeps): Promise<RecallResult>;
52
+ //# sourceMappingURL=recall-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recall-tool.d.ts","sourceRoot":"","sources":["../../src/mcp/recall-tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKhE,eAAO,MAAM,gBAAgB,WAAW,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;CAmBhC,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B,kFAAkF;IAClF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AASD;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAoB/F"}
@@ -0,0 +1,60 @@
1
+ import { recall as recallEngine } from "../recall/engine.js";
2
+ import { MemorySqliteStore } from "../sqlite/store.js";
3
+ import { MemoryVectorStore } from "../vector/store.js";
4
+ import { SessionChunkStore } from "../vector/session.js";
5
+ export const RECALL_TOOL_NAME = "recall";
6
+ /**
7
+ * MCP tool descriptor for `recall`, as plain JSON (no MCP SDK types at build
8
+ * time — the SDK is an optional, runtime-resolved dependency). The low-level
9
+ * MCP Server validates the request envelope; arguments are read defensively in
10
+ * {@link runRecall} and the server handler.
11
+ */
12
+ export const recallToolDefinition = {
13
+ name: RECALL_TOOL_NAME,
14
+ description: "Semantic search over the user's VortEX memory (markdown frontmatter memories + session archive). " +
15
+ "Returns structured hits: score, name, description, type, tags, and a short excerpt. " +
16
+ "Use it to recall prior context, decisions, preferences, or facts the user has stored.",
17
+ inputSchema: {
18
+ type: "object",
19
+ properties: {
20
+ query: { type: "string", description: "Natural-language search query." },
21
+ k: { type: "number", description: "Maximum number of hits to return (default 5)." },
22
+ source: {
23
+ type: "string",
24
+ enum: ["memory", "session-archive"],
25
+ description: "Restrict the search to one corpus. Omit to search all.",
26
+ },
27
+ },
28
+ required: ["query"],
29
+ },
30
+ };
31
+ const EMPTY_RESULT = {
32
+ query: "",
33
+ intent: { filters: {}, semanticText: "", notes: ["empty query"] },
34
+ stage: { appliedFilters: {}, hardFilterCandidates: 0, hardFilterDropped: false, corpusSize: 0 },
35
+ hits: [],
36
+ };
37
+ /**
38
+ * Open the recall stores, run a hybrid recall query, and always close the stores
39
+ * (releasing the SQLite file lock — critical on Windows). The embedder is injected,
40
+ * not opened here, so its one-time model load is amortised across the server's life.
41
+ */
42
+ export async function runRecall(args, deps) {
43
+ const query = (args.query ?? "").trim();
44
+ if (query.length === 0) {
45
+ return EMPTY_RESULT;
46
+ }
47
+ const k = args.k && args.k > 0 ? args.k : deps.defaultK ?? 5;
48
+ const sqlStore = new MemorySqliteStore(deps.dbPath);
49
+ const vecStore = new MemoryVectorStore({ db: deps.dbPath });
50
+ const chunkStore = new SessionChunkStore(deps.dbPath);
51
+ try {
52
+ return await recallEngine({ query, k, source: args.source, noHardFilter: args.noHardFilter }, { sqlite: sqlStore, vector: vecStore, embed: deps.embed, sessionChunks: chunkStore });
53
+ }
54
+ finally {
55
+ chunkStore.close();
56
+ vecStore.close();
57
+ sqlStore.close();
58
+ }
59
+ }
60
+ //# sourceMappingURL=recall-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recall-tool.js","sourceRoot":"","sources":["../../src/mcp/recall-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,mGAAmG;QACnG,sFAAsF;QACtF,uFAAuF;IACzF,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gCAAgC,EAAE;YACxE,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+CAA+C,EAAE;YACnF,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;gBACnC,WAAW,EAAE,wDAAwD;aACtE;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB;CACF,CAAC;AAiBF,MAAM,YAAY,GAAiB;IACjC,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,aAAa,CAAC,EAAE;IACjE,KAAK,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,oBAAoB,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,0 +1,32 @@
1
+ import type { EmbedFn } from "../vector/types.js";
2
+ export interface RecallServerOptions {
3
+ /** Warm embedder, created once by the host (see bin.ts / createLocalEmbedder). */
4
+ readonly embed: EmbedFn;
5
+ /** Absolute path to <dataDir>/_indexes/memory.sqlite. */
6
+ readonly dbPath: string;
7
+ /**
8
+ * Absolute path to the instance data dir (parent of data/<topic>/). Required
9
+ * for the document tools (suggest/write/decline). If omitted, those tools
10
+ * return an error rather than guessing a path.
11
+ */
12
+ readonly dataDir?: string;
13
+ readonly defaultK?: number;
14
+ readonly name?: string;
15
+ readonly version?: string;
16
+ }
17
+ /**
18
+ * The MCP SDK (`@modelcontextprotocol/sdk`) is an OPTIONAL dependency of
19
+ * memory-extended — only consumers who run the MCP server need it, exactly as
20
+ * `@huggingface/transformers` is optional for those who run the local embedder.
21
+ * So the SDK is loaded at runtime via dynamic import (a runtime-resolved
22
+ * specifier keeps tsc from requiring its types at build time), and the server
23
+ * is returned typed loosely. Hosts that never call this never pay for the SDK.
24
+ *
25
+ * Returns the connected-but-not-transported `Server` instance; the caller
26
+ * attaches a transport (stdio for slice 1) with `await server.connect(t)`.
27
+ */
28
+ export declare function createRecallServer(options: RecallServerOptions): Promise<{
29
+ connect: (transport: unknown) => Promise<void>;
30
+ close: () => Promise<void>;
31
+ }>;
32
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAsBlD,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC;IAC9E,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC,CA6FD"}