{"_id":"@dakera-ai/ai-sdk","_rev":"4-3ac8d3f0eb21b750ad7bc1b2b410bc98","name":"@dakera-ai/ai-sdk","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@dakera-ai/ai-sdk","version":"0.1.0","keywords":["vercel","ai-sdk","ai","dakera","memory","middleware","tools","rag","agents","typescript"],"author":{"name":"Dakera Team"},"license":"MIT","_id":"@dakera-ai/ai-sdk@0.1.0","maintainers":[{"name":"ferhimedamine","email":"ferhi.med.amine@gmail.com"}],"homepage":"https://github.com/dakera-ai/dakera-ai-sdk","bugs":{"url":"https://github.com/dakera-ai/dakera-ai-sdk/issues"},"dist":{"shasum":"7838e9ba7f223784ddd3a6de6168057373486327","tarball":"https://registry.npmjs.org/@dakera-ai/ai-sdk/-/ai-sdk-0.1.0.tgz","fileCount":7,"integrity":"sha512-s2ZJo+GEnhAd5Rqalls0Y9UcIfdANpU2eY5h+vWWKlAncmV+3O3QStiOOasozYzukfsqAUEAbsdjPYY5kldLJA==","signatures":[{"sig":"MEYCIQCHCOcHAcAiTHOp+w/Mb5FojBVH23pwSS1iiZtYzVrKHAIhAMlbz3JSIQhrOAFLQF7/bhWviwS8i1uNuw86+1amywHP","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":65740},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"27b480dd71c4879e26bbb94986306bbf23db6587","scripts":{"lint":"eslint src tests --ext .ts","test":"vitest run","build":"tsup src/index.ts --format cjs,esm --dts --clean","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"ferhimedamine","email":"ferhi.med.amine@gmail.com"},"repository":{"url":"git+https://github.com/dakera-ai/dakera-ai-sdk.git","type":"git"},"_npmVersion":"10.9.8","description":"Vercel AI SDK integration for Dakera AI memory — persistent, decay-weighted cross-session memory via language model middleware and tools","directories":{},"_nodeVersion":"22.23.1","_hasShrinkwrap":false,"devDependencies":{"ai":"^7.0.0","zod":"^4.0.0","tsup":"^8.0.0","vitest":"^4.1.5","typescript":"^6.0.3","@types/node":"^26.1.0","@ai-sdk/provider":"^4.0.1","@dakera-ai/dakera":"^0.11.100"},"peerDependencies":{"ai":">=6.0.0","zod":">=3.23.0","@dakera-ai/dakera":">=0.11.54"},"_npmOperationalInternal":{"tmp":"tmp/ai-sdk_0.1.0_1783019874429_0.6692883425734553","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@dakera-ai/ai-sdk","version":"0.1.1","keywords":["vercel","ai-sdk","ai","dakera","memory","middleware","tools","rag","agents","typescript"],"author":{"name":"Dakera Team"},"license":"MIT","_id":"@dakera-ai/ai-sdk@0.1.1","maintainers":[{"name":"ferhimedamine","email":"ferhi.med.amine@gmail.com"}],"homepage":"https://github.com/dakera-ai/dakera-ai-sdk","bugs":{"url":"https://github.com/dakera-ai/dakera-ai-sdk/issues"},"dist":{"shasum":"3d8e19492dccd936e051d20cca184b2dfbef3125","tarball":"https://registry.npmjs.org/@dakera-ai/ai-sdk/-/ai-sdk-0.1.1.tgz","fileCount":7,"integrity":"sha512-an8/h95v2/bJ4kaASnqp1VTO9Wk/Grv/gTRN8tw3O+c535vHBMltCJ9Bi0FigEqnDgn5zvcOelxoZeogFx1siw==","signatures":[{"sig":"MEUCIQCKxKht8TF8K+z8BVljsz4gB07relZu0+mqTT0bBJmhnwIgSYnMvJkjGHKIT+ccd4qy+r7bTGE4hNdHZRrypgDY5Gc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":65740},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"72bbb1dbde7c4ff51809dd661620a349ef71fd84","scripts":{"lint":"eslint src tests --ext .ts","test":"vitest run","build":"tsup src/index.ts --format cjs,esm --dts --clean","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"ferhimedamine","email":"ferhi.med.amine@gmail.com"},"repository":{"url":"git+https://github.com/dakera-ai/dakera-ai-sdk.git","type":"git"},"_npmVersion":"10.9.8","description":"Vercel AI SDK integration for Dakera AI memory — persistent, decay-weighted cross-session memory via language model middleware and tools","directories":{},"_nodeVersion":"22.23.1","_hasShrinkwrap":false,"devDependencies":{"ai":"^7.0.0","zod":"^4.0.0","tsup":"^8.0.0","vitest":"^4.1.5","typescript":"^6.0.3","@types/node":"^26.1.0","@ai-sdk/provider":"^4.0.1","@dakera-ai/dakera":"^0.11.100"},"peerDependencies":{"ai":">=6.0.0","zod":">=3.23.0","@dakera-ai/dakera":">=0.11.54"},"_npmOperationalInternal":{"tmp":"tmp/ai-sdk_0.1.1_1783022091355_0.8475030176207015","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@dakera-ai/ai-sdk","version":"0.1.2","keywords":["vercel","ai-sdk","ai","dakera","memory","middleware","tools","rag","agents","typescript"],"author":{"name":"Dakera Team"},"license":"MIT","_id":"@dakera-ai/ai-sdk@0.1.2","maintainers":[{"name":"ferhimedamine","email":"ferhi.med.amine@gmail.com"}],"homepage":"https://github.com/dakera-ai/dakera-ai-sdk","bugs":{"url":"https://github.com/dakera-ai/dakera-ai-sdk/issues"},"dist":{"shasum":"57e38fe3488ac7975671fc88b08845b43f4fc252","tarball":"https://registry.npmjs.org/@dakera-ai/ai-sdk/-/ai-sdk-0.1.2.tgz","fileCount":7,"integrity":"sha512-ruR5xPN9ZunLCg3o0qvJMhZjfPsqRGrVXZ+gzMGC2o3J4zg+7rT3aPNdFUotZFHDEKId/IUZ+iUlFmZUzIy0Yg==","signatures":[{"sig":"MEUCIAUqXH/Qm4ou0BM6by3g4KaDaL2awH4zkM9mXngULWAsAiEAlgw0T91ofPFRTrOX/ZCGGuUzbGB9zNqEzsz6WPNAxmU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":65740},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"2f13e945a7b1dfd2a8abfca8b4f042765111904b","scripts":{"lint":"eslint src tests --ext .ts","test":"vitest run","build":"tsup src/index.ts --format cjs,esm --dts --clean","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"ferhimedamine","email":"ferhi.med.amine@gmail.com"},"repository":{"url":"git+https://github.com/dakera-ai/dakera-ai-sdk.git","type":"git"},"_npmVersion":"10.9.8","description":"Vercel AI SDK integration for Dakera AI memory — persistent, decay-weighted cross-session memory via language model middleware and tools","directories":{},"_nodeVersion":"22.23.1","_hasShrinkwrap":false,"devDependencies":{"ai":"^7.0.0","zod":"^4.0.0","tsup":"^8.0.0","vitest":"^4.1.5","typescript":"^6.0.3","@types/node":"^26.1.0","@ai-sdk/provider":"^4.0.1","@dakera-ai/dakera":"^0.11.100"},"peerDependencies":{"ai":">=6.0.0","zod":">=3.23.0","@dakera-ai/dakera":">=0.11.54"},"_npmOperationalInternal":{"tmp":"tmp/ai-sdk_0.1.2_1783022362910_0.8131505862066044","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"_id":"@dakera-ai/ai-sdk@0.2.0","bugs":{"url":"https://github.com/dakera-ai/dakera-ai-sdk/issues"},"dist":{"shasum":"01d392b9711acbda8ba1280803b07e91f45e3c09","tarball":"https://registry.npmjs.org/@dakera-ai/ai-sdk/-/ai-sdk-0.2.0.tgz","fileCount":7,"integrity":"sha512-e9tWM+kALh3UKzVsOnTaM/AVZhEhEAAHYjldA8eE/LPkhVEg5vImE196MGKLVwOkRcL/GUtajFyLMibH3zIHgA==","signatures":[{"sig":"MEYCIQD5cFglN4i1vnXF0TQ65Lw79P4K+dLILdkNi05XcDM7GgIhAIqS+H4Tt2c8+DUvwS24VromRfr+mx1z3ZfajrNKVtR5","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD5rLCBCOzBLW4RMCLIguYCAbfaFyI7i+JE4nEK2v29FQIgC88rvJDnNl/aCiKnn+rLpwriC6z4diNo0vaC6tnYvEo="}],"unpackedSize":31339},"main":"dist/index.js","name":"@dakera-ai/ai-sdk","types":"dist/index.d.ts","author":{"name":"Dakera Team"},"module":"dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"2d697bbcb2878a33bd2551b5b20e6ea1ba5df78f","license":"MIT","scripts":{"lint":"eslint src tests --ext .ts","test":"vitest run","build":"tsup src/index.ts --format cjs,esm --dts --clean","typecheck":"tsc --noEmit","test:watch":"vitest"},"version":"0.2.0","_npmUser":{"name":"ferhimedamine","email":"ferhi.med.amine@gmail.com"},"homepage":"https://github.com/dakera-ai/dakera-ai-sdk","keywords":["vercel","ai-sdk","ai","dakera","memory","middleware","tools","rag","agents","typescript"],"repository":{"url":"git+https://github.com/dakera-ai/dakera-ai-sdk.git","type":"git"},"_npmVersion":"10.9.9","description":"Vercel AI SDK integration for Dakera AI memory — persistent, decay-weighted cross-session memory via language model middleware and tools","directories":{},"maintainers":[{"name":"ferhimedamine","email":"ferhi.med.amine@gmail.com"}],"_nodeVersion":"22.23.3","_hasShrinkwrap":false,"devDependencies":{"ai":"^7.0.0","zod":"^4.0.0","tsup":"^8.0.0","vitest":"^4.1.5","typescript":"^6.0.3","@types/node":"^26.1.0","@ai-sdk/provider":"^4.0.1","@dakera-ai/dakera":"^0.12.1"},"peerDependencies":{"ai":">=6.0.0","zod":">=3.23.0","@dakera-ai/dakera":"^0.12.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai-sdk_0.2.0_1790883573956_0.5209031829628326"}}},"time":{"created":"2026-07-02T19:17:54.278Z","modified":"2026-10-01T19:39:34.928Z","0.1.0":"2026-07-02T19:17:54.569Z","0.1.1":"2026-07-02T19:54:51.484Z","0.1.2":"2026-07-02T19:59:23.037Z","0.2.0":"2026-10-01T19:39:34.049Z"},"bugs":{"url":"https://github.com/dakera-ai/dakera-ai-sdk/issues"},"author":{"name":"Dakera Team"},"license":"MIT","homepage":"https://github.com/dakera-ai/dakera-ai-sdk","keywords":["vercel","ai-sdk","ai","dakera","memory","middleware","tools","rag","agents","typescript"],"repository":{"url":"git+https://github.com/dakera-ai/dakera-ai-sdk.git","type":"git"},"description":"Vercel AI SDK integration for Dakera AI memory — persistent, decay-weighted cross-session memory via language model middleware and tools","maintainers":[{"name":"ferhimedamine","email":"ferhi.med.amine@gmail.com"}],"readme":"# @dakera-ai/ai-sdk\n\n[![npm version](https://img.shields.io/npm/v/@dakera-ai/ai-sdk.svg)](https://www.npmjs.com/package/@dakera-ai/ai-sdk)\n[![CI](https://github.com/dakera-ai/dakera-ai-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/dakera-ai/dakera-ai-sdk/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5%2B-blue.svg)](https://www.typescriptlang.org/)\n\nVercel AI SDK integration for [Dakera](https://dakera.ai) — a self-hosted memory server that adds **persistent, decay-weighted vector recall** across agent sessions.\n\nMemories are importance-scored and decay over time, so stale context stops competing with fresh, relevant facts. The integration plugs into the AI SDK's two standard extension points — **language model middleware** and **tools** — so you can add cross-session memory to any AI SDK app without changing your model or provider code.\n\n**Compatibility:** `@dakera-ai/dakera` ^0.12.1; Dakera server v0.12.0 (also compatible with v0.11.108).\n\n## Quick start\n\n```bash\nnpm install @dakera-ai/ai-sdk ai @dakera-ai/dakera zod\n```\n\nRun a Dakera server first (self-hosted, zero external dependencies):\n\n```bash\n# Docker Compose — server + MinIO object storage\ncurl -sSL https://raw.githubusercontent.com/dakera-ai/dakera-deploy/main/docker-compose.yml | \\\n  docker compose -f - up -d\n```\n\nThen set two environment variables:\n\n```bash\nexport DAKERA_URL=http://localhost:3000   # default — can omit\nexport DAKERA_API_KEY=dk-your-key-here\n```\n\n## Pattern 1 — Memory middleware (transparent)\n\n`createDakeraMemoryMiddleware` wraps any language model. On every call it:\n\n1. Recalls the most relevant memories for the current prompt\n2. Injects them as a system message before generation\n3. Stores the new exchange back into Dakera\n\nYour generation code stays unchanged.\n\n```typescript\nimport { generateText, wrapLanguageModel } from \"ai\";\nimport { openai } from \"@ai-sdk/openai\";\nimport { createDakeraMemoryMiddleware } from \"@dakera-ai/ai-sdk\";\n\nconst model = wrapLanguageModel({\n  model: openai(\"gpt-4o\"),\n  middleware: createDakeraMemoryMiddleware({\n    agentId: \"user-1234\",   // scopes memories to this agent / user\n    recallK: 5,             // inject up to 5 relevant memories per call\n  }),\n});\n\n// Session 1\nawait generateText({\n  model,\n  prompt: \"I'm building a Rust vector database called Velox.\",\n});\n\n// Session 2 — days later, different process\nconst { text } = await generateText({\n  model,\n  prompt: \"What am I working on?\",\n});\n// → \"You're building Velox, a Rust vector database.\"\n```\n\n### Streaming\n\nThe middleware works with `streamText` unchanged:\n\n```typescript\nimport { streamText, wrapLanguageModel } from \"ai\";\nimport { openai } from \"@ai-sdk/openai\";\nimport { createDakeraMemoryMiddleware } from \"@dakera-ai/ai-sdk\";\n\nconst model = wrapLanguageModel({\n  model: openai(\"gpt-4o\"),\n  middleware: createDakeraMemoryMiddleware({ agentId: \"user-1234\" }),\n});\n\nconst { textStream } = streamText({\n  model,\n  prompt: \"Summarise what I've told you about my project.\",\n});\n\nfor await (const chunk of textStream) {\n  process.stdout.write(chunk);\n}\n```\n\n### Middleware options\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `agentId` | `string` | — | Scopes stored/recalled memories **(required)** |\n| `apiUrl` | `string` | `$DAKERA_URL` / `http://localhost:3000` | Dakera server URL |\n| `apiKey` | `string` | `$DAKERA_API_KEY` | API key (`dk-...`) |\n| `client` | `DakeraClient` | — | Pre-built client (overrides `apiUrl`/`apiKey`) |\n| `recallK` | `number` | `5` | Memories to recall and inject per call |\n| `minImportance` | `number` | `0` | Minimum importance score to recall (0 – 1) |\n| `importance` | `number` | `0.7` | Importance assigned to stored memories (0 – 1) |\n| `store` | `boolean` | `true` | Persist the exchange after generation |\n| `header` | `string` | `\"Relevant memories…\"` | System-message header prepended to the memory block |\n\n## Pattern 2 — Memory tools (model-driven)\n\n`createDakeraTools` returns `recallMemory` and `storeMemory` tools. The model decides when to look something up or persist a new fact — useful for agentic workflows where explicit memory control improves quality.\n\n```typescript\nimport { generateText } from \"ai\";\nimport { openai } from \"@ai-sdk/openai\";\nimport { createDakeraTools } from \"@dakera-ai/ai-sdk\";\n\nconst tools = createDakeraTools({ agentId: \"user-1234\" });\n\nconst { text } = await generateText({\n  model: openai(\"gpt-4o\"),\n  tools,\n  maxSteps: 4,\n  prompt: \"Remember that I prefer metric units. Then convert 5 miles to km.\",\n});\n// Model calls storeMemory(\"User prefers metric units\", importance 0.8),\n// then answers: \"5 miles = 8.047 km\"\n```\n\n### Tool options\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `agentId` | `string` | — | Scopes stored/recalled memories **(required)** |\n| `apiUrl` | `string` | `$DAKERA_URL` / `http://localhost:3000` | Dakera server URL |\n| `apiKey` | `string` | `$DAKERA_API_KEY` | API key (`dk-...`) |\n| `client` | `DakeraClient` | — | Pre-built client (overrides `apiUrl`/`apiKey`) |\n| `recallK` | `number` | `5` | Default `topK` for the recall tool |\n| `importance` | `number` | `0.7` | Default importance for the store tool |\n\n## Pattern 3 — Combined (transparent + explicit)\n\nUse the middleware for automatic continuity and the tools when you want the model to manage memory deliberately in the same call:\n\n```typescript\nimport { generateText, wrapLanguageModel } from \"ai\";\nimport { openai } from \"@ai-sdk/openai\";\nimport { createDakeraMemoryMiddleware, createDakeraTools } from \"@dakera-ai/ai-sdk\";\nimport { DakeraClient } from \"@dakera-ai/dakera\";\n\n// Share one client instance across middleware and tools\nconst client = new DakeraClient({ baseUrl: process.env.DAKERA_URL! });\nconst agentId = \"user-1234\";\n\nconst model = wrapLanguageModel({\n  model: openai(\"gpt-4o\"),\n  // Recall automatically, but let tools handle persistence\n  middleware: createDakeraMemoryMiddleware({ client, agentId, store: false }),\n});\n\nconst tools = createDakeraTools({ client, agentId });\n\nconst { text } = await generateText({\n  model,\n  tools,\n  maxSteps: 6,\n  system:\n    \"You are a helpful assistant. Use storeMemory for facts the user will want remembered across sessions.\",\n  prompt: \"My deadline for the Velox project is Friday the 11th.\",\n});\n```\n\n## Using a pre-built client\n\nShare connection config across multiple agents or avoid repeating credentials:\n\n```typescript\nimport { DakeraClient } from \"@dakera-ai/dakera\";\nimport { createDakeraMemoryMiddleware, createDakeraTools } from \"@dakera-ai/ai-sdk\";\n\nconst client = new DakeraClient({\n  baseUrl: \"http://my-dakera.internal:3000\",\n  apiKey: process.env.DAKERA_API_KEY,\n});\n\n// All agents share the same connection\nconst supportMiddleware = createDakeraMemoryMiddleware({ client, agentId: \"support-bot\" });\nconst salesTools = createDakeraTools({ client, agentId: \"sales-bot\" });\n```\n\n## Running the examples\n\n```bash\ngit clone https://github.com/dakera-ai/dakera-ai-sdk\ncd dakera-ai-sdk/examples\nnpm install\nDAKERA_URL=http://localhost:3000 DAKERA_API_KEY=dk-dev npx tsx 01-middleware.ts\n```\n\nSee [`examples/README.md`](examples/README.md) for all examples and prerequisites.\n\n## Troubleshooting\n\n**`Cannot find name 'process'`** — add `\"types\": [\"node\"]` to your `tsconfig.json` `compilerOptions`.\n\n**Memory recall is empty on first call** — expected. The first call has no history. After the first exchange the store step runs, and subsequent calls will recall.\n\n**Storage errors break my app** — they won't. The middleware catches all storage errors so a Dakera outage never interrupts generation.\n\n**Getting 401 from the server** — verify `DAKERA_API_KEY` matches the server's env. Keys look like `dk-...` when generated via the Dakera admin API, but any shared string works.\n\n**Using with Next.js / edge runtime** — set `DAKERA_URL` and `DAKERA_API_KEY` as Next.js environment variables and import from `@dakera-ai/ai-sdk` in server components or API routes.\n\n## License\n\nMIT © [Dakera](https://dakera.ai)\n","readmeFilename":"README.md"}