@dudousxd/nestjs-agent 1.13.0 → 1.14.0

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/dist/index.cjs CHANGED
@@ -2648,19 +2648,34 @@ var ToolsController = class {
2648
2648
  this.agents = agents;
2649
2649
  }
2650
2650
  async list(req, agent) {
2651
- if (agent !== void 0 && this.agents.get(agent) === void 0) {
2651
+ if (agent !== void 0 && agent !== import_nestjs_agent_core15.ALL_AGENTS && this.agents.get(agent) === void 0) {
2652
2652
  throw new import_common15.NotFoundException(`No agent named "${agent}"`);
2653
2653
  }
2654
2654
  const actor = await this.actorResolver.resolve(req);
2655
- const deps = this.depsFactory.forAgent(agent);
2656
- const specs = await deps.registry.visibleSpecs(actor, deps.rolesPolicy, deps.toolAllowList);
2657
- return specs.map((spec) => ({
2658
- name: spec.name,
2659
- kind: spec.kind,
2660
- ...spec.presentation !== void 0 ? {
2661
- presentation: spec.presentation
2662
- } : {}
2663
- }));
2655
+ const names = agent === import_nestjs_agent_core15.ALL_AGENTS ? [
2656
+ void 0,
2657
+ ...this.agents.list().map((definition) => definition.name)
2658
+ ] : [
2659
+ agent
2660
+ ];
2661
+ const entries = /* @__PURE__ */ new Map();
2662
+ for (const name of names) {
2663
+ const deps = this.depsFactory.forAgent(name);
2664
+ const specs = await deps.registry.visibleSpecs(actor, deps.rolesPolicy, deps.toolAllowList);
2665
+ for (const spec of specs) {
2666
+ if (entries.has(spec.name)) continue;
2667
+ entries.set(spec.name, {
2668
+ name: spec.name,
2669
+ kind: spec.kind,
2670
+ ...spec.presentation !== void 0 ? {
2671
+ presentation: spec.presentation
2672
+ } : {}
2673
+ });
2674
+ }
2675
+ }
2676
+ return [
2677
+ ...entries.values()
2678
+ ];
2664
2679
  }
2665
2680
  };
2666
2681
  _ts_decorate15([