agent-swarm-kit 1.1.74 → 1.1.76

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,6 +13052,31 @@ 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
+ // Remove Markdown italic (_text_) and bold (**text** or __text__)
13061
+ .replace(/(?:__|\*\*)(.*?)(?:__|\*\*)/g, "$1")
13062
+ .replace(/(?:_|\*)(.*?)(?:_|\*)/g, "$1")
13063
+ // Remove inline code blocks (`code` or ```code```)
13064
+ .replace(/`{1,3}(.*?)`{1,3}/g, "$1")
13065
+ // Remove links ([text](url))
13066
+ .replace(/\[([^\]]*)\]\([^\)]*\)/g, "$1")
13067
+ // Remove images (![text](url))
13068
+ .replace(/!\[([^\]]*)\]\([^\)]*\)/g, "$1")
13069
+ // Remove headers (# Header)
13070
+ .replace(/^(#+)\s*(.*)/gm, "$2")
13071
+ // Remove blockquotes (> text)
13072
+ .replace(/^>+\s*(.*)/gm, "$1")
13073
+ // Remove horizontal rules (---, ***, ___)
13074
+ .replace(/^-{3,}$|^[*]{3,}$|^_{3,}$/gm, "")
13075
+ // Remove HTML tags
13076
+ .replace(/<\/?[^>]+(>|$)/g, "")
13077
+ .trim());
13078
+ };
13079
+
13055
13080
  /**
13056
13081
  * Maximum number of concurrent threads for documentation generation tasks.
13057
13082
  * Used by execpool in writeSwarmDoc and writeAgentDoc to limit parallel execution, balancing performance and resource usage.
@@ -13212,22 +13237,22 @@ class DocService {
13212
13237
  const result = [];
13213
13238
  {
13214
13239
  result.push("---");
13215
- result.push(`title: ${prefix}/${swarmSchema.swarmName}`);
13240
+ result.push(`title: ${prefix}/${sanitizeMarkdown(swarmSchema.swarmName)}`);
13216
13241
  result.push(`group: ${prefix}`);
13217
13242
  result.push("---");
13218
13243
  result.push("");
13219
13244
  }
13220
13245
  {
13221
- result.push(`# ${swarmSchema.swarmName}`);
13246
+ result.push(`# ${sanitizeMarkdown(swarmSchema.swarmName)}`);
13222
13247
  if (swarmSchema.docDescription) {
13223
13248
  result.push("");
13224
- result.push(`> ${swarmSchema.docDescription}`);
13249
+ result.push(`> ${sanitizeMarkdown(swarmSchema.docDescription)}`);
13225
13250
  }
13226
13251
  result.push("");
13227
13252
  }
13228
13253
  {
13229
13254
  const umlSchema = this.swarmMetaService.toUML(swarmSchema.swarmName);
13230
- const umlName = `swarm_schema_${swarmSchema.swarmName}.svg`;
13255
+ const umlName = `swarm_schema_${sanitizeMarkdown(swarmSchema.swarmName)}.svg`;
13231
13256
  const umlSvg = await GLOBAL_CONFIG.CC_FN_PLANTUML(umlSchema);
13232
13257
  if (umlSvg) {
13233
13258
  await writeFileAtomic(path.join(dirName, "image", umlName), umlSvg);
@@ -13238,11 +13263,11 @@ class DocService {
13238
13263
  if (swarmSchema.defaultAgent) {
13239
13264
  result.push("## Default agent");
13240
13265
  result.push("");
13241
- result.push(` - [${swarmSchema.defaultAgent}](./agent/${swarmSchema.defaultAgent}.md)`);
13266
+ result.push(` - [${sanitizeMarkdown(swarmSchema.defaultAgent)}](./agent/${sanitizeMarkdown(swarmSchema.defaultAgent)}.md)`);
13242
13267
  const { docDescription } = this.agentSchemaService.get(swarmSchema.defaultAgent);
13243
13268
  if (docDescription) {
13244
13269
  result.push("");
13245
- result.push(`\t${docDescription}`);
13270
+ result.push(`\t${sanitizeMarkdown(docDescription)}`);
13246
13271
  }
13247
13272
  result.push("");
13248
13273
  }
@@ -13253,11 +13278,11 @@ class DocService {
13253
13278
  if (!swarmSchema.agentList[i]) {
13254
13279
  continue;
13255
13280
  }
13256
- result.push(`${i + 1}. [${swarmSchema.agentList[i]}](./agent/${swarmSchema.agentList[i]}.md)`);
13281
+ result.push(`${i + 1}. [${sanitizeMarkdown(swarmSchema.agentList[i])}](./agent/${sanitizeMarkdown(swarmSchema.agentList[i])}.md)`);
13257
13282
  const { docDescription } = this.agentSchemaService.get(swarmSchema.agentList[i]);
13258
13283
  if (docDescription) {
13259
13284
  result.push("");
13260
- result.push(`\t${docDescription}`);
13285
+ result.push(`\t${sanitizeMarkdown(docDescription)}`);
13261
13286
  }
13262
13287
  result.push("");
13263
13288
  }
@@ -13269,11 +13294,11 @@ class DocService {
13269
13294
  if (!swarmSchema.policies[i]) {
13270
13295
  continue;
13271
13296
  }
13272
- result.push(`${i + 1}. ${swarmSchema.policies[i]}`);
13297
+ result.push(`${i + 1}. ${sanitizeMarkdown(swarmSchema.policies[i])}`);
13273
13298
  const { docDescription } = this.policySchemaService.get(swarmSchema.policies[i]);
13274
13299
  if (docDescription) {
13275
13300
  result.push("");
13276
- result.push(`\t${docDescription}`);
13301
+ result.push(`\t${sanitizeMarkdown(docDescription)}`);
13277
13302
  }
13278
13303
  result.push("");
13279
13304
  }
@@ -13287,11 +13312,11 @@ class DocService {
13287
13312
  result.push("");
13288
13313
  const callbackList = Object.keys(swarmSchema.callbacks);
13289
13314
  for (let i = 0; i !== callbackList.length; i++) {
13290
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13315
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13291
13316
  }
13292
13317
  result.push("");
13293
13318
  }
13294
- await writeFileAtomic(path.join(dirName, `./${swarmSchema.swarmName}.md`), result.join("\n"));
13319
+ await writeFileAtomic(path.join(dirName, `./${sanitizeMarkdown(swarmSchema.swarmName)}.md`), result.join("\n"));
13295
13320
  }, {
13296
13321
  maxExec: THREAD_POOL_SIZE,
13297
13322
  delay: THREAD_POOL_DELAY,
@@ -13313,21 +13338,21 @@ class DocService {
13313
13338
  const result = [];
13314
13339
  {
13315
13340
  result.push("---");
13316
- result.push(`title: ${prefix}/${agentSchema.agentName}`);
13341
+ result.push(`title: ${prefix}/${sanitizeMarkdown(agentSchema.agentName)}`);
13317
13342
  result.push(`group: ${prefix}`);
13318
13343
  result.push("---");
13319
13344
  result.push("");
13320
13345
  }
13321
13346
  {
13322
- result.push(`# ${agentSchema.agentName}`);
13347
+ result.push(`# ${sanitizeMarkdown(agentSchema.agentName)}`);
13323
13348
  if (agentSchema.docDescription) {
13324
13349
  result.push("");
13325
- result.push(`> ${agentSchema.docDescription}`);
13350
+ result.push(`> ${sanitizeMarkdown(agentSchema.docDescription)}`);
13326
13351
  }
13327
13352
  result.push("");
13328
13353
  }
13329
13354
  if (agentSchema.completion) {
13330
- result.push(`**Completion:** \`${agentSchema.completion}\``);
13355
+ result.push(`**Completion:** \`${sanitizeMarkdown(agentSchema.completion)}\``);
13331
13356
  result.push("");
13332
13357
  }
13333
13358
  {
@@ -13336,7 +13361,7 @@ class DocService {
13336
13361
  }
13337
13362
  {
13338
13363
  const umlSchema = this.agentMetaService.toUML(agentSchema.agentName, true);
13339
- const umlName = `agent_schema_${agentSchema.agentName}.svg`;
13364
+ const umlName = `agent_schema_${sanitizeMarkdown(agentSchema.agentName)}.svg`;
13340
13365
  const umlSvg = await GLOBAL_CONFIG.CC_FN_PLANTUML(umlSchema);
13341
13366
  if (umlSvg) {
13342
13367
  await writeFileAtomic(path.join(dirName, "image", umlName), umlSvg);
@@ -13363,7 +13388,7 @@ class DocService {
13363
13388
  result.push(`## Main prompt`);
13364
13389
  result.push("");
13365
13390
  result.push("```");
13366
- result.push(prompt);
13391
+ result.push(sanitizeMarkdown(prompt));
13367
13392
  result.push("```");
13368
13393
  result.push("");
13369
13394
  }
@@ -13392,7 +13417,7 @@ class DocService {
13392
13417
  if (!system[i]) {
13393
13418
  continue;
13394
13419
  }
13395
- result.push(`${i + 1}. \`${system[i]}\``);
13420
+ result.push(`${i + 1}. \`${sanitizeMarkdown(system[i])}\``);
13396
13421
  result.push("");
13397
13422
  }
13398
13423
  }
@@ -13403,11 +13428,11 @@ class DocService {
13403
13428
  if (!agentSchema.dependsOn[i]) {
13404
13429
  continue;
13405
13430
  }
13406
- result.push(`${i + 1}. [${agentSchema.dependsOn[i]}](./${agentSchema.dependsOn[i]}.md)`);
13431
+ result.push(`${i + 1}. [${sanitizeMarkdown(agentSchema.dependsOn[i])}](./${sanitizeMarkdown(agentSchema.dependsOn[i])}.md)`);
13407
13432
  const { docDescription } = this.agentSchemaService.get(agentSchema.dependsOn[i]);
13408
13433
  if (docDescription) {
13409
13434
  result.push("");
13410
- result.push(docDescription);
13435
+ result.push(sanitizeMarkdown(docDescription));
13411
13436
  }
13412
13437
  result.push("");
13413
13438
  }
@@ -13419,11 +13444,11 @@ class DocService {
13419
13444
  if (!agentSchema.mcp[i]) {
13420
13445
  continue;
13421
13446
  }
13422
- result.push(`${i + 1}. ${agentSchema.mcp[i]}`);
13447
+ result.push(`${i + 1}. ${sanitizeMarkdown(agentSchema.mcp[i])}`);
13423
13448
  const { docDescription } = this.mcpSchemaService.get(agentSchema.mcp[i]);
13424
13449
  if (docDescription) {
13425
13450
  result.push("");
13426
- result.push(docDescription);
13451
+ result.push(sanitizeMarkdown(docDescription));
13427
13452
  }
13428
13453
  result.push("");
13429
13454
  }
@@ -13459,18 +13484,18 @@ class DocService {
13459
13484
  continue;
13460
13485
  }
13461
13486
  const { function: fn, docNote, callbacks } = tools[i];
13462
- result.push(`### ${i + 1}. ${agentSchema.tools[i]}`);
13487
+ result.push(`### ${i + 1}. ${sanitizeMarkdown(agentSchema.tools[i])}`);
13463
13488
  if (fn.name) {
13464
13489
  result.push("");
13465
13490
  result.push("#### Name for model");
13466
13491
  result.push("");
13467
- result.push(`\`${fn.name}\``);
13492
+ result.push(`\`${sanitizeMarkdown(fn.name)}\``);
13468
13493
  }
13469
13494
  if (fn.description) {
13470
13495
  result.push("");
13471
13496
  result.push("#### Description for model");
13472
13497
  result.push("");
13473
- result.push(`\`${fn.description}\``);
13498
+ result.push(`\`${sanitizeMarkdown(fn.description)}\``);
13474
13499
  }
13475
13500
  if (fn.parameters?.properties) {
13476
13501
  result.push("");
@@ -13478,18 +13503,18 @@ class DocService {
13478
13503
  const entries = Object.entries(fn.parameters.properties);
13479
13504
  entries.forEach(([key, { type, description, enum: e }], idx) => {
13480
13505
  result.push("");
13481
- result.push(`> **${idx + 1}. ${key}**`);
13506
+ result.push(`> **${idx + 1}. ${sanitizeMarkdown(key)}**`);
13482
13507
  {
13483
13508
  result.push("");
13484
- result.push(`*Type:* \`${type}\``);
13509
+ result.push(`*Type:* \`${sanitizeMarkdown(type)}\``);
13485
13510
  }
13486
13511
  {
13487
13512
  result.push("");
13488
- result.push(`*Description:* \`${description}\``);
13513
+ result.push(`*Description:* \`${sanitizeMarkdown(description)}\``);
13489
13514
  }
13490
13515
  if (e) {
13491
13516
  result.push("");
13492
- result.push(`*Enum:* \`${e.join(", ")}\``);
13517
+ result.push(`*Enum:* \`${e.map(sanitizeMarkdown).join(", ")}\``);
13493
13518
  }
13494
13519
  {
13495
13520
  result.push("");
@@ -13507,14 +13532,14 @@ class DocService {
13507
13532
  result.push("");
13508
13533
  const callbackList = Object.keys(callbacks);
13509
13534
  for (let i = 0; i !== callbackList.length; i++) {
13510
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13535
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13511
13536
  }
13512
13537
  }
13513
13538
  if (docNote) {
13514
13539
  result.push("");
13515
13540
  result.push("#### Note for developer");
13516
13541
  result.push("");
13517
- result.push(`*${docNote}*`);
13542
+ result.push(`*${sanitizeMarkdown(docNote)}*`);
13518
13543
  }
13519
13544
  result.push("");
13520
13545
  }
@@ -13526,17 +13551,17 @@ class DocService {
13526
13551
  if (!agentSchema.storages[i]) {
13527
13552
  continue;
13528
13553
  }
13529
- result.push(`### ${i + 1}. ${agentSchema.storages[i]}`);
13554
+ result.push(`### ${i + 1}. ${sanitizeMarkdown(agentSchema.storages[i])}`);
13530
13555
  const { docDescription, embedding, shared, callbacks } = this.storageSchemaService.get(agentSchema.storages[i]);
13531
13556
  if (docDescription) {
13532
13557
  result.push("");
13533
13558
  result.push(`#### Storage description`);
13534
13559
  result.push("");
13535
- result.push(docDescription);
13560
+ result.push(sanitizeMarkdown(docDescription));
13536
13561
  }
13537
13562
  if (embedding) {
13538
13563
  result.push("");
13539
- result.push(`*Embedding:* \`${embedding}\``);
13564
+ result.push(`*Embedding:* \`${sanitizeMarkdown(embedding)}\``);
13540
13565
  }
13541
13566
  {
13542
13567
  result.push("");
@@ -13548,7 +13573,7 @@ class DocService {
13548
13573
  result.push("");
13549
13574
  const callbackList = Object.keys(callbacks);
13550
13575
  for (let i = 0; i !== callbackList.length; i++) {
13551
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13576
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13552
13577
  }
13553
13578
  }
13554
13579
  result.push("");
@@ -13572,13 +13597,13 @@ class DocService {
13572
13597
  if (!agentSchema.states[i]) {
13573
13598
  continue;
13574
13599
  }
13575
- result.push(`### ${i + 1}. ${agentSchema.states[i]}`);
13600
+ result.push(`### ${i + 1}. ${sanitizeMarkdown(agentSchema.states[i])}`);
13576
13601
  const { docDescription, shared, callbacks } = this.stateSchemaService.get(agentSchema.states[i]);
13577
13602
  if (docDescription) {
13578
13603
  result.push("");
13579
13604
  result.push(`#### State description`);
13580
13605
  result.push("");
13581
- result.push(docDescription);
13606
+ result.push(sanitizeMarkdown(docDescription));
13582
13607
  }
13583
13608
  {
13584
13609
  const computeSchemasCurrentList = computeSchemasTotalList.filter(([stateName]) => stateName === agentSchema.states[i]);
@@ -13589,10 +13614,10 @@ class DocService {
13589
13614
  for (let i = 0; i !== computeSchemasCurrentList.length; i++) {
13590
13615
  const [, { computeName, docDescription }] = computeSchemasCurrentList[i];
13591
13616
  result.push("");
13592
- result.push(`> **${i + 1}. ${computeName}**`);
13617
+ result.push(`> **${i + 1}. ${sanitizeMarkdown(computeName)}**`);
13593
13618
  {
13594
13619
  result.push("");
13595
- result.push(`*Description:* \`${docDescription}\``);
13620
+ result.push(`*Description:* \`${sanitizeMarkdown(docDescription)}\``);
13596
13621
  }
13597
13622
  }
13598
13623
  result.push("");
@@ -13605,7 +13630,7 @@ class DocService {
13605
13630
  result.push("");
13606
13631
  const callbackList = Object.keys(callbacks);
13607
13632
  for (let i = 0; i !== callbackList.length; i++) {
13608
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13633
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13609
13634
  }
13610
13635
  }
13611
13636
  }
@@ -13623,13 +13648,13 @@ class DocService {
13623
13648
  if (!agentSchema.wikiList[i]) {
13624
13649
  continue;
13625
13650
  }
13626
- result.push(`### ${i + 1}. ${agentSchema.wikiList[i]}`);
13651
+ result.push(`### ${i + 1}. ${sanitizeMarkdown(agentSchema.wikiList[i])}`);
13627
13652
  const { docDescription, callbacks } = this.wikiSchemaService.get(agentSchema.wikiList[i]);
13628
13653
  if (docDescription) {
13629
13654
  result.push("");
13630
13655
  result.push(`#### Wiki description`);
13631
13656
  result.push("");
13632
- result.push(docDescription);
13657
+ result.push(sanitizeMarkdown(docDescription));
13633
13658
  }
13634
13659
  if (callbacks) {
13635
13660
  result.push("");
@@ -13637,7 +13662,7 @@ class DocService {
13637
13662
  result.push("");
13638
13663
  const callbackList = Object.keys(callbacks);
13639
13664
  for (let i = 0; i !== callbackList.length; i++) {
13640
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13665
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13641
13666
  }
13642
13667
  }
13643
13668
  result.push("");
@@ -13648,11 +13673,11 @@ class DocService {
13648
13673
  result.push("");
13649
13674
  const callbackList = Object.keys(agentSchema.callbacks);
13650
13675
  for (let i = 0; i !== callbackList.length; i++) {
13651
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13676
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13652
13677
  }
13653
13678
  result.push("");
13654
13679
  }
13655
- await writeFileAtomic(path.join(dirName, `./agent/${agentSchema.agentName}.md`), result.join("\n"));
13680
+ await writeFileAtomic(path.join(dirName, `./agent/${sanitizeMarkdown(agentSchema.agentName)}.md`), result.join("\n"));
13656
13681
  }, {
13657
13682
  maxExec: THREAD_POOL_SIZE,
13658
13683
  delay: THREAD_POOL_DELAY,
package/build/index.mjs CHANGED
@@ -13050,6 +13050,31 @@ 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
+ // Remove Markdown italic (_text_) and bold (**text** or __text__)
13059
+ .replace(/(?:__|\*\*)(.*?)(?:__|\*\*)/g, "$1")
13060
+ .replace(/(?:_|\*)(.*?)(?:_|\*)/g, "$1")
13061
+ // Remove inline code blocks (`code` or ```code```)
13062
+ .replace(/`{1,3}(.*?)`{1,3}/g, "$1")
13063
+ // Remove links ([text](url))
13064
+ .replace(/\[([^\]]*)\]\([^\)]*\)/g, "$1")
13065
+ // Remove images (![text](url))
13066
+ .replace(/!\[([^\]]*)\]\([^\)]*\)/g, "$1")
13067
+ // Remove headers (# Header)
13068
+ .replace(/^(#+)\s*(.*)/gm, "$2")
13069
+ // Remove blockquotes (> text)
13070
+ .replace(/^>+\s*(.*)/gm, "$1")
13071
+ // Remove horizontal rules (---, ***, ___)
13072
+ .replace(/^-{3,}$|^[*]{3,}$|^_{3,}$/gm, "")
13073
+ // Remove HTML tags
13074
+ .replace(/<\/?[^>]+(>|$)/g, "")
13075
+ .trim());
13076
+ };
13077
+
13053
13078
  /**
13054
13079
  * Maximum number of concurrent threads for documentation generation tasks.
13055
13080
  * Used by execpool in writeSwarmDoc and writeAgentDoc to limit parallel execution, balancing performance and resource usage.
@@ -13210,22 +13235,22 @@ class DocService {
13210
13235
  const result = [];
13211
13236
  {
13212
13237
  result.push("---");
13213
- result.push(`title: ${prefix}/${swarmSchema.swarmName}`);
13238
+ result.push(`title: ${prefix}/${sanitizeMarkdown(swarmSchema.swarmName)}`);
13214
13239
  result.push(`group: ${prefix}`);
13215
13240
  result.push("---");
13216
13241
  result.push("");
13217
13242
  }
13218
13243
  {
13219
- result.push(`# ${swarmSchema.swarmName}`);
13244
+ result.push(`# ${sanitizeMarkdown(swarmSchema.swarmName)}`);
13220
13245
  if (swarmSchema.docDescription) {
13221
13246
  result.push("");
13222
- result.push(`> ${swarmSchema.docDescription}`);
13247
+ result.push(`> ${sanitizeMarkdown(swarmSchema.docDescription)}`);
13223
13248
  }
13224
13249
  result.push("");
13225
13250
  }
13226
13251
  {
13227
13252
  const umlSchema = this.swarmMetaService.toUML(swarmSchema.swarmName);
13228
- const umlName = `swarm_schema_${swarmSchema.swarmName}.svg`;
13253
+ const umlName = `swarm_schema_${sanitizeMarkdown(swarmSchema.swarmName)}.svg`;
13229
13254
  const umlSvg = await GLOBAL_CONFIG.CC_FN_PLANTUML(umlSchema);
13230
13255
  if (umlSvg) {
13231
13256
  await writeFileAtomic(join(dirName, "image", umlName), umlSvg);
@@ -13236,11 +13261,11 @@ class DocService {
13236
13261
  if (swarmSchema.defaultAgent) {
13237
13262
  result.push("## Default agent");
13238
13263
  result.push("");
13239
- result.push(` - [${swarmSchema.defaultAgent}](./agent/${swarmSchema.defaultAgent}.md)`);
13264
+ result.push(` - [${sanitizeMarkdown(swarmSchema.defaultAgent)}](./agent/${sanitizeMarkdown(swarmSchema.defaultAgent)}.md)`);
13240
13265
  const { docDescription } = this.agentSchemaService.get(swarmSchema.defaultAgent);
13241
13266
  if (docDescription) {
13242
13267
  result.push("");
13243
- result.push(`\t${docDescription}`);
13268
+ result.push(`\t${sanitizeMarkdown(docDescription)}`);
13244
13269
  }
13245
13270
  result.push("");
13246
13271
  }
@@ -13251,11 +13276,11 @@ class DocService {
13251
13276
  if (!swarmSchema.agentList[i]) {
13252
13277
  continue;
13253
13278
  }
13254
- result.push(`${i + 1}. [${swarmSchema.agentList[i]}](./agent/${swarmSchema.agentList[i]}.md)`);
13279
+ result.push(`${i + 1}. [${sanitizeMarkdown(swarmSchema.agentList[i])}](./agent/${sanitizeMarkdown(swarmSchema.agentList[i])}.md)`);
13255
13280
  const { docDescription } = this.agentSchemaService.get(swarmSchema.agentList[i]);
13256
13281
  if (docDescription) {
13257
13282
  result.push("");
13258
- result.push(`\t${docDescription}`);
13283
+ result.push(`\t${sanitizeMarkdown(docDescription)}`);
13259
13284
  }
13260
13285
  result.push("");
13261
13286
  }
@@ -13267,11 +13292,11 @@ class DocService {
13267
13292
  if (!swarmSchema.policies[i]) {
13268
13293
  continue;
13269
13294
  }
13270
- result.push(`${i + 1}. ${swarmSchema.policies[i]}`);
13295
+ result.push(`${i + 1}. ${sanitizeMarkdown(swarmSchema.policies[i])}`);
13271
13296
  const { docDescription } = this.policySchemaService.get(swarmSchema.policies[i]);
13272
13297
  if (docDescription) {
13273
13298
  result.push("");
13274
- result.push(`\t${docDescription}`);
13299
+ result.push(`\t${sanitizeMarkdown(docDescription)}`);
13275
13300
  }
13276
13301
  result.push("");
13277
13302
  }
@@ -13285,11 +13310,11 @@ class DocService {
13285
13310
  result.push("");
13286
13311
  const callbackList = Object.keys(swarmSchema.callbacks);
13287
13312
  for (let i = 0; i !== callbackList.length; i++) {
13288
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13313
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13289
13314
  }
13290
13315
  result.push("");
13291
13316
  }
13292
- await writeFileAtomic(join(dirName, `./${swarmSchema.swarmName}.md`), result.join("\n"));
13317
+ await writeFileAtomic(join(dirName, `./${sanitizeMarkdown(swarmSchema.swarmName)}.md`), result.join("\n"));
13293
13318
  }, {
13294
13319
  maxExec: THREAD_POOL_SIZE,
13295
13320
  delay: THREAD_POOL_DELAY,
@@ -13311,21 +13336,21 @@ class DocService {
13311
13336
  const result = [];
13312
13337
  {
13313
13338
  result.push("---");
13314
- result.push(`title: ${prefix}/${agentSchema.agentName}`);
13339
+ result.push(`title: ${prefix}/${sanitizeMarkdown(agentSchema.agentName)}`);
13315
13340
  result.push(`group: ${prefix}`);
13316
13341
  result.push("---");
13317
13342
  result.push("");
13318
13343
  }
13319
13344
  {
13320
- result.push(`# ${agentSchema.agentName}`);
13345
+ result.push(`# ${sanitizeMarkdown(agentSchema.agentName)}`);
13321
13346
  if (agentSchema.docDescription) {
13322
13347
  result.push("");
13323
- result.push(`> ${agentSchema.docDescription}`);
13348
+ result.push(`> ${sanitizeMarkdown(agentSchema.docDescription)}`);
13324
13349
  }
13325
13350
  result.push("");
13326
13351
  }
13327
13352
  if (agentSchema.completion) {
13328
- result.push(`**Completion:** \`${agentSchema.completion}\``);
13353
+ result.push(`**Completion:** \`${sanitizeMarkdown(agentSchema.completion)}\``);
13329
13354
  result.push("");
13330
13355
  }
13331
13356
  {
@@ -13334,7 +13359,7 @@ class DocService {
13334
13359
  }
13335
13360
  {
13336
13361
  const umlSchema = this.agentMetaService.toUML(agentSchema.agentName, true);
13337
- const umlName = `agent_schema_${agentSchema.agentName}.svg`;
13362
+ const umlName = `agent_schema_${sanitizeMarkdown(agentSchema.agentName)}.svg`;
13338
13363
  const umlSvg = await GLOBAL_CONFIG.CC_FN_PLANTUML(umlSchema);
13339
13364
  if (umlSvg) {
13340
13365
  await writeFileAtomic(join(dirName, "image", umlName), umlSvg);
@@ -13361,7 +13386,7 @@ class DocService {
13361
13386
  result.push(`## Main prompt`);
13362
13387
  result.push("");
13363
13388
  result.push("```");
13364
- result.push(prompt);
13389
+ result.push(sanitizeMarkdown(prompt));
13365
13390
  result.push("```");
13366
13391
  result.push("");
13367
13392
  }
@@ -13390,7 +13415,7 @@ class DocService {
13390
13415
  if (!system[i]) {
13391
13416
  continue;
13392
13417
  }
13393
- result.push(`${i + 1}. \`${system[i]}\``);
13418
+ result.push(`${i + 1}. \`${sanitizeMarkdown(system[i])}\``);
13394
13419
  result.push("");
13395
13420
  }
13396
13421
  }
@@ -13401,11 +13426,11 @@ class DocService {
13401
13426
  if (!agentSchema.dependsOn[i]) {
13402
13427
  continue;
13403
13428
  }
13404
- result.push(`${i + 1}. [${agentSchema.dependsOn[i]}](./${agentSchema.dependsOn[i]}.md)`);
13429
+ result.push(`${i + 1}. [${sanitizeMarkdown(agentSchema.dependsOn[i])}](./${sanitizeMarkdown(agentSchema.dependsOn[i])}.md)`);
13405
13430
  const { docDescription } = this.agentSchemaService.get(agentSchema.dependsOn[i]);
13406
13431
  if (docDescription) {
13407
13432
  result.push("");
13408
- result.push(docDescription);
13433
+ result.push(sanitizeMarkdown(docDescription));
13409
13434
  }
13410
13435
  result.push("");
13411
13436
  }
@@ -13417,11 +13442,11 @@ class DocService {
13417
13442
  if (!agentSchema.mcp[i]) {
13418
13443
  continue;
13419
13444
  }
13420
- result.push(`${i + 1}. ${agentSchema.mcp[i]}`);
13445
+ result.push(`${i + 1}. ${sanitizeMarkdown(agentSchema.mcp[i])}`);
13421
13446
  const { docDescription } = this.mcpSchemaService.get(agentSchema.mcp[i]);
13422
13447
  if (docDescription) {
13423
13448
  result.push("");
13424
- result.push(docDescription);
13449
+ result.push(sanitizeMarkdown(docDescription));
13425
13450
  }
13426
13451
  result.push("");
13427
13452
  }
@@ -13457,18 +13482,18 @@ class DocService {
13457
13482
  continue;
13458
13483
  }
13459
13484
  const { function: fn, docNote, callbacks } = tools[i];
13460
- result.push(`### ${i + 1}. ${agentSchema.tools[i]}`);
13485
+ result.push(`### ${i + 1}. ${sanitizeMarkdown(agentSchema.tools[i])}`);
13461
13486
  if (fn.name) {
13462
13487
  result.push("");
13463
13488
  result.push("#### Name for model");
13464
13489
  result.push("");
13465
- result.push(`\`${fn.name}\``);
13490
+ result.push(`\`${sanitizeMarkdown(fn.name)}\``);
13466
13491
  }
13467
13492
  if (fn.description) {
13468
13493
  result.push("");
13469
13494
  result.push("#### Description for model");
13470
13495
  result.push("");
13471
- result.push(`\`${fn.description}\``);
13496
+ result.push(`\`${sanitizeMarkdown(fn.description)}\``);
13472
13497
  }
13473
13498
  if (fn.parameters?.properties) {
13474
13499
  result.push("");
@@ -13476,18 +13501,18 @@ class DocService {
13476
13501
  const entries = Object.entries(fn.parameters.properties);
13477
13502
  entries.forEach(([key, { type, description, enum: e }], idx) => {
13478
13503
  result.push("");
13479
- result.push(`> **${idx + 1}. ${key}**`);
13504
+ result.push(`> **${idx + 1}. ${sanitizeMarkdown(key)}**`);
13480
13505
  {
13481
13506
  result.push("");
13482
- result.push(`*Type:* \`${type}\``);
13507
+ result.push(`*Type:* \`${sanitizeMarkdown(type)}\``);
13483
13508
  }
13484
13509
  {
13485
13510
  result.push("");
13486
- result.push(`*Description:* \`${description}\``);
13511
+ result.push(`*Description:* \`${sanitizeMarkdown(description)}\``);
13487
13512
  }
13488
13513
  if (e) {
13489
13514
  result.push("");
13490
- result.push(`*Enum:* \`${e.join(", ")}\``);
13515
+ result.push(`*Enum:* \`${e.map(sanitizeMarkdown).join(", ")}\``);
13491
13516
  }
13492
13517
  {
13493
13518
  result.push("");
@@ -13505,14 +13530,14 @@ class DocService {
13505
13530
  result.push("");
13506
13531
  const callbackList = Object.keys(callbacks);
13507
13532
  for (let i = 0; i !== callbackList.length; i++) {
13508
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13533
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13509
13534
  }
13510
13535
  }
13511
13536
  if (docNote) {
13512
13537
  result.push("");
13513
13538
  result.push("#### Note for developer");
13514
13539
  result.push("");
13515
- result.push(`*${docNote}*`);
13540
+ result.push(`*${sanitizeMarkdown(docNote)}*`);
13516
13541
  }
13517
13542
  result.push("");
13518
13543
  }
@@ -13524,17 +13549,17 @@ class DocService {
13524
13549
  if (!agentSchema.storages[i]) {
13525
13550
  continue;
13526
13551
  }
13527
- result.push(`### ${i + 1}. ${agentSchema.storages[i]}`);
13552
+ result.push(`### ${i + 1}. ${sanitizeMarkdown(agentSchema.storages[i])}`);
13528
13553
  const { docDescription, embedding, shared, callbacks } = this.storageSchemaService.get(agentSchema.storages[i]);
13529
13554
  if (docDescription) {
13530
13555
  result.push("");
13531
13556
  result.push(`#### Storage description`);
13532
13557
  result.push("");
13533
- result.push(docDescription);
13558
+ result.push(sanitizeMarkdown(docDescription));
13534
13559
  }
13535
13560
  if (embedding) {
13536
13561
  result.push("");
13537
- result.push(`*Embedding:* \`${embedding}\``);
13562
+ result.push(`*Embedding:* \`${sanitizeMarkdown(embedding)}\``);
13538
13563
  }
13539
13564
  {
13540
13565
  result.push("");
@@ -13546,7 +13571,7 @@ class DocService {
13546
13571
  result.push("");
13547
13572
  const callbackList = Object.keys(callbacks);
13548
13573
  for (let i = 0; i !== callbackList.length; i++) {
13549
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13574
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13550
13575
  }
13551
13576
  }
13552
13577
  result.push("");
@@ -13570,13 +13595,13 @@ class DocService {
13570
13595
  if (!agentSchema.states[i]) {
13571
13596
  continue;
13572
13597
  }
13573
- result.push(`### ${i + 1}. ${agentSchema.states[i]}`);
13598
+ result.push(`### ${i + 1}. ${sanitizeMarkdown(agentSchema.states[i])}`);
13574
13599
  const { docDescription, shared, callbacks } = this.stateSchemaService.get(agentSchema.states[i]);
13575
13600
  if (docDescription) {
13576
13601
  result.push("");
13577
13602
  result.push(`#### State description`);
13578
13603
  result.push("");
13579
- result.push(docDescription);
13604
+ result.push(sanitizeMarkdown(docDescription));
13580
13605
  }
13581
13606
  {
13582
13607
  const computeSchemasCurrentList = computeSchemasTotalList.filter(([stateName]) => stateName === agentSchema.states[i]);
@@ -13587,10 +13612,10 @@ class DocService {
13587
13612
  for (let i = 0; i !== computeSchemasCurrentList.length; i++) {
13588
13613
  const [, { computeName, docDescription }] = computeSchemasCurrentList[i];
13589
13614
  result.push("");
13590
- result.push(`> **${i + 1}. ${computeName}**`);
13615
+ result.push(`> **${i + 1}. ${sanitizeMarkdown(computeName)}**`);
13591
13616
  {
13592
13617
  result.push("");
13593
- result.push(`*Description:* \`${docDescription}\``);
13618
+ result.push(`*Description:* \`${sanitizeMarkdown(docDescription)}\``);
13594
13619
  }
13595
13620
  }
13596
13621
  result.push("");
@@ -13603,7 +13628,7 @@ class DocService {
13603
13628
  result.push("");
13604
13629
  const callbackList = Object.keys(callbacks);
13605
13630
  for (let i = 0; i !== callbackList.length; i++) {
13606
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13631
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13607
13632
  }
13608
13633
  }
13609
13634
  }
@@ -13621,13 +13646,13 @@ class DocService {
13621
13646
  if (!agentSchema.wikiList[i]) {
13622
13647
  continue;
13623
13648
  }
13624
- result.push(`### ${i + 1}. ${agentSchema.wikiList[i]}`);
13649
+ result.push(`### ${i + 1}. ${sanitizeMarkdown(agentSchema.wikiList[i])}`);
13625
13650
  const { docDescription, callbacks } = this.wikiSchemaService.get(agentSchema.wikiList[i]);
13626
13651
  if (docDescription) {
13627
13652
  result.push("");
13628
13653
  result.push(`#### Wiki description`);
13629
13654
  result.push("");
13630
- result.push(docDescription);
13655
+ result.push(sanitizeMarkdown(docDescription));
13631
13656
  }
13632
13657
  if (callbacks) {
13633
13658
  result.push("");
@@ -13635,7 +13660,7 @@ class DocService {
13635
13660
  result.push("");
13636
13661
  const callbackList = Object.keys(callbacks);
13637
13662
  for (let i = 0; i !== callbackList.length; i++) {
13638
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13663
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13639
13664
  }
13640
13665
  }
13641
13666
  result.push("");
@@ -13646,11 +13671,11 @@ class DocService {
13646
13671
  result.push("");
13647
13672
  const callbackList = Object.keys(agentSchema.callbacks);
13648
13673
  for (let i = 0; i !== callbackList.length; i++) {
13649
- result.push(`${i + 1}. \`${callbackList[i]}\``);
13674
+ result.push(`${i + 1}. \`${sanitizeMarkdown(callbackList[i])}\``);
13650
13675
  }
13651
13676
  result.push("");
13652
13677
  }
13653
- await writeFileAtomic(join(dirName, `./agent/${agentSchema.agentName}.md`), result.join("\n"));
13678
+ await writeFileAtomic(join(dirName, `./agent/${sanitizeMarkdown(agentSchema.agentName)}.md`), result.join("\n"));
13654
13679
  }, {
13655
13680
  maxExec: THREAD_POOL_SIZE,
13656
13681
  delay: THREAD_POOL_DELAY,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.1.74",
3
+ "version": "1.1.76",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",