agent-swarm-kit 1.1.70 → 1.1.71

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
@@ -13344,41 +13344,57 @@ class DocService {
13344
13344
  result.push("");
13345
13345
  }
13346
13346
  }
13347
- if (typeof agentSchema.prompt === "string") {
13347
+ const getPrompt = async () => {
13348
+ try {
13349
+ if (typeof agentSchema.prompt === "string") {
13350
+ return agentSchema.prompt;
13351
+ }
13352
+ if (typeof agentSchema.prompt === "function") {
13353
+ return await agentSchema.prompt("docs", agentSchema.agentName);
13354
+ }
13355
+ return null;
13356
+ }
13357
+ catch {
13358
+ return null;
13359
+ }
13360
+ };
13361
+ const prompt = await getPrompt();
13362
+ if (prompt) {
13348
13363
  result.push(`## Main prompt`);
13349
13364
  result.push("");
13350
13365
  result.push("```");
13351
- result.push(agentSchema.prompt);
13366
+ result.push(prompt);
13352
13367
  result.push("```");
13353
13368
  result.push("");
13354
13369
  }
13355
- if (agentSchema.systemStatic || agentSchema.system) {
13356
- result.push(`## System prompt`);
13357
- result.push("");
13358
- let offset = 0;
13359
- if (agentSchema.systemStatic) {
13360
- for (let i = 0; i !== agentSchema.systemStatic.length; i++) {
13361
- if (!agentSchema.systemStatic[i]) {
13362
- continue;
13363
- }
13364
- result.push(`${i + 1}. \`${agentSchema.systemStatic[i]}\``);
13365
- result.push("");
13366
- offset = i;
13370
+ const getSystem = async () => {
13371
+ let system = [];
13372
+ try {
13373
+ if (agentSchema.systemStatic) {
13374
+ system = system.concat(agentSchema.systemStatic);
13367
13375
  }
13368
- }
13369
- if (agentSchema.system) {
13370
- for (let i = 0; i !== agentSchema.system.length; i++) {
13371
- if (!agentSchema.system[i]) {
13372
- continue;
13373
- }
13374
- result.push(`${i + offset + 1}. \`${agentSchema.system[i]}\``);
13375
- result.push("");
13376
+ if (agentSchema.system) {
13377
+ system = system.concat(agentSchema.system);
13378
+ }
13379
+ if (agentSchema.systemDynamic) {
13380
+ system = system.concat(await agentSchema.systemDynamic("docs", agentSchema.agentName));
13376
13381
  }
13377
13382
  }
13378
- }
13379
- if (agentSchema.systemDynamic) {
13380
- result.push("***Dynamic system prompt found***");
13383
+ finally {
13384
+ return system;
13385
+ }
13386
+ };
13387
+ const system = await getSystem();
13388
+ if (system.length) {
13389
+ result.push(`## System prompt`);
13381
13390
  result.push("");
13391
+ for (let i = 0; i !== system.length; i++) {
13392
+ if (!system[i]) {
13393
+ continue;
13394
+ }
13395
+ result.push(`${i + 1}. \`${system[i]}\``);
13396
+ result.push("");
13397
+ }
13382
13398
  }
13383
13399
  if (agentSchema.dependsOn) {
13384
13400
  result.push(`## Depends on`);
@@ -13412,17 +13428,37 @@ class DocService {
13412
13428
  result.push("");
13413
13429
  }
13414
13430
  }
13415
- if (agentSchema.tools) {
13431
+ const getTools = async () => {
13432
+ try {
13433
+ if (!agentSchema.tools) {
13434
+ return null;
13435
+ }
13436
+ return await Promise.all(agentSchema.tools
13437
+ .map((toolName) => this.toolSchemaService.get(toolName))
13438
+ .map(async (tool) => {
13439
+ const { function: upperFn, ...other } = tool;
13440
+ const fn = typeof upperFn === "function"
13441
+ ? await upperFn("docs", agentSchema.agentName)
13442
+ : upperFn;
13443
+ return {
13444
+ ...other,
13445
+ function: fn,
13446
+ };
13447
+ }));
13448
+ }
13449
+ catch {
13450
+ return null;
13451
+ }
13452
+ };
13453
+ const tools = await getTools();
13454
+ if (tools) {
13416
13455
  result.push(`## Used tools`);
13417
13456
  result.push("");
13418
- for (let i = 0; i !== agentSchema.tools.length; i++) {
13419
- if (!agentSchema.tools[i]) {
13420
- continue;
13421
- }
13422
- const { function: fn, docNote, callbacks, } = this.toolSchemaService.get(agentSchema.tools[i]);
13423
- if (typeof fn === "function") {
13457
+ for (let i = 0; i !== tools.length; i++) {
13458
+ if (!tools[i]) {
13424
13459
  continue;
13425
13460
  }
13461
+ const { function: fn, docNote, callbacks } = tools[i];
13426
13462
  result.push(`### ${i + 1}. ${agentSchema.tools[i]}`);
13427
13463
  if (fn.name) {
13428
13464
  result.push("");
package/build/index.mjs CHANGED
@@ -13342,41 +13342,57 @@ class DocService {
13342
13342
  result.push("");
13343
13343
  }
13344
13344
  }
13345
- if (typeof agentSchema.prompt === "string") {
13345
+ const getPrompt = async () => {
13346
+ try {
13347
+ if (typeof agentSchema.prompt === "string") {
13348
+ return agentSchema.prompt;
13349
+ }
13350
+ if (typeof agentSchema.prompt === "function") {
13351
+ return await agentSchema.prompt("docs", agentSchema.agentName);
13352
+ }
13353
+ return null;
13354
+ }
13355
+ catch {
13356
+ return null;
13357
+ }
13358
+ };
13359
+ const prompt = await getPrompt();
13360
+ if (prompt) {
13346
13361
  result.push(`## Main prompt`);
13347
13362
  result.push("");
13348
13363
  result.push("```");
13349
- result.push(agentSchema.prompt);
13364
+ result.push(prompt);
13350
13365
  result.push("```");
13351
13366
  result.push("");
13352
13367
  }
13353
- if (agentSchema.systemStatic || agentSchema.system) {
13354
- result.push(`## System prompt`);
13355
- result.push("");
13356
- let offset = 0;
13357
- if (agentSchema.systemStatic) {
13358
- for (let i = 0; i !== agentSchema.systemStatic.length; i++) {
13359
- if (!agentSchema.systemStatic[i]) {
13360
- continue;
13361
- }
13362
- result.push(`${i + 1}. \`${agentSchema.systemStatic[i]}\``);
13363
- result.push("");
13364
- offset = i;
13368
+ const getSystem = async () => {
13369
+ let system = [];
13370
+ try {
13371
+ if (agentSchema.systemStatic) {
13372
+ system = system.concat(agentSchema.systemStatic);
13365
13373
  }
13366
- }
13367
- if (agentSchema.system) {
13368
- for (let i = 0; i !== agentSchema.system.length; i++) {
13369
- if (!agentSchema.system[i]) {
13370
- continue;
13371
- }
13372
- result.push(`${i + offset + 1}. \`${agentSchema.system[i]}\``);
13373
- result.push("");
13374
+ if (agentSchema.system) {
13375
+ system = system.concat(agentSchema.system);
13376
+ }
13377
+ if (agentSchema.systemDynamic) {
13378
+ system = system.concat(await agentSchema.systemDynamic("docs", agentSchema.agentName));
13374
13379
  }
13375
13380
  }
13376
- }
13377
- if (agentSchema.systemDynamic) {
13378
- result.push("***Dynamic system prompt found***");
13381
+ finally {
13382
+ return system;
13383
+ }
13384
+ };
13385
+ const system = await getSystem();
13386
+ if (system.length) {
13387
+ result.push(`## System prompt`);
13379
13388
  result.push("");
13389
+ for (let i = 0; i !== system.length; i++) {
13390
+ if (!system[i]) {
13391
+ continue;
13392
+ }
13393
+ result.push(`${i + 1}. \`${system[i]}\``);
13394
+ result.push("");
13395
+ }
13380
13396
  }
13381
13397
  if (agentSchema.dependsOn) {
13382
13398
  result.push(`## Depends on`);
@@ -13410,17 +13426,37 @@ class DocService {
13410
13426
  result.push("");
13411
13427
  }
13412
13428
  }
13413
- if (agentSchema.tools) {
13429
+ const getTools = async () => {
13430
+ try {
13431
+ if (!agentSchema.tools) {
13432
+ return null;
13433
+ }
13434
+ return await Promise.all(agentSchema.tools
13435
+ .map((toolName) => this.toolSchemaService.get(toolName))
13436
+ .map(async (tool) => {
13437
+ const { function: upperFn, ...other } = tool;
13438
+ const fn = typeof upperFn === "function"
13439
+ ? await upperFn("docs", agentSchema.agentName)
13440
+ : upperFn;
13441
+ return {
13442
+ ...other,
13443
+ function: fn,
13444
+ };
13445
+ }));
13446
+ }
13447
+ catch {
13448
+ return null;
13449
+ }
13450
+ };
13451
+ const tools = await getTools();
13452
+ if (tools) {
13414
13453
  result.push(`## Used tools`);
13415
13454
  result.push("");
13416
- for (let i = 0; i !== agentSchema.tools.length; i++) {
13417
- if (!agentSchema.tools[i]) {
13418
- continue;
13419
- }
13420
- const { function: fn, docNote, callbacks, } = this.toolSchemaService.get(agentSchema.tools[i]);
13421
- if (typeof fn === "function") {
13455
+ for (let i = 0; i !== tools.length; i++) {
13456
+ if (!tools[i]) {
13422
13457
  continue;
13423
13458
  }
13459
+ const { function: fn, docNote, callbacks } = tools[i];
13424
13460
  result.push(`### ${i + 1}. ${agentSchema.tools[i]}`);
13425
13461
  if (fn.name) {
13426
13462
  result.push("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.1.70",
3
+ "version": "1.1.71",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",