From 8648c28cbc82fa8c8527b3ba7766a4938de19f2f Mon Sep 17 00:00:00 2001 From: Agnik47 <140933190+Agnik47@users.noreply.github.com> Date: Fri, 21 Aug 2026 18:23:39 +0530 Subject: [PATCH] fix(tools): export the promptTemplate types from @supermemory/tools/ai-sdk The documented custom prompt-template example does not compile: import { withSupermemory, type MemoryPromptData } from "@supermemory/tools/ai-sdk" // ^ TS2305: no exported member 'MemoryPromptData' `src/ai-sdk.ts` re-exported only `withSupermemory` from `./vercel`, dropping `MemoryPromptData`, `PromptTemplate` and `WithSupermemoryOptions`. `./vercel` is not listed in the package's `exports` map, so those types were unreachable from anywhere in the published package -- every `promptTemplate` snippet in packages/tools/README.md and apps/docs/integrations/ai-sdk.mdx fails to typecheck as written. The sibling entry points already do this: `@supermemory/tools/mastra` and `@supermemory/tools/voltagent` both export `PromptTemplate` and `MemoryPromptData`. The AI SDK entry point was the only one that did not. `promptTemplate` has been documented for the AI SDK since #660 and the type has never been reachable from it. Adds a regression test that imports the three types and exercises the documented template, so the re-export cannot be dropped again without `check-types` failing. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01NhupP1YqDMS3K1xouqwUnf --- packages/tools/src/ai-sdk-exports.test.ts | 41 +++++++++++++++++++++++ packages/tools/src/ai-sdk.ts | 10 +++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 packages/tools/src/ai-sdk-exports.test.ts diff --git a/packages/tools/src/ai-sdk-exports.test.ts b/packages/tools/src/ai-sdk-exports.test.ts new file mode 100644 index 000000000..d04d07d95 --- /dev/null +++ b/packages/tools/src/ai-sdk-exports.test.ts @@ -0,0 +1,41 @@ +import { describe, expect, it } from "vitest" +import { + type MemoryPromptData, + type PromptTemplate, + type WithSupermemoryOptions, + withSupermemory, +} from "./ai-sdk" + +// The documented custom prompt-template example (packages/tools/README.md and +// apps/docs/integrations/ai-sdk.mdx) imports these types from this entry point. +// `./vercel` is not listed in the package's `exports` map, so there is nowhere +// else a consumer can reach them from: dropping the re-export again breaks +// every documented `promptTemplate` snippet at compile time. Importing and +// using them here makes `check-types` fail if that happens. +describe("@supermemory/tools/ai-sdk public surface", () => { + it("re-exports the middleware wrapper", () => { + expect(typeof withSupermemory).toBe("function") + }) + + it("types the documented promptTemplate example", () => { + const claudePrompt: PromptTemplate = (data: MemoryPromptData) => + `${data.userMemories}${data.generalSearchMemories}` + + const options: WithSupermemoryOptions = { + containerTag: "user-123", + customId: "conv-1", + mode: "full", + promptTemplate: claudePrompt, + } + + expect( + options.promptTemplate?.({ + userMemories: "- Prefers TypeScript", + generalSearchMemories: "- Asked about zod", + searchResults: [{ memory: "Prefers TypeScript" }], + }), + ).toBe( + "- Prefers TypeScript- Asked about zod", + ) + }) +}) diff --git a/packages/tools/src/ai-sdk.ts b/packages/tools/src/ai-sdk.ts index f8d88154f..80a5607c5 100644 --- a/packages/tools/src/ai-sdk.ts +++ b/packages/tools/src/ai-sdk.ts @@ -372,4 +372,12 @@ export function supermemoryTools( } } -export { withSupermemory } from "./vercel" +// `./vercel` is not a published subpath, so this entry point is the only way +// consumers can reach the middleware types — including the `promptTemplate` +// data shape used by the documented custom-template example. +export { + withSupermemory, + type WithSupermemoryOptions, + type PromptTemplate, + type MemoryPromptData, +} from "./vercel"