@elizaos/plugin-sql 1.4.3 → 1.4.5
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.
- package/dist/index.js +35 -21
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -917,7 +917,7 @@ var BaseDrizzleAdapter = class extends DatabaseAdapter {
|
|
|
917
917
|
});
|
|
918
918
|
} catch (error) {
|
|
919
919
|
logger.error(
|
|
920
|
-
`Error creating
|
|
920
|
+
`Error creating entities: ${error instanceof Error ? error.message : String(error)}, entityId: ${entities[0].id}, (metadata?.)name: ${entities[0].metadata?.name}`
|
|
921
921
|
);
|
|
922
922
|
logger.trace(error);
|
|
923
923
|
return false;
|
|
@@ -1114,7 +1114,7 @@ var BaseDrizzleAdapter = class extends DatabaseAdapter {
|
|
|
1114
1114
|
return this.withDatabase(async () => {
|
|
1115
1115
|
await this.db.insert(componentTable).values({
|
|
1116
1116
|
...component,
|
|
1117
|
-
createdAt: new Date(
|
|
1117
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1118
1118
|
});
|
|
1119
1119
|
return true;
|
|
1120
1120
|
});
|
|
@@ -1126,10 +1126,14 @@ var BaseDrizzleAdapter = class extends DatabaseAdapter {
|
|
|
1126
1126
|
*/
|
|
1127
1127
|
async updateComponent(component) {
|
|
1128
1128
|
return this.withDatabase(async () => {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1129
|
+
try {
|
|
1130
|
+
await this.db.update(componentTable).set({
|
|
1131
|
+
...component,
|
|
1132
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
1133
|
+
}).where(eq(componentTable.id, component.id));
|
|
1134
|
+
} catch (e) {
|
|
1135
|
+
console.error("updateComponent error", e);
|
|
1136
|
+
}
|
|
1133
1137
|
});
|
|
1134
1138
|
}
|
|
1135
1139
|
/**
|
|
@@ -1575,18 +1579,20 @@ var BaseDrizzleAdapter = class extends DatabaseAdapter {
|
|
|
1575
1579
|
logger.debug(`Memory already exists, skipping creation: ${memoryId}`);
|
|
1576
1580
|
return memoryId;
|
|
1577
1581
|
}
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1582
|
+
if (memory.unique === void 0) {
|
|
1583
|
+
memory.unique = true;
|
|
1584
|
+
if (memory.embedding && Array.isArray(memory.embedding)) {
|
|
1585
|
+
const similarMemories = await this.searchMemoriesByEmbedding(memory.embedding, {
|
|
1586
|
+
tableName,
|
|
1587
|
+
// Use the scope fields from the memory object for similarity check
|
|
1588
|
+
roomId: memory.roomId,
|
|
1589
|
+
worldId: memory.worldId,
|
|
1590
|
+
entityId: memory.entityId,
|
|
1591
|
+
match_threshold: 0.95,
|
|
1592
|
+
count: 1
|
|
1593
|
+
});
|
|
1594
|
+
memory.unique = similarMemories.length === 0;
|
|
1595
|
+
}
|
|
1590
1596
|
}
|
|
1591
1597
|
const contentToInsert = typeof memory.content === "string" ? memory.content : JSON.stringify(memory.content ?? {});
|
|
1592
1598
|
const metadataToInsert = typeof memory.metadata === "string" ? memory.metadata : JSON.stringify(memory.metadata ?? {});
|
|
@@ -1602,7 +1608,7 @@ var BaseDrizzleAdapter = class extends DatabaseAdapter {
|
|
|
1602
1608
|
worldId: memory.worldId,
|
|
1603
1609
|
// Include worldId
|
|
1604
1610
|
agentId: memory.agentId || this.agentId,
|
|
1605
|
-
unique: memory.unique
|
|
1611
|
+
unique: memory.unique,
|
|
1606
1612
|
createdAt: memory.createdAt ? new Date(memory.createdAt) : /* @__PURE__ */ new Date()
|
|
1607
1613
|
}
|
|
1608
1614
|
]);
|
|
@@ -1898,7 +1904,6 @@ var BaseDrizzleAdapter = class extends DatabaseAdapter {
|
|
|
1898
1904
|
* @returns {Promise<UUID[]>} A Promise that resolves to an array of room IDs.
|
|
1899
1905
|
*/
|
|
1900
1906
|
async getRoomsForParticipant(entityId) {
|
|
1901
|
-
console.log("getRoomsForParticipant", entityId);
|
|
1902
1907
|
return this.withDatabase(async () => {
|
|
1903
1908
|
const result = await this.db.select({ roomId: participantTable.roomId }).from(participantTable).innerJoin(roomTable, eq(participantTable.roomId, roomTable.id)).where(and(eq(participantTable.entityId, entityId), eq(roomTable.agentId, this.agentId)));
|
|
1904
1909
|
return result.map((row) => row.roomId);
|
|
@@ -3139,7 +3144,16 @@ function resolvePgliteDir(dir, fallbackDir) {
|
|
|
3139
3144
|
if (existsSync(envPath)) {
|
|
3140
3145
|
dotenv.config({ path: envPath });
|
|
3141
3146
|
}
|
|
3142
|
-
|
|
3147
|
+
let monoPath;
|
|
3148
|
+
if (existsSync(path.join(process.cwd(), "packages", "core"))) {
|
|
3149
|
+
monoPath = process.cwd();
|
|
3150
|
+
} else {
|
|
3151
|
+
const twoUp = path.resolve(process.cwd(), "../..");
|
|
3152
|
+
if (existsSync(path.join(twoUp, "packages", "core"))) {
|
|
3153
|
+
monoPath = twoUp;
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
const base = dir ?? process.env.PGLITE_DATA_DIR ?? fallbackDir ?? (monoPath ? path.join(monoPath, ".eliza", ".elizadb") : void 0) ?? path.join(process.cwd(), ".eliza", ".elizadb");
|
|
3143
3157
|
const resolved = expandTildePath(base);
|
|
3144
3158
|
const legacyPath = path.join(process.cwd(), ".elizadb");
|
|
3145
3159
|
if (resolved === legacyPath) {
|