@elizaos/plugin-sql 2.0.0-alpha.12 → 2.0.0-alpha.14

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.
@@ -3152,7 +3152,7 @@ import {
3152
3152
  sql as sql27
3153
3153
  } from "drizzle-orm";
3154
3154
 
3155
- // ../../../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/stringify.js
3155
+ // node_modules/uuid/dist/stringify.js
3156
3156
  var byteToHex = [];
3157
3157
  for (let i = 0;i < 256; ++i) {
3158
3158
  byteToHex.push((i + 256).toString(16).slice(1));
@@ -3161,7 +3161,7 @@ function unsafeStringify(arr, offset = 0) {
3161
3161
  return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
3162
3162
  }
3163
3163
 
3164
- // ../../../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/rng.js
3164
+ // node_modules/uuid/dist/rng.js
3165
3165
  var getRandomValues;
3166
3166
  var rnds8 = new Uint8Array(16);
3167
3167
  function rng() {
@@ -3174,11 +3174,11 @@ function rng() {
3174
3174
  return getRandomValues(rnds8);
3175
3175
  }
3176
3176
 
3177
- // ../../../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/native.js
3177
+ // node_modules/uuid/dist/native.js
3178
3178
  var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
3179
3179
  var native_default = { randomUUID };
3180
3180
 
3181
- // ../../../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/v4.js
3181
+ // node_modules/uuid/dist/v4.js
3182
3182
  function _v4(options, buf, offset) {
3183
3183
  options = options || {};
3184
3184
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -3789,6 +3789,76 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
3789
3789
  });
3790
3790
  return result || [];
3791
3791
  }
3792
+ async getAgentsByIds(agentIds) {
3793
+ if (agentIds.length === 0)
3794
+ return [];
3795
+ return this.withDatabase(async () => {
3796
+ const rows = await this.db.select().from(agentTable).where(inArray(agentTable.id, agentIds));
3797
+ return rows.map((row) => {
3798
+ const bioValue = !row.bio ? "" : Array.isArray(row.bio) ? row.bio : row.bio;
3799
+ return {
3800
+ ...row,
3801
+ username: row.username || "",
3802
+ id: row.id,
3803
+ system: !row.system ? undefined : row.system,
3804
+ bio: bioValue,
3805
+ createdAt: row.createdAt.getTime(),
3806
+ updatedAt: row.updatedAt.getTime()
3807
+ };
3808
+ });
3809
+ });
3810
+ }
3811
+ async createAgents(agents) {
3812
+ if (agents.length === 0)
3813
+ return [];
3814
+ return this.withDatabase(async () => {
3815
+ const ids = [];
3816
+ for (const agent of agents) {
3817
+ if (agent.id) {
3818
+ const success = await this.createAgent(agent);
3819
+ if (success)
3820
+ ids.push(agent.id);
3821
+ }
3822
+ }
3823
+ return ids;
3824
+ });
3825
+ }
3826
+ async updateAgents(updates) {
3827
+ for (const { agentId, agent } of updates) {
3828
+ const success = await this.updateAgent(agentId, agent);
3829
+ if (!success)
3830
+ return false;
3831
+ }
3832
+ return true;
3833
+ }
3834
+ async upsertAgents(agents) {
3835
+ for (const agent of agents) {
3836
+ if (!agent.id)
3837
+ continue;
3838
+ const existing = await this.getAgent(agent.id);
3839
+ if (existing) {
3840
+ await this.updateAgent(agent.id, agent);
3841
+ } else {
3842
+ await this.createAgent(agent);
3843
+ }
3844
+ }
3845
+ }
3846
+ async deleteAgents(agentIds) {
3847
+ if (agentIds.length === 0)
3848
+ return true;
3849
+ return this.withDatabase(async () => {
3850
+ try {
3851
+ await this.db.delete(agentTable).where(inArray(agentTable.id, agentIds));
3852
+ return true;
3853
+ } catch (error) {
3854
+ logger9.error({
3855
+ src: "plugin:sql",
3856
+ error: error instanceof Error ? error.message : String(error)
3857
+ }, "Failed to delete agents");
3858
+ return false;
3859
+ }
3860
+ });
3861
+ }
3792
3862
  async createAgent(agent) {
3793
3863
  const _isDuplicateKeyError = (error) => {
3794
3864
  if (!error || typeof error !== "object")
@@ -6095,5 +6165,5 @@ export {
6095
6165
  DatabaseMigrationService
6096
6166
  };
6097
6167
 
6098
- //# debugId=061DAA0E0FEB9C4C64756E2164756E21
6168
+ //# debugId=2FA11FD9AF0B213A64756E2164756E21
6099
6169
  //# sourceMappingURL=index.browser.js.map