Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions packages/tools/src/ai-sdk-exports.test.ts
Original file line number Diff line number Diff line change
@@ -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) =>
`<context><user_profile>${data.userMemories}</user_profile><relevant_memories>${data.generalSearchMemories}</relevant_memories></context>`

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(
"<context><user_profile>- Prefers TypeScript</user_profile><relevant_memories>- Asked about zod</relevant_memories></context>",
)
})
})
10 changes: 9 additions & 1 deletion packages/tools/src/ai-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"