@elizaos/plugin-sql 2.0.0-alpha.13 → 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.
@@ -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=8FA1400A2757EA4764756E2164756E21
6168
+ //# debugId=2FA11FD9AF0B213A64756E2164756E21
6099
6169
  //# sourceMappingURL=index.browser.js.map