{"_id":"@anura-gate/anura-graph","_rev":"4-8a90aec3919b3a0b0633d902ecf0f2ca","name":"@anura-gate/anura-graph","dist-tags":{"latest":"0.4.0"},"versions":{"0.1.0":{"name":"@anura-gate/anura-graph","version":"0.1.0","keywords":["graphmem","knowledge-graph","ai","memory","mcp","rag","graph-rag"],"license":"MIT","_id":"@anura-gate/anura-graph@0.1.0","maintainers":[{"name":"anuragate","email":"ahmadajmal1514@gmail.com"}],"dist":{"shasum":"41a3d3fdeadb69f1b63a0d419e97334548eb7d0a","tarball":"https://registry.npmjs.org/@anura-gate/anura-graph/-/anura-graph-0.1.0.tgz","fileCount":13,"integrity":"sha512-A9a6Ntd4pSv4FdJX1BD2gKCuUvzBULe36442a7Zx/9KohHyOzd1i0sYXIZnHX4hIqcILBdh24u3tPQvR60hGfQ==","signatures":[{"sig":"MEUCIQCPC3dWD2zjRwp1huBSRZkVBvAgVS9k6fUo5AjfGFV4wwIgD0ieriPN1Foaun8dpBDtbF2zQ4g0K9bodJftFiTX4og=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21929},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"1930d8fa309c39c88f55f551bb07fd45520bb9d3","scripts":{"build":"tsc","prepublishOnly":"tsc"},"_npmUser":{"name":"anuragate","email":"ahmadajmal1514@gmail.com"},"_npmVersion":"10.9.2","description":"Typed client for the GraphMem knowledge graph API","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/anura-graph_0.1.0_1771602528402_0.49689419785522104","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@anura-gate/anura-graph","version":"0.3.0","keywords":["graphmem","knowledge-graph","ai","memory","mcp","rag","graph-rag"],"license":"MIT","_id":"@anura-gate/anura-graph@0.3.0","maintainers":[{"name":"anuragate","email":"ahmadajmal1514@gmail.com"}],"homepage":"https://anuramemory.com","bugs":{"url":"https://github.com/anura-gate/graphmem/issues"},"dist":{"shasum":"fef60db1920a34314a271af0eae23983817afb49","tarball":"https://registry.npmjs.org/@anura-gate/anura-graph/-/anura-graph-0.3.0.tgz","fileCount":19,"integrity":"sha512-pBIqZJDQ/4+I+GZSTKL5g2veQ84vBX2N5aGHY/qSXcAF7a1uFbPGsJ5zrTSY/9MvZCv3TGuT3JLivgeBNCdovQ==","signatures":[{"sig":"MEQCHxUgTvxyTGibNFozF4+pp4iQoZcOS0Kc3IxxC1c+JGQCIQDrwu05RJyKHTEo5bSDDiiHmF2XT8er3tdCrISV27fL3g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":70037},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"a6e5a2c148d0c2c434be7d867aada91439e1d7d1","scripts":{"build":"tsc","prepublishOnly":"tsc"},"_npmUser":{"name":"anuragate","email":"ahmadajmal1514@gmail.com"},"repository":{"url":"git+https://github.com/anura-gate/graphmem.git","type":"git","directory":"packages/graphmem"},"_npmVersion":"10.9.2","description":"Typed client for the GraphMem knowledge graph API","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/anura-graph_0.3.0_1771699392583_0.9021556809104403","host":"s3://npm-registry-packages-npm-production"}},"0.3.1":{"name":"@anura-gate/anura-graph","version":"0.3.1","keywords":["graphmem","knowledge-graph","ai","memory","mcp","rag","graph-rag"],"license":"MIT","_id":"@anura-gate/anura-graph@0.3.1","maintainers":[{"name":"anuragate","email":"ahmadajmal1514@gmail.com"}],"homepage":"https://anuramemory.com","bugs":{"url":"https://github.com/anura-gate/graphmem/issues"},"dist":{"shasum":"a227ab57855799345009cda34921abebb7e08014","tarball":"https://registry.npmjs.org/@anura-gate/anura-graph/-/anura-graph-0.3.1.tgz","fileCount":19,"integrity":"sha512-12scCe7DLBAWAaaUD2lG7ZB3TbRy6Vm8Ttewogp+Qg0PeFX40AqtvKIHmCWeMrJWqyKW10ncs54083crjKNK3Q==","signatures":[{"sig":"MEYCIQDs/N6WJBItpOAUjudRfljY4bt2D2RkikipazFeenYf3QIhAJpm/Z6/d/xJKRv1veDt2u1mm9cpC/oLkduJCe8YNNyP","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":73178},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"1f72d529cb2d049e883a18ec0fec7d45eeb28eec","scripts":{"build":"tsc","prepublishOnly":"tsc"},"_npmUser":{"name":"anuragate","email":"ahmadajmal1514@gmail.com"},"repository":{"url":"git+https://github.com/anura-gate/graphmem.git","type":"git","directory":"packages/graphmem"},"_npmVersion":"10.9.2","description":"Typed client for the GraphMem knowledge graph API","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/anura-graph_0.3.1_1772111448328_0.485352367024495","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@anura-gate/anura-graph","version":"0.4.0","description":"Typed client for the GraphMem knowledge graph API","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"type":"module","scripts":{"build":"tsc","prepublishOnly":"tsc"},"keywords":["graphmem","knowledge-graph","ai","memory","mcp","rag","graph-rag"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/anura-gate/graphmem.git","directory":"packages/graphmem"},"homepage":"https://anuramemory.com","engines":{"node":">=18"},"devDependencies":{"typescript":"^5.0.0"},"_id":"@anura-gate/anura-graph@0.4.0","gitHead":"1ddf54f0f461c9da2953e741035c91bc28c94d7c","bugs":{"url":"https://github.com/anura-gate/graphmem/issues"},"_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-luHF3c+mjfhO5jzysXRpLmb1j8o8deYOnMZGtNnIejkPGpuTWhaSV0RdnNEYbiivi+itDBYx3A5MAdzRHAS+ZA==","shasum":"1981b3b2497e4f17ba24307d5d45e06aaac5aa3b","tarball":"https://registry.npmjs.org/@anura-gate/anura-graph/-/anura-graph-0.4.0.tgz","fileCount":19,"unpackedSize":74872,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHVMcJKFL47Ch2nYXNr+bCpgsqVbpHpe4axodMpZ2zW2AiEAsrVEnvgArMQR/m8dEySxTL+d6lH0MBTokwWxsi8eWr0="}]},"_npmUser":{"name":"anuragate","email":"ahmadajmal1514@gmail.com"},"directories":{},"maintainers":[{"name":"anuragate","email":"ahmadajmal1514@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/anura-graph_0.4.0_1772113567702_0.6834908061795693"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-20T15:48:48.317Z","modified":"2026-02-26T13:46:08.022Z","0.1.0":"2026-02-20T15:48:48.544Z","0.3.0":"2026-02-21T18:43:12.725Z","0.3.1":"2026-02-26T13:10:48.491Z","0.4.0":"2026-02-26T13:46:07.852Z"},"bugs":{"url":"https://github.com/anura-gate/graphmem/issues"},"license":"MIT","homepage":"https://anuramemory.com","keywords":["graphmem","knowledge-graph","ai","memory","mcp","rag","graph-rag"],"repository":{"type":"git","url":"git+https://github.com/anura-gate/graphmem.git","directory":"packages/graphmem"},"description":"Typed client for the GraphMem knowledge graph API","maintainers":[{"name":"anuragate","email":"ahmadajmal1514@gmail.com"}],"readme":"# @anura-gate/anura-graph\n\nTyped TypeScript/JavaScript client for the [Anura Memory](https://anuramemory.com) API. Zero dependencies.\n\nAnura Memory provides two memory products for AI agents:\n\n- **GraphRag** — Knowledge graph with automatic triple extraction, deduplication, and hybrid retrieval\n- **FilesRag** — Markdown file storage with heading-based chunking and semantic search\n\n## Installation\n\n```bash\nnpm install @anura-gate/anura-graph\n```\n\n## Quick Start\n\n```typescript\nimport { GraphMem } from '@anura-gate/anura-graph';\n\nconst mem = new GraphMem({\n  apiKey: 'gm_your_key_here',\n  // baseUrl: 'https://anuramemory.com' (default)\n});\n\n// --- GraphRag ---\nawait mem.remember(\"Alice is VP of Engineering at Acme Corp\");\nconst ctx = await mem.getContext(\"Tell me about Alice\");\n\n// --- FilesRag ---\nawait mem.writeFile({ path: \"/notes/standup.md\", content: \"# Standup\\n## 2026-02-21\\n- Shipped auth module\" });\nconst results = await mem.searchFiles(\"auth module\");\n```\n\n## Configuration\n\n```typescript\nnew GraphMem({\n  apiKey: 'gm_...',                    // required — from dashboard\n  baseUrl: 'https://anuramemory.com',  // default\n  retry: {\n    maxRetries: 3,                     // default\n    baseDelayMs: 500,                  // exponential backoff base\n    maxDelayMs: 10_000,                // max delay cap\n    retryOn: [429, 500, 502, 503, 504] // retryable status codes\n  }\n});\n```\n\n## API Reference\n\n### GraphRag\n\n#### `remember(text): Promise<RememberResult>`\n\nExtract knowledge from text and store as triples in the graph.\n\n```typescript\nconst result = await mem.remember(\n  \"Albert Einstein was born in Ulm, Germany. He developed the theory of relativity.\"\n);\n// { extractedCount: 2, mergedCount: 2, conflicts: [], message: \"...\" }\n```\n\nIf a new fact contradicts an existing one on a single-valued predicate (e.g., `LIVES_IN`, `WORKS_AT`), the old value is replaced and the conflict is returned:\n\n```typescript\nconst r = await mem.remember(\"Alice now works at Microsoft\");\n// r.conflicts → [{ subjectName: \"alice\", predicate: \"WORKS_AT\", oldObject: \"google\", newObject: \"microsoft\", resolution: \"auto_recency\" }]\n```\n\n#### `getContext(query, options?): Promise<ContextResult>`\n\nRetrieve context from the knowledge graph using hybrid search (graph traversal + vector similarity + community summaries).\n\n```typescript\n// Markdown format (ideal for LLM system prompts)\nconst ctx = await mem.getContext(\"Einstein\", { format: \"markdown\" });\n// ctx.content → \"- Albert Einstein → BORN_IN → Ulm...\"\n\n// JSON format\nconst json = await mem.getContext(\"Einstein\", { format: \"json\" });\n// json.entities, json.edges, json.vectorEntities, json.communities\n\n// Hybrid mode (graph + vector + communities)\nconst hybrid = await mem.getContext(\"Einstein\", { mode: \"hybrid\" });\n```\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `format` | `\"json\" \\| \"markdown\" \\| \"text\"` | `\"json\"` | Response format |\n| `mode` | `\"graph\" \\| \"hybrid\"` | auto | Search mode |\n\n#### `search(entity, options?): Promise<SearchResult>`\n\nFind an entity and its direct (1-hop) connections. In fuzzy mode, filter results by entity type.\n\n```typescript\nconst result = await mem.search(\"typescript\");\nconsole.log(result.entity); // { name: \"Typescript\", type: \"technology\", userId: \"...\" }\nconsole.log(result.edges);  // all incoming + outgoing relationships\n\n// Search with type filter (fuzzy mode)\nconst result = await mem.search(\"alice\", { type: \"person\" });\n```\n\n#### `ingestTriples(triples): Promise<IngestResult>`\n\nIngest pre-formatted triples directly (no LLM extraction, max 100 per request).\n\n```typescript\nconst result = await mem.ingestTriples([\n  { subject: \"TypeScript\", predicate: \"CREATED_BY\", object: \"Microsoft\" },\n  { subject: \"TypeScript\", predicate: \"SUPERSET_OF\", object: \"JavaScript\" },\n]);\n```\n\n#### `getGraph(options?): Promise<GraphData>`\n\nGet the full graph (all nodes, edges, communities). Optionally filter by entity type.\n\n```typescript\nconst graph = await mem.getGraph();\n// graph.nodes: GraphNode[], graph.edges: GraphEdge[], graph.communities?: GraphCommunity[]\n\n// Filter graph by entity type\nconst people = await mem.getGraph({ type: \"person\" });\nconst orgs = await mem.getGraph({ type: \"person,organization\" });\n```\n\n#### `deleteEdge(id, options?): Promise<void>`\n\nDelete an edge. Optionally blacklist the triple to prevent re-creation.\n\n```typescript\nawait mem.deleteEdge(\"edge_id\");\nawait mem.deleteEdge(\"edge_id\", { blacklist: true });\n```\n\n#### `updateEdgeWeight(id, options?): Promise<void>`\n\nSet or increment an edge's weight. Higher-weight edges appear first in context retrieval.\n\n```typescript\nawait mem.updateEdgeWeight(\"edge_id\", { weight: 5.0 });     // absolute\nawait mem.updateEdgeWeight(\"edge_id\", { increment: 1.0 });  // delta\n```\n\n#### `deleteNode(id): Promise<void>`\n\nDelete a node and all its connected edges.\n\n#### `exportGraph(): Promise<ExportData>`\n\nExport the entire graph as portable JSON.\n\n#### `importGraph(data): Promise<ImportResult>`\n\nImport a graph export into the current project (merges, does not delete existing data).\n\n#### `listCommunities(): Promise<Community[]>`\n\nList all detected communities.\n\n#### `detectCommunities(): Promise<DetectCommunitiesResult>`\n\nRun Louvain community detection + LLM summarization.\n\n```typescript\nconst result = await mem.detectCommunities();\n// { communityCount: 3, entityCount: 25, message: \"...\" }\n```\n\n### FilesRag\n\n#### `writeFile(options): Promise<WriteFileResult>`\n\nCreate or update a markdown memory file. Files are automatically chunked by `##` headings and indexed for semantic search.\n\n```typescript\nconst result = await mem.writeFile({\n  path: \"/docs/architecture.md\",\n  content: \"# Architecture\\n\\n## Backend\\nNode.js with Prisma...\\n\\n## Frontend\\nNext.js with React...\",\n  name: \"architecture.md\", // optional, derived from path if omitted\n});\n// { file: { id, name, path, size, ... }, chunkCount: 3, created: true }\n```\n\nIf a file already exists at the given path, its content is replaced and re-indexed.\n\n#### `listFiles(): Promise<MemoryFile[]>`\n\nList all files in the current project.\n\n```typescript\nconst files = await mem.listFiles();\n// [{ id, name, path, size, createdAt, updatedAt }, ...]\n```\n\n#### `readFile(id): Promise<FileWithContent>`\n\nGet a file with its content.\n\n```typescript\nconst file = await mem.readFile(\"file_id\");\nconsole.log(file.content); // full markdown content\n```\n\n#### `updateFile(id, content, name?): Promise<WriteFileResult>`\n\nUpdate a file's content (re-chunks and re-indexes).\n\n```typescript\nconst result = await mem.updateFile(\"file_id\", \"# Updated content\\n...\");\n```\n\n#### `deleteMemoryFile(id): Promise<void>`\n\nDelete a file and all its indexed chunks.\n\n#### `searchFiles(query, options?): Promise<FileSearchResult[]>`\n\nSemantic search across file chunks. Pass `fileId` to scope the search to a single file.\n\n```typescript\nconst results = await mem.searchFiles(\"authentication flow\", { limit: 5 });\n// Search within a single file:\n// const results = await mem.searchFiles(\"auth\", { fileId: \"file_abc123\" });\nfor (const r of results) {\n  console.log(r.file.path);\n  for (const chunk of r.chunks) {\n    console.log(`  ${chunk.headingTitle} (${chunk.score.toFixed(2)})`);\n    console.log(`  ${chunk.excerpt}`);\n  }\n}\n```\n\n### Projects\n\n#### `listProjects(): Promise<Project[]>`\n#### `createProject(name): Promise<Project>`\n#### `deleteProject(id): Promise<void>`\n#### `selectProject(id): Promise<void>`\n\n### Traces\n\n#### `listTraces(options?): Promise<Trace[]>`\n#### `getTrace(id): Promise<TraceDetail>`\n\n### Blacklist\n\n#### `listBlacklist(options?): Promise<BlacklistedTriple[]>`\n#### `addToBlacklist(subject, predicate, object): Promise<{ id: string }>`\n#### `removeFromBlacklist(id): Promise<void>`\n\n### Conflict Log\n\n#### `listConflicts(options?): Promise<ConflictLogEntry[]>`\n\nList conflict resolution log entries (newest first, paginated).\n\n```typescript\nconst conflicts = await mem.listConflicts({ limit: 10 });\n// [{ id, subjectName, predicate, oldObject, newObject, resolution, createdAt }, ...]\n```\n\n### Pending Facts\n\n#### `listPending(options?): Promise<PendingFact[]>`\n#### `approveFact(id): Promise<void>`\n#### `rejectFact(id, options?): Promise<void>`\n#### `approveAll(): Promise<void>`\n#### `rejectAll(): Promise<void>`\n\n### Usage\n\n#### `getUsage(): Promise<UsageInfo>`\n\n```typescript\nconst usage = await mem.getUsage();\n// { tier: \"FREE\", factLimit: 100, currentFacts: 42, nodesCount: 20, edgesCount: 22,\n//   fileStorageLimit: 52428800, fileCountLimit: 20, currentFileStorage: 1024, currentFileCount: 3 }\n```\n\n### Health\n\n#### `health(): Promise<HealthResult>`\n\n## Error Handling\n\nAll methods throw `GraphMemError` on failure:\n\n```typescript\nimport { GraphMemError } from '@anura-gate/anura-graph';\n\ntry {\n  await mem.readFile(\"nonexistent\");\n} catch (err) {\n  if (err instanceof GraphMemError) {\n    console.log(err.status);  // 404\n    console.log(err.message); // \"File not found\"\n    console.log(err.body);    // full response body\n  }\n}\n```\n\n## Rate Limiting\n\nAfter each request, rate limit info is available:\n\n```typescript\nawait mem.remember(\"some fact\");\nconsole.log(mem.rateLimit.remaining); // requests remaining\nconsole.log(mem.rateLimit.limit);     // total allowed per window\nconsole.log(mem.rateLimit.reset);     // unix timestamp when window resets\n```\n\n## Types\n\nAll types are exported:\n\n```typescript\nimport type {\n  // GraphRag\n  RememberResult, ConflictResolution, ConflictLogEntry,\n  ContextResult, SearchResult, Triple,\n  GraphNode, GraphEdge, GraphData, Community,\n  // FilesRag\n  MemoryFile, FileWithContent, FileSearchResult,\n  WriteFileOptions, WriteFileResult,\n  // Config\n  GraphMemConfig, RetryConfig, RateLimitInfo, UsageInfo,\n} from '@anura-gate/anura-graph';\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}