@elizaos/plugin-sql 1.6.2-alpha.8 → 1.6.2-beta.0

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.
@@ -18641,7 +18641,7 @@ function formatDefaultValue(value, type) {
18641
18641
  return String(value);
18642
18642
  }
18643
18643
  function generateCreateIndexSQL(index5) {
18644
- const unique4 = index5.isUnique ? "UNIQUE " : "";
18644
+ const unique3 = index5.isUnique ? "UNIQUE " : "";
18645
18645
  const method = index5.method || "btree";
18646
18646
  const columns = index5.columns.map((c) => {
18647
18647
  if (c.isExpression) {
@@ -18657,7 +18657,7 @@ function generateCreateIndexSQL(index5) {
18657
18657
  } else {
18658
18658
  tableRef = `"${index5.table || ""}"`;
18659
18659
  }
18660
- return `CREATE ${unique4}INDEX "${indexName}" ON ${tableRef} USING ${method} (${columns});`;
18660
+ return `CREATE ${unique3}INDEX "${indexName}" ON ${tableRef} USING ${method} (${columns});`;
18661
18661
  }
18662
18662
  function generateDropIndexSQL(index5) {
18663
18663
  const indexName = index5.name ? index5.name.includes(".") ? index5.name.split(".")[1] : index5.name : index5;
@@ -19788,7 +19788,7 @@ import {
19788
19788
 
19789
19789
  // src/schema/agent.ts
19790
19790
  import { sql } from "drizzle-orm";
19791
- import { boolean, jsonb, pgTable, text, timestamp, unique, uuid } from "drizzle-orm/pg-core";
19791
+ import { boolean, jsonb, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
19792
19792
  var agentTable = pgTable("agents", {
19793
19793
  id: uuid("id").primaryKey().defaultRandom(),
19794
19794
  enabled: boolean("enabled").default(true).notNull(),
@@ -19806,15 +19806,11 @@ var agentTable = pgTable("agents", {
19806
19806
  plugins: jsonb("plugins").$type().default(sql`'[]'::jsonb`).notNull(),
19807
19807
  settings: jsonb("settings").$type().default(sql`'{}'::jsonb`).notNull(),
19808
19808
  style: jsonb("style").$type().default(sql`'{}'::jsonb`).notNull()
19809
- }, (table) => {
19810
- return {
19811
- nameUnique: unique("name_unique").on(table.name)
19812
- };
19813
19809
  });
19814
19810
 
19815
19811
  // src/schema/entity.ts
19816
19812
  import { sql as sql2 } from "drizzle-orm";
19817
- import { jsonb as jsonb2, pgTable as pgTable2, text as text2, timestamp as timestamp2, unique as unique2, uuid as uuid2 } from "drizzle-orm/pg-core";
19813
+ import { jsonb as jsonb2, pgTable as pgTable2, text as text2, timestamp as timestamp2, unique, uuid as uuid2 } from "drizzle-orm/pg-core";
19818
19814
  var entityTable = pgTable2("entities", {
19819
19815
  id: uuid2("id").notNull().primaryKey(),
19820
19816
  agentId: uuid2("agent_id").notNull().references(() => agentTable.id, {
@@ -19825,7 +19821,7 @@ var entityTable = pgTable2("entities", {
19825
19821
  metadata: jsonb2("metadata").default(sql2`'{}'::jsonb`).notNull()
19826
19822
  }, (table) => {
19827
19823
  return {
19828
- idAgentIdUnique: unique2("id_agent_id_unique").on(table.id, table.agentId)
19824
+ idAgentIdUnique: unique("id_agent_id_unique").on(table.id, table.agentId)
19829
19825
  };
19830
19826
  });
19831
19827
 
@@ -20058,7 +20054,7 @@ import {
20058
20054
  pgTable as pgTable11,
20059
20055
  text as text10,
20060
20056
  timestamp as timestamp11,
20061
- unique as unique3,
20057
+ unique as unique2,
20062
20058
  uuid as uuid11
20063
20059
  } from "drizzle-orm/pg-core";
20064
20060
  var relationshipTable = pgTable11("relationships", {
@@ -20071,7 +20067,7 @@ var relationshipTable = pgTable11("relationships", {
20071
20067
  metadata: jsonb9("metadata")
20072
20068
  }, (table) => [
20073
20069
  index4("idx_relationships_users").on(table.sourceEntityId, table.targetEntityId),
20074
- unique3("unique_relationship").on(table.sourceEntityId, table.targetEntityId, table.agentId),
20070
+ unique2("unique_relationship").on(table.sourceEntityId, table.targetEntityId, table.agentId),
20075
20071
  foreignKey5({
20076
20072
  name: "fk_user_a",
20077
20073
  columns: [table.sourceEntityId],
@@ -20257,17 +20253,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
20257
20253
  async createAgent(agent) {
20258
20254
  return this.withDatabase(async () => {
20259
20255
  try {
20260
- const conditions = [];
20261
20256
  if (agent.id) {
20262
- conditions.push(eq(agentTable.id, agent.id));
20263
- }
20264
- if (agent.name) {
20265
- conditions.push(eq(agentTable.name, agent.name));
20266
- }
20267
- const existing = conditions.length > 0 ? await this.db.select({ id: agentTable.id }).from(agentTable).where(or(...conditions)).limit(1) : [];
20268
- if (existing.length > 0) {
20269
- logger7.warn(`Attempted to create an agent with a duplicate ID or name. ID: ${agent.id}, name: ${agent.name}`);
20270
- return false;
20257
+ const existing = await this.db.select({ id: agentTable.id }).from(agentTable).where(eq(agentTable.id, agent.id)).limit(1);
20258
+ if (existing.length > 0) {
20259
+ logger7.warn(`Attempted to create an agent with a duplicate ID. ID: ${agent.id}`);
20260
+ return false;
20261
+ }
20271
20262
  }
20272
20263
  await this.db.transaction(async (tx) => {
20273
20264
  await tx.insert(agentTable).values({
@@ -20650,7 +20641,7 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
20650
20641
  });
20651
20642
  }
20652
20643
  async getMemories(params) {
20653
- const { entityId, agentId, roomId, worldId, tableName, unique: unique4, start, end, offset } = params;
20644
+ const { entityId, agentId, roomId, worldId, tableName, unique: unique3, start, end, offset } = params;
20654
20645
  if (!tableName)
20655
20646
  throw new Error("tableName is required");
20656
20647
  if (offset !== undefined && offset < 0) {
@@ -20673,7 +20664,7 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
20673
20664
  if (end) {
20674
20665
  conditions.push(lte(memoryTable.createdAt, new Date(end)));
20675
20666
  }
20676
- if (unique4) {
20667
+ if (unique3) {
20677
20668
  conditions.push(eq(memoryTable.unique, true));
20678
20669
  }
20679
20670
  if (agentId) {
@@ -21294,12 +21285,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
21294
21285
  logger7.debug(`All memories removed successfully: roomId: ${roomId}, tableName: ${tableName}`);
21295
21286
  });
21296
21287
  }
21297
- async countMemories(roomId, unique4 = true, tableName = "") {
21288
+ async countMemories(roomId, unique3 = true, tableName = "") {
21298
21289
  if (!tableName)
21299
21290
  throw new Error("tableName is required");
21300
21291
  return this.withDatabase(async () => {
21301
21292
  const conditions = [eq(memoryTable.roomId, roomId), eq(memoryTable.type, tableName)];
21302
- if (unique4) {
21293
+ if (unique3) {
21303
21294
  conditions.push(eq(memoryTable.unique, true));
21304
21295
  }
21305
21296
  const result = await this.db.select({ count: sql22`count(*)` }).from(memoryTable).where(and(...conditions));
@@ -22215,5 +22206,5 @@ export {
22215
22206
  DatabaseMigrationService
22216
22207
  };
22217
22208
 
22218
- //# debugId=314F050492DB8CE564756E2164756E21
22209
+ //# debugId=2E7587FF28B8361264756E2164756E21
22219
22210
  //# sourceMappingURL=index.browser.js.map