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"