agent-swarm-kit 1.0.64 → 1.0.65

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
@@ -910,7 +910,7 @@ var setConfig = function (config) {
910
910
  Object.assign(GLOBAL_CONFIG, config);
911
911
  };
912
912
 
913
- var AGENT_CHANGE_SYMBOL = Symbol('agent-change');
913
+ var AGENT_CHANGE_SYMBOL = Symbol("agent-change");
914
914
  var getPlaceholder = function () {
915
915
  return GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS[Math.floor(Math.random() * GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS.length)];
916
916
  };
@@ -1297,6 +1297,13 @@ var ClientAgent = /** @class */ (function () {
1297
1297
  })
1298
1298
  .catch(function (error) {
1299
1299
  var _a, _b;
1300
+ console.error("agent-swarm tool call error functionName=".concat(tool.function.name, " error=").concat(functoolsKit.getErrorMessage(error)), {
1301
+ clientId: _this.params.clientId,
1302
+ agentName: _this.params.agentName,
1303
+ tool_call_id: tool.id,
1304
+ arguments: tool.function.arguments,
1305
+ error: functoolsKit.errorData(error),
1306
+ });
1300
1307
  ((_a = targetFn.callbacks) === null || _a === void 0 ? void 0 : _a.onCallError) &&
1301
1308
  ((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onCallError(tool.id, _this.params.clientId, _this.params.agentName, tool.function.arguments, error));
1302
1309
  _this._toolErrorSubject.next();
package/build/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { scoped } from 'di-scoped';
2
- import { ToolRegistry, trycatch, singleshot, memoize, sleep, Subject, queued, not, randomString, createAwaiter, cancelable, CANCELED_PROMISE_SYMBOL, execpool, SortedArray, schedule, ttl, Source } from 'functools-kit';
2
+ import { ToolRegistry, trycatch, singleshot, memoize, sleep, Subject, queued, getErrorMessage, errorData, not, randomString, createAwaiter, cancelable, CANCELED_PROMISE_SYMBOL, execpool, SortedArray, schedule, ttl, Source } from 'functools-kit';
3
3
  import { createActivator } from 'di-kit';
4
4
  import { omit } from 'lodash-es';
5
5
  import xml2js from 'xml2js';
@@ -908,7 +908,7 @@ var setConfig = function (config) {
908
908
  Object.assign(GLOBAL_CONFIG, config);
909
909
  };
910
910
 
911
- var AGENT_CHANGE_SYMBOL = Symbol('agent-change');
911
+ var AGENT_CHANGE_SYMBOL = Symbol("agent-change");
912
912
  var getPlaceholder = function () {
913
913
  return GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS[Math.floor(Math.random() * GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS.length)];
914
914
  };
@@ -1295,6 +1295,13 @@ var ClientAgent = /** @class */ (function () {
1295
1295
  })
1296
1296
  .catch(function (error) {
1297
1297
  var _a, _b;
1298
+ console.error("agent-swarm tool call error functionName=".concat(tool.function.name, " error=").concat(getErrorMessage(error)), {
1299
+ clientId: _this.params.clientId,
1300
+ agentName: _this.params.agentName,
1301
+ tool_call_id: tool.id,
1302
+ arguments: tool.function.arguments,
1303
+ error: errorData(error),
1304
+ });
1298
1305
  ((_a = targetFn.callbacks) === null || _a === void 0 ? void 0 : _a.onCallError) &&
1299
1306
  ((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onCallError(tool.id, _this.params.clientId, _this.params.agentName, tool.function.arguments, error));
1300
1307
  _this._toolErrorSubject.next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.0.64",
3
+ "version": "1.0.65",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -733,35 +733,136 @@ interface IEmbeddingSchema {
733
733
  type EmbeddingName = string;
734
734
 
735
735
  type StorageId = string | number;
736
+ /**
737
+ * Interface representing the data stored in the storage.
738
+ */
736
739
  interface IStorageData {
737
740
  id: StorageId;
738
741
  }
742
+ /**
743
+ * Interface representing the schema of the storage.
744
+ * @template T - Type of the storage data.
745
+ */
739
746
  interface IStorageSchema<T extends IStorageData = IStorageData> {
747
+ /**
748
+ * Function to get data from the storage.
749
+ * @param clientId - The client ID.
750
+ * @param storageName - The name of the storage.
751
+ * @returns A promise that resolves to an array of storage data or an array of storage data.
752
+ */
740
753
  getData?: (clientId: string, storageName: StorageName) => Promise<T[]> | T[];
754
+ /**
755
+ * Function to create an index for an item.
756
+ * @param item - The item to index.
757
+ * @returns A promise that resolves to a string or a string.
758
+ */
741
759
  createIndex(item: T): Promise<string> | string;
760
+ /**
761
+ * The name of the embedding.
762
+ */
742
763
  embedding: EmbeddingName;
764
+ /**
765
+ * The name of the storage.
766
+ */
743
767
  storageName: StorageName;
768
+ /**
769
+ * Optional callbacks for storage events.
770
+ */
744
771
  callbacks?: Partial<IStorageCallbacks<T>>;
745
772
  }
773
+ /**
774
+ * Interface representing the callbacks for storage events.
775
+ * @template T - Type of the storage data.
776
+ */
746
777
  interface IStorageCallbacks<T extends IStorageData = IStorageData> {
778
+ /**
779
+ * Callback function for update events.
780
+ * @param items - The updated items.
781
+ * @param clientId - The client ID.
782
+ * @param storageName - The name of the storage.
783
+ */
747
784
  onUpdate: (items: T[], clientId: string, storageName: StorageName) => void;
785
+ /**
786
+ * Callback function for search events.
787
+ * @param search - The search query.
788
+ * @param index - The sorted array of storage data.
789
+ * @param clientId - The client ID.
790
+ * @param storageName - The name of the storage.
791
+ */
748
792
  onSearch: (search: string, index: SortedArray<T>, clientId: string, storageName: StorageName) => void;
749
793
  }
794
+ /**
795
+ * Interface representing the parameters for storage.
796
+ * @template T - Type of the storage data.
797
+ */
750
798
  interface IStorageParams<T extends IStorageData = IStorageData> extends IStorageSchema<T>, Partial<IEmbeddingCallbacks> {
799
+ /**
800
+ * The client ID.
801
+ */
751
802
  clientId: string;
803
+ /**
804
+ * Function to calculate similarity.
805
+ */
752
806
  calculateSimilarity: IEmbeddingSchema["calculateSimilarity"];
807
+ /**
808
+ * Function to create an embedding.
809
+ */
753
810
  createEmbedding: IEmbeddingSchema["createEmbedding"];
811
+ /**
812
+ * The name of the storage.
813
+ */
754
814
  storageName: StorageName;
815
+ /**
816
+ * Logger instance.
817
+ */
755
818
  logger: ILogger;
756
819
  }
820
+ /**
821
+ * Interface representing the storage.
822
+ * @template T - Type of the storage data.
823
+ */
757
824
  interface IStorage<T extends IStorageData = IStorageData> {
825
+ /**
826
+ * Function to take items from the storage.
827
+ * @param search - The search query.
828
+ * @param total - The total number of items to take.
829
+ * @param score - Optional score parameter.
830
+ * @returns A promise that resolves to an array of storage data.
831
+ */
758
832
  take(search: string, total: number, score?: number): Promise<T[]>;
833
+ /**
834
+ * Function to upsert an item in the storage.
835
+ * @param item - The item to upsert.
836
+ * @returns A promise that resolves when the operation is complete.
837
+ */
759
838
  upsert(item: T): Promise<void>;
839
+ /**
840
+ * Function to remove an item from the storage.
841
+ * @param itemId - The ID of the item to remove.
842
+ * @returns A promise that resolves when the operation is complete.
843
+ */
760
844
  remove(itemId: IStorageData["id"]): Promise<void>;
845
+ /**
846
+ * Function to get an item from the storage.
847
+ * @param itemId - The ID of the item to get.
848
+ * @returns A promise that resolves to the item or null if not found.
849
+ */
761
850
  get(itemId: IStorageData["id"]): Promise<T | null>;
851
+ /**
852
+ * Function to list items from the storage.
853
+ * @param filter - Optional filter function.
854
+ * @returns A promise that resolves to an array of storage data.
855
+ */
762
856
  list(filter?: (item: T) => boolean): Promise<T[]>;
857
+ /**
858
+ * Function to clear the storage.
859
+ * @returns A promise that resolves when the operation is complete.
860
+ */
763
861
  clear(): Promise<void>;
764
862
  }
863
+ /**
864
+ * Type representing the name of the storage.
865
+ */
765
866
  type StorageName = string;
766
867
 
767
868
  /**