agent-swarm-kit 1.1.163 → 1.1.165

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
@@ -18565,9 +18565,35 @@ const addAdvisorInternal = beginContext((advisorSchema) => {
18565
18565
  return advisorSchema.advisorName;
18566
18566
  });
18567
18567
  /**
18568
- * Adds an advisor schema to the system
18568
+ * Adds an advisor schema to the system.
18569
+ * Registers the advisor with validation and schema services, making it available for chat operations.
18570
+ *
18569
18571
  * @function addAdvisor
18570
- * @param {IAdvisorSchema} advisorSchema - The schema definition for advisor.
18572
+ * @template T - The type of message content the advisor accepts (defaults to string). Can be a custom object, Blob, or string.
18573
+ * @param {IAdvisorSchema<T>} advisorSchema - The schema definition for advisor, including name, chat handler, and optional callbacks.
18574
+ * @returns {string} The advisorName that was registered.
18575
+ *
18576
+ * @example
18577
+ * // Using default string message type
18578
+ * addAdvisor({
18579
+ * advisorName: "TextAdvisor",
18580
+ * getChat: async (args) => `Response to: ${args.message}`
18581
+ * });
18582
+ *
18583
+ * @example
18584
+ * // Using custom message type
18585
+ * interface CustomMessage { text: string; metadata: Record<string, any> }
18586
+ * addAdvisor<CustomMessage>({
18587
+ * advisorName: "StructuredAdvisor",
18588
+ * getChat: async (args) => `Processing: ${args.message.text}`
18589
+ * });
18590
+ *
18591
+ * @example
18592
+ * // Using Blob message type
18593
+ * addAdvisor<Blob>({
18594
+ * advisorName: "BlobAdvisor",
18595
+ * getChat: async (args) => `Received blob of size: ${args.message.size}`
18596
+ * });
18571
18597
  */
18572
18598
  function addAdvisor(advisorSchema) {
18573
18599
  return addAdvisorInternal(advisorSchema);
@@ -19367,7 +19393,7 @@ function overrideMCP(mcpSchema) {
19367
19393
  const METHOD_NAME$X = "function.test.overrideAdvisor";
19368
19394
  /**
19369
19395
  * Function implementation
19370
- */
19396
+ */
19371
19397
  const overrideAdvisorInternal = beginContext((publicAdvisorSchema) => {
19372
19398
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19373
19399
  swarm$1.loggerService.log(METHOD_NAME$X, {
@@ -19381,20 +19407,29 @@ const overrideAdvisorInternal = beginContext((publicAdvisorSchema) => {
19381
19407
  * This function updates the configuration of an advisor identified by its `advisorName`, applying the provided schema properties.
19382
19408
  * It operates outside any existing method or execution contexts to ensure isolation, leveraging `beginContext` for a clean execution scope.
19383
19409
  * Logs the override operation if logging is enabled in the global configuration.
19410
+ * Only the provided properties will be updated - omitted properties remain unchanged.
19384
19411
  *
19385
- *
19386
- * @param {TAdvisorSchema} advisorSchema - The schema definition for advisor.
19412
+ * @function overrideAdvisor
19413
+ * @template T - The type of message content the advisor accepts (defaults to string). Can be a custom object, Blob, or string.
19414
+ * @param {TAdvisorSchema<T>} advisorSchema - Partial schema definition for advisor. Must include `advisorName`, other properties are optional.
19415
+ * @returns {IAdvisorSchema<T>} The updated complete advisor schema.
19387
19416
  * @throws {Error} If the advisor schema service encounters an error during the override operation (e.g., invalid advisorName or schema).
19388
19417
  *
19389
19418
  * @example
19390
- * // Override an advisor's schema with new properties
19419
+ * // Override advisor's description only
19391
19420
  * overrideAdvisor({
19392
19421
  * advisorName: "KnowledgeBase",
19393
- * description: "Updated knowledge repository",
19394
- * storage: "AdvisorStorage",
19422
+ * docDescription: "Updated knowledge repository",
19395
19423
  * });
19396
- * // Logs the operation (if enabled) and updates the advisor schema in the swarm.
19397
- */
19424
+ *
19425
+ * @example
19426
+ * // Override advisor with custom message type
19427
+ * interface CustomMessage { query: string; context: string[] }
19428
+ * overrideAdvisor<CustomMessage>({
19429
+ * advisorName: "StructuredAdvisor",
19430
+ * getChat: async (args) => `Query: ${args.message.query}`
19431
+ * });
19432
+ */
19398
19433
  function overrideAdvisor(advisorSchema) {
19399
19434
  return overrideAdvisorInternal(advisorSchema);
19400
19435
  }
@@ -20125,11 +20160,33 @@ const askInternal = beginContext(async (message, advisorName, images = []) => {
20125
20160
  return await getChat(args);
20126
20161
  });
20127
20162
  /**
20128
- * Initiates an ask process within a chat context
20163
+ * Initiates an ask process within a chat context.
20164
+ * Sends a message to the specified advisor and returns the chat response.
20165
+ * Supports custom message types including objects, Blob, or string.
20166
+ *
20129
20167
  * @function ask
20130
- * @param {string} message - The message content to process or send.
20131
- * @param {AdvisorName} advisorName - The name of the advisor.
20132
- * @param {Image[]} [images] - Optional array of images (as Uint8Array or string).
20168
+ * @template T - The type of message content (defaults to string). Can be a custom object, Blob, or string.
20169
+ * @param {T} message - The message content to process or send. Type should match the advisor's expected message type.
20170
+ * @param {AdvisorName} advisorName - The name of the advisor to handle the message.
20171
+ * @param {Image[]} [images] - Optional array of images (as Uint8Array or string) to accompany the message.
20172
+ * @returns {Promise<string>} The response from the advisor's chat handler.
20173
+ *
20174
+ * @example
20175
+ * // Using default string message type
20176
+ * const response = await ask("Hello", "TextAdvisor");
20177
+ *
20178
+ * @example
20179
+ * // Using custom message type
20180
+ * interface CustomMessage { text: string; priority: number }
20181
+ * const response = await ask<CustomMessage>(
20182
+ * { text: "Important", priority: 1 },
20183
+ * "StructuredAdvisor"
20184
+ * );
20185
+ *
20186
+ * @example
20187
+ * // Using Blob message type with images
20188
+ * const blob = new Blob(["data"], { type: "text/plain" });
20189
+ * const response = await ask<Blob>(blob, "BlobAdvisor", [imageData]);
20133
20190
  */
20134
20191
  async function ask(message, advisorName, images) {
20135
20192
  return await askInternal(message, advisorName, images);
package/build/index.mjs CHANGED
@@ -18545,9 +18545,35 @@ const addAdvisorInternal = beginContext((advisorSchema) => {
18545
18545
  return advisorSchema.advisorName;
18546
18546
  });
18547
18547
  /**
18548
- * Adds an advisor schema to the system
18548
+ * Adds an advisor schema to the system.
18549
+ * Registers the advisor with validation and schema services, making it available for chat operations.
18550
+ *
18549
18551
  * @function addAdvisor
18550
- * @param {IAdvisorSchema} advisorSchema - The schema definition for advisor.
18552
+ * @template T - The type of message content the advisor accepts (defaults to string). Can be a custom object, Blob, or string.
18553
+ * @param {IAdvisorSchema<T>} advisorSchema - The schema definition for advisor, including name, chat handler, and optional callbacks.
18554
+ * @returns {string} The advisorName that was registered.
18555
+ *
18556
+ * @example
18557
+ * // Using default string message type
18558
+ * addAdvisor({
18559
+ * advisorName: "TextAdvisor",
18560
+ * getChat: async (args) => `Response to: ${args.message}`
18561
+ * });
18562
+ *
18563
+ * @example
18564
+ * // Using custom message type
18565
+ * interface CustomMessage { text: string; metadata: Record<string, any> }
18566
+ * addAdvisor<CustomMessage>({
18567
+ * advisorName: "StructuredAdvisor",
18568
+ * getChat: async (args) => `Processing: ${args.message.text}`
18569
+ * });
18570
+ *
18571
+ * @example
18572
+ * // Using Blob message type
18573
+ * addAdvisor<Blob>({
18574
+ * advisorName: "BlobAdvisor",
18575
+ * getChat: async (args) => `Received blob of size: ${args.message.size}`
18576
+ * });
18551
18577
  */
18552
18578
  function addAdvisor(advisorSchema) {
18553
18579
  return addAdvisorInternal(advisorSchema);
@@ -19347,7 +19373,7 @@ function overrideMCP(mcpSchema) {
19347
19373
  const METHOD_NAME$X = "function.test.overrideAdvisor";
19348
19374
  /**
19349
19375
  * Function implementation
19350
- */
19376
+ */
19351
19377
  const overrideAdvisorInternal = beginContext((publicAdvisorSchema) => {
19352
19378
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19353
19379
  swarm$1.loggerService.log(METHOD_NAME$X, {
@@ -19361,20 +19387,29 @@ const overrideAdvisorInternal = beginContext((publicAdvisorSchema) => {
19361
19387
  * This function updates the configuration of an advisor identified by its `advisorName`, applying the provided schema properties.
19362
19388
  * It operates outside any existing method or execution contexts to ensure isolation, leveraging `beginContext` for a clean execution scope.
19363
19389
  * Logs the override operation if logging is enabled in the global configuration.
19390
+ * Only the provided properties will be updated - omitted properties remain unchanged.
19364
19391
  *
19365
- *
19366
- * @param {TAdvisorSchema} advisorSchema - The schema definition for advisor.
19392
+ * @function overrideAdvisor
19393
+ * @template T - The type of message content the advisor accepts (defaults to string). Can be a custom object, Blob, or string.
19394
+ * @param {TAdvisorSchema<T>} advisorSchema - Partial schema definition for advisor. Must include `advisorName`, other properties are optional.
19395
+ * @returns {IAdvisorSchema<T>} The updated complete advisor schema.
19367
19396
  * @throws {Error} If the advisor schema service encounters an error during the override operation (e.g., invalid advisorName or schema).
19368
19397
  *
19369
19398
  * @example
19370
- * // Override an advisor's schema with new properties
19399
+ * // Override advisor's description only
19371
19400
  * overrideAdvisor({
19372
19401
  * advisorName: "KnowledgeBase",
19373
- * description: "Updated knowledge repository",
19374
- * storage: "AdvisorStorage",
19402
+ * docDescription: "Updated knowledge repository",
19375
19403
  * });
19376
- * // Logs the operation (if enabled) and updates the advisor schema in the swarm.
19377
- */
19404
+ *
19405
+ * @example
19406
+ * // Override advisor with custom message type
19407
+ * interface CustomMessage { query: string; context: string[] }
19408
+ * overrideAdvisor<CustomMessage>({
19409
+ * advisorName: "StructuredAdvisor",
19410
+ * getChat: async (args) => `Query: ${args.message.query}`
19411
+ * });
19412
+ */
19378
19413
  function overrideAdvisor(advisorSchema) {
19379
19414
  return overrideAdvisorInternal(advisorSchema);
19380
19415
  }
@@ -20105,11 +20140,33 @@ const askInternal = beginContext(async (message, advisorName, images = []) => {
20105
20140
  return await getChat(args);
20106
20141
  });
20107
20142
  /**
20108
- * Initiates an ask process within a chat context
20143
+ * Initiates an ask process within a chat context.
20144
+ * Sends a message to the specified advisor and returns the chat response.
20145
+ * Supports custom message types including objects, Blob, or string.
20146
+ *
20109
20147
  * @function ask
20110
- * @param {string} message - The message content to process or send.
20111
- * @param {AdvisorName} advisorName - The name of the advisor.
20112
- * @param {Image[]} [images] - Optional array of images (as Uint8Array or string).
20148
+ * @template T - The type of message content (defaults to string). Can be a custom object, Blob, or string.
20149
+ * @param {T} message - The message content to process or send. Type should match the advisor's expected message type.
20150
+ * @param {AdvisorName} advisorName - The name of the advisor to handle the message.
20151
+ * @param {Image[]} [images] - Optional array of images (as Uint8Array or string) to accompany the message.
20152
+ * @returns {Promise<string>} The response from the advisor's chat handler.
20153
+ *
20154
+ * @example
20155
+ * // Using default string message type
20156
+ * const response = await ask("Hello", "TextAdvisor");
20157
+ *
20158
+ * @example
20159
+ * // Using custom message type
20160
+ * interface CustomMessage { text: string; priority: number }
20161
+ * const response = await ask<CustomMessage>(
20162
+ * { text: "Important", priority: 1 },
20163
+ * "StructuredAdvisor"
20164
+ * );
20165
+ *
20166
+ * @example
20167
+ * // Using Blob message type with images
20168
+ * const blob = new Blob(["data"], { type: "text/plain" });
20169
+ * const response = await ask<Blob>(blob, "BlobAdvisor", [imageData]);
20113
20170
  */
20114
20171
  async function ask(message, advisorName, images) {
20115
20172
  return await askInternal(message, advisorName, images);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.1.163",
3
+ "version": "1.1.165",
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
@@ -2752,7 +2752,7 @@ interface IOutlineSchema<Data extends IOutlineData = IOutlineData, Param extends
2752
2752
  * If a function is provided, it may return a string or a Promise resolving to a string.
2753
2753
  * This prompt is typically sent to the completion engine or model to guide the generation process.
2754
2754
  */
2755
- prompt: string | ((outlineName: OutlineName) => (string | Promise<string>));
2755
+ prompt?: string | ((outlineName: OutlineName) => (string | Promise<string>));
2756
2756
  /**
2757
2757
  * The system prompt(s) provided to the language model for the outline operation.
2758
2758
  * Can be a static array of strings or a function that generates the system prompts dynamically based on the outline name.
@@ -4143,19 +4143,19 @@ type Image$1 = Uint8Array | string;
4143
4143
  * @interface IAdvisorCallbacks
4144
4144
  * Callback functions for advisor operations
4145
4145
  */
4146
- interface IAdvisorCallbacks {
4146
+ interface IAdvisorCallbacks<T = string> {
4147
4147
  /**
4148
4148
  * Optional callback triggered when a chat operation occurs
4149
4149
  */
4150
- onChat?: (args: IChatArgs) => void;
4150
+ onChat?: (args: IChatArgs<T>) => void;
4151
4151
  }
4152
4152
  /**
4153
4153
  * @interface IChatArgs
4154
4154
  * Arguments required for chat operations
4155
4155
  */
4156
- interface IChatArgs {
4156
+ interface IChatArgs<T = string> {
4157
4157
  /** Message content for the chat*/
4158
- message: string;
4158
+ message: T;
4159
4159
  /** Optional array of images associated with the chat. */
4160
4160
  images?: Image$1[];
4161
4161
  }
@@ -4163,17 +4163,17 @@ interface IChatArgs {
4163
4163
  * @interface IAdvisorSchema
4164
4164
  * Schema definition for advisor configuration
4165
4165
  */
4166
- interface IAdvisorSchema {
4166
+ interface IAdvisorSchema<T = string> {
4167
4167
  /** Optional description of the advisor documentation*/
4168
4168
  docDescription?: string;
4169
4169
  /** Name identifier for the advisor*/
4170
4170
  advisorName: AdvisorName;
4171
4171
  /**
4172
4172
  * Function to get chat response
4173
- */
4174
- getChat(args: IChatArgs): Promise<string>;
4173
+ */
4174
+ getChat(args: IChatArgs<T>): Promise<string>;
4175
4175
  /** Optional callbacks for advisor operations*/
4176
- callbacks?: IAdvisorCallbacks;
4176
+ callbacks?: IAdvisorCallbacks<T>;
4177
4177
  }
4178
4178
  /**
4179
4179
  * Type alias for advisor name identifier.
@@ -8239,7 +8239,7 @@ declare class AdvisorSchemaService {
8239
8239
  * @public
8240
8240
  * Logs the override operation and updates the registry with the new schema
8241
8241
  */
8242
- override: (key: AdvisorName, value: Partial<IAdvisorSchema>) => IAdvisorSchema;
8242
+ override: (key: AdvisorName, value: Partial<IAdvisorSchema>) => IAdvisorSchema<string>;
8243
8243
  /**
8244
8244
  * Retrieves an advisor schema by key
8245
8245
  * @public
@@ -10296,11 +10296,37 @@ interface IFetchInfoToolParams<T = Record<string, any>> extends IFetchInfoParams
10296
10296
  declare function addFetchInfo<T = Record<string, any>>(params: IFetchInfoToolParams<T>): string;
10297
10297
 
10298
10298
  /**
10299
- * Adds an advisor schema to the system
10299
+ * Adds an advisor schema to the system.
10300
+ * Registers the advisor with validation and schema services, making it available for chat operations.
10301
+ *
10300
10302
  * @function addAdvisor
10301
- * @param {IAdvisorSchema} advisorSchema - The schema definition for advisor.
10303
+ * @template T - The type of message content the advisor accepts (defaults to string). Can be a custom object, Blob, or string.
10304
+ * @param {IAdvisorSchema<T>} advisorSchema - The schema definition for advisor, including name, chat handler, and optional callbacks.
10305
+ * @returns {string} The advisorName that was registered.
10306
+ *
10307
+ * @example
10308
+ * // Using default string message type
10309
+ * addAdvisor({
10310
+ * advisorName: "TextAdvisor",
10311
+ * getChat: async (args) => `Response to: ${args.message}`
10312
+ * });
10313
+ *
10314
+ * @example
10315
+ * // Using custom message type
10316
+ * interface CustomMessage { text: string; metadata: Record<string, any> }
10317
+ * addAdvisor<CustomMessage>({
10318
+ * advisorName: "StructuredAdvisor",
10319
+ * getChat: async (args) => `Processing: ${args.message.text}`
10320
+ * });
10321
+ *
10322
+ * @example
10323
+ * // Using Blob message type
10324
+ * addAdvisor<Blob>({
10325
+ * advisorName: "BlobAdvisor",
10326
+ * getChat: async (args) => `Received blob of size: ${args.message.size}`
10327
+ * });
10302
10328
  */
10303
- declare function addAdvisor(advisorSchema: IAdvisorSchema): string;
10329
+ declare function addAdvisor<T = string>(advisorSchema: IAdvisorSchema<T>): string;
10304
10330
 
10305
10331
  /**
10306
10332
  * Adds a new agent to the agent registry for use within the swarm system.
@@ -10737,30 +10763,39 @@ declare function overrideMCP(mcpSchema: TMCPSchema): IMCPSchema;
10737
10763
  /**
10738
10764
  * Type representing a partial advisor schema configuration.
10739
10765
  * Used for advisor service configuration with optional properties.
10740
- */
10741
- type TAdvisorSchema = {
10742
- advisorName: IAdvisorSchema["advisorName"];
10743
- } & Partial<IAdvisorSchema>;
10766
+ */
10767
+ type TAdvisorSchema<T = string> = {
10768
+ advisorName: IAdvisorSchema<T>["advisorName"];
10769
+ } & Partial<IAdvisorSchema<T>>;
10744
10770
  /**
10745
10771
  * Overrides an existing advisor schema in the swarm system with a new or partial schema.
10746
10772
  * This function updates the configuration of an advisor identified by its `advisorName`, applying the provided schema properties.
10747
10773
  * It operates outside any existing method or execution contexts to ensure isolation, leveraging `beginContext` for a clean execution scope.
10748
10774
  * Logs the override operation if logging is enabled in the global configuration.
10775
+ * Only the provided properties will be updated - omitted properties remain unchanged.
10749
10776
  *
10750
- *
10751
- * @param {TAdvisorSchema} advisorSchema - The schema definition for advisor.
10777
+ * @function overrideAdvisor
10778
+ * @template T - The type of message content the advisor accepts (defaults to string). Can be a custom object, Blob, or string.
10779
+ * @param {TAdvisorSchema<T>} advisorSchema - Partial schema definition for advisor. Must include `advisorName`, other properties are optional.
10780
+ * @returns {IAdvisorSchema<T>} The updated complete advisor schema.
10752
10781
  * @throws {Error} If the advisor schema service encounters an error during the override operation (e.g., invalid advisorName or schema).
10753
10782
  *
10754
10783
  * @example
10755
- * // Override an advisor's schema with new properties
10784
+ * // Override advisor's description only
10756
10785
  * overrideAdvisor({
10757
10786
  * advisorName: "KnowledgeBase",
10758
- * description: "Updated knowledge repository",
10759
- * storage: "AdvisorStorage",
10787
+ * docDescription: "Updated knowledge repository",
10760
10788
  * });
10761
- * // Logs the operation (if enabled) and updates the advisor schema in the swarm.
10762
- */
10763
- declare function overrideAdvisor(advisorSchema: TAdvisorSchema): IAdvisorSchema;
10789
+ *
10790
+ * @example
10791
+ * // Override advisor with custom message type
10792
+ * interface CustomMessage { query: string; context: string[] }
10793
+ * overrideAdvisor<CustomMessage>({
10794
+ * advisorName: "StructuredAdvisor",
10795
+ * getChat: async (args) => `Query: ${args.message.query}`
10796
+ * });
10797
+ */
10798
+ declare function overrideAdvisor<T = string>(advisorSchema: TAdvisorSchema<T>): TAdvisorSchema<T>;
10764
10799
 
10765
10800
  /**
10766
10801
  * @module overrideCompute
@@ -11184,13 +11219,35 @@ declare function executeForce(content: string, clientId: string): Promise<string
11184
11219
  /** Image type as either an array of Uint8Array or an array of strings */
11185
11220
  type Image = Uint8Array | string;
11186
11221
  /**
11187
- * Initiates an ask process within a chat context
11222
+ * Initiates an ask process within a chat context.
11223
+ * Sends a message to the specified advisor and returns the chat response.
11224
+ * Supports custom message types including objects, Blob, or string.
11225
+ *
11188
11226
  * @function ask
11189
- * @param {string} message - The message content to process or send.
11190
- * @param {AdvisorName} advisorName - The name of the advisor.
11191
- * @param {Image[]} [images] - Optional array of images (as Uint8Array or string).
11227
+ * @template T - The type of message content (defaults to string). Can be a custom object, Blob, or string.
11228
+ * @param {T} message - The message content to process or send. Type should match the advisor's expected message type.
11229
+ * @param {AdvisorName} advisorName - The name of the advisor to handle the message.
11230
+ * @param {Image[]} [images] - Optional array of images (as Uint8Array or string) to accompany the message.
11231
+ * @returns {Promise<string>} The response from the advisor's chat handler.
11232
+ *
11233
+ * @example
11234
+ * // Using default string message type
11235
+ * const response = await ask("Hello", "TextAdvisor");
11236
+ *
11237
+ * @example
11238
+ * // Using custom message type
11239
+ * interface CustomMessage { text: string; priority: number }
11240
+ * const response = await ask<CustomMessage>(
11241
+ * { text: "Important", priority: 1 },
11242
+ * "StructuredAdvisor"
11243
+ * );
11244
+ *
11245
+ * @example
11246
+ * // Using Blob message type with images
11247
+ * const blob = new Blob(["data"], { type: "text/plain" });
11248
+ * const response = await ask<Blob>(blob, "BlobAdvisor", [imageData]);
11192
11249
  */
11193
- declare function ask(message: string, advisorName: AdvisorName, images?: Image[]): Promise<string>;
11250
+ declare function ask<T = string>(message: T, advisorName: AdvisorName, images?: Image[]): Promise<string>;
11194
11251
 
11195
11252
  /**
11196
11253
  * Processes an outline request to generate structured JSON data based on a specified outline schema.
@@ -11903,7 +11960,7 @@ declare function getTool(toolName: ToolName): IAgentTool<Record<string, ToolValu
11903
11960
  * @function getAdvisor
11904
11961
  * @param {AdvisorName} advisorName - The name of the advisor.
11905
11962
  */
11906
- declare function getAdvisor(advisorName: AdvisorName): IAdvisorSchema;
11963
+ declare function getAdvisor(advisorName: AdvisorName): IAdvisorSchema<string>;
11907
11964
 
11908
11965
  /**
11909
11966
  * Retrieves the raw, unmodified history for a given client session.