From 76a32dfd00b472cc54f31949b668f2e5024d7258 Mon Sep 17 00:00:00 2001 From: Sreeram Sreedhar Date: Mon, 20 Apr 2026 16:35:58 -0700 Subject: [PATCH] bug fixes --- packages/tools/src/convex-component/src/ai-sdk/tools.ts | 2 -- packages/tools/src/convex-component/src/client/index.ts | 1 + .../tools/src/convex-component/src/component/queries.ts | 7 +++++-- packages/tools/src/convex-component/src/react/index.tsx | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/tools/src/convex-component/src/ai-sdk/tools.ts b/packages/tools/src/convex-component/src/ai-sdk/tools.ts index 42ed9e11..db04e9ee 100644 --- a/packages/tools/src/convex-component/src/ai-sdk/tools.ts +++ b/packages/tools/src/convex-component/src/ai-sdk/tools.ts @@ -48,7 +48,6 @@ export function supermemoryConvexTools( * Search through user's memories using semantic search * The AI agent calls this when it needs to recall information */ - // @ts-expect-error - AI SDK v4 tool type compatibility searchMemories: tool({ description: "Search through the user's memories and past conversations. Use this to recall information the user has shared previously, their preferences, or relevant context from past interactions.", @@ -113,7 +112,6 @@ export function supermemoryConvexTools( * Add new information to user's memory * The AI agent calls this when the user shares important information */ - // @ts-expect-error - AI SDK v4 tool type compatibility addMemory: tool({ description: "Store new information about the user that should be remembered for future conversations. Use this when the user shares preferences, facts about themselves, or important context that should be recalled later.", diff --git a/packages/tools/src/convex-component/src/client/index.ts b/packages/tools/src/convex-component/src/client/index.ts index 23069ef9..03df67ce 100644 --- a/packages/tools/src/convex-component/src/client/index.ts +++ b/packages/tools/src/convex-component/src/client/index.ts @@ -201,6 +201,7 @@ export function createSupermemoryClient( */ getApiStats: async (args?: { containerTag?: string + limit?: number }): Promise => { return await client.query(query("getApiStats"), args || {}) }, diff --git a/packages/tools/src/convex-component/src/component/queries.ts b/packages/tools/src/convex-component/src/component/queries.ts index b230a6b4..75e4411f 100644 --- a/packages/tools/src/convex-component/src/component/queries.ts +++ b/packages/tools/src/convex-component/src/component/queries.ts @@ -156,16 +156,19 @@ export const getApiLogs = query({ export const getApiStats = query({ args: { containerTag: v.optional(v.string()), + limit: v.optional(v.number()), }, handler: async (ctx, args) => { + const limit = args.limit || 1000 const logs = args.containerTag ? await ctx.db .query("apiLogs") .withIndex("by_container", (q) => q.eq("containerTag", args.containerTag), ) - .collect() - : await ctx.db.query("apiLogs").collect() + .order("desc") + .take(limit) + : await ctx.db.query("apiLogs").order("desc").take(limit) const stats = { totalCalls: logs.length, diff --git a/packages/tools/src/convex-component/src/react/index.tsx b/packages/tools/src/convex-component/src/react/index.tsx index af4f8066..8be3f8c1 100644 --- a/packages/tools/src/convex-component/src/react/index.tsx +++ b/packages/tools/src/convex-component/src/react/index.tsx @@ -290,7 +290,7 @@ export function useApiLogs( * ``` */ export function useApiStats( - args?: { containerTag?: string }, + args?: { containerTag?: string; limit?: number }, componentPath = "supermemory", ) { const query =