From 9a9b6c00f999c5f13403369ac2685873fab439f7 Mon Sep 17 00:00:00 2001 From: Antonio Piazza Date: Fri, 10 Jan 2025 08:21:46 +0100 Subject: [PATCH 1/4] Fix seed values Fixed unquoted column names. Added required column values. --- packages/adapter-supabase/seed.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/adapter-supabase/seed.sql b/packages/adapter-supabase/seed.sql index 063c5fbe53..8ccc6f7134 100644 --- a/packages/adapter-supabase/seed.sql +++ b/packages/adapter-supabase/seed.sql @@ -1,3 +1,3 @@ -INSERT INTO public.accounts (id, name, email, avatarUrl, details) VALUES ('00000000-0000-0000-0000-000000000000', 'Default Agent', 'default@agent.com', '', '{}'); -INSERT INTO public.rooms (id) VALUES ('00000000-0000-0000-0000-000000000000'); -INSERT INTO public.participants (userId, roomId) VALUES ('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000'); +INSERT INTO public.accounts (id, name, email, "avatarUrl", details) VALUES ('00000000-0000-0000-0000-000000000000', 'Default Agent', 'default@agent.com', '', '{}'); +INSERT INTO public.rooms (id, "createdAt") VALUES ('00000000-0000-0000-0000-000000000000', NOW()); +INSERT INTO public.participants (id, "createdAt", "userId", "roomId", "userState", last_messsage_read) VALUES ('00000000-0000-0000-0000-000000000000', NOW(), 'Default Agent', NULL, NULL); From e3f4aab41c73fd4e6aec9db7238bfd2c2c8b0125 Mon Sep 17 00:00:00 2001 From: Antonio Piazza Date: Fri, 10 Jan 2025 08:25:42 +0100 Subject: [PATCH 2/4] Update seed.sql Added roomId value. --- packages/adapter-supabase/seed.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/adapter-supabase/seed.sql b/packages/adapter-supabase/seed.sql index 8ccc6f7134..4385fa4786 100644 --- a/packages/adapter-supabase/seed.sql +++ b/packages/adapter-supabase/seed.sql @@ -1,3 +1,3 @@ INSERT INTO public.accounts (id, name, email, "avatarUrl", details) VALUES ('00000000-0000-0000-0000-000000000000', 'Default Agent', 'default@agent.com', '', '{}'); INSERT INTO public.rooms (id, "createdAt") VALUES ('00000000-0000-0000-0000-000000000000', NOW()); -INSERT INTO public.participants (id, "createdAt", "userId", "roomId", "userState", last_messsage_read) VALUES ('00000000-0000-0000-0000-000000000000', NOW(), 'Default Agent', NULL, NULL); +INSERT INTO public.participants (id, "createdAt", "userId", "roomId", "userState", last_messsage_read) VALUES ('00000000-0000-0000-0000-000000000000', NOW(), 'Default Agent', '00000000-0000-0000-0000-000000000000', NULL, NULL); From 4c192343eea43ba2bf4fa20efb7d212b46152b3c Mon Sep 17 00:00:00 2001 From: Antonio Piazza Date: Fri, 10 Jan 2025 08:41:39 +0100 Subject: [PATCH 3/4] Fixed: Program fails when no, or multiple rooms exist Allows getRoom() to return NULL if no room exists, and returns single room if multiple rooms exist with the same "roomId" without breaking the program. --- packages/adapter-supabase/src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/adapter-supabase/src/index.ts b/packages/adapter-supabase/src/index.ts index 9c8d643f61..8bad6009f8 100644 --- a/packages/adapter-supabase/src/index.ts +++ b/packages/adapter-supabase/src/index.ts @@ -20,12 +20,12 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { .from("rooms") .select("id") .eq("id", roomId) - .single(); + .maybeSingle(); if (error) { - throw new Error(`Error getting room: ${error.message}`); + console.error(`Error getting room: ${error.message}`); + return null; } - return data ? (data.id as UUID) : null; } From 2b68b6ca723def5495502796f1f3d3da0d392692 Mon Sep 17 00:00:00 2001 From: Monil Patel Date: Fri, 10 Jan 2025 16:50:24 -0800 Subject: [PATCH 4/4] elizaLogger --- packages/adapter-supabase/src/index.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/adapter-supabase/src/index.ts b/packages/adapter-supabase/src/index.ts index 8bad6009f8..3800b845c9 100644 --- a/packages/adapter-supabase/src/index.ts +++ b/packages/adapter-supabase/src/index.ts @@ -23,7 +23,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { .maybeSingle(); if (error) { - console.error(`Error getting room: ${error.message}`); + elizaLogger.error(`Error getting room: ${error.message}`); return null; } return data ? (data.id as UUID) : null; @@ -56,7 +56,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { .single(); if (error) { - console.error("Error getting participant user state:", error); + elizaLogger.error("Error getting participant user state:", error); return null; } @@ -75,7 +75,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { .eq("userId", userId); if (error) { - console.error("Error setting participant user state:", error); + elizaLogger.error("Error setting participant user state:", error); throw new Error("Failed to set participant user state"); } } @@ -127,7 +127,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { const { data, error } = await query; if (error) { - console.error("Error retrieving memories by room IDs:", error); + elizaLogger.error("Error retrieving memories by room IDs:", error); return []; } @@ -155,7 +155,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { .from("accounts") .upsert([account]); if (error) { - console.error(error.message); + elizaLogger.error(error.message); return false; } return true; @@ -175,7 +175,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { .eq("id", params.roomId); if (response.error) { - console.error("Error!" + response.error); + elizaLogger.error("Error!" + response.error); return []; } const { data } = response; @@ -194,7 +194,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { ) .flat(); } catch (error) { - console.error("error", error); + elizaLogger.error("error", error); throw error; } } @@ -267,7 +267,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { }); if (error) { - console.error("Error inserting log:", error); + elizaLogger.error("Error inserting log:", error); throw new Error(error.message); } } @@ -357,7 +357,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { .single(); if (error) { - console.error("Error retrieving memory by ID:", error); + elizaLogger.error("Error retrieving memory by ID:", error); return null; } @@ -571,7 +571,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { .insert({ userId: userId, roomId: roomId }); if (error) { - console.error(`Error adding participant: ${error.message}`); + elizaLogger.error(`Error adding participant: ${error.message}`); return false; } return true; @@ -585,7 +585,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { .eq("roomId", roomId); if (error) { - console.error(`Error removing participant: ${error.message}`); + elizaLogger.error(`Error removing participant: ${error.message}`); return false; } return true; @@ -695,7 +695,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { .single(); if (error) { - console.error('Error fetching cache:', error); + elizaLogger.error('Error fetching cache:', error); return undefined; } @@ -717,7 +717,7 @@ export class SupabaseDatabaseAdapter extends DatabaseAdapter { }); if (error) { - console.error('Error setting cache:', error); + elizaLogger.error('Error setting cache:', error); return false; }