From 46d97b624cabff33d4de7596afa0ecad4dda4d3e Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Tue, 21 Apr 2026 22:19:33 +0000 Subject: [PATCH] fix: add biome-ignore comments for AI SDK internal types and fix formatting The AI SDK middleware requires `any` types because the SDK's internal call options and prompt types are not exported. Added biome-ignore comments to suppress noExplicitAny warnings and ran format-lint to fix formatting issues. Co-Authored-By: Claude Opus 4.5 --- .../memory-graph/memory-graph-wrapper.tsx | 10 +++-- .../src/components/memory-graph.tsx | 20 ++++++--- .../convex-component/src/ai-sdk/middleware.ts | 44 +++++++++++++------ .../convex-component/src/component/actions.ts | 14 +++++- .../src/convex-component/src/react/index.tsx | 1 - .../tools/test/claude-memory-real-example.ts | 28 ++++++++---- 6 files changed, 82 insertions(+), 35 deletions(-) diff --git a/apps/web/components/memory-graph/memory-graph-wrapper.tsx b/apps/web/components/memory-graph/memory-graph-wrapper.tsx index 655f2482..6b28f6a1 100644 --- a/apps/web/components/memory-graph/memory-graph-wrapper.tsx +++ b/apps/web/components/memory-graph/memory-graph-wrapper.tsx @@ -71,10 +71,12 @@ export function MemoryGraph({ maxNodes={maxNodes} canvasRef={canvasRef} totalCount={totalCount} - colors={{ - bg: "transparent", - edgeDerives: "#9ca3af", - } as any} + colors={ + { + bg: "transparent", + edgeDerives: "#9ca3af", + } as any + } {...rest} > {children} diff --git a/packages/memory-graph/src/components/memory-graph.tsx b/packages/memory-graph/src/components/memory-graph.tsx index 66631fd8..49e08c50 100644 --- a/packages/memory-graph/src/components/memory-graph.tsx +++ b/packages/memory-graph/src/components/memory-graph.tsx @@ -197,7 +197,11 @@ export function MemoryGraph({ setViewportVersion((v) => v + 1) } - const { hasMore: more, isLoadingMore: loading, onLoadMore: load } = loadMoreRef.current + const { + hasMore: more, + isLoadingMore: loading, + onLoadMore: load, + } = loadMoreRef.current if (!more || loading || !load || !viewportRef.current) return const vp = viewportRef.current @@ -205,14 +209,17 @@ export function MemoryGraph({ if (currentNodes.length === 0) return const topLeft = vp.screenToWorld(0, 0) - const bottomRight = vp.screenToWorld(containerSize.width, containerSize.height) + const bottomRight = vp.screenToWorld( + containerSize.width, + containerSize.height, + ) const viewW = bottomRight.x - topLeft.x const viewH = bottomRight.y - topLeft.y - let minX = Infinity - let minY = Infinity - let maxX = -Infinity - let maxY = -Infinity + let minX = Number.POSITIVE_INFINITY + let minY = Number.POSITIVE_INFINITY + let maxX = Number.NEGATIVE_INFINITY + let maxY = Number.NEGATIVE_INFINITY for (const n of currentNodes) { if (n.x < minX) minX = n.x if (n.y < minY) minY = n.y @@ -613,7 +620,6 @@ export function MemoryGraph({ colors={colors} /> - {!isLoading && !nodes.some((n) => n.type === "document") && children && (
{children}
)} diff --git a/packages/tools/src/convex-component/src/ai-sdk/middleware.ts b/packages/tools/src/convex-component/src/ai-sdk/middleware.ts index 33bdfe17..0c425b7d 100644 --- a/packages/tools/src/convex-component/src/ai-sdk/middleware.ts +++ b/packages/tools/src/convex-component/src/ai-sdk/middleware.ts @@ -13,7 +13,9 @@ import type { FunctionReference } from "convex/server" * a direct dependency on @ai-sdk/provider. */ interface WrappableLanguageModel { + // biome-ignore lint/suspicious/noExplicitAny: AI SDK internal types not exported doGenerate: (options: any) => Promise + // biome-ignore lint/suspicious/noExplicitAny: AI SDK internal types not exported doStream: (options: any) => Promise [key: string]: unknown } @@ -49,7 +51,7 @@ export interface SupermemoryOptions { export interface MemoryPromptData { userMemories: string generalSearchMemories: string - searchResults: any[] + searchResults: unknown[] } const DEFAULT_PROMPT_TEMPLATE = (data: MemoryPromptData) => @@ -119,10 +121,12 @@ export function withSupermemory( return { ...model, + // biome-ignore lint/suspicious/noExplicitAny: AI SDK internal types not exported doGenerate: async (callOptions: any) => { try { // Extract user's last message for query-based search const lastUserMessage = callOptions.prompt + // biome-ignore lint/suspicious/noExplicitAny: AI SDK internal types not exported .filter((msg: any) => msg.role === "user") .slice(-1)[0] @@ -131,13 +135,14 @@ export function withSupermemory( ? typeof lastUserMessage.content === "string" ? lastUserMessage.content : lastUserMessage.content + // biome-ignore lint/suspicious/noExplicitAny: AI SDK internal types not exported .map((c: any) => (c.type === "text" ? c.text : "")) .join(" ") : "" let userMemories = "" let generalSearchMemories = "" - let searchResults: any[] = [] + let searchResults: unknown[] = [] // Fetch profile if needed if (mode === "profile" || mode === "full") { @@ -175,6 +180,7 @@ export function withSupermemory( searchResults = searchResult.results generalSearchMemories = searchResults .map( + // biome-ignore lint/suspicious/noExplicitAny: search result types not exported (r: any) => `- ${r.memory || r.chunk} (similarity: ${r.similarity.toFixed(2)})`, ) @@ -204,11 +210,15 @@ export function withSupermemory( if (addMemory === "always" && userQuery) { if (verbose) console.log("[Supermemory] Auto-saving user message...") - convexClient.action(addAction, { - content: userQuery, - containerTag, - metadata: { source: "ai-middleware", auto: true }, - }).catch((e) => console.error("[Supermemory] Failed to auto-save:", e)) + convexClient + .action(addAction, { + content: userQuery, + containerTag, + metadata: { source: "ai-middleware", auto: true }, + }) + .catch((e) => + console.error("[Supermemory] Failed to auto-save:", e), + ) } // Call original model with enhanced context @@ -223,10 +233,12 @@ export function withSupermemory( } }, + // biome-ignore lint/suspicious/noExplicitAny: AI SDK internal types not exported doStream: async (callOptions: any) => { // For streaming, we inject context upfront then stream normally try { const lastUserMessage = callOptions.prompt + // biome-ignore lint/suspicious/noExplicitAny: AI SDK internal types not exported .filter((msg: any) => msg.role === "user") .slice(-1)[0] @@ -235,13 +247,14 @@ export function withSupermemory( ? typeof lastUserMessage.content === "string" ? lastUserMessage.content : lastUserMessage.content + // biome-ignore lint/suspicious/noExplicitAny: AI SDK internal types not exported .map((c: any) => (c.type === "text" ? c.text : "")) .join(" ") : "" let userMemories = "" let generalSearchMemories = "" - let searchResults: any[] = [] + let searchResults: unknown[] = [] if (mode === "profile" || mode === "full") { const profile = await convexClient.action(profileAction, { @@ -265,6 +278,7 @@ export function withSupermemory( searchResults = searchResult.results generalSearchMemories = searchResults + // biome-ignore lint/suspicious/noExplicitAny: search result types not exported .map((r: any) => `- ${r.memory || r.chunk}`) .join("\n") } @@ -281,11 +295,15 @@ export function withSupermemory( ] if (addMemory === "always" && userQuery) { - convexClient.action(addAction, { - content: userQuery, - containerTag, - metadata: { source: "ai-middleware", auto: true }, - }).catch((e) => console.error("[Supermemory] Failed to auto-save:", e)) + convexClient + .action(addAction, { + content: userQuery, + containerTag, + metadata: { source: "ai-middleware", auto: true }, + }) + .catch((e) => + console.error("[Supermemory] Failed to auto-save:", e), + ) } return await model.doStream({ diff --git a/packages/tools/src/convex-component/src/component/actions.ts b/packages/tools/src/convex-component/src/component/actions.ts index 48e81351..525b49f6 100644 --- a/packages/tools/src/convex-component/src/component/actions.ts +++ b/packages/tools/src/convex-component/src/component/actions.ts @@ -145,7 +145,12 @@ export const search = action({ }) // Log API call - const logBody = { q: args.q, containerTag: args.containerTag, searchMode: args.searchMode, limit: args.limit } + const logBody = { + q: args.q, + containerTag: args.containerTag, + searchMode: args.searchMode, + limit: args.limit, + } await ctx.runMutation(internal.mutations.logApiCall, { endpoint: "search", containerTag: args.containerTag, @@ -159,7 +164,12 @@ export const search = action({ const responseTime = Date.now() - startTime try { - const logBody = { q: args.q, containerTag: args.containerTag, searchMode: args.searchMode, limit: args.limit } + const logBody = { + q: args.q, + containerTag: args.containerTag, + searchMode: args.searchMode, + limit: args.limit, + } await ctx.runMutation(internal.mutations.logApiCall, { endpoint: "search", containerTag: args.containerTag, diff --git a/packages/tools/src/convex-component/src/react/index.tsx b/packages/tools/src/convex-component/src/react/index.tsx index c55a70a0..4baffe75 100644 --- a/packages/tools/src/convex-component/src/react/index.tsx +++ b/packages/tools/src/convex-component/src/react/index.tsx @@ -153,7 +153,6 @@ export function listMemories( return useQuery(query, args) as Memory[] | undefined } - // Export all types export type { AddMemoryArgs, diff --git a/packages/tools/test/claude-memory-real-example.ts b/packages/tools/test/claude-memory-real-example.ts index bb6070d4..dbd03b21 100644 --- a/packages/tools/test/claude-memory-real-example.ts +++ b/packages/tools/test/claude-memory-real-example.ts @@ -119,10 +119,16 @@ export async function realClaudeMemoryExample() { const toolResults = [] if (responseData.content) { - const memoryToolCalls = responseData.content.filter( - (block: any): block is { type: 'tool_use'; id: string; name: 'memory'; input: { command: MemoryCommand; path: string } } => - block.type === "tool_use" && block.name === "memory", - ) + const memoryToolCalls = responseData.content.filter( + ( + block: any, + ): block is { + type: "tool_use" + id: string + name: "memory" + input: { command: MemoryCommand; path: string } + } => block.type === "tool_use" && block.name === "memory", + ) const results = await Promise.all( memoryToolCalls.map((block: any) => { @@ -196,10 +202,16 @@ export async function processClaudeResponse( const toolResults = [] if (claudeResponseData.content) { - const memoryToolCalls = claudeResponseData.content.filter( - (block: any): block is { type: 'tool_use'; id: string; name: 'memory'; input: { command: MemoryCommand; path: string } } => - block.type === "tool_use" && block.name === "memory", - ) + const memoryToolCalls = claudeResponseData.content.filter( + ( + block: any, + ): block is { + type: "tool_use" + id: string + name: "memory" + input: { command: MemoryCommand; path: string } + } => block.type === "tool_use" && block.name === "memory", + ) const results = await Promise.all( memoryToolCalls.map((block: any) =>