@elizaos/plugin-sql 1.6.2-alpha.2 → 1.6.2-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -634,7 +634,7 @@ var init_subquery = __esm(() => {
634
634
  });
635
635
 
636
636
  // ../../node_modules/drizzle-orm/version.js
637
- var version = "0.44.5";
637
+ var version = "0.44.6";
638
638
  var init_version = () => {};
639
639
 
640
640
  // ../../node_modules/drizzle-orm/tracing.js
@@ -8187,10 +8187,6 @@ var agentTable = pgTable("agents", {
8187
8187
  plugins: jsonb("plugins").$type().default(sql`'[]'::jsonb`).notNull(),
8188
8188
  settings: jsonb("settings").$type().default(sql`'{}'::jsonb`).notNull(),
8189
8189
  style: jsonb("style").$type().default(sql`'{}'::jsonb`).notNull()
8190
- }, (table3) => {
8191
- return {
8192
- nameUnique: unique("name_unique").on(table3.name)
8193
- };
8194
8190
  });
8195
8191
 
8196
8192
  // src/schema/entity.ts
@@ -8629,17 +8625,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
8629
8625
  async createAgent(agent) {
8630
8626
  return this.withDatabase(async () => {
8631
8627
  try {
8632
- const conditions2 = [];
8633
8628
  if (agent.id) {
8634
- conditions2.push(eq(agentTable.id, agent.id));
8635
- }
8636
- if (agent.name) {
8637
- conditions2.push(eq(agentTable.name, agent.name));
8638
- }
8639
- const existing = conditions2.length > 0 ? await this.db.select({ id: agentTable.id }).from(agentTable).where(or(...conditions2)).limit(1) : [];
8640
- if (existing.length > 0) {
8641
- logger8.warn(`Attempted to create an agent with a duplicate ID or name. ID: ${agent.id}, name: ${agent.name}`);
8642
- return false;
8629
+ const existing = await this.db.select({ id: agentTable.id }).from(agentTable).where(eq(agentTable.id, agent.id)).limit(1);
8630
+ if (existing.length > 0) {
8631
+ logger8.warn(`Attempted to create an agent with a duplicate ID. ID: ${agent.id}`);
8632
+ return false;
8633
+ }
8643
8634
  }
8644
8635
  await this.db.transaction(async (tx) => {
8645
8636
  await tx.insert(agentTable).values({
@@ -9022,9 +9013,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
9022
9013
  });
9023
9014
  }
9024
9015
  async getMemories(params) {
9025
- const { entityId, agentId, roomId, worldId, tableName, unique: unique2, start, end } = params;
9016
+ const { entityId, agentId, roomId, worldId, tableName, unique: unique2, start, end, offset } = params;
9026
9017
  if (!tableName)
9027
9018
  throw new Error("tableName is required");
9019
+ if (offset !== undefined && offset < 0) {
9020
+ throw new Error("offset must be a non-negative number");
9021
+ }
9028
9022
  return this.withDatabase(async () => {
9029
9023
  const conditions2 = [eq(memoryTable.type, tableName)];
9030
9024
  if (start) {
@@ -9048,7 +9042,7 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
9048
9042
  if (agentId) {
9049
9043
  conditions2.push(eq(memoryTable.agentId, agentId));
9050
9044
  }
9051
- const query = this.db.select({
9045
+ const baseQuery = this.db.select({
9052
9046
  memory: {
9053
9047
  id: memoryTable.id,
9054
9048
  type: memoryTable.type,
@@ -9062,7 +9056,17 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
9062
9056
  },
9063
9057
  embedding: embeddingTable[this.embeddingDimension]
9064
9058
  }).from(memoryTable).leftJoin(embeddingTable, eq(embeddingTable.memoryId, memoryTable.id)).where(and(...conditions2)).orderBy(desc(memoryTable.createdAt));
9065
- const rows = params.count ? await query.limit(params.count) : await query;
9059
+ const rows = await (async () => {
9060
+ if (params.count && offset !== undefined && offset > 0) {
9061
+ return baseQuery.limit(params.count).offset(offset);
9062
+ } else if (params.count) {
9063
+ return baseQuery.limit(params.count);
9064
+ } else if (offset !== undefined && offset > 0) {
9065
+ return baseQuery.offset(offset);
9066
+ } else {
9067
+ return baseQuery;
9068
+ }
9069
+ })();
9066
9070
  return rows.map((row) => ({
9067
9071
  id: row.memory.id,
9068
9072
  type: row.memory.type,
@@ -11081,5 +11085,5 @@ export {
11081
11085
  DatabaseMigrationService
11082
11086
  };
11083
11087
 
11084
- //# debugId=F87541CC826D31E064756E2164756E21
11088
+ //# debugId=8BA1B17BEE8B070C64756E2164756E21
11085
11089
  //# sourceMappingURL=index.node.js.map