@supermemory/tools 从 1.4.x 升级到 2.0.0 要改哪些代码 supermemory/tools 从 1.4.x 升级到 2.0.0 要改哪些代码【免费下载链接】supermemoryMemory and context engine app that is extremely fast, scalable, and can be run fully locally. The Memory API for the AI era.项目地址: https://gitcode.com/GitHub_Trending/su/supermemorysupermemory/toolsv2.0.0 是一次破坏性升级breaking release四个集成Vercel AI SDK、OpenAI、Mastra、VoltAgent的 API 统一为单一的配置对象签名并统一了会话分组概念。如果你当前的代码还在用 1.4.x 的写法位置参数传containerTag、conversationId或threadId分组会话升级到 2.0.0 后这些调用点都会失效。官方文档明确建议更新调用并重新测试后再在生产中升级依赖。破坏性改动一览区域v1.4.xv2.0.0签名withSupermemory(model, user-123, { ... })withSupermemory(model, { containerTag: user-123, ... })会话分组conversationIdVercel/OpenAI、threadIdMastra统一为customIdcustomId可选必填— 缺失或为空时抛错containerTag位置参数选项对象上的必填字段addMemory默认值neveralwaysVoltAgentverbose硬编码为false从选项读取、实际生效升级前需要SUPERMEMORY_API_KEY或调用时传apiKey这一点两个版本都要求不受本次升级影响。第一步升级依赖npm install supermemory/tools^2.0.0第二步找出所有需要改的调用点在代码库中搜索以下符号定位所有受影响的调用点withSupermemory(SupermemoryInputProcessorSupermemoryOutputProcessorcreateSupermemoryProcessorcreateSupermemoryOutputProcessor然后把改动按集成类型逐一处理。Vercel AI SDK位置参数改为配置对象v1.4.x 的旧写法// v1.4.x import { withSupermemory } from supermemory/tools/ai-sdk; const model withSupermemory(openai(gpt-4), user-123, { conversationId: conv-456, mode: full, });改为 v2.0.0// v2.0.0 import { withSupermemory } from supermemory/tools/ai-sdk; const model withSupermemory(openai(gpt-4), { containerTag: user-123, customId: conv-456, mode: full, });注意两点原来的第二个位置参数user-123移入选项对象字段名变为containerTagconversationId改名为customId且必填——传空字符串或省略会在构造时直接抛错customId is required — provide a non-empty string to group messages into a single document。OpenAI SDK同样的签名迁移// v1.4.x import { withSupermemory } from supermemory/tools/openai; const client withSupermemory(openai, user-123, { conversationId: conv-456, });// v2.0.0 import { withSupermemory } from supermemory/tools/openai; const client withSupermemory(openai, { containerTag: user-123, customId: conv-456, });OpenAI 集成中containerTag和customId都会被校验缺失时抛出带明确错误信息的异常。Mastra构造函数和工厂函数都改为单一选项参数threadId 消失v1.4.x// v1.4.x import { SupermemoryInputProcessor, createSupermemoryOutputProcessor, } from supermemory/tools/mastra; const input new SupermemoryInputProcessor(user-123, { mode: full, }); const output createSupermemoryOutputProcessor(user-123, { threadId: conv-456, addMemory: always, });v2.0.0// v2.0.0 import { SupermemoryInputProcessor, createSupermemoryOutputProcessor, } from supermemory/tools/mastra; const input new SupermemoryInputProcessor({ containerTag: user-123, customId: conv-456, mode: full, }); const output createSupermemoryOutputProcessor({ containerTag: user-123, customId: conv-456, });threadId已移除一律用customId替代。有一个服务端场景的行为值得注意Mastra 的RequestContext中的 thread ID 仍然优先于构造时传入的customId——后者只作为没有 per-request thread ID 时的回退值源码实现见 getEffectiveCustomId。VoltAgent调用形状不变但有两处行为变化VoltAgent 本来就使用配置对象签名所以调用形状不需要改。v2.0.0 带来两个行为修复verbose: true现在真正生效v1.4.x 中硬编码为false。如果你此前隐式依赖verbose: false而传了verbose: true升级后会出现日志按需调整。当mode: profile下设置了高级搜索参数threshold、limit、rerank、rewriteQuery、filters、include、searchMode时会记录一条运行时警告——这些参数在 profile 模式下会被忽略。新默认值addMemory 从 never 变为 always四个集成的addMemory默认值都从never变成了always。如果你的 v1.4.x 代码依赖旧的never默认行为只检索、不写入新记忆必须显式声明const model withSupermemory(openai(gpt-4), { containerTag: user-123, customId: conv-456, addMemory: never, // preserve v1.4.x behavior });会话持久化路径变了v1.4.x 中 Vercel 中间件在没有传conversationId时会回退到client.add并使用合成的customId。v2.0.0 中由于customId必填所有会话持久化统一走/v4/conversations端点通过addConversation没有回退路径实现见 conversations-client.ts。验证跑一遍测试套件官方迁移清单的最后一项就是运行你的测试套件。原因是 v2.0.0 的校验都发生在构造时——缺失containerTag或customId、customId为空字符串都会在withSupermemory(...)或 Processor 构造那一刻立即抛错不需要等实际调用模型才能发现。也就是说只要代码能构造成功、测试通过字段层面的迁移就完成了再配合实际跑一次对话请求确认记忆检索与写入正常就可以把版本推到生产。继续深入的参考Vercel AI SDK 集成文档OpenAI 集成文档Mastra 集成文档VoltAgent 集成文档升级指南原文tools-v2-upgrade.mdx【免费下载链接】supermemoryMemory and context engine app that is extremely fast, scalable, and can be run fully locally. The Memory API for the AI era.项目地址: https://gitcode.com/GitHub_Trending/su/supermemory创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考