@memvid/sdk 2.0.113

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 (46) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +244 -0
  3. package/dist/__tests__/basic.test.d.ts +1 -0
  4. package/dist/__tests__/basic.test.js +41 -0
  5. package/dist/adapters/autogen.d.ts +23 -0
  6. package/dist/adapters/autogen.js +163 -0
  7. package/dist/adapters/basic.d.ts +1 -0
  8. package/dist/adapters/basic.js +11 -0
  9. package/dist/adapters/crewai.d.ts +23 -0
  10. package/dist/adapters/crewai.js +160 -0
  11. package/dist/adapters/google_adk.d.ts +25 -0
  12. package/dist/adapters/google_adk.js +158 -0
  13. package/dist/adapters/haystack.d.ts +1 -0
  14. package/dist/adapters/haystack.js +11 -0
  15. package/dist/adapters/langchain.d.ts +28 -0
  16. package/dist/adapters/langchain.js +156 -0
  17. package/dist/adapters/langgraph.d.ts +1 -0
  18. package/dist/adapters/langgraph.js +11 -0
  19. package/dist/adapters/llamaindex.d.ts +33 -0
  20. package/dist/adapters/llamaindex.js +195 -0
  21. package/dist/adapters/mcp.d.ts +1 -0
  22. package/dist/adapters/mcp.js +11 -0
  23. package/dist/adapters/openai.d.ts +26 -0
  24. package/dist/adapters/openai.js +169 -0
  25. package/dist/adapters/semantic_kernel.d.ts +1 -0
  26. package/dist/adapters/semantic_kernel.js +11 -0
  27. package/dist/adapters/vercel_ai.d.ts +27 -0
  28. package/dist/adapters/vercel_ai.js +148 -0
  29. package/dist/clip.d.ts +182 -0
  30. package/dist/clip.js +371 -0
  31. package/dist/embeddings.d.ts +156 -0
  32. package/dist/embeddings.js +289 -0
  33. package/dist/entities.d.ts +251 -0
  34. package/dist/entities.js +489 -0
  35. package/dist/error.d.ts +91 -0
  36. package/dist/error.js +203 -0
  37. package/dist/index.d.ts +53 -0
  38. package/dist/index.js +458 -0
  39. package/dist/noop.d.ts +2 -0
  40. package/dist/noop.js +55 -0
  41. package/dist/registry.d.ts +5 -0
  42. package/dist/registry.js +53 -0
  43. package/dist/types.d.ts +275 -0
  44. package/dist/types.js +2 -0
  45. package/index.node +0 -0
  46. package/package.json +81 -0
@@ -0,0 +1,23 @@
1
+ /**
2
+ * CrewAI adapter exposing Memvid core methods as CrewAI-compatible tools.
3
+ *
4
+ * CrewAI.js tools follow the OpenAI function calling format. This adapter
5
+ * provides three tools compatible with CrewAI's agent system:
6
+ * - memvid_put: Store documents in memory
7
+ * - memvid_find: Search for relevant documents
8
+ * - memvid_ask: Query with RAG-style answer synthesis
9
+ *
10
+ * Usage:
11
+ * import { use } from "memvid-sdk";
12
+ *
13
+ * const mem = await use("crewai", "knowledge.mv2");
14
+ *
15
+ * // Access tools for CrewAI agents
16
+ * const tools = mem.tools; // Array of tool definitions
17
+ *
18
+ * // Use with CrewAI (tools follow OpenAI function calling format)
19
+ * // Tools can be used with any agent framework supporting this format
20
+ *
21
+ * Note: CrewAI for Node.js uses OpenAI-compatible tool definitions.
22
+ */
23
+ export {};
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ /**
3
+ * CrewAI adapter exposing Memvid core methods as CrewAI-compatible tools.
4
+ *
5
+ * CrewAI.js tools follow the OpenAI function calling format. This adapter
6
+ * provides three tools compatible with CrewAI's agent system:
7
+ * - memvid_put: Store documents in memory
8
+ * - memvid_find: Search for relevant documents
9
+ * - memvid_ask: Query with RAG-style answer synthesis
10
+ *
11
+ * Usage:
12
+ * import { use } from "memvid-sdk";
13
+ *
14
+ * const mem = await use("crewai", "knowledge.mv2");
15
+ *
16
+ * // Access tools for CrewAI agents
17
+ * const tools = mem.tools; // Array of tool definitions
18
+ *
19
+ * // Use with CrewAI (tools follow OpenAI function calling format)
20
+ * // Tools can be used with any agent framework supporting this format
21
+ *
22
+ * Note: CrewAI for Node.js uses OpenAI-compatible tool definitions.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const noop_1 = require("../noop");
26
+ const registry_1 = require("../registry");
27
+ const KIND = "crewai";
28
+ (0, registry_1.register)(KIND, async (core, _apiKey) => {
29
+ // CrewAI uses OpenAI-compatible tool definitions
30
+ // No external imports needed - we create the tool structure directly
31
+ // Define the memvid_put tool
32
+ const memvidPutTool = {
33
+ type: "function",
34
+ function: {
35
+ name: "memvid_put",
36
+ description: "Store a document in Memvid memory. Use this to save information " +
37
+ "that should be retrievable later. Returns the frame ID of the stored document.",
38
+ parameters: {
39
+ type: "object",
40
+ properties: {
41
+ title: {
42
+ type: "string",
43
+ description: "Title of the document",
44
+ },
45
+ label: {
46
+ type: "string",
47
+ description: "Category or label for the document",
48
+ },
49
+ text: {
50
+ type: "string",
51
+ description: "Text content to store",
52
+ },
53
+ metadata: {
54
+ type: "object",
55
+ description: "Optional key-value metadata",
56
+ additionalProperties: true,
57
+ },
58
+ },
59
+ required: ["title", "label", "text"],
60
+ },
61
+ },
62
+ execute: async (args) => {
63
+ const frameId = await core.put({
64
+ title: args.title,
65
+ label: args.label,
66
+ text: args.text,
67
+ metadata: args.metadata ?? {},
68
+ enable_embedding: true,
69
+ auto_tag: true,
70
+ extract_dates: true,
71
+ });
72
+ return `Document stored with frame_id: ${frameId}`;
73
+ },
74
+ };
75
+ // Define the memvid_find tool
76
+ const memvidFindTool = {
77
+ type: "function",
78
+ function: {
79
+ name: "memvid_find",
80
+ description: "Search Memvid memory for documents matching a query. " +
81
+ "Returns the most relevant documents with snippets and metadata.",
82
+ parameters: {
83
+ type: "object",
84
+ properties: {
85
+ query: {
86
+ type: "string",
87
+ description: "Search query string",
88
+ },
89
+ top_k: {
90
+ type: "number",
91
+ description: "Number of results to return (default: 5)",
92
+ },
93
+ },
94
+ required: ["query"],
95
+ },
96
+ },
97
+ execute: async (args) => {
98
+ const query = args.query;
99
+ const topK = args.top_k ?? 5;
100
+ const response = (await core.find(query, { k: topK }));
101
+ const hits = response.hits ?? [];
102
+ if (hits.length === 0) {
103
+ return `No results found for query: '${query}'`;
104
+ }
105
+ const results = [];
106
+ for (let i = 0; i < hits.length; i++) {
107
+ const hit = hits[i];
108
+ const title = hit.title ?? "Untitled";
109
+ const snippet = (hit.text ?? hit.snippet ?? "").slice(0, 200);
110
+ const score = hit.score ?? 0;
111
+ results.push(`${i + 1}. [${title}] (score: ${score.toFixed(2)}): ${snippet}...`);
112
+ }
113
+ return `Found ${hits.length} results:\n${results.join("\n")}`;
114
+ },
115
+ };
116
+ // Define the memvid_ask tool
117
+ const memvidAskTool = {
118
+ type: "function",
119
+ function: {
120
+ name: "memvid_ask",
121
+ description: "Ask a question and get an answer synthesized from Memvid memory. " +
122
+ "Uses retrieval-augmented generation to find relevant context and generate a response.",
123
+ parameters: {
124
+ type: "object",
125
+ properties: {
126
+ question: {
127
+ type: "string",
128
+ description: "Question to answer",
129
+ },
130
+ mode: {
131
+ type: "string",
132
+ enum: ["auto", "lex", "sem"],
133
+ description: "Search mode: 'auto' (hybrid), 'lex' (keyword), or 'sem' (semantic)",
134
+ },
135
+ },
136
+ required: ["question"],
137
+ },
138
+ },
139
+ execute: async (args) => {
140
+ const question = args.question;
141
+ const mode = args.mode ?? "auto";
142
+ const response = (await core.ask(question, { mode }));
143
+ const answer = response.answer ?? "No answer generated";
144
+ const sources = response.sources ?? [];
145
+ let result = `Answer: ${answer}`;
146
+ if (sources.length > 0) {
147
+ const sourceTitles = sources.slice(0, 3).map((s) => s.title ?? "Unknown");
148
+ result += `\n\nSources: ${sourceTitles.join(", ")}`;
149
+ }
150
+ return result;
151
+ },
152
+ };
153
+ const tools = [memvidPutTool, memvidFindTool, memvidAskTool];
154
+ return {
155
+ tools,
156
+ functions: [],
157
+ nodes: (0, noop_1.createNoOp)("crewai adapter nodes not provided", "memvid.adapters.crewai.nodes"),
158
+ asQueryEngine: null,
159
+ };
160
+ });
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Google ADK (Agent Development Kit) adapter exposing Memvid core methods as ADK function tools.
3
+ *
4
+ * This adapter provides tools formatted for Google's Agent Development Kit.
5
+ * The tools can be used directly with ADK agents and the Gemini API.
6
+ *
7
+ * Usage:
8
+ * import { use } from "memvid-sdk";
9
+ *
10
+ * const mem = await use("google-adk", "knowledge.mv2");
11
+ *
12
+ * // Access tools for Google ADK
13
+ * const tools = mem.tools; // Array of ADK function declarations
14
+ * const executors = mem.functions; // Function executors
15
+ *
16
+ * // Use with Gemini API or ADK TypeScript
17
+ * import { GoogleGenerativeAI } from "@google/generative-ai";
18
+ *
19
+ * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
20
+ * const model = genAI.getGenerativeModel({
21
+ * model: "gemini-2.0-flash",
22
+ * tools: [{ functionDeclarations: mem.tools }],
23
+ * });
24
+ */
25
+ export {};
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ /**
3
+ * Google ADK (Agent Development Kit) adapter exposing Memvid core methods as ADK function tools.
4
+ *
5
+ * This adapter provides tools formatted for Google's Agent Development Kit.
6
+ * The tools can be used directly with ADK agents and the Gemini API.
7
+ *
8
+ * Usage:
9
+ * import { use } from "memvid-sdk";
10
+ *
11
+ * const mem = await use("google-adk", "knowledge.mv2");
12
+ *
13
+ * // Access tools for Google ADK
14
+ * const tools = mem.tools; // Array of ADK function declarations
15
+ * const executors = mem.functions; // Function executors
16
+ *
17
+ * // Use with Gemini API or ADK TypeScript
18
+ * import { GoogleGenerativeAI } from "@google/generative-ai";
19
+ *
20
+ * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
21
+ * const model = genAI.getGenerativeModel({
22
+ * model: "gemini-2.0-flash",
23
+ * tools: [{ functionDeclarations: mem.tools }],
24
+ * });
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ const noop_1 = require("../noop");
28
+ const registry_1 = require("../registry");
29
+ const KIND = "google-adk";
30
+ (0, registry_1.register)(KIND, async (core, apiKey) => {
31
+ // Set up API key if provided
32
+ const key = apiKey?.google ?? apiKey?.default;
33
+ if (key && !process.env.GOOGLE_API_KEY) {
34
+ process.env.GOOGLE_API_KEY = key;
35
+ }
36
+ // Define Google ADK function declarations
37
+ const functionDeclarations = [
38
+ {
39
+ name: "memvid_put",
40
+ description: "Store a document in Memvid memory for later retrieval. " +
41
+ "Use this to save information that should be searchable later.",
42
+ parameters: {
43
+ type: "object",
44
+ properties: {
45
+ title: {
46
+ type: "string",
47
+ description: "Title of the document",
48
+ },
49
+ label: {
50
+ type: "string",
51
+ description: "Category or label for the document",
52
+ },
53
+ text: {
54
+ type: "string",
55
+ description: "Text content to store",
56
+ },
57
+ metadata: {
58
+ type: "object",
59
+ description: "Optional key-value metadata",
60
+ },
61
+ },
62
+ required: ["title", "label", "text"],
63
+ },
64
+ },
65
+ {
66
+ name: "memvid_find",
67
+ description: "Search Memvid memory for documents matching a query. " +
68
+ "Returns the most relevant documents with snippets and scores.",
69
+ parameters: {
70
+ type: "object",
71
+ properties: {
72
+ query: {
73
+ type: "string",
74
+ description: "Search query string",
75
+ },
76
+ top_k: {
77
+ type: "number",
78
+ description: "Number of results to return (default: 5)",
79
+ },
80
+ },
81
+ required: ["query"],
82
+ },
83
+ },
84
+ {
85
+ name: "memvid_ask",
86
+ description: "Ask a question and get an answer synthesized from Memvid memory " +
87
+ "using retrieval-augmented generation.",
88
+ parameters: {
89
+ type: "object",
90
+ properties: {
91
+ question: {
92
+ type: "string",
93
+ description: "Question to answer",
94
+ },
95
+ mode: {
96
+ type: "string",
97
+ enum: ["auto", "lex", "sem"],
98
+ description: "Search mode: 'auto' (hybrid), 'lex' (keyword), or 'sem' (semantic)",
99
+ },
100
+ },
101
+ required: ["question"],
102
+ },
103
+ },
104
+ ];
105
+ // Create executor functions for each tool
106
+ const executors = {
107
+ memvid_put: async (args) => {
108
+ const frameId = await core.put({
109
+ title: args.title,
110
+ label: args.label,
111
+ text: args.text,
112
+ metadata: args.metadata ?? {},
113
+ enable_embedding: true,
114
+ auto_tag: true,
115
+ extract_dates: true,
116
+ });
117
+ return `Document stored with frame_id: ${frameId}`;
118
+ },
119
+ memvid_find: async (args) => {
120
+ const query = args.query;
121
+ const topK = args.top_k ?? 5;
122
+ const response = (await core.find(query, { k: topK }));
123
+ const hits = response.hits ?? [];
124
+ if (hits.length === 0) {
125
+ return `No results found for query: '${query}'`;
126
+ }
127
+ const results = [];
128
+ for (let i = 0; i < hits.length; i++) {
129
+ const hit = hits[i];
130
+ const title = hit.title ?? "Untitled";
131
+ const snippet = (hit.text ?? hit.snippet ?? "").slice(0, 200);
132
+ const score = hit.score ?? 0;
133
+ results.push(`${i + 1}. [${title}] (score: ${score.toFixed(2)}): ${snippet}...`);
134
+ }
135
+ return `Found ${hits.length} results:\n${results.join("\n")}`;
136
+ },
137
+ memvid_ask: async (args) => {
138
+ const question = args.question;
139
+ const mode = args.mode ?? "auto";
140
+ const response = (await core.ask(question, { mode }));
141
+ const answer = response.answer ?? "No answer generated";
142
+ const sources = response.sources ?? [];
143
+ let result = `Answer: ${answer}`;
144
+ if (sources.length > 0) {
145
+ const sourceTitles = sources.slice(0, 3).map((s) => s.title ?? "Unknown");
146
+ result += `\n\nSources: ${sourceTitles.join(", ")}`;
147
+ }
148
+ return result;
149
+ },
150
+ };
151
+ // Return tools in Google ADK format
152
+ return {
153
+ tools: functionDeclarations, // FunctionDeclaration array for Gemini/ADK
154
+ functions: executors, // Executors keyed by function name
155
+ nodes: (0, noop_1.createNoOp)("google-adk adapter does not provide nodes", "memvid.adapters.google-adk.nodes"),
156
+ asQueryEngine: null,
157
+ };
158
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const noop_1 = require("../noop");
4
+ const registry_1 = require("../registry");
5
+ const KIND = "haystack";
6
+ (0, registry_1.register)(KIND, async () => ({
7
+ tools: (0, noop_1.createNoOp)("haystack adapter unavailable; install 'haystack-ai' to enable", "memvid.adapters.haystack.tools"),
8
+ functions: [],
9
+ nodes: (0, noop_1.createNoOp)("haystack adapter nodes unavailable", "memvid.adapters.haystack.nodes"),
10
+ asQueryEngine: null,
11
+ }));
@@ -0,0 +1,28 @@
1
+ /**
2
+ * LangChain adapter exposing Memvid core methods as tools.
3
+ *
4
+ * LangChain.js tools are created using the DynamicStructuredTool class or
5
+ * by implementing the StructuredTool interface. This adapter provides three tools:
6
+ * - memvid_put: Store documents in memory
7
+ * - memvid_find: Search for relevant documents
8
+ * - memvid_ask: Query with RAG-style answer synthesis
9
+ *
10
+ * Usage:
11
+ * import { use } from "memvid-sdk";
12
+ *
13
+ * const mem = await use("langchain", "knowledge.mv2");
14
+ *
15
+ * // Access tools for LangChain agents
16
+ * const tools = mem.tools; // Array of DynamicStructuredTool objects
17
+ *
18
+ * // Use with LangChain agent
19
+ * import { ChatOpenAI } from "@langchain/openai";
20
+ * import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
21
+ *
22
+ * const llm = new ChatOpenAI({ model: "gpt-4" });
23
+ * const agent = createToolCallingAgent({ llm, tools: mem.tools, prompt });
24
+ * const executor = AgentExecutor.fromAgentAndTools({ agent, tools: mem.tools });
25
+ *
26
+ * Note: Requires @langchain/core package to be installed.
27
+ */
28
+ export {};
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ /**
3
+ * LangChain adapter exposing Memvid core methods as tools.
4
+ *
5
+ * LangChain.js tools are created using the DynamicStructuredTool class or
6
+ * by implementing the StructuredTool interface. This adapter provides three tools:
7
+ * - memvid_put: Store documents in memory
8
+ * - memvid_find: Search for relevant documents
9
+ * - memvid_ask: Query with RAG-style answer synthesis
10
+ *
11
+ * Usage:
12
+ * import { use } from "memvid-sdk";
13
+ *
14
+ * const mem = await use("langchain", "knowledge.mv2");
15
+ *
16
+ * // Access tools for LangChain agents
17
+ * const tools = mem.tools; // Array of DynamicStructuredTool objects
18
+ *
19
+ * // Use with LangChain agent
20
+ * import { ChatOpenAI } from "@langchain/openai";
21
+ * import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
22
+ *
23
+ * const llm = new ChatOpenAI({ model: "gpt-4" });
24
+ * const agent = createToolCallingAgent({ llm, tools: mem.tools, prompt });
25
+ * const executor = AgentExecutor.fromAgentAndTools({ agent, tools: mem.tools });
26
+ *
27
+ * Note: Requires @langchain/core package to be installed.
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ const noop_1 = require("../noop");
31
+ const registry_1 = require("../registry");
32
+ const KIND = "langchain";
33
+ // Dynamic import helper to avoid TypeScript module resolution issues
34
+ async function tryImportLangChain() {
35
+ try {
36
+ // Use require for better compatibility with npm module resolution
37
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
38
+ const toolsModule = require("@langchain/core/tools");
39
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
40
+ const zodModule = require("zod");
41
+ return {
42
+ tool: toolsModule.tool,
43
+ z: zodModule.z,
44
+ };
45
+ }
46
+ catch {
47
+ return null;
48
+ }
49
+ }
50
+ (0, registry_1.register)(KIND, async (core, _apiKey) => {
51
+ // Try to import LangChain
52
+ const imports = await tryImportLangChain();
53
+ if (!imports) {
54
+ return {
55
+ tools: (0, noop_1.createNoOp)("langchain adapter unavailable; install '@langchain/core' and 'zod' to enable", "memvid.adapters.langchain.tools"),
56
+ functions: [],
57
+ nodes: (0, noop_1.createNoOp)("langchain adapter does not provide nodes", "memvid.adapters.langchain.nodes"),
58
+ asQueryEngine: null,
59
+ };
60
+ }
61
+ const { tool, z } = imports;
62
+ // Define the memvid_put tool using the `tool` function (compatible with createReactAgent)
63
+ const memvidPut = tool(async (params) => {
64
+ const frameId = await core.put({
65
+ title: params.title,
66
+ label: params.label,
67
+ text: params.text,
68
+ metadata: params.metadata ?? {},
69
+ enable_embedding: true,
70
+ auto_tag: true,
71
+ extract_dates: true,
72
+ });
73
+ return `Document stored with frame_id: ${frameId}`;
74
+ }, {
75
+ name: "memvid_put",
76
+ description: "Store a document in Memvid memory for later retrieval. " +
77
+ "Use this tool to save information that should be searchable later. " +
78
+ "The document will be indexed for both keyword and semantic search.",
79
+ schema: z.object({
80
+ title: z.string().describe("Title of the document"),
81
+ label: z.string().describe("Category or label for the document"),
82
+ text: z.string().describe("Text content to store"),
83
+ metadata: z
84
+ .record(z.unknown())
85
+ .optional()
86
+ .describe("Optional key-value metadata"),
87
+ }),
88
+ });
89
+ // Define the memvid_find tool
90
+ const memvidFind = tool(async (params) => {
91
+ const response = (await core.find(params.query, {
92
+ k: params.top_k ?? 5,
93
+ }));
94
+ const hits = response.hits ?? [];
95
+ if (hits.length === 0) {
96
+ return `No results found for query: '${params.query}'`;
97
+ }
98
+ const results = [];
99
+ for (let i = 0; i < hits.length; i++) {
100
+ const hit = hits[i];
101
+ const title = hit.title ?? "Untitled";
102
+ const snippet = (hit.text ?? hit.snippet ?? "").slice(0, 200);
103
+ const score = hit.score ?? 0;
104
+ results.push(`${i + 1}. [${title}] (score: ${score.toFixed(2)}): ${snippet}...`);
105
+ }
106
+ return `Found ${hits.length} results:\n${results.join("\n")}`;
107
+ }, {
108
+ name: "memvid_find",
109
+ description: "Search Memvid memory for documents matching a query. " +
110
+ "Returns the most relevant documents with snippets and metadata. " +
111
+ "Use this when you need to find specific information in stored documents.",
112
+ schema: z.object({
113
+ query: z.string().describe("Search query string"),
114
+ top_k: z
115
+ .number()
116
+ .optional()
117
+ .default(5)
118
+ .describe("Number of results to return (default: 5)"),
119
+ }),
120
+ });
121
+ // Define the memvid_ask tool
122
+ const memvidAsk = tool(async (params) => {
123
+ const response = (await core.ask(params.question, {
124
+ mode: params.mode ?? "auto",
125
+ }));
126
+ const answer = response.answer ?? "No answer generated";
127
+ const sources = response.sources ?? [];
128
+ let result = `Answer: ${answer}`;
129
+ if (sources.length > 0) {
130
+ const sourceTitles = sources.slice(0, 3).map((s) => s.title ?? "Unknown");
131
+ result += `\n\nSources: ${sourceTitles.join(", ")}`;
132
+ }
133
+ return result;
134
+ }, {
135
+ name: "memvid_ask",
136
+ description: "Ask a question and get an answer synthesized from Memvid memory. " +
137
+ "Uses retrieval-augmented generation to find relevant context " +
138
+ "and generate a comprehensive response. Best for complex questions " +
139
+ "that require synthesizing information from multiple sources.",
140
+ schema: z.object({
141
+ question: z.string().describe("Question to answer"),
142
+ mode: z
143
+ .enum(["auto", "lex", "sem"])
144
+ .optional()
145
+ .default("auto")
146
+ .describe("Search mode: 'auto' (hybrid), 'lex' (keyword), or 'sem' (semantic)"),
147
+ }),
148
+ });
149
+ const tools = [memvidPut, memvidFind, memvidAsk];
150
+ return {
151
+ tools,
152
+ functions: [],
153
+ nodes: (0, noop_1.createNoOp)("langchain adapter does not provide nodes", "memvid.adapters.langchain.nodes"),
154
+ asQueryEngine: null,
155
+ };
156
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const noop_1 = require("../noop");
4
+ const registry_1 = require("../registry");
5
+ const KIND = "langgraph";
6
+ (0, registry_1.register)(KIND, async () => ({
7
+ tools: (0, noop_1.createNoOp)("langgraph adapter unavailable; install 'langgraph' to enable", "memvid.adapters.langgraph.tools"),
8
+ functions: [],
9
+ nodes: (0, noop_1.createNoOp)("langgraph adapter nodes unavailable", "memvid.adapters.langgraph.nodes"),
10
+ asQueryEngine: null,
11
+ }));
@@ -0,0 +1,33 @@
1
+ /**
2
+ * LlamaIndex adapter exposing Memvid helpers as FunctionTool and QueryEngineTool.
3
+ *
4
+ * LlamaIndex.TS uses FunctionTool for wrapping functions and QueryEngineTool
5
+ * for wrapping query engines. This adapter provides:
6
+ * - memvid_put: Store documents in memory
7
+ * - memvid_find: Search for relevant documents
8
+ * - memvid_ask: Query with RAG-style answer synthesis
9
+ * - asQueryEngine(): Factory for creating a LlamaIndex QueryEngine
10
+ *
11
+ * Usage:
12
+ * import { use } from "memvid-sdk";
13
+ *
14
+ * const mem = await use("llamaindex", "knowledge.mv2");
15
+ *
16
+ * // Access tools for LlamaIndex agents
17
+ * const tools = mem.tools; // Array of FunctionTool objects
18
+ *
19
+ * // Use with LlamaIndex agent
20
+ * import { OpenAIAgent } from "llamaindex";
21
+ *
22
+ * const agent = new OpenAIAgent({
23
+ * tools: mem.tools,
24
+ * });
25
+ * const response = await agent.chat({ message: "What do you know about X?" });
26
+ *
27
+ * // Or use as a QueryEngine
28
+ * const queryEngine = mem.asQueryEngine();
29
+ * const result = await queryEngine.query({ query: "Summarize the key points" });
30
+ *
31
+ * Note: Requires llamaindex package to be installed.
32
+ */
33
+ export {};