agent-swarm-kit 1.2.2 → 1.2.4

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/build/index.cjs CHANGED
@@ -719,9 +719,13 @@ class PersistBase {
719
719
  * @throws {Error} If reading the directory fails (e.g., permissions or directory not found).
720
720
  */
721
721
  async getCount() {
722
- const files = await fs.readdir(this._directory);
723
- const { length } = files.filter((file) => file.endsWith(".json"));
724
- return length;
722
+ let count = 0;
723
+ for await (const entry of await fs.opendir(this._directory)) {
724
+ if (entry.isFile() && entry.name.endsWith(".json")) {
725
+ count++;
726
+ }
727
+ }
728
+ return count;
725
729
  }
726
730
  /**
727
731
  * Reads an entity from storage by its ID, parsing it from a JSON file.
@@ -824,9 +828,13 @@ class PersistBase {
824
828
  entityName: this.entityName,
825
829
  });
826
830
  try {
827
- const files = await fs.readdir(this._directory);
828
- const entityFiles = files.filter((file) => file.endsWith(".json"));
829
- for (const file of entityFiles) {
831
+ const filesToRemove = [];
832
+ for await (const entry of await fs.opendir(this._directory)) {
833
+ if (entry.isFile() && entry.name.endsWith(".json")) {
834
+ filesToRemove.push(entry.name);
835
+ }
836
+ }
837
+ for (const file of filesToRemove) {
830
838
  await fs.unlink(path.join(this._directory, file));
831
839
  }
832
840
  }
@@ -846,11 +854,13 @@ class PersistBase {
846
854
  entityName: this.entityName,
847
855
  });
848
856
  try {
849
- const files = await fs.readdir(this._directory);
850
- const entityIds = files
851
- .filter((file) => file.endsWith(".json"))
852
- .map((file) => file.slice(0, -5))
853
- .sort((a, b) => a.localeCompare(b, undefined, {
857
+ const entityIds = [];
858
+ for await (const entry of await fs.opendir(this._directory)) {
859
+ if (entry.isFile() && entry.name.endsWith(".json")) {
860
+ entityIds.push(entry.name.slice(0, -5));
861
+ }
862
+ }
863
+ entityIds.sort((a, b) => a.localeCompare(b, undefined, {
854
864
  numeric: true,
855
865
  sensitivity: "base",
856
866
  }));
@@ -874,11 +884,13 @@ class PersistBase {
874
884
  entityName: this.entityName,
875
885
  });
876
886
  try {
877
- const files = await fs.readdir(this._directory);
878
- const entityIds = files
879
- .filter((file) => file.endsWith(".json"))
880
- .map((file) => file.slice(0, -5))
881
- .sort((a, b) => a.localeCompare(b, undefined, {
887
+ const entityIds = [];
888
+ for await (const entry of await fs.opendir(this._directory)) {
889
+ if (entry.isFile() && entry.name.endsWith(".json")) {
890
+ entityIds.push(entry.name.slice(0, -5));
891
+ }
892
+ }
893
+ entityIds.sort((a, b) => a.localeCompare(b, undefined, {
882
894
  numeric: true,
883
895
  sensitivity: "base",
884
896
  }));
package/build/index.mjs CHANGED
@@ -699,9 +699,13 @@ class PersistBase {
699
699
  * @throws {Error} If reading the directory fails (e.g., permissions or directory not found).
700
700
  */
701
701
  async getCount() {
702
- const files = await fs__default.readdir(this._directory);
703
- const { length } = files.filter((file) => file.endsWith(".json"));
704
- return length;
702
+ let count = 0;
703
+ for await (const entry of await fs__default.opendir(this._directory)) {
704
+ if (entry.isFile() && entry.name.endsWith(".json")) {
705
+ count++;
706
+ }
707
+ }
708
+ return count;
705
709
  }
706
710
  /**
707
711
  * Reads an entity from storage by its ID, parsing it from a JSON file.
@@ -804,9 +808,13 @@ class PersistBase {
804
808
  entityName: this.entityName,
805
809
  });
806
810
  try {
807
- const files = await fs__default.readdir(this._directory);
808
- const entityFiles = files.filter((file) => file.endsWith(".json"));
809
- for (const file of entityFiles) {
811
+ const filesToRemove = [];
812
+ for await (const entry of await fs__default.opendir(this._directory)) {
813
+ if (entry.isFile() && entry.name.endsWith(".json")) {
814
+ filesToRemove.push(entry.name);
815
+ }
816
+ }
817
+ for (const file of filesToRemove) {
810
818
  await fs__default.unlink(join(this._directory, file));
811
819
  }
812
820
  }
@@ -826,11 +834,13 @@ class PersistBase {
826
834
  entityName: this.entityName,
827
835
  });
828
836
  try {
829
- const files = await fs__default.readdir(this._directory);
830
- const entityIds = files
831
- .filter((file) => file.endsWith(".json"))
832
- .map((file) => file.slice(0, -5))
833
- .sort((a, b) => a.localeCompare(b, undefined, {
837
+ const entityIds = [];
838
+ for await (const entry of await fs__default.opendir(this._directory)) {
839
+ if (entry.isFile() && entry.name.endsWith(".json")) {
840
+ entityIds.push(entry.name.slice(0, -5));
841
+ }
842
+ }
843
+ entityIds.sort((a, b) => a.localeCompare(b, undefined, {
834
844
  numeric: true,
835
845
  sensitivity: "base",
836
846
  }));
@@ -854,11 +864,13 @@ class PersistBase {
854
864
  entityName: this.entityName,
855
865
  });
856
866
  try {
857
- const files = await fs__default.readdir(this._directory);
858
- const entityIds = files
859
- .filter((file) => file.endsWith(".json"))
860
- .map((file) => file.slice(0, -5))
861
- .sort((a, b) => a.localeCompare(b, undefined, {
867
+ const entityIds = [];
868
+ for await (const entry of await fs__default.opendir(this._directory)) {
869
+ if (entry.isFile() && entry.name.endsWith(".json")) {
870
+ entityIds.push(entry.name.slice(0, -5));
871
+ }
872
+ }
873
+ entityIds.sort((a, b) => a.localeCompare(b, undefined, {
862
874
  numeric: true,
863
875
  sensitivity: "base",
864
876
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "dependencies": {
82
82
  "di-kit": "^1.0.18",
83
- "di-scoped": "^1.0.20",
83
+ "di-scoped": "^1.0.21",
84
84
  "functools-kit": "^1.0.95",
85
85
  "get-moment-stamp": "^1.1.1",
86
86
  "lodash-es": "4.17.21",