
Security News
GPT-6 Astra Attempts Supply Chain Attacks Against Open Source Maintainers in Testing
GPT-6 Astra hits 100% on ExploitBench and finds zero-days autonomously, while independent tests reveal scope violations and monitoring gaps.
@memoweft/adapter-ai-sdk
Advanced tools
Vercel AI SDK adapter for MemoWeft — inject long-term memory via middleware (recall) and persist the user's turn on finish (write).
中文版 · README.zh-CN.md
Vercel AI SDK adapter for MemoWeft. Give your AI SDK app long-term memory: read = recall relevant memory and inject it into the prompt; write = persist the user's own words after each turn.
This is an external integration package. It wraps MemoWeft's public Core facade (createMemoWeftCore) — it does not touch Core internals. ai is a peer dependency (bring your own).
@memoweft/adapter-ai-sdk@0.2.3 supports Core ^0.5.1 || ^0.6.0 || ^0.7.0 || ^1.0.0-rc.1. To use the current 1.0 release candidate:
npm i ai memoweft@rc @memoweft/adapter-ai-sdk@0.2.3
To build the adapter from source instead, use the repository workspace:
git clone https://github.com/memoweft/memoweft.git
cd memoweft
npm ci
npm run build
npm run build --workspace @memoweft/adapter-ai-sdk
Its peer range is ai ^7 and memoweft ^0.5.1 || ^0.6.0 || ^0.7.0 || ^1.0.0-rc.1; 0.2.3 resolves cleanly against Core 0.7.0, the 1.0 RC series, and final 1.x releases with no --legacy-peer-deps. You also need an ai provider (e.g. @ai-sdk/openai) for a real model.
createMemoWeftMiddleware(core) returns a Vercel AI SDK LanguageModelMiddleware. In transformParams it takes the last user message text, calls core.recall({ query }), and injects the recalled cognitions into that user message before the model sees it.
import { wrapLanguageModel, generateText } from 'ai';
import { createMemoWeftCore } from 'memoweft';
import { createMemoWeftMiddleware } from '@memoweft/adapter-ai-sdk';
const core = createMemoWeftCore({ dbPath: './memory.db' });
const model = wrapLanguageModel({
model: baseModel, // your @ai-sdk/* model
middleware: createMemoWeftMiddleware(core),
});
const { text } = await generateText({ model, prompt: 'Explain recursion.' });
The injected block uses MemoWeft's own neutral wording (ported verbatim from Core's knowledgeBlock). Low-confidence items are explicitly marked "only guesses — do not treat as established facts." The adapter adds no persona / character prompt of its own — tone and role stay the host's job.
If recall returns nothing, the query has no user text, or recall fails, the adapter passes the original params through unchanged.
Options: { subjectId?, lang?: 'en' | 'zh', onRecall? }.
createPersistOnEnd(core, { userMessage, originId }) returns a callback for generateText/streamText's onEnd (the SDK's onFinish is a deprecated alias for onEnd). After the turn ends it calls core.ingestUserMessage to store the user's own words as one spoken evidence.
import { createPersistOnEnd } from '@memoweft/adapter-ai-sdk';
const userMessage = 'I strongly prefer short, direct answers.';
await generateText({
model,
prompt: userMessage,
onEnd: createPersistOnEnd(core, { userMessage, originId: 'turn-1' }),
});
Why you pass userMessage explicitly: the SDK's onEnd event carries only result-side fields (text, steps, usage, response…). It does not carry the original user input, and the request body sent to the provider has already been rewritten by the read middleware (recalled memory injected). So the only clean source of the user's real words is the value you already hold when you call generateText. The onEnd event object is not used — it is just the trigger.
originId (your turn/message id) for idempotency — the same turn stores at most one evidence even if onEnd fires more than once.ingestUserMessage stores spoken evidence, which does not involve the observed cloud-consent flags.onError (or are swallowed), leaving the host's turn handling intact.There is also a plain persistUserTurn(core, { userMessage, originId? }) if you want to call it outside an onEnd hook.
See examples/basic.ts — a two-turn chat where turn 1's words are stored and recalled into turn 2's prompt.
The Host (apps/memoweft-host) is MemoWeft's reference application — chat UI, multi-session, backups. This adapter is the opposite direction: it lets your app (built on the Vercel AI SDK) reuse MemoWeft as a memory backend, without the Host. Both talk to the same public Core facade; they don't depend on each other. Pick the Host if you want a ready UI; pick this adapter if you already have an AI SDK app and just want the memory layer.
observed cloud sharing, and does not pass authorization bits on the write path.MIT
FAQs
Vercel AI SDK adapter for MemoWeft — inject long-term memory via middleware (recall) and persist the user's turn on finish (write).
We found that @memoweft/adapter-ai-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
GPT-6 Astra hits 100% on ExploitBench and finds zero-days autonomously, while independent tests reveal scope violations and monitoring gaps.

Product
Socket can now send alerts and supply chain attack notifications to Microsoft Teams, with filters that route the right updates to each channel.

Security News
pnpm 12 rewrites the package manager in Rust, cutting install times by up to 90% while preserving pnpm 11 workflows and lockfiles.