agent-swarm-kit 1.0.64 → 1.0.66

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
@@ -478,6 +478,9 @@ var HistoryInstance = /** @class */ (function () {
478
478
  if (callbacks.onInit) {
479
479
  callbacks.onInit(clientId);
480
480
  }
481
+ if (callbacks.onRef) {
482
+ callbacks.onRef(this);
483
+ }
481
484
  if (callbacks.filterCondition) {
482
485
  this.iterate = function (agentName) {
483
486
  return __asyncGenerator(this, arguments, function () {
@@ -910,7 +913,7 @@ var setConfig = function (config) {
910
913
  Object.assign(GLOBAL_CONFIG, config);
911
914
  };
912
915
 
913
- var AGENT_CHANGE_SYMBOL = Symbol('agent-change');
916
+ var AGENT_CHANGE_SYMBOL = Symbol("agent-change");
914
917
  var getPlaceholder = function () {
915
918
  return GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS[Math.floor(Math.random() * GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS.length)];
916
919
  };
@@ -1297,6 +1300,13 @@ var ClientAgent = /** @class */ (function () {
1297
1300
  })
1298
1301
  .catch(function (error) {
1299
1302
  var _a, _b;
1303
+ console.error("agent-swarm tool call error functionName=".concat(tool.function.name, " error=").concat(functoolsKit.getErrorMessage(error)), {
1304
+ clientId: _this.params.clientId,
1305
+ agentName: _this.params.agentName,
1306
+ tool_call_id: tool.id,
1307
+ arguments: tool.function.arguments,
1308
+ error: functoolsKit.errorData(error),
1309
+ });
1300
1310
  ((_a = targetFn.callbacks) === null || _a === void 0 ? void 0 : _a.onCallError) &&
1301
1311
  ((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onCallError(tool.id, _this.params.clientId, _this.params.agentName, tool.function.arguments, error));
1302
1312
  _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';
@@ -476,6 +476,9 @@ var HistoryInstance = /** @class */ (function () {
476
476
  if (callbacks.onInit) {
477
477
  callbacks.onInit(clientId);
478
478
  }
479
+ if (callbacks.onRef) {
480
+ callbacks.onRef(this);
481
+ }
479
482
  if (callbacks.filterCondition) {
480
483
  this.iterate = function (agentName) {
481
484
  return __asyncGenerator(this, arguments, function () {
@@ -908,7 +911,7 @@ var setConfig = function (config) {
908
911
  Object.assign(GLOBAL_CONFIG, config);
909
912
  };
910
913
 
911
- var AGENT_CHANGE_SYMBOL = Symbol('agent-change');
914
+ var AGENT_CHANGE_SYMBOL = Symbol("agent-change");
912
915
  var getPlaceholder = function () {
913
916
  return GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS[Math.floor(Math.random() * GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS.length)];
914
917
  };
@@ -1295,6 +1298,13 @@ var ClientAgent = /** @class */ (function () {
1295
1298
  })
1296
1299
  .catch(function (error) {
1297
1300
  var _a, _b;
1301
+ console.error("agent-swarm tool call error functionName=".concat(tool.function.name, " error=").concat(getErrorMessage(error)), {
1302
+ clientId: _this.params.clientId,
1303
+ agentName: _this.params.agentName,
1304
+ tool_call_id: tool.id,
1305
+ arguments: tool.function.arguments,
1306
+ error: errorData(error),
1307
+ });
1298
1308
  ((_a = targetFn.callbacks) === null || _a === void 0 ? void 0 : _a.onCallError) &&
1299
1309
  ((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onCallError(tool.id, _this.params.clientId, _this.params.agentName, tool.function.arguments, error));
1300
1310
  _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.66",
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
@@ -436,6 +436,11 @@ interface IHistoryInstanceCallbacks {
436
436
  * @param clientId - The client ID.
437
437
  */
438
438
  onInit: (clientId: string) => void;
439
+ /**
440
+ * Callback to obtain history ref
441
+ * @param clientId - The client ID.
442
+ */
443
+ onRef: (history: HistoryInstance) => void;
439
444
  }
440
445
  /**
441
446
  * Interface for History Adapter
@@ -733,35 +738,136 @@ interface IEmbeddingSchema {
733
738
  type EmbeddingName = string;
734
739
 
735
740
  type StorageId = string | number;
741
+ /**
742
+ * Interface representing the data stored in the storage.
743
+ */
736
744
  interface IStorageData {
737
745
  id: StorageId;
738
746
  }
747
+ /**
748
+ * Interface representing the schema of the storage.
749
+ * @template T - Type of the storage data.
750
+ */
739
751
  interface IStorageSchema<T extends IStorageData = IStorageData> {
752
+ /**
753
+ * Function to get data from the storage.
754
+ * @param clientId - The client ID.
755
+ * @param storageName - The name of the storage.
756
+ * @returns A promise that resolves to an array of storage data or an array of storage data.
757
+ */
740
758
  getData?: (clientId: string, storageName: StorageName) => Promise<T[]> | T[];
759
+ /**
760
+ * Function to create an index for an item.
761
+ * @param item - The item to index.
762
+ * @returns A promise that resolves to a string or a string.
763
+ */
741
764
  createIndex(item: T): Promise<string> | string;
765
+ /**
766
+ * The name of the embedding.
767
+ */
742
768
  embedding: EmbeddingName;
769
+ /**
770
+ * The name of the storage.
771
+ */
743
772
  storageName: StorageName;
773
+ /**
774
+ * Optional callbacks for storage events.
775
+ */
744
776
  callbacks?: Partial<IStorageCallbacks<T>>;
745
777
  }
778
+ /**
779
+ * Interface representing the callbacks for storage events.
780
+ * @template T - Type of the storage data.
781
+ */
746
782
  interface IStorageCallbacks<T extends IStorageData = IStorageData> {
783
+ /**
784
+ * Callback function for update events.
785
+ * @param items - The updated items.
786
+ * @param clientId - The client ID.
787
+ * @param storageName - The name of the storage.
788
+ */
747
789
  onUpdate: (items: T[], clientId: string, storageName: StorageName) => void;
790
+ /**
791
+ * Callback function for search events.
792
+ * @param search - The search query.
793
+ * @param index - The sorted array of storage data.
794
+ * @param clientId - The client ID.
795
+ * @param storageName - The name of the storage.
796
+ */
748
797
  onSearch: (search: string, index: SortedArray<T>, clientId: string, storageName: StorageName) => void;
749
798
  }
799
+ /**
800
+ * Interface representing the parameters for storage.
801
+ * @template T - Type of the storage data.
802
+ */
750
803
  interface IStorageParams<T extends IStorageData = IStorageData> extends IStorageSchema<T>, Partial<IEmbeddingCallbacks> {
804
+ /**
805
+ * The client ID.
806
+ */
751
807
  clientId: string;
808
+ /**
809
+ * Function to calculate similarity.
810
+ */
752
811
  calculateSimilarity: IEmbeddingSchema["calculateSimilarity"];
812
+ /**
813
+ * Function to create an embedding.
814
+ */
753
815
  createEmbedding: IEmbeddingSchema["createEmbedding"];
816
+ /**
817
+ * The name of the storage.
818
+ */
754
819
  storageName: StorageName;
820
+ /**
821
+ * Logger instance.
822
+ */
755
823
  logger: ILogger;
756
824
  }
825
+ /**
826
+ * Interface representing the storage.
827
+ * @template T - Type of the storage data.
828
+ */
757
829
  interface IStorage<T extends IStorageData = IStorageData> {
830
+ /**
831
+ * Function to take items from the storage.
832
+ * @param search - The search query.
833
+ * @param total - The total number of items to take.
834
+ * @param score - Optional score parameter.
835
+ * @returns A promise that resolves to an array of storage data.
836
+ */
758
837
  take(search: string, total: number, score?: number): Promise<T[]>;
838
+ /**
839
+ * Function to upsert an item in the storage.
840
+ * @param item - The item to upsert.
841
+ * @returns A promise that resolves when the operation is complete.
842
+ */
759
843
  upsert(item: T): Promise<void>;
844
+ /**
845
+ * Function to remove an item from the storage.
846
+ * @param itemId - The ID of the item to remove.
847
+ * @returns A promise that resolves when the operation is complete.
848
+ */
760
849
  remove(itemId: IStorageData["id"]): Promise<void>;
850
+ /**
851
+ * Function to get an item from the storage.
852
+ * @param itemId - The ID of the item to get.
853
+ * @returns A promise that resolves to the item or null if not found.
854
+ */
761
855
  get(itemId: IStorageData["id"]): Promise<T | null>;
856
+ /**
857
+ * Function to list items from the storage.
858
+ * @param filter - Optional filter function.
859
+ * @returns A promise that resolves to an array of storage data.
860
+ */
762
861
  list(filter?: (item: T) => boolean): Promise<T[]>;
862
+ /**
863
+ * Function to clear the storage.
864
+ * @returns A promise that resolves when the operation is complete.
865
+ */
763
866
  clear(): Promise<void>;
764
867
  }
868
+ /**
869
+ * Type representing the name of the storage.
870
+ */
765
871
  type StorageName = string;
766
872
 
767
873
  /**