{"_id":"@alsoleg/agentmemo","name":"@alsoleg/agentmemo","dist-tags":{"latest":"0.3.0"},"versions":{"0.3.0":{"name":"@alsoleg/agentmemo","version":"0.3.0","description":"TypeScript client for agentmemo — agent memory via MCP stdio bridge","license":"MIT","author":{"name":"Oleg"},"homepage":"https://github.com/alsoleg89/agentmemo#readme","repository":{"type":"git","url":"git+https://github.com/alsoleg89/agentmemo.git","directory":"npm"},"bugs":{"url":"https://github.com/alsoleg89/agentmemo/issues"},"keywords":["ai","agents","memory","knowledge","llm","mcp"],"engines":{"node":">=18.0.0"},"type":"module","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.js"}}},"main":"./dist/cjs/index.js","module":"./dist/esm/index.js","types":"./dist/esm/index.d.ts","scripts":{"build":"npm run build:esm && npm run build:cjs","build:esm":"tsc -p tsconfig.build.json --outDir dist/esm","build:cjs":"tsc -p tsconfig.build.json --outDir dist/cjs --module commonjs --moduleResolution node && node --input-type=module -e \"import{writeFileSync}from'node:fs';writeFileSync('dist/cjs/package.json',JSON.stringify({type:'commonjs'}))\"","typecheck":"tsc --noEmit","clean":"node --input-type=module -e \"import{rmSync}from'node:fs';rmSync('dist',{recursive:true,force:true})\"","postinstall":"node scripts/postinstall.js"},"devDependencies":{"@types/node":"^25.5.0","typescript":"^5.4.0"},"_id":"@alsoleg/agentmemo@0.3.0","gitHead":"b23b244820e6142d187b878ace218b0c33cf12de","_nodeVersion":"20.20.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-GeFB6H9N7KqE6ttBJQFarEYjle1ZPlXIjiJglJ/er2RZhxY4JLtRqrlu0wNvkhWx2+XXzP10yrtut7GAoFU4GA==","shasum":"f4fff0501d88d50031619a9c8ca5c85500ce41ee","tarball":"https://registry.npmjs.org/@alsoleg/agentmemo/-/agentmemo-0.3.0.tgz","fileCount":28,"unpackedSize":63554,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCWlDtLtn3jpAODOp/bfDSlOaZgnz3bgRbeZceVkOE1dgIgMGaOcONOJNMhGH/SvvGATKtY2ncUfGneq0hOoeRsTpg="}]},"_npmUser":{"name":"alsoleg","email":"alsoleg@protonmail.com"},"directories":{},"maintainers":[{"name":"alsoleg","email":"alsoleg@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/agentmemo_0.3.0_1774776259497_0.44775296425147926"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-29T09:24:19.361Z","0.3.0":"2026-03-29T09:24:19.638Z","modified":"2026-03-29T09:24:19.910Z"},"maintainers":[{"name":"alsoleg","email":"alsoleg@protonmail.com"}],"description":"TypeScript client for agentmemo — agent memory via MCP stdio bridge","homepage":"https://github.com/alsoleg89/agentmemo#readme","keywords":["ai","agents","memory","knowledge","llm","mcp"],"repository":{"type":"git","url":"git+https://github.com/alsoleg89/agentmemo.git","directory":"npm"},"author":{"name":"Oleg"},"bugs":{"url":"https://github.com/alsoleg89/agentmemo/issues"},"license":"MIT","readme":"# @alsoleg/agentmemo\n\n![npm](https://img.shields.io/npm/v/@alsoleg/agentmemo)\n![License](https://img.shields.io/badge/license-MIT-green)\n\n**Agent memory for Node.js and TypeScript.** Stores facts, retrieves what's relevant, forgets the rest.\n\nTypeScript client for the [agentmemo](https://github.com/alsoleg89/agentmemo) Python library — communicates with the `agentmemo-mcp` subprocess via JSON-RPC 2.0 over stdio.\n\n---\n\n## Requirements\n\n- Node.js 18+\n- Python 3.11+ with `pip`\n\n## Install\n\n```bash\nnpm install @alsoleg/agentmemo\n```\n\nThe postinstall script automatically runs `pip install \"agentmemo[mcp]\"`. If pip is not found, a warning is printed — install it manually:\n\n```bash\npip install \"agentmemo[mcp]\"\n```\n\n---\n\n## Quickstart\n\n```typescript\nimport { KnowledgeBase } from '@alsoleg/agentmemo';\n\nconst kb = new KnowledgeBase({\n  agentId: 'my-agent',\n  storage: 'sqlite',\n  dbPath: '/absolute/path/to/memory.db',\n});\n\n// Add a fact\nawait kb.add('User prefers TypeScript');\n\n// Recall relevant facts for a query\nconst context = await kb.recall('what language does user prefer?');\nconsole.log(context);\n// -> \"[semantic] User prefers TypeScript\"\n\n// Use context in your prompt\nconst response = await openai.chat.completions.create({\n  model: 'gpt-4o',\n  messages: [\n    { role: 'system', content: `You are a helpful assistant.\\n\\n${context}` },\n    { role: 'user', content: 'Write me a script' },\n  ],\n});\n\nawait kb.close();\n```\n\n---\n\n## API\n\n### `new KnowledgeBase(options?)`\n\n```typescript\nconst kb = new KnowledgeBase({\n  agentId?: string,    // default: \"default\"\n  storage?: 'yaml' | 'sqlite',  // default: \"yaml\"\n  dataDir?: string,   // base dir for YAML/SQLite (use absolute path!)\n  dbPath?: string,    // full path to SQLite file\n  command?: string,   // path to agentmemo-mcp binary\n});\n```\n\n> Use absolute paths for `dataDir` and `dbPath` — the subprocess may run from a different working directory.\n\n### Methods\n\n```typescript\nawait kb.add(content, options?)   // → Fact\nawait kb.recall(query, options?)  // → string (formatted facts)\nawait kb.forget(factId)           // → void\nawait kb.listFacts()              // → Fact[]\nawait kb.stats()                  // → Stats\nawait kb.snapshot(name)           // → void\nawait kb.restore(name)            // → void\nawait kb.close()                  // → void (shuts down subprocess)\n```\n\n### `add` options\n\n```typescript\n{\n  type?: 'semantic' | 'procedural' | 'episodic',  // default: \"semantic\"\n  importance?: number,  // 0.0–1.0, default: 0.8\n  tags?: string[],\n}\n```\n\n### `recall` options\n\n```typescript\n{\n  topK?: number,  // max facts to return, default: 5\n}\n```\n\n---\n\n## Memory types\n\n| Type | Use for | Example |\n|---|---|---|\n| `semantic` | Facts about the user/world | \"User works at Acme Corp\" |\n| `procedural` | How the user wants things done | \"Always use TypeScript strict mode\" |\n| `episodic` | Specific past events | \"Deploy failed last Tuesday\" |\n\n---\n\n## Concurrent calls\n\nAll method calls are safe to run concurrently:\n\n```typescript\nconst [facts, stats] = await Promise.all([\n  kb.listFacts(),\n  kb.stats(),\n]);\n```\n\n---\n\n## Snapshots\n\n```typescript\nawait kb.snapshot('before-refactor');\nawait kb.restore('before-refactor');\n```\n\nRequires SQLite or YAML storage backend.\n\n---\n\n## Lifecycle\n\nAlways call `kb.close()` when done:\n\n```typescript\nconst kb = new KnowledgeBase({ agentId: 'bot' });\ntry {\n  await kb.add('...');\n  const ctx = await kb.recall('...');\n} finally {\n  await kb.close();\n}\n```\n\n---\n\n## Environment variables\n\n| Variable | Default | Description |\n|---|---|---|\n| `AGENTMEMO_AGENT_ID` | `default` | Agent namespace |\n| `AGENTMEMO_STORAGE` | `yaml` | `yaml` or `sqlite` |\n| `AGENTMEMO_DATA_DIR` | `.agentmemo` | Base dir (use absolute path) |\n| `AGENTMEMO_DB_PATH` | — | Full path to SQLite file |\n\n---\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-79c8d2768e7b574c30c079f2e3428ace"}