@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.
@@ -3315,7 +3315,7 @@ ToolCallController = _ts_decorate18([
3315
3315
  ], ToolCallController);
3316
3316
 
3317
3317
  // src/controller/tools.controller.ts
3318
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
3318
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_REGISTRY as AGENT_REGISTRY3, ALL_AGENTS, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
3319
3319
  import { Controller as Controller12, Get as Get10, Inject as Inject17, NotFoundException as NotFoundException3, Query as Query5, Req as Req11 } from "@nestjs/common";
3320
3320
  function _ts_decorate19(decorators, target, key, desc) {
3321
3321
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -3356,19 +3356,34 @@ var ToolsController = class {
3356
3356
  this.agents = agents;
3357
3357
  }
3358
3358
  async list(req, agent) {
3359
- if (agent !== void 0 && this.agents.get(agent) === void 0) {
3359
+ if (agent !== void 0 && agent !== ALL_AGENTS && this.agents.get(agent) === void 0) {
3360
3360
  throw new NotFoundException3(`No agent named "${agent}"`);
3361
3361
  }
3362
3362
  const actor = await this.actorResolver.resolve(req);
3363
- const deps = this.depsFactory.forAgent(agent);
3364
- const specs = await deps.registry.visibleSpecs(actor, deps.rolesPolicy, deps.toolAllowList);
3365
- return specs.map((spec) => ({
3366
- name: spec.name,
3367
- kind: spec.kind,
3368
- ...spec.presentation !== void 0 ? {
3369
- presentation: spec.presentation
3370
- } : {}
3371
- }));
3363
+ const names = agent === ALL_AGENTS ? [
3364
+ void 0,
3365
+ ...this.agents.list().map((definition) => definition.name)
3366
+ ] : [
3367
+ agent
3368
+ ];
3369
+ const entries = /* @__PURE__ */ new Map();
3370
+ for (const name of names) {
3371
+ const deps = this.depsFactory.forAgent(name);
3372
+ const specs = await deps.registry.visibleSpecs(actor, deps.rolesPolicy, deps.toolAllowList);
3373
+ for (const spec of specs) {
3374
+ if (entries.has(spec.name)) continue;
3375
+ entries.set(spec.name, {
3376
+ name: spec.name,
3377
+ kind: spec.kind,
3378
+ ...spec.presentation !== void 0 ? {
3379
+ presentation: spec.presentation
3380
+ } : {}
3381
+ });
3382
+ }
3383
+ }
3384
+ return [
3385
+ ...entries.values()
3386
+ ];
3372
3387
  }
3373
3388
  };
3374
3389
  _ts_decorate19([