Skip to content

fix(tools): make check-types pass on main - #1861

Open
Kulraj69 wants to merge 10 commits into
supermemoryai:mainfrom
Kulraj69:fix/tools-check-types-zod4
Open

Kulraj69 wants to merge 10 commits into
supermemoryai:mainfrom
Kulraj69:fix/tools-check-types-zod4

Conversation

@Kulraj69

@Kulraj69 Kulraj69 commented Oct 31, 2026 •

Copy link
Copy Markdown

What

bun run check-types in packages/tools fails on main (118 errors). This PR makes it pass (0 errors).

Root cause

packages/tools pins zod: ^4.6.6, but the ai SDK's FlexibleSchema types resolve through the hoisted root [email protected]. Two physical zod copies → every tool() schema in src/ai-sdk.ts fails tsc with ZodObject<...> is not assignable to FlexibleSchema<never>. CI doesn't catch it because ci.yml type-checks only sdk-playground and memory-graph.

Changes

  • zod alignment: packages/tools now pins zod: ^3.25.76 (same as the workspace root) and imports from its bundled zod/v4, so tool() schemas and ai's types come from one physical copy. The package keeps the v4 API; no source behavior change.
  • src/shared/cache.ts: constrain MemoryCache<T extends {}> and instantiate new LRUCache<string, T>(...) so lru-cache v11 generics hold.
  • tsconfig.json: exclude test/chatapp (a standalone Next.js example app with its own tsconfig/jsx/deps, e.g. @posthog/ai) from the package type-check.
  • Test/example drift (no behavior changes):
    • 5 files: stale ./claude-memory import → ../src/claude-memory
    • test-supermemory.ts: update withSupermemory call to the current 2-arg (client, options) shape with required namespace/id
    • mastra tests: add the now-required state to ProcessInputArgs literals (35 sites)
    • with-supermemory mocks: add required totalTokens to LanguageModelV2Usage, drop the stale rawCall field
    • openai-middleware / voltagent unit tests: strict-index and UIMessage typing fixes
    • anthropic-example.ts: type the command literals (MemoryCommand), narrow block.input, fix the messages[0] index and BetaContentBlock[] assignment

Verified locally (bun 1.3.6, bun install --frozen-lockfile equivalent)

  • tsc --noEmit: 0 errors in packages/tools; also re-verified 0 errors in validation, lib, hooks, ui, memory-graph, apps/mcp
  • bun run --cwd packages/tools test:unit: 150/150 tests pass (8 files)
  • bun run --cwd packages/tools build: passes
  • bunx biome ci on touched files: no errors

Note for maintainers

ci.yml doesn't type-check packages/tools, which is how this drifted. Adding a bun run --cwd packages/tools check-types step would cover it - happy to include that here if you want (your AGENTS.md asks contributors not to touch workflows unprompted, so I left it out).

Refs the check-types note in #1738.

Ask Polylane for an impact assessment of this pull request:

Assess with Polylane

@Kulraj69

Copy link
Copy Markdown
Author

Hi — this PR has been open since Oct 31 with no review yet. It takes bun run check-types in packages/tools from 118 errors on main to 0 by removing the duplicate zod copy that the ai SDK's types resolve through. It currently shows conflicts against main; I'm happy to rebase if you want to look at it.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant