@elizaos/plugin-sql 1.6.5-alpha.21 → 1.6.5-alpha.23
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/browser/index.browser.js +907 -97
- package/dist/browser/index.browser.js.map +19 -19
- package/dist/browser/tsconfig.build.tsbuildinfo +1 -1
- package/dist/node/index.node.js +220 -50
- package/dist/node/index.node.js.map +23 -23
- package/dist/node/tsconfig.build.node.tsbuildinfo +1 -1
- package/package.json +12 -12
package/dist/node/index.node.js
CHANGED
|
@@ -634,7 +634,7 @@ var init_subquery = __esm(() => {
|
|
|
634
634
|
});
|
|
635
635
|
|
|
636
636
|
// ../../node_modules/drizzle-orm/version.js
|
|
637
|
-
var version = "0.
|
|
637
|
+
var version = "0.45.0";
|
|
638
638
|
var init_version = () => {};
|
|
639
639
|
|
|
640
640
|
// ../../node_modules/drizzle-orm/tracing.js
|
|
@@ -1261,6 +1261,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
|
|
|
1261
1261
|
decoder = field;
|
|
1262
1262
|
} else if (is(field, SQL)) {
|
|
1263
1263
|
decoder = field.decoder;
|
|
1264
|
+
} else if (is(field, Subquery)) {
|
|
1265
|
+
decoder = field._.sql.decoder;
|
|
1264
1266
|
} else {
|
|
1265
1267
|
decoder = field.sql.decoder;
|
|
1266
1268
|
}
|
|
@@ -1301,7 +1303,7 @@ function orderSelectedFields(fields, pathPrefix) {
|
|
|
1301
1303
|
return result;
|
|
1302
1304
|
}
|
|
1303
1305
|
const newPath = pathPrefix ? [...pathPrefix, name] : [name];
|
|
1304
|
-
if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased)) {
|
|
1306
|
+
if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased) || is(field, Subquery)) {
|
|
1305
1307
|
result.push({ path: newPath, field });
|
|
1306
1308
|
} else if (is(field, Table)) {
|
|
1307
1309
|
result.push(...orderSelectedFields(field[Table.Symbol.Columns], newPath));
|
|
@@ -1739,7 +1741,9 @@ var init_date = __esm(() => {
|
|
|
1739
1741
|
return "date";
|
|
1740
1742
|
}
|
|
1741
1743
|
mapFromDriverValue(value) {
|
|
1742
|
-
|
|
1744
|
+
if (typeof value === "string")
|
|
1745
|
+
return new Date(value);
|
|
1746
|
+
return value;
|
|
1743
1747
|
}
|
|
1744
1748
|
mapToDriverValue(value) {
|
|
1745
1749
|
return value.toISOString();
|
|
@@ -1759,6 +1763,11 @@ var init_date = __esm(() => {
|
|
|
1759
1763
|
getSQLType() {
|
|
1760
1764
|
return "date";
|
|
1761
1765
|
}
|
|
1766
|
+
mapFromDriverValue(value) {
|
|
1767
|
+
if (typeof value === "string")
|
|
1768
|
+
return value;
|
|
1769
|
+
return value.toISOString().slice(0, -14);
|
|
1770
|
+
}
|
|
1762
1771
|
};
|
|
1763
1772
|
});
|
|
1764
1773
|
|
|
@@ -2581,9 +2590,11 @@ var init_timestamp = __esm(() => {
|
|
|
2581
2590
|
const precision = this.precision === undefined ? "" : ` (${this.precision})`;
|
|
2582
2591
|
return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
2583
2592
|
}
|
|
2584
|
-
mapFromDriverValue
|
|
2585
|
-
|
|
2586
|
-
|
|
2593
|
+
mapFromDriverValue(value) {
|
|
2594
|
+
if (typeof value === "string")
|
|
2595
|
+
return new Date(this.withTimezone ? value : value + "+0000");
|
|
2596
|
+
return value;
|
|
2597
|
+
}
|
|
2587
2598
|
mapToDriverValue = (value) => {
|
|
2588
2599
|
return value.toISOString();
|
|
2589
2600
|
};
|
|
@@ -2612,6 +2623,17 @@ var init_timestamp = __esm(() => {
|
|
|
2612
2623
|
const precision = this.precision === undefined ? "" : `(${this.precision})`;
|
|
2613
2624
|
return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
2614
2625
|
}
|
|
2626
|
+
mapFromDriverValue(value) {
|
|
2627
|
+
if (typeof value === "string")
|
|
2628
|
+
return value;
|
|
2629
|
+
const shortened = value.toISOString().slice(0, -1).replace("T", " ");
|
|
2630
|
+
if (this.withTimezone) {
|
|
2631
|
+
const offset = value.getTimezoneOffset();
|
|
2632
|
+
const sign = offset <= 0 ? "+" : "-";
|
|
2633
|
+
return `${shortened}${sign}${Math.floor(Math.abs(offset) / 60).toString().padStart(2, "0")}`;
|
|
2634
|
+
}
|
|
2635
|
+
return shortened;
|
|
2636
|
+
}
|
|
2615
2637
|
};
|
|
2616
2638
|
});
|
|
2617
2639
|
|
|
@@ -3727,7 +3749,8 @@ var init_dialect = __esm(() => {
|
|
|
3727
3749
|
const setSize = columnNames.length;
|
|
3728
3750
|
return sql.join(columnNames.flatMap((colName, i) => {
|
|
3729
3751
|
const col = tableColumns[colName];
|
|
3730
|
-
const
|
|
3752
|
+
const onUpdateFnResult = col.onUpdateFn?.();
|
|
3753
|
+
const value = set[colName] ?? (is(onUpdateFnResult, SQL) ? onUpdateFnResult : sql.param(onUpdateFnResult, col));
|
|
3731
3754
|
const res = sql`${sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;
|
|
3732
3755
|
if (i < setSize - 1) {
|
|
3733
3756
|
return [res, sql.raw(", ")];
|
|
@@ -3776,6 +3799,16 @@ var init_dialect = __esm(() => {
|
|
|
3776
3799
|
} else {
|
|
3777
3800
|
chunk.push(field);
|
|
3778
3801
|
}
|
|
3802
|
+
} else if (is(field, Subquery)) {
|
|
3803
|
+
const entries = Object.entries(field._.selectedFields);
|
|
3804
|
+
if (entries.length === 1) {
|
|
3805
|
+
const entry = entries[0][1];
|
|
3806
|
+
const fieldDecoder = is(entry, SQL) ? entry.decoder : is(entry, Column) ? { mapFromDriverValue: (v) => entry.mapFromDriverValue(v) } : entry.sql.decoder;
|
|
3807
|
+
if (fieldDecoder) {
|
|
3808
|
+
field._.sql.decoder = fieldDecoder;
|
|
3809
|
+
}
|
|
3810
|
+
}
|
|
3811
|
+
chunk.push(field);
|
|
3779
3812
|
}
|
|
3780
3813
|
if (i < columnsLen - 1) {
|
|
3781
3814
|
chunk.push(sql`, `);
|
|
@@ -7429,7 +7462,12 @@ class RuntimeMigrator {
|
|
|
7429
7462
|
logger6.warn({ src: "plugin:sql", pluginName, tableName: tableData.name, expectedSchema }, "Plugin table is using public schema - consider using pgSchema for better isolation");
|
|
7430
7463
|
}
|
|
7431
7464
|
if (isCorePLugin && actualSchema !== "public") {
|
|
7432
|
-
logger6.warn({
|
|
7465
|
+
logger6.warn({
|
|
7466
|
+
src: "plugin:sql",
|
|
7467
|
+
pluginName: "@elizaos/plugin-sql",
|
|
7468
|
+
tableName: tableData.name,
|
|
7469
|
+
actualSchema
|
|
7470
|
+
}, "Core plugin table should use public schema");
|
|
7433
7471
|
}
|
|
7434
7472
|
}
|
|
7435
7473
|
}
|
|
@@ -7674,13 +7712,21 @@ class RuntimeMigrator {
|
|
|
7674
7712
|
logger6.debug({ src: "plugin:sql", pluginName, lockId: lockIdStr }, "Advisory lock acquired");
|
|
7675
7713
|
}
|
|
7676
7714
|
} catch (lockError) {
|
|
7677
|
-
logger6.warn({
|
|
7715
|
+
logger6.warn({
|
|
7716
|
+
src: "plugin:sql",
|
|
7717
|
+
pluginName,
|
|
7718
|
+
error: lockError instanceof Error ? lockError.message : String(lockError)
|
|
7719
|
+
}, "Failed to acquire advisory lock, continuing without lock");
|
|
7678
7720
|
lockAcquired = false;
|
|
7679
7721
|
}
|
|
7680
7722
|
} else {
|
|
7681
7723
|
logger6.debug({ src: "plugin:sql" }, "Development database detected, skipping advisory locks");
|
|
7682
7724
|
}
|
|
7683
|
-
await this.extensionManager.installRequiredExtensions([
|
|
7725
|
+
await this.extensionManager.installRequiredExtensions([
|
|
7726
|
+
"vector",
|
|
7727
|
+
"fuzzystrmatch",
|
|
7728
|
+
"pgcrypto"
|
|
7729
|
+
]);
|
|
7684
7730
|
const currentSnapshot = await generateSnapshot(schema2);
|
|
7685
7731
|
await this.ensureSchemasExist(currentSnapshot);
|
|
7686
7732
|
this.validateSchemaUsage(pluginName, currentSnapshot);
|
|
@@ -7729,7 +7775,12 @@ class RuntimeMigrator {
|
|
|
7729
7775
|
const isProduction = false;
|
|
7730
7776
|
const allowDestructive = options.force || options.allowDataLoss || process.env.ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS === "true";
|
|
7731
7777
|
if (!allowDestructive) {
|
|
7732
|
-
logger6.error({
|
|
7778
|
+
logger6.error({
|
|
7779
|
+
src: "plugin:sql",
|
|
7780
|
+
pluginName,
|
|
7781
|
+
environment: isProduction ? "PRODUCTION" : "DEVELOPMENT",
|
|
7782
|
+
warnings: dataLossCheck.warnings
|
|
7783
|
+
}, "Destructive migration blocked - set ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true or use force option");
|
|
7733
7784
|
const errorMessage = isProduction ? `Destructive migration blocked in production for ${pluginName}. Set ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true or use drizzle-kit.` : `Destructive migration blocked for ${pluginName}. Set ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true to proceed.`;
|
|
7734
7785
|
throw new Error(errorMessage);
|
|
7735
7786
|
}
|
|
@@ -7756,7 +7807,11 @@ class RuntimeMigrator {
|
|
|
7756
7807
|
logger6.info({ src: "plugin:sql", pluginName }, "Migration completed successfully");
|
|
7757
7808
|
return;
|
|
7758
7809
|
} catch (error) {
|
|
7759
|
-
logger6.error({
|
|
7810
|
+
logger6.error({
|
|
7811
|
+
src: "plugin:sql",
|
|
7812
|
+
pluginName,
|
|
7813
|
+
error: error instanceof Error ? error.message : String(error)
|
|
7814
|
+
}, "Migration failed");
|
|
7760
7815
|
throw error;
|
|
7761
7816
|
} finally {
|
|
7762
7817
|
const postgresUrl = process.env.POSTGRES_URL || process.env.DATABASE_URL || "";
|
|
@@ -7767,7 +7822,11 @@ class RuntimeMigrator {
|
|
|
7767
7822
|
await this.db.execute(sql`SELECT pg_advisory_unlock(CAST(${lockIdStr} AS bigint))`);
|
|
7768
7823
|
logger6.debug({ src: "plugin:sql", pluginName }, "Advisory lock released");
|
|
7769
7824
|
} catch (unlockError) {
|
|
7770
|
-
logger6.warn({
|
|
7825
|
+
logger6.warn({
|
|
7826
|
+
src: "plugin:sql",
|
|
7827
|
+
pluginName,
|
|
7828
|
+
error: unlockError instanceof Error ? unlockError.message : String(unlockError)
|
|
7829
|
+
}, "Failed to release advisory lock");
|
|
7771
7830
|
}
|
|
7772
7831
|
}
|
|
7773
7832
|
}
|
|
@@ -7794,7 +7853,10 @@ class RuntimeMigrator {
|
|
|
7794
7853
|
await this.db.execute(sql`ROLLBACK`);
|
|
7795
7854
|
logger6.error({ src: "plugin:sql", error: error instanceof Error ? error.message : String(error) }, "Migration failed, rolled back");
|
|
7796
7855
|
} catch (rollbackError) {
|
|
7797
|
-
logger6.error({
|
|
7856
|
+
logger6.error({
|
|
7857
|
+
src: "plugin:sql",
|
|
7858
|
+
error: rollbackError instanceof Error ? rollbackError.message : String(rollbackError)
|
|
7859
|
+
}, "Failed to rollback transaction");
|
|
7798
7860
|
}
|
|
7799
7861
|
}
|
|
7800
7862
|
throw error;
|
|
@@ -7841,7 +7903,11 @@ class RuntimeMigrator {
|
|
|
7841
7903
|
}
|
|
7842
7904
|
return dataLossCheck;
|
|
7843
7905
|
} catch (error) {
|
|
7844
|
-
logger6.error({
|
|
7906
|
+
logger6.error({
|
|
7907
|
+
src: "plugin:sql",
|
|
7908
|
+
pluginName,
|
|
7909
|
+
error: error instanceof Error ? error.message : String(error)
|
|
7910
|
+
}, "Failed to check migration");
|
|
7845
7911
|
throw error;
|
|
7846
7912
|
}
|
|
7847
7913
|
}
|
|
@@ -8686,7 +8752,11 @@ class DatabaseMigrationService {
|
|
|
8686
8752
|
this.registeredSchemas.set(plugin.name, plugin.schema);
|
|
8687
8753
|
}
|
|
8688
8754
|
}
|
|
8689
|
-
logger9.info({
|
|
8755
|
+
logger9.info({
|
|
8756
|
+
src: "plugin:sql",
|
|
8757
|
+
schemasDiscovered: this.registeredSchemas.size,
|
|
8758
|
+
totalPlugins: plugins.length
|
|
8759
|
+
}, "Plugin schemas discovered");
|
|
8690
8760
|
}
|
|
8691
8761
|
registerSchema(pluginName, schema2) {
|
|
8692
8762
|
this.registeredSchemas.set(pluginName, schema2);
|
|
@@ -8702,7 +8772,12 @@ class DatabaseMigrationService {
|
|
|
8702
8772
|
force: options?.force ?? false,
|
|
8703
8773
|
dryRun: options?.dryRun ?? false
|
|
8704
8774
|
};
|
|
8705
|
-
logger9.info({
|
|
8775
|
+
logger9.info({
|
|
8776
|
+
src: "plugin:sql",
|
|
8777
|
+
environment: isProduction ? "PRODUCTION" : "DEVELOPMENT",
|
|
8778
|
+
pluginCount: this.registeredSchemas.size,
|
|
8779
|
+
dryRun: migrationOptions.dryRun
|
|
8780
|
+
}, "Starting migrations");
|
|
8706
8781
|
let successCount = 0;
|
|
8707
8782
|
let failureCount = 0;
|
|
8708
8783
|
const errors2 = [];
|
|
@@ -9149,9 +9224,7 @@ var cacheTable = pgTable("cache", {
|
|
|
9149
9224
|
value: jsonb("value").notNull(),
|
|
9150
9225
|
createdAt: timestamp("created_at", { withTimezone: true }).default(sql`now()`).notNull(),
|
|
9151
9226
|
expiresAt: timestamp("expires_at", { withTimezone: true })
|
|
9152
|
-
}, (table3) => [
|
|
9153
|
-
primaryKey({ columns: [table3.key, table3.agentId] })
|
|
9154
|
-
]);
|
|
9227
|
+
}, (table3) => [primaryKey({ columns: [table3.key, table3.agentId] })]);
|
|
9155
9228
|
// src/schema/component.ts
|
|
9156
9229
|
init_drizzle_orm();
|
|
9157
9230
|
init_pg_core();
|
|
@@ -9332,18 +9405,14 @@ init_pg_core();
|
|
|
9332
9405
|
var channelParticipantsTable = pgTable("channel_participants", {
|
|
9333
9406
|
channelId: text("channel_id").notNull().references(() => channelTable.id, { onDelete: "cascade" }),
|
|
9334
9407
|
entityId: text("entity_id").notNull()
|
|
9335
|
-
}, (table3) => [
|
|
9336
|
-
primaryKey({ columns: [table3.channelId, table3.entityId] })
|
|
9337
|
-
]);
|
|
9408
|
+
}, (table3) => [primaryKey({ columns: [table3.channelId, table3.entityId] })]);
|
|
9338
9409
|
// src/schema/messageServerAgent.ts
|
|
9339
9410
|
init_pg_core();
|
|
9340
9411
|
init_agent();
|
|
9341
9412
|
var messageServerAgentsTable = pgTable("message_server_agents", {
|
|
9342
9413
|
messageServerId: uuid("message_server_id").notNull().references(() => messageServerTable.id, { onDelete: "cascade" }),
|
|
9343
9414
|
agentId: uuid("agent_id").notNull().references(() => agentTable.id, { onDelete: "cascade" })
|
|
9344
|
-
}, (table3) => [
|
|
9345
|
-
primaryKey({ columns: [table3.messageServerId, table3.agentId] })
|
|
9346
|
-
]);
|
|
9415
|
+
}, (table3) => [primaryKey({ columns: [table3.messageServerId, table3.agentId] })]);
|
|
9347
9416
|
// src/base.ts
|
|
9348
9417
|
class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
9349
9418
|
maxRetries = 3;
|
|
@@ -9405,10 +9474,19 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
9405
9474
|
const backoffDelay = Math.min(this.baseDelay * 2 ** (attempt - 1), this.maxDelay);
|
|
9406
9475
|
const jitter = Math.random() * this.jitterMax;
|
|
9407
9476
|
const delay = backoffDelay + jitter;
|
|
9408
|
-
logger10.warn({
|
|
9477
|
+
logger10.warn({
|
|
9478
|
+
src: "plugin:sql",
|
|
9479
|
+
attempt,
|
|
9480
|
+
maxRetries: this.maxRetries,
|
|
9481
|
+
error: error instanceof Error ? error.message : String(error)
|
|
9482
|
+
}, "Database operation failed, retrying");
|
|
9409
9483
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
9410
9484
|
} else {
|
|
9411
|
-
logger10.error({
|
|
9485
|
+
logger10.error({
|
|
9486
|
+
src: "plugin:sql",
|
|
9487
|
+
totalAttempts: attempt,
|
|
9488
|
+
error: error instanceof Error ? error.message : String(error)
|
|
9489
|
+
}, "Max retry attempts reached");
|
|
9412
9490
|
throw error instanceof Error ? error : new Error(String(error));
|
|
9413
9491
|
}
|
|
9414
9492
|
}
|
|
@@ -9475,7 +9553,11 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
9475
9553
|
});
|
|
9476
9554
|
return true;
|
|
9477
9555
|
} catch (error) {
|
|
9478
|
-
logger10.error({
|
|
9556
|
+
logger10.error({
|
|
9557
|
+
src: "plugin:sql",
|
|
9558
|
+
agentId: agent.id,
|
|
9559
|
+
error: error instanceof Error ? error.message : String(error)
|
|
9560
|
+
}, "Failed to create agent");
|
|
9479
9561
|
return false;
|
|
9480
9562
|
}
|
|
9481
9563
|
});
|
|
@@ -9511,7 +9593,11 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
9511
9593
|
});
|
|
9512
9594
|
return true;
|
|
9513
9595
|
} catch (error) {
|
|
9514
|
-
logger10.error({
|
|
9596
|
+
logger10.error({
|
|
9597
|
+
src: "plugin:sql",
|
|
9598
|
+
agentId,
|
|
9599
|
+
error: error instanceof Error ? error.message : String(error)
|
|
9600
|
+
}, "Failed to update agent");
|
|
9515
9601
|
return false;
|
|
9516
9602
|
}
|
|
9517
9603
|
});
|
|
@@ -9562,7 +9648,11 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
9562
9648
|
}
|
|
9563
9649
|
return true;
|
|
9564
9650
|
} catch (error) {
|
|
9565
|
-
logger10.error({
|
|
9651
|
+
logger10.error({
|
|
9652
|
+
src: "plugin:sql",
|
|
9653
|
+
agentId,
|
|
9654
|
+
error: error instanceof Error ? error.message : String(error)
|
|
9655
|
+
}, "Failed to delete agent");
|
|
9566
9656
|
throw error;
|
|
9567
9657
|
}
|
|
9568
9658
|
});
|
|
@@ -9665,7 +9755,11 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
9665
9755
|
return true;
|
|
9666
9756
|
});
|
|
9667
9757
|
} catch (error) {
|
|
9668
|
-
logger10.error({
|
|
9758
|
+
logger10.error({
|
|
9759
|
+
src: "plugin:sql",
|
|
9760
|
+
entityId: entities[0]?.id,
|
|
9761
|
+
error: error instanceof Error ? error.message : String(error)
|
|
9762
|
+
}, "Failed to create entities");
|
|
9669
9763
|
return false;
|
|
9670
9764
|
}
|
|
9671
9765
|
});
|
|
@@ -9682,7 +9776,11 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
9682
9776
|
}
|
|
9683
9777
|
return true;
|
|
9684
9778
|
} catch (error) {
|
|
9685
|
-
logger10.error({
|
|
9779
|
+
logger10.error({
|
|
9780
|
+
src: "plugin:sql",
|
|
9781
|
+
entityId: entity2.id,
|
|
9782
|
+
error: error instanceof Error ? error.message : String(error)
|
|
9783
|
+
}, "Failed to ensure entity exists");
|
|
9686
9784
|
return false;
|
|
9687
9785
|
}
|
|
9688
9786
|
}
|
|
@@ -10032,7 +10130,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10032
10130
|
levenshtein_score: Number(row.levenshtein_score)
|
|
10033
10131
|
})).filter((row) => Array.isArray(row.embedding));
|
|
10034
10132
|
} catch (error) {
|
|
10035
|
-
logger10.error({
|
|
10133
|
+
logger10.error({
|
|
10134
|
+
src: "plugin:sql",
|
|
10135
|
+
tableName: opts.query_table_name,
|
|
10136
|
+
fieldName: opts.query_field_name,
|
|
10137
|
+
error: error instanceof Error ? error.message : String(error)
|
|
10138
|
+
}, "Failed to get cached embeddings");
|
|
10036
10139
|
if (error instanceof Error && error.message === "levenshtein argument exceeds maximum length of 255 characters") {
|
|
10037
10140
|
return [];
|
|
10038
10141
|
}
|
|
@@ -10054,7 +10157,13 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10054
10157
|
});
|
|
10055
10158
|
});
|
|
10056
10159
|
} catch (error) {
|
|
10057
|
-
logger10.error({
|
|
10160
|
+
logger10.error({
|
|
10161
|
+
src: "plugin:sql",
|
|
10162
|
+
type: params.type,
|
|
10163
|
+
roomId: params.roomId,
|
|
10164
|
+
entityId: params.entityId,
|
|
10165
|
+
error: error instanceof Error ? error.message : String(error)
|
|
10166
|
+
}, "Failed to create log entry");
|
|
10058
10167
|
throw error;
|
|
10059
10168
|
}
|
|
10060
10169
|
});
|
|
@@ -10416,7 +10525,11 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10416
10525
|
});
|
|
10417
10526
|
return true;
|
|
10418
10527
|
} catch (error) {
|
|
10419
|
-
logger10.error({
|
|
10528
|
+
logger10.error({
|
|
10529
|
+
src: "plugin:sql",
|
|
10530
|
+
memoryId: memory.id,
|
|
10531
|
+
error: error instanceof Error ? error.message : String(error)
|
|
10532
|
+
}, "Failed to update memory");
|
|
10420
10533
|
return false;
|
|
10421
10534
|
}
|
|
10422
10535
|
});
|
|
@@ -10583,7 +10696,13 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10583
10696
|
}).onConflictDoNothing();
|
|
10584
10697
|
return true;
|
|
10585
10698
|
} catch (error) {
|
|
10586
|
-
logger10.error({
|
|
10699
|
+
logger10.error({
|
|
10700
|
+
src: "plugin:sql",
|
|
10701
|
+
entityId,
|
|
10702
|
+
roomId,
|
|
10703
|
+
agentId: this.agentId,
|
|
10704
|
+
error: error instanceof Error ? error.message : String(error)
|
|
10705
|
+
}, "Failed to add participant to room");
|
|
10587
10706
|
return false;
|
|
10588
10707
|
}
|
|
10589
10708
|
});
|
|
@@ -10599,7 +10718,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10599
10718
|
await this.db.insert(participantTable).values(values).onConflictDoNothing().execute();
|
|
10600
10719
|
return true;
|
|
10601
10720
|
} catch (error) {
|
|
10602
|
-
logger10.error({
|
|
10721
|
+
logger10.error({
|
|
10722
|
+
src: "plugin:sql",
|
|
10723
|
+
roomId,
|
|
10724
|
+
agentId: this.agentId,
|
|
10725
|
+
error: error instanceof Error ? error.message : String(error)
|
|
10726
|
+
}, "Failed to add participants to room");
|
|
10603
10727
|
return false;
|
|
10604
10728
|
}
|
|
10605
10729
|
});
|
|
@@ -10613,7 +10737,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10613
10737
|
const removed = result.length > 0;
|
|
10614
10738
|
return removed;
|
|
10615
10739
|
} catch (error) {
|
|
10616
|
-
logger10.error({
|
|
10740
|
+
logger10.error({
|
|
10741
|
+
src: "plugin:sql",
|
|
10742
|
+
entityId,
|
|
10743
|
+
roomId,
|
|
10744
|
+
error: error instanceof Error ? error.message : String(error)
|
|
10745
|
+
}, "Failed to remove participant from room");
|
|
10617
10746
|
return false;
|
|
10618
10747
|
}
|
|
10619
10748
|
});
|
|
@@ -10660,7 +10789,13 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10660
10789
|
await tx.update(participantTable).set({ roomState: state }).where(and(eq(participantTable.roomId, roomId), eq(participantTable.entityId, entityId), eq(participantTable.agentId, this.agentId)));
|
|
10661
10790
|
});
|
|
10662
10791
|
} catch (error) {
|
|
10663
|
-
logger10.error({
|
|
10792
|
+
logger10.error({
|
|
10793
|
+
src: "plugin:sql",
|
|
10794
|
+
roomId,
|
|
10795
|
+
entityId,
|
|
10796
|
+
state,
|
|
10797
|
+
error: error instanceof Error ? error.message : String(error)
|
|
10798
|
+
}, "Failed to set participant follow state");
|
|
10664
10799
|
throw error;
|
|
10665
10800
|
}
|
|
10666
10801
|
});
|
|
@@ -10680,7 +10815,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10680
10815
|
await this.db.insert(relationshipTable).values(saveParams);
|
|
10681
10816
|
return true;
|
|
10682
10817
|
} catch (error) {
|
|
10683
|
-
logger10.error({
|
|
10818
|
+
logger10.error({
|
|
10819
|
+
src: "plugin:sql",
|
|
10820
|
+
agentId: this.agentId,
|
|
10821
|
+
error: error instanceof Error ? error.message : String(error),
|
|
10822
|
+
saveParams
|
|
10823
|
+
}, "Error creating relationship");
|
|
10684
10824
|
return false;
|
|
10685
10825
|
}
|
|
10686
10826
|
});
|
|
@@ -10693,7 +10833,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10693
10833
|
metadata: relationship.metadata || {}
|
|
10694
10834
|
}).where(eq(relationshipTable.id, relationship.id));
|
|
10695
10835
|
} catch (error) {
|
|
10696
|
-
logger10.error({
|
|
10836
|
+
logger10.error({
|
|
10837
|
+
src: "plugin:sql",
|
|
10838
|
+
agentId: this.agentId,
|
|
10839
|
+
error: error instanceof Error ? error.message : String(error),
|
|
10840
|
+
relationshipId: relationship.id
|
|
10841
|
+
}, "Error updating relationship");
|
|
10697
10842
|
throw error;
|
|
10698
10843
|
}
|
|
10699
10844
|
});
|
|
@@ -10755,7 +10900,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10755
10900
|
}
|
|
10756
10901
|
return;
|
|
10757
10902
|
} catch (error) {
|
|
10758
|
-
logger10.error({
|
|
10903
|
+
logger10.error({
|
|
10904
|
+
src: "plugin:sql",
|
|
10905
|
+
agentId: this.agentId,
|
|
10906
|
+
error: error instanceof Error ? error.message : String(error),
|
|
10907
|
+
key
|
|
10908
|
+
}, "Error fetching cache");
|
|
10759
10909
|
return;
|
|
10760
10910
|
}
|
|
10761
10911
|
});
|
|
@@ -10775,7 +10925,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10775
10925
|
});
|
|
10776
10926
|
return true;
|
|
10777
10927
|
} catch (error) {
|
|
10778
|
-
logger10.error({
|
|
10928
|
+
logger10.error({
|
|
10929
|
+
src: "plugin:sql",
|
|
10930
|
+
agentId: this.agentId,
|
|
10931
|
+
error: error instanceof Error ? error.message : String(error),
|
|
10932
|
+
key
|
|
10933
|
+
}, "Error setting cache");
|
|
10779
10934
|
return false;
|
|
10780
10935
|
}
|
|
10781
10936
|
});
|
|
@@ -10788,7 +10943,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10788
10943
|
});
|
|
10789
10944
|
return true;
|
|
10790
10945
|
} catch (error) {
|
|
10791
|
-
logger10.error({
|
|
10946
|
+
logger10.error({
|
|
10947
|
+
src: "plugin:sql",
|
|
10948
|
+
agentId: this.agentId,
|
|
10949
|
+
error: error instanceof Error ? error.message : String(error),
|
|
10950
|
+
key
|
|
10951
|
+
}, "Error deleting cache");
|
|
10792
10952
|
return false;
|
|
10793
10953
|
}
|
|
10794
10954
|
});
|
|
@@ -10964,7 +11124,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
10964
11124
|
await this.db.delete(memoryTable).where(inArray(memoryTable.id, memoryIdsInRooms));
|
|
10965
11125
|
}
|
|
10966
11126
|
await this.db.delete(roomTable).where(inArray(roomTable.id, roomIds));
|
|
10967
|
-
logger10.debug({
|
|
11127
|
+
logger10.debug({
|
|
11128
|
+
src: "plugin:sql",
|
|
11129
|
+
worldId,
|
|
11130
|
+
roomsDeleted: roomIds.length,
|
|
11131
|
+
memoriesDeleted: memoryIdsInRooms.length
|
|
11132
|
+
}, "World cleanup completed");
|
|
10968
11133
|
}
|
|
10969
11134
|
});
|
|
10970
11135
|
}
|
|
@@ -11409,6 +11574,7 @@ init_sql();
|
|
|
11409
11574
|
init_tracing();
|
|
11410
11575
|
init_utils();
|
|
11411
11576
|
var { Pool, types: types3 } = pg;
|
|
11577
|
+
var NativePool = pg.native ? pg.native.Pool : undefined;
|
|
11412
11578
|
|
|
11413
11579
|
class NodePgPreparedQuery extends PgPreparedQuery {
|
|
11414
11580
|
constructor(client, queryString, params, logger12, cache, queryMetadata, cacheConfig, fields, name, _isResponseInArrayMode, customResultMapper) {
|
|
@@ -11566,7 +11732,7 @@ class NodePgSession extends PgSession {
|
|
|
11566
11732
|
return new NodePgPreparedQuery(this.client, query.sql, query.params, this.logger, this.cache, queryMetadata, cacheConfig, fields, name, isResponseInArrayMode, customResultMapper);
|
|
11567
11733
|
}
|
|
11568
11734
|
async transaction(transaction, config) {
|
|
11569
|
-
const session2 = this.client instanceof Pool ? new NodePgSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
|
|
11735
|
+
const session2 = this.client instanceof Pool || NativePool && this.client instanceof NativePool ? new NodePgSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
|
|
11570
11736
|
const tx = new NodePgTransaction(this.dialect, session2, this.schema);
|
|
11571
11737
|
await tx.execute(sql`begin${config ? sql` ${tx.getTransactionConfigSQL(config)}` : undefined}`);
|
|
11572
11738
|
try {
|
|
@@ -11577,7 +11743,7 @@ class NodePgSession extends PgSession {
|
|
|
11577
11743
|
await tx.execute(sql`rollback`);
|
|
11578
11744
|
throw error;
|
|
11579
11745
|
} finally {
|
|
11580
|
-
if (this.client instanceof Pool) {
|
|
11746
|
+
if (this.client instanceof Pool || NativePool && this.client instanceof NativePool) {
|
|
11581
11747
|
session2.client.release();
|
|
11582
11748
|
}
|
|
11583
11749
|
}
|
|
@@ -11930,7 +12096,11 @@ function createDatabaseAdapter(config, agentId) {
|
|
|
11930
12096
|
}
|
|
11931
12097
|
rlsServerId = stringToUuid(rlsServerIdString);
|
|
11932
12098
|
managerKey = rlsServerId;
|
|
11933
|
-
logger14.debug({
|
|
12099
|
+
logger14.debug({
|
|
12100
|
+
src: "plugin:sql",
|
|
12101
|
+
rlsServerId: rlsServerId.slice(0, 8),
|
|
12102
|
+
serverIdString: rlsServerIdString
|
|
12103
|
+
}, "Using connection pool for RLS server");
|
|
11934
12104
|
}
|
|
11935
12105
|
if (!globalSingletons.postgresConnectionManagers) {
|
|
11936
12106
|
globalSingletons.postgresConnectionManagers = new Map;
|
|
@@ -11996,5 +12166,5 @@ export {
|
|
|
11996
12166
|
DatabaseMigrationService
|
|
11997
12167
|
};
|
|
11998
12168
|
|
|
11999
|
-
//# debugId=
|
|
12169
|
+
//# debugId=EA546D2333E8154064756E2164756E21
|
|
12000
12170
|
//# sourceMappingURL=index.node.js.map
|