agent-swarm-kit 1.1.77 → 1.1.78

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
@@ -13052,35 +13052,6 @@ class SwarmMetaService {
13052
13052
  }
13053
13053
  }
13054
13054
 
13055
- const sanitizeMarkdown = (input) => {
13056
- if (typeof input !== 'string') {
13057
- return input;
13058
- }
13059
- return input
13060
- // Escape special HTML characters to prevent XSS
13061
- .replace(/&/g, '&')
13062
- .replace(/</g, '&lt;')
13063
- .replace(/>/g, '&gt;')
13064
- // Remove Markdown italic (_text_) and bold (**text** or __text__)
13065
- .replace(/(?:__|\*\*)(.*?)(?:__|\*\*)/g, '$1')
13066
- .replace(/(?:_|\*)(.*?)(?:_|\*)/g, '$1')
13067
- // Remove inline code blocks (`code` or ```code```)
13068
- .replace(/`{1,3}(.*?)`{1,3}/g, '$1')
13069
- // Remove links ([text](url))
13070
- .replace(/\[([^\]]*)\]\([^\)]*\)/g, '$1')
13071
- // Remove images (![text](url))
13072
- .replace(/!\[([^\]]*)\]\([^\)]*\)/g, '$1')
13073
- // Remove headers (# Header)
13074
- .replace(/^(#+)\s*(.*)/gm, '$2')
13075
- // Remove blockquotes (> text)
13076
- .replace(/^>+\s*(.*)/gm, '$1')
13077
- // Remove horizontal rules (---, ***, ___)
13078
- .replace(/^-{3,}$|^[*]{3,}$|^_{3,}$/gm, '')
13079
- // Remove HTML tags
13080
- .replace(/<\/?[^>]+(>|$)/g, '')
13081
- .trim();
13082
- };
13083
-
13084
13055
  /**
13085
13056
  * Maximum number of concurrent threads for documentation generation tasks.
13086
13057
  * Used by execpool in writeSwarmDoc and writeAgentDoc to limit parallel execution, balancing performance and resource usage.
@@ -13233,7 +13204,7 @@ class DocService {
13233
13204
  * @returns {Promise<void>} A promise resolving when the swarm documentation file is written.
13234
13205
  * @private
13235
13206
  */
13236
- this.writeSwarmDoc = functoolsKit.execpool(async (swarmSchema, prefix, dirName) => {
13207
+ this.writeSwarmDoc = functoolsKit.execpool(async (swarmSchema, prefix, dirName, sanitizeMarkdown = (t) => t) => {
13237
13208
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
13238
13209
  this.loggerService.info("docService writeSwarmDoc", {
13239
13210
  swarmSchema,
@@ -13256,7 +13227,7 @@ class DocService {
13256
13227
  }
13257
13228
  {
13258
13229
  const umlSchema = this.swarmMetaService.toUML(swarmSchema.swarmName);
13259
- const umlName = `swarm_schema_${sanitizeMarkdown(swarmSchema.swarmName)}.svg`;
13230
+ const umlName = `swarm_schema_${swarmSchema.swarmName}.svg`;
13260
13231
  const umlSvg = await GLOBAL_CONFIG.CC_FN_PLANTUML(umlSchema);
13261
13232
  if (umlSvg) {
13262
13233
  await writeFileAtomic(path.join(dirName, "image", umlName), umlSvg);
@@ -13267,7 +13238,7 @@ class DocService {
13267
13238
  if (swarmSchema.defaultAgent) {
13268
13239
  result.push("## Default agent");
13269
13240
  result.push("");
13270
- result.push(` - [${sanitizeMarkdown(swarmSchema.defaultAgent)}](./agent/${sanitizeMarkdown(swarmSchema.defaultAgent)}.md)`);
13241
+ result.push(` - [${sanitizeMarkdown(swarmSchema.defaultAgent)}](./agent/${swarmSchema.defaultAgent}.md)`);
13271
13242
  const { docDescription } = this.agentSchemaService.get(swarmSchema.defaultAgent);
13272
13243
  if (docDescription) {
13273
13244
  result.push("");
@@ -13282,7 +13253,7 @@ class DocService {
13282
13253
  if (!swarmSchema.agentList[i]) {
13283
13254
  continue;
13284
13255
  }
13285
- result.push(`${i + 1}. [${sanitizeMarkdown(swarmSchema.agentList[i])}](./agent/${sanitizeMarkdown(swarmSchema.agentList[i])}.md)`);
13256
+ result.push(`${i + 1}. [${sanitizeMarkdown(swarmSchema.agentList[i])}](./agent/${swarmSchema.agentList[i]}.md)`);
13286
13257
  const { docDescription } = this.agentSchemaService.get(swarmSchema.agentList[i]);
13287
13258
  if (docDescription) {
13288
13259
  result.push("");
@@ -13320,7 +13291,7 @@ class DocService {
13320
13291
  }
13321
13292
  result.push("");
13322
13293
  }
13323
- await writeFileAtomic(path.join(dirName, `./${sanitizeMarkdown(swarmSchema.swarmName)}.md`), result.join("\n"));
13294
+ await writeFileAtomic(path.join(dirName, `./${swarmSchema.swarmName}.md`), result.join("\n"));
13324
13295
  }, {
13325
13296
  maxExec: THREAD_POOL_SIZE,
13326
13297
  delay: THREAD_POOL_DELAY,
@@ -13334,7 +13305,7 @@ class DocService {
13334
13305
  * @returns {Promise<void>} A promise resolving when the agent documentation file is written.
13335
13306
  * @private
13336
13307
  */
13337
- this.writeAgentDoc = functoolsKit.execpool(async (agentSchema, prefix, dirName) => {
13308
+ this.writeAgentDoc = functoolsKit.execpool(async (agentSchema, prefix, dirName, sanitizeMarkdown = (t) => t) => {
13338
13309
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
13339
13310
  this.loggerService.info("docService writeAgentDoc", {
13340
13311
  agentSchema,
@@ -13365,7 +13336,7 @@ class DocService {
13365
13336
  }
13366
13337
  {
13367
13338
  const umlSchema = this.agentMetaService.toUML(agentSchema.agentName, true);
13368
- const umlName = `agent_schema_${sanitizeMarkdown(agentSchema.agentName)}.svg`;
13339
+ const umlName = `agent_schema_${agentSchema.agentName}.svg`;
13369
13340
  const umlSvg = await GLOBAL_CONFIG.CC_FN_PLANTUML(umlSchema);
13370
13341
  if (umlSvg) {
13371
13342
  await writeFileAtomic(path.join(dirName, "image", umlName), umlSvg);
@@ -13432,7 +13403,7 @@ class DocService {
13432
13403
  if (!agentSchema.dependsOn[i]) {
13433
13404
  continue;
13434
13405
  }
13435
- result.push(`${i + 1}. [${sanitizeMarkdown(agentSchema.dependsOn[i])}](./${sanitizeMarkdown(agentSchema.dependsOn[i])}.md)`);
13406
+ result.push(`${i + 1}. [${sanitizeMarkdown(agentSchema.dependsOn[i])}](./${agentSchema.dependsOn[i]}.md)`);
13436
13407
  const { docDescription } = this.agentSchemaService.get(agentSchema.dependsOn[i]);
13437
13408
  if (docDescription) {
13438
13409
  result.push("");
@@ -13681,7 +13652,7 @@ class DocService {
13681
13652
  }
13682
13653
  result.push("");
13683
13654
  }
13684
- await writeFileAtomic(path.join(dirName, `./agent/${sanitizeMarkdown(agentSchema.agentName)}.md`), result.join("\n"));
13655
+ await writeFileAtomic(path.join(dirName, `./agent/${agentSchema.agentName}.md`), result.join("\n"));
13685
13656
  }, {
13686
13657
  maxExec: THREAD_POOL_SIZE,
13687
13658
  delay: THREAD_POOL_DELAY,
@@ -13693,7 +13664,7 @@ class DocService {
13693
13664
  * @param {string} [dirName=join(process.cwd(), "docs/chat")] - The base directory for documentation output, defaults to "docs/chat" in the current working directory.
13694
13665
  * @returns {Promise<void>} A promise resolving when all documentation files are written.
13695
13666
  */
13696
- this.dumpDocs = async (prefix = "swarm", dirName = path.join(process.cwd(), "docs/chat")) => {
13667
+ this.dumpDocs = async (prefix = "swarm", dirName = path.join(process.cwd(), "docs/chat"), sanitizeMarkdown = (text) => text) => {
13697
13668
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
13698
13669
  this.loggerService.info("docService dumpDocs", {
13699
13670
  dirName,
@@ -13708,13 +13679,13 @@ class DocService {
13708
13679
  this.loggerService.info("docService dumpDocs building swarm docs");
13709
13680
  await Promise.all(this.swarmValidationService.getSwarmList().map(async (swarmName) => {
13710
13681
  const swarmSchema = this.swarmSchemaService.get(swarmName);
13711
- await this.writeSwarmDoc(swarmSchema, prefix, dirName);
13682
+ await this.writeSwarmDoc(swarmSchema, prefix, dirName, sanitizeMarkdown);
13712
13683
  }));
13713
13684
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
13714
13685
  this.loggerService.info("docService dumpDocs building agent docs");
13715
13686
  await Promise.all(this.agentValidationService.getAgentList().map(async (agentName) => {
13716
13687
  const agentSchema = this.agentSchemaService.get(agentName);
13717
- await this.writeAgentDoc(agentSchema, prefix, dirName);
13688
+ await this.writeAgentDoc(agentSchema, prefix, dirName, sanitizeMarkdown);
13718
13689
  }));
13719
13690
  };
13720
13691
  /**
@@ -18053,7 +18024,7 @@ const METHOD_NAME$1g = "cli.dumpDocs";
18053
18024
  * @param {function} [PlantUML] - An optional function to process PlantUML diagrams.
18054
18025
  * @returns {Promise<void>} - A promise that resolves when the documentation has been dumped.
18055
18026
  */
18056
- const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantUML) => {
18027
+ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantUML, sanitizeMarkdown = (t) => t) => {
18057
18028
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18058
18029
  swarm$1.loggerService.log(METHOD_NAME$1g, {
18059
18030
  dirName,
@@ -18075,7 +18046,7 @@ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantU
18075
18046
  console.error(`agent-swarm missing dependsOn for agentName=${agentName}`);
18076
18047
  }
18077
18048
  });
18078
- return swarm$1.docService.dumpDocs(prefix, dirName);
18049
+ return swarm$1.docService.dumpDocs(prefix, dirName, sanitizeMarkdown);
18079
18050
  });
18080
18051
 
18081
18052
  const METHOD_NAME$1f = "cli.dumpAgent";
package/build/index.mjs CHANGED
@@ -13050,35 +13050,6 @@ class SwarmMetaService {
13050
13050
  }
13051
13051
  }
13052
13052
 
13053
- const sanitizeMarkdown = (input) => {
13054
- if (typeof input !== 'string') {
13055
- return input;
13056
- }
13057
- return input
13058
- // Escape special HTML characters to prevent XSS
13059
- .replace(/&/g, '&amp;')
13060
- .replace(/</g, '&lt;')
13061
- .replace(/>/g, '&gt;')
13062
- // Remove Markdown italic (_text_) and bold (**text** or __text__)
13063
- .replace(/(?:__|\*\*)(.*?)(?:__|\*\*)/g, '$1')
13064
- .replace(/(?:_|\*)(.*?)(?:_|\*)/g, '$1')
13065
- // Remove inline code blocks (`code` or ```code```)
13066
- .replace(/`{1,3}(.*?)`{1,3}/g, '$1')
13067
- // Remove links ([text](url))
13068
- .replace(/\[([^\]]*)\]\([^\)]*\)/g, '$1')
13069
- // Remove images (![text](url))
13070
- .replace(/!\[([^\]]*)\]\([^\)]*\)/g, '$1')
13071
- // Remove headers (# Header)
13072
- .replace(/^(#+)\s*(.*)/gm, '$2')
13073
- // Remove blockquotes (> text)
13074
- .replace(/^>+\s*(.*)/gm, '$1')
13075
- // Remove horizontal rules (---, ***, ___)
13076
- .replace(/^-{3,}$|^[*]{3,}$|^_{3,}$/gm, '')
13077
- // Remove HTML tags
13078
- .replace(/<\/?[^>]+(>|$)/g, '')
13079
- .trim();
13080
- };
13081
-
13082
13053
  /**
13083
13054
  * Maximum number of concurrent threads for documentation generation tasks.
13084
13055
  * Used by execpool in writeSwarmDoc and writeAgentDoc to limit parallel execution, balancing performance and resource usage.
@@ -13231,7 +13202,7 @@ class DocService {
13231
13202
  * @returns {Promise<void>} A promise resolving when the swarm documentation file is written.
13232
13203
  * @private
13233
13204
  */
13234
- this.writeSwarmDoc = execpool(async (swarmSchema, prefix, dirName) => {
13205
+ this.writeSwarmDoc = execpool(async (swarmSchema, prefix, dirName, sanitizeMarkdown = (t) => t) => {
13235
13206
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
13236
13207
  this.loggerService.info("docService writeSwarmDoc", {
13237
13208
  swarmSchema,
@@ -13254,7 +13225,7 @@ class DocService {
13254
13225
  }
13255
13226
  {
13256
13227
  const umlSchema = this.swarmMetaService.toUML(swarmSchema.swarmName);
13257
- const umlName = `swarm_schema_${sanitizeMarkdown(swarmSchema.swarmName)}.svg`;
13228
+ const umlName = `swarm_schema_${swarmSchema.swarmName}.svg`;
13258
13229
  const umlSvg = await GLOBAL_CONFIG.CC_FN_PLANTUML(umlSchema);
13259
13230
  if (umlSvg) {
13260
13231
  await writeFileAtomic(join(dirName, "image", umlName), umlSvg);
@@ -13265,7 +13236,7 @@ class DocService {
13265
13236
  if (swarmSchema.defaultAgent) {
13266
13237
  result.push("## Default agent");
13267
13238
  result.push("");
13268
- result.push(` - [${sanitizeMarkdown(swarmSchema.defaultAgent)}](./agent/${sanitizeMarkdown(swarmSchema.defaultAgent)}.md)`);
13239
+ result.push(` - [${sanitizeMarkdown(swarmSchema.defaultAgent)}](./agent/${swarmSchema.defaultAgent}.md)`);
13269
13240
  const { docDescription } = this.agentSchemaService.get(swarmSchema.defaultAgent);
13270
13241
  if (docDescription) {
13271
13242
  result.push("");
@@ -13280,7 +13251,7 @@ class DocService {
13280
13251
  if (!swarmSchema.agentList[i]) {
13281
13252
  continue;
13282
13253
  }
13283
- result.push(`${i + 1}. [${sanitizeMarkdown(swarmSchema.agentList[i])}](./agent/${sanitizeMarkdown(swarmSchema.agentList[i])}.md)`);
13254
+ result.push(`${i + 1}. [${sanitizeMarkdown(swarmSchema.agentList[i])}](./agent/${swarmSchema.agentList[i]}.md)`);
13284
13255
  const { docDescription } = this.agentSchemaService.get(swarmSchema.agentList[i]);
13285
13256
  if (docDescription) {
13286
13257
  result.push("");
@@ -13318,7 +13289,7 @@ class DocService {
13318
13289
  }
13319
13290
  result.push("");
13320
13291
  }
13321
- await writeFileAtomic(join(dirName, `./${sanitizeMarkdown(swarmSchema.swarmName)}.md`), result.join("\n"));
13292
+ await writeFileAtomic(join(dirName, `./${swarmSchema.swarmName}.md`), result.join("\n"));
13322
13293
  }, {
13323
13294
  maxExec: THREAD_POOL_SIZE,
13324
13295
  delay: THREAD_POOL_DELAY,
@@ -13332,7 +13303,7 @@ class DocService {
13332
13303
  * @returns {Promise<void>} A promise resolving when the agent documentation file is written.
13333
13304
  * @private
13334
13305
  */
13335
- this.writeAgentDoc = execpool(async (agentSchema, prefix, dirName) => {
13306
+ this.writeAgentDoc = execpool(async (agentSchema, prefix, dirName, sanitizeMarkdown = (t) => t) => {
13336
13307
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
13337
13308
  this.loggerService.info("docService writeAgentDoc", {
13338
13309
  agentSchema,
@@ -13363,7 +13334,7 @@ class DocService {
13363
13334
  }
13364
13335
  {
13365
13336
  const umlSchema = this.agentMetaService.toUML(agentSchema.agentName, true);
13366
- const umlName = `agent_schema_${sanitizeMarkdown(agentSchema.agentName)}.svg`;
13337
+ const umlName = `agent_schema_${agentSchema.agentName}.svg`;
13367
13338
  const umlSvg = await GLOBAL_CONFIG.CC_FN_PLANTUML(umlSchema);
13368
13339
  if (umlSvg) {
13369
13340
  await writeFileAtomic(join(dirName, "image", umlName), umlSvg);
@@ -13430,7 +13401,7 @@ class DocService {
13430
13401
  if (!agentSchema.dependsOn[i]) {
13431
13402
  continue;
13432
13403
  }
13433
- result.push(`${i + 1}. [${sanitizeMarkdown(agentSchema.dependsOn[i])}](./${sanitizeMarkdown(agentSchema.dependsOn[i])}.md)`);
13404
+ result.push(`${i + 1}. [${sanitizeMarkdown(agentSchema.dependsOn[i])}](./${agentSchema.dependsOn[i]}.md)`);
13434
13405
  const { docDescription } = this.agentSchemaService.get(agentSchema.dependsOn[i]);
13435
13406
  if (docDescription) {
13436
13407
  result.push("");
@@ -13679,7 +13650,7 @@ class DocService {
13679
13650
  }
13680
13651
  result.push("");
13681
13652
  }
13682
- await writeFileAtomic(join(dirName, `./agent/${sanitizeMarkdown(agentSchema.agentName)}.md`), result.join("\n"));
13653
+ await writeFileAtomic(join(dirName, `./agent/${agentSchema.agentName}.md`), result.join("\n"));
13683
13654
  }, {
13684
13655
  maxExec: THREAD_POOL_SIZE,
13685
13656
  delay: THREAD_POOL_DELAY,
@@ -13691,7 +13662,7 @@ class DocService {
13691
13662
  * @param {string} [dirName=join(process.cwd(), "docs/chat")] - The base directory for documentation output, defaults to "docs/chat" in the current working directory.
13692
13663
  * @returns {Promise<void>} A promise resolving when all documentation files are written.
13693
13664
  */
13694
- this.dumpDocs = async (prefix = "swarm", dirName = join(process.cwd(), "docs/chat")) => {
13665
+ this.dumpDocs = async (prefix = "swarm", dirName = join(process.cwd(), "docs/chat"), sanitizeMarkdown = (text) => text) => {
13695
13666
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
13696
13667
  this.loggerService.info("docService dumpDocs", {
13697
13668
  dirName,
@@ -13706,13 +13677,13 @@ class DocService {
13706
13677
  this.loggerService.info("docService dumpDocs building swarm docs");
13707
13678
  await Promise.all(this.swarmValidationService.getSwarmList().map(async (swarmName) => {
13708
13679
  const swarmSchema = this.swarmSchemaService.get(swarmName);
13709
- await this.writeSwarmDoc(swarmSchema, prefix, dirName);
13680
+ await this.writeSwarmDoc(swarmSchema, prefix, dirName, sanitizeMarkdown);
13710
13681
  }));
13711
13682
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
13712
13683
  this.loggerService.info("docService dumpDocs building agent docs");
13713
13684
  await Promise.all(this.agentValidationService.getAgentList().map(async (agentName) => {
13714
13685
  const agentSchema = this.agentSchemaService.get(agentName);
13715
- await this.writeAgentDoc(agentSchema, prefix, dirName);
13686
+ await this.writeAgentDoc(agentSchema, prefix, dirName, sanitizeMarkdown);
13716
13687
  }));
13717
13688
  };
13718
13689
  /**
@@ -18051,7 +18022,7 @@ const METHOD_NAME$1g = "cli.dumpDocs";
18051
18022
  * @param {function} [PlantUML] - An optional function to process PlantUML diagrams.
18052
18023
  * @returns {Promise<void>} - A promise that resolves when the documentation has been dumped.
18053
18024
  */
18054
- const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantUML) => {
18025
+ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantUML, sanitizeMarkdown = (t) => t) => {
18055
18026
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18056
18027
  swarm$1.loggerService.log(METHOD_NAME$1g, {
18057
18028
  dirName,
@@ -18073,7 +18044,7 @@ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantU
18073
18044
  console.error(`agent-swarm missing dependsOn for agentName=${agentName}`);
18074
18045
  }
18075
18046
  });
18076
- return swarm$1.docService.dumpDocs(prefix, dirName);
18047
+ return swarm$1.docService.dumpDocs(prefix, dirName, sanitizeMarkdown);
18077
18048
  });
18078
18049
 
18079
18050
  const METHOD_NAME$1f = "cli.dumpAgent";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.1.77",
3
+ "version": "1.1.78",
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
@@ -8237,7 +8237,7 @@ declare class DocService {
8237
8237
  * @param {string} [dirName=join(process.cwd(), "docs/chat")] - The base directory for documentation output, defaults to "docs/chat" in the current working directory.
8238
8238
  * @returns {Promise<void>} A promise resolving when all documentation files are written.
8239
8239
  */
8240
- dumpDocs: (prefix?: string, dirName?: string) => Promise<void>;
8240
+ dumpDocs: (prefix?: string, dirName?: string, sanitizeMarkdown?: (text: string) => string) => Promise<void>;
8241
8241
  /**
8242
8242
  * Dumps system-wide performance data to a JSON file using PerfService.toRecord.
8243
8243
  * Ensures the output directory exists, then writes a timestamped file, logging the process if GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO is enabled.
@@ -10990,7 +10990,7 @@ declare const swarm: ISwarmDI;
10990
10990
  * @param {function} [PlantUML] - An optional function to process PlantUML diagrams.
10991
10991
  * @returns {Promise<void>} - A promise that resolves when the documentation has been dumped.
10992
10992
  */
10993
- declare const dumpDocs: (prefix?: any, dirName?: any, PlantUML?: (uml: string) => Promise<string>) => Promise<void>;
10993
+ declare const dumpDocs: (prefix?: any, dirName?: any, PlantUML?: (uml: string) => Promise<string>, sanitizeMarkdown?: (text: string) => string) => Promise<void>;
10994
10994
 
10995
10995
  /**
10996
10996
  * The config for UML generation