@dudousxd/nestjs-agent 0.3.1 → 0.3.3

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.js CHANGED
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/agent.module.ts
5
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_DURABLE_RUNNER, AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE3, AGENT_REGISTRY as AGENT_REGISTRY4, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry4, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
5
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_DURABLE_RUNNER, AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE3, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry5, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
6
6
  import { Global, Module } from "@nestjs/common";
7
7
  import { DiscoveryModule, RouterModule } from "@nestjs/core";
8
8
 
@@ -232,6 +232,9 @@ var AgentService = class {
232
232
  ...params.regenerate === true ? {
233
233
  regenerate: true
234
234
  } : {},
235
+ ...params.attachments !== void 0 ? {
236
+ attachments: params.attachments
237
+ } : {},
235
238
  ...params.pageContext !== void 0 ? {
236
239
  pageContext: params.pageContext
237
240
  } : {}
@@ -387,9 +390,9 @@ AgentService = _ts_decorate2([
387
390
  ])
388
391
  ], AgentService);
389
392
 
390
- // src/controller/chat.controller.ts
391
- import { AGENT_ACTOR_RESOLVER, AgentStreamError } from "@dudousxd/nestjs-agent-core";
392
- import { Body, Controller, Get, Inject as Inject3, Param, Post, Req, Res } from "@nestjs/common";
393
+ // src/controller/agents.controller.ts
394
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
395
+ import { Controller, Get, Inject as Inject3 } from "@nestjs/common";
393
396
  function _ts_decorate3(decorators, target, key, desc) {
394
397
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
395
398
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -407,6 +410,64 @@ function _ts_param3(paramIndex, decorator) {
407
410
  };
408
411
  }
409
412
  __name(_ts_param3, "_ts_param");
413
+ var AgentsController = class {
414
+ static {
415
+ __name(this, "AgentsController");
416
+ }
417
+ agents;
418
+ depsFactory;
419
+ constructor(agents, depsFactory) {
420
+ this.agents = agents;
421
+ this.depsFactory = depsFactory;
422
+ }
423
+ list() {
424
+ const defaultAgentName = this.depsFactory.defaultAgentName();
425
+ return this.agents.list().map((definition) => ({
426
+ name: definition.name,
427
+ description: definition.description ?? "",
428
+ ...definition.name === defaultAgentName ? {
429
+ isDefault: true
430
+ } : {}
431
+ }));
432
+ }
433
+ };
434
+ _ts_decorate3([
435
+ Get(),
436
+ _ts_metadata3("design:type", Function),
437
+ _ts_metadata3("design:paramtypes", []),
438
+ _ts_metadata3("design:returntype", Array)
439
+ ], AgentsController.prototype, "list", null);
440
+ AgentsController = _ts_decorate3([
441
+ Controller("agents"),
442
+ _ts_param3(0, Inject3(AGENT_REGISTRY2)),
443
+ _ts_param3(1, Inject3(AGENT_DEPS_FACTORY2)),
444
+ _ts_metadata3("design:type", Function),
445
+ _ts_metadata3("design:paramtypes", [
446
+ typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
447
+ typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
448
+ ])
449
+ ], AgentsController);
450
+
451
+ // src/controller/chat.controller.ts
452
+ import { AGENT_ACTOR_RESOLVER, AgentStreamError } from "@dudousxd/nestjs-agent-core";
453
+ import { Body, Controller as Controller2, Get as Get2, Inject as Inject4, Param, Post, Req, Res } from "@nestjs/common";
454
+ function _ts_decorate4(decorators, target, key, desc) {
455
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
456
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
457
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
458
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
459
+ }
460
+ __name(_ts_decorate4, "_ts_decorate");
461
+ function _ts_metadata4(k, v) {
462
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
463
+ }
464
+ __name(_ts_metadata4, "_ts_metadata");
465
+ function _ts_param4(paramIndex, decorator) {
466
+ return function(target, key) {
467
+ decorator(target, key, paramIndex);
468
+ };
469
+ }
470
+ __name(_ts_param4, "_ts_param");
410
471
  var ChatController = class {
411
472
  static {
412
473
  __name(this, "ChatController");
@@ -428,6 +489,9 @@ var ChatController = class {
428
489
  ...body.agent !== void 0 ? {
429
490
  agentName: body.agent
430
491
  } : {},
492
+ ...body.attachments !== void 0 ? {
493
+ attachments: body.attachments
494
+ } : {},
431
495
  ...body.pageContext !== void 0 ? {
432
496
  pageContext: body.pageContext
433
497
  } : {},
@@ -466,11 +530,26 @@ data: ${JSON.stringify({
466
530
 
467
531
  `);
468
532
  const decoder = new TextDecoder();
533
+ let buffer = "";
469
534
  try {
470
535
  for await (const chunk of this.agent.subscribe(runId)) {
471
- res.write(`data: ${JSON.stringify({
472
- delta: decoder.decode(chunk)
473
- })}
536
+ buffer += decoder.decode(chunk, {
537
+ stream: true
538
+ });
539
+ let newline = buffer.indexOf("\n");
540
+ while (newline !== -1) {
541
+ const line = buffer.slice(0, newline);
542
+ buffer = buffer.slice(newline + 1);
543
+ if (line.length > 0) {
544
+ res.write(`data: ${line}
545
+
546
+ `);
547
+ }
548
+ newline = buffer.indexOf("\n");
549
+ }
550
+ }
551
+ if (buffer.length > 0) {
552
+ res.write(`data: ${buffer}
474
553
 
475
554
  `);
476
555
  }
@@ -491,46 +570,46 @@ data: ${JSON.stringify(payload)}
491
570
  res.end();
492
571
  }
493
572
  };
494
- _ts_decorate3([
573
+ _ts_decorate4([
495
574
  Post("chat"),
496
- _ts_param3(0, Req()),
497
- _ts_param3(1, Res()),
498
- _ts_param3(2, Body()),
499
- _ts_metadata3("design:type", Function),
500
- _ts_metadata3("design:paramtypes", [
575
+ _ts_param4(0, Req()),
576
+ _ts_param4(1, Res()),
577
+ _ts_param4(2, Body()),
578
+ _ts_metadata4("design:type", Function),
579
+ _ts_metadata4("design:paramtypes", [
501
580
  typeof Request === "undefined" ? Object : Request,
502
581
  typeof Response === "undefined" ? Object : Response,
503
582
  typeof ChatBody === "undefined" ? Object : ChatBody
504
583
  ]),
505
- _ts_metadata3("design:returntype", Promise)
584
+ _ts_metadata4("design:returntype", Promise)
506
585
  ], ChatController.prototype, "chat", null);
507
- _ts_decorate3([
508
- Get("chat/:runId/stream"),
509
- _ts_param3(0, Param("runId")),
510
- _ts_param3(1, Res()),
511
- _ts_metadata3("design:type", Function),
512
- _ts_metadata3("design:paramtypes", [
586
+ _ts_decorate4([
587
+ Get2("chat/:runId/stream"),
588
+ _ts_param4(0, Param("runId")),
589
+ _ts_param4(1, Res()),
590
+ _ts_metadata4("design:type", Function),
591
+ _ts_metadata4("design:paramtypes", [
513
592
  String,
514
593
  typeof Response === "undefined" ? Object : Response
515
594
  ]),
516
- _ts_metadata3("design:returntype", Promise)
595
+ _ts_metadata4("design:returntype", Promise)
517
596
  ], ChatController.prototype, "stream", null);
518
- _ts_decorate3([
597
+ _ts_decorate4([
519
598
  Post("chat/:runId/cancel"),
520
- _ts_param3(0, Req()),
521
- _ts_param3(1, Param("runId")),
522
- _ts_metadata3("design:type", Function),
523
- _ts_metadata3("design:paramtypes", [
599
+ _ts_param4(0, Req()),
600
+ _ts_param4(1, Param("runId")),
601
+ _ts_metadata4("design:type", Function),
602
+ _ts_metadata4("design:paramtypes", [
524
603
  typeof Request === "undefined" ? Object : Request,
525
604
  String
526
605
  ]),
527
- _ts_metadata3("design:returntype", Promise)
606
+ _ts_metadata4("design:returntype", Promise)
528
607
  ], ChatController.prototype, "cancel", null);
529
- ChatController = _ts_decorate3([
530
- Controller(),
531
- _ts_param3(1, Inject3(AGENT_ACTOR_RESOLVER)),
532
- _ts_metadata3("design:type", Function),
533
- _ts_metadata3("design:paramtypes", [
608
+ ChatController = _ts_decorate4([
609
+ Controller2(),
610
+ _ts_param4(1, Inject4(AGENT_ACTOR_RESOLVER)),
611
+ _ts_metadata4("design:type", Function),
612
+ _ts_metadata4("design:paramtypes", [
534
613
  typeof AgentService === "undefined" ? Object : AgentService,
535
614
  typeof ActorResolver === "undefined" ? Object : ActorResolver
536
615
  ])
@@ -538,24 +617,24 @@ ChatController = _ts_decorate3([
538
617
 
539
618
  // src/controller/quota.controller.ts
540
619
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2 } from "@dudousxd/nestjs-agent-core";
541
- import { Controller as Controller2, Get as Get2, Inject as Inject4, Req as Req2 } from "@nestjs/common";
542
- function _ts_decorate4(decorators, target, key, desc) {
620
+ import { Controller as Controller3, Get as Get3, Inject as Inject5, Req as Req2 } from "@nestjs/common";
621
+ function _ts_decorate5(decorators, target, key, desc) {
543
622
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
544
623
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
545
624
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
546
625
  return c > 3 && r && Object.defineProperty(target, key, r), r;
547
626
  }
548
- __name(_ts_decorate4, "_ts_decorate");
549
- function _ts_metadata4(k, v) {
627
+ __name(_ts_decorate5, "_ts_decorate");
628
+ function _ts_metadata5(k, v) {
550
629
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
551
630
  }
552
- __name(_ts_metadata4, "_ts_metadata");
553
- function _ts_param4(paramIndex, decorator) {
631
+ __name(_ts_metadata5, "_ts_metadata");
632
+ function _ts_param5(paramIndex, decorator) {
554
633
  return function(target, key) {
555
634
  decorator(target, key, paramIndex);
556
635
  };
557
636
  }
558
- __name(_ts_param4, "_ts_param");
637
+ __name(_ts_param5, "_ts_param");
559
638
  var QuotaController = class {
560
639
  static {
561
640
  __name(this, "QuotaController");
@@ -571,20 +650,20 @@ var QuotaController = class {
571
650
  return this.agent.quotaToday(actor.id);
572
651
  }
573
652
  };
574
- _ts_decorate4([
575
- Get2("today"),
576
- _ts_param4(0, Req2()),
577
- _ts_metadata4("design:type", Function),
578
- _ts_metadata4("design:paramtypes", [
653
+ _ts_decorate5([
654
+ Get3("today"),
655
+ _ts_param5(0, Req2()),
656
+ _ts_metadata5("design:type", Function),
657
+ _ts_metadata5("design:paramtypes", [
579
658
  typeof Request === "undefined" ? Object : Request
580
659
  ]),
581
- _ts_metadata4("design:returntype", Promise)
660
+ _ts_metadata5("design:returntype", Promise)
582
661
  ], QuotaController.prototype, "today", null);
583
- QuotaController = _ts_decorate4([
584
- Controller2("quota"),
585
- _ts_param4(1, Inject4(AGENT_ACTOR_RESOLVER2)),
586
- _ts_metadata4("design:type", Function),
587
- _ts_metadata4("design:paramtypes", [
662
+ QuotaController = _ts_decorate5([
663
+ Controller3("quota"),
664
+ _ts_param5(1, Inject5(AGENT_ACTOR_RESOLVER2)),
665
+ _ts_metadata5("design:type", Function),
666
+ _ts_metadata5("design:paramtypes", [
588
667
  typeof AgentService === "undefined" ? Object : AgentService,
589
668
  typeof ActorResolver === "undefined" ? Object : ActorResolver
590
669
  ])
@@ -592,24 +671,24 @@ QuotaController = _ts_decorate4([
592
671
 
593
672
  // src/controller/threads.controller.ts
594
673
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3 } from "@dudousxd/nestjs-agent-core";
595
- import { Body as Body2, Controller as Controller3, Delete, Get as Get3, Inject as Inject5, Param as Param2, Patch, Post as Post2, Req as Req3 } from "@nestjs/common";
596
- function _ts_decorate5(decorators, target, key, desc) {
674
+ import { Body as Body2, Controller as Controller4, Delete, Get as Get4, Inject as Inject6, Param as Param2, Patch, Post as Post2, Req as Req3 } from "@nestjs/common";
675
+ function _ts_decorate6(decorators, target, key, desc) {
597
676
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
598
677
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
599
678
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
600
679
  return c > 3 && r && Object.defineProperty(target, key, r), r;
601
680
  }
602
- __name(_ts_decorate5, "_ts_decorate");
603
- function _ts_metadata5(k, v) {
681
+ __name(_ts_decorate6, "_ts_decorate");
682
+ function _ts_metadata6(k, v) {
604
683
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
605
684
  }
606
- __name(_ts_metadata5, "_ts_metadata");
607
- function _ts_param5(paramIndex, decorator) {
685
+ __name(_ts_metadata6, "_ts_metadata");
686
+ function _ts_param6(paramIndex, decorator) {
608
687
  return function(target, key) {
609
688
  decorator(target, key, paramIndex);
610
689
  };
611
690
  }
612
- __name(_ts_param5, "_ts_param");
691
+ __name(_ts_param6, "_ts_param");
613
692
  var ThreadsController = class {
614
693
  static {
615
694
  __name(this, "ThreadsController");
@@ -661,92 +740,92 @@ var ThreadsController = class {
661
740
  };
662
741
  }
663
742
  };
664
- _ts_decorate5([
665
- Get3(),
666
- _ts_param5(0, Req3()),
667
- _ts_metadata5("design:type", Function),
668
- _ts_metadata5("design:paramtypes", [
743
+ _ts_decorate6([
744
+ Get4(),
745
+ _ts_param6(0, Req3()),
746
+ _ts_metadata6("design:type", Function),
747
+ _ts_metadata6("design:paramtypes", [
669
748
  typeof Request === "undefined" ? Object : Request
670
749
  ]),
671
- _ts_metadata5("design:returntype", Promise)
750
+ _ts_metadata6("design:returntype", Promise)
672
751
  ], ThreadsController.prototype, "list", null);
673
- _ts_decorate5([
674
- Get3(":id"),
675
- _ts_param5(0, Req3()),
676
- _ts_param5(1, Param2("id")),
677
- _ts_metadata5("design:type", Function),
678
- _ts_metadata5("design:paramtypes", [
752
+ _ts_decorate6([
753
+ Get4(":id"),
754
+ _ts_param6(0, Req3()),
755
+ _ts_param6(1, Param2("id")),
756
+ _ts_metadata6("design:type", Function),
757
+ _ts_metadata6("design:paramtypes", [
679
758
  typeof Request === "undefined" ? Object : Request,
680
759
  String
681
760
  ]),
682
- _ts_metadata5("design:returntype", Promise)
761
+ _ts_metadata6("design:returntype", Promise)
683
762
  ], ThreadsController.prototype, "detail", null);
684
- _ts_decorate5([
763
+ _ts_decorate6([
685
764
  Delete(":id"),
686
- _ts_param5(0, Req3()),
687
- _ts_param5(1, Param2("id")),
688
- _ts_metadata5("design:type", Function),
689
- _ts_metadata5("design:paramtypes", [
765
+ _ts_param6(0, Req3()),
766
+ _ts_param6(1, Param2("id")),
767
+ _ts_metadata6("design:type", Function),
768
+ _ts_metadata6("design:paramtypes", [
690
769
  typeof Request === "undefined" ? Object : Request,
691
770
  String
692
771
  ]),
693
- _ts_metadata5("design:returntype", Promise)
772
+ _ts_metadata6("design:returntype", Promise)
694
773
  ], ThreadsController.prototype, "remove", null);
695
- _ts_decorate5([
774
+ _ts_decorate6([
696
775
  Post2(":id/fork-from/:messageId"),
697
- _ts_param5(0, Req3()),
698
- _ts_param5(1, Param2("id")),
699
- _ts_param5(2, Param2("messageId")),
700
- _ts_metadata5("design:type", Function),
701
- _ts_metadata5("design:paramtypes", [
776
+ _ts_param6(0, Req3()),
777
+ _ts_param6(1, Param2("id")),
778
+ _ts_param6(2, Param2("messageId")),
779
+ _ts_metadata6("design:type", Function),
780
+ _ts_metadata6("design:paramtypes", [
702
781
  typeof Request === "undefined" ? Object : Request,
703
782
  String,
704
783
  String
705
784
  ]),
706
- _ts_metadata5("design:returntype", Promise)
785
+ _ts_metadata6("design:returntype", Promise)
707
786
  ], ThreadsController.prototype, "fork", null);
708
- _ts_decorate5([
787
+ _ts_decorate6([
709
788
  Patch(":id"),
710
- _ts_param5(0, Req3()),
711
- _ts_param5(1, Param2("id")),
712
- _ts_param5(2, Body2()),
713
- _ts_metadata5("design:type", Function),
714
- _ts_metadata5("design:paramtypes", [
789
+ _ts_param6(0, Req3()),
790
+ _ts_param6(1, Param2("id")),
791
+ _ts_param6(2, Body2()),
792
+ _ts_metadata6("design:type", Function),
793
+ _ts_metadata6("design:paramtypes", [
715
794
  typeof Request === "undefined" ? Object : Request,
716
795
  String,
717
796
  typeof RenameThreadBody === "undefined" ? Object : RenameThreadBody
718
797
  ]),
719
- _ts_metadata5("design:returntype", Promise)
798
+ _ts_metadata6("design:returntype", Promise)
720
799
  ], ThreadsController.prototype, "rename", null);
721
- _ts_decorate5([
800
+ _ts_decorate6([
722
801
  Post2(":id/promote"),
723
- _ts_param5(0, Req3()),
724
- _ts_param5(1, Param2("id")),
725
- _ts_metadata5("design:type", Function),
726
- _ts_metadata5("design:paramtypes", [
802
+ _ts_param6(0, Req3()),
803
+ _ts_param6(1, Param2("id")),
804
+ _ts_metadata6("design:type", Function),
805
+ _ts_metadata6("design:paramtypes", [
727
806
  typeof Request === "undefined" ? Object : Request,
728
807
  String
729
808
  ]),
730
- _ts_metadata5("design:returntype", Promise)
809
+ _ts_metadata6("design:returntype", Promise)
731
810
  ], ThreadsController.prototype, "promote", null);
732
- _ts_decorate5([
811
+ _ts_decorate6([
733
812
  Delete(":id/from/:messageId"),
734
- _ts_param5(0, Req3()),
735
- _ts_param5(1, Param2("id")),
736
- _ts_param5(2, Param2("messageId")),
737
- _ts_metadata5("design:type", Function),
738
- _ts_metadata5("design:paramtypes", [
813
+ _ts_param6(0, Req3()),
814
+ _ts_param6(1, Param2("id")),
815
+ _ts_param6(2, Param2("messageId")),
816
+ _ts_metadata6("design:type", Function),
817
+ _ts_metadata6("design:paramtypes", [
739
818
  typeof Request === "undefined" ? Object : Request,
740
819
  String,
741
820
  String
742
821
  ]),
743
- _ts_metadata5("design:returntype", Promise)
822
+ _ts_metadata6("design:returntype", Promise)
744
823
  ], ThreadsController.prototype, "truncateFrom", null);
745
- ThreadsController = _ts_decorate5([
746
- Controller3("threads"),
747
- _ts_param5(1, Inject5(AGENT_ACTOR_RESOLVER3)),
748
- _ts_metadata5("design:type", Function),
749
- _ts_metadata5("design:paramtypes", [
824
+ ThreadsController = _ts_decorate6([
825
+ Controller4("threads"),
826
+ _ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER3)),
827
+ _ts_metadata6("design:type", Function),
828
+ _ts_metadata6("design:paramtypes", [
750
829
  typeof AgentService === "undefined" ? Object : AgentService,
751
830
  typeof ActorResolver === "undefined" ? Object : ActorResolver
752
831
  ])
@@ -754,24 +833,24 @@ ThreadsController = _ts_decorate5([
754
833
 
755
834
  // src/controller/tool-call.controller.ts
756
835
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4 } from "@dudousxd/nestjs-agent-core";
757
- import { Body as Body3, Controller as Controller4, Inject as Inject6, Post as Post3, Req as Req4 } from "@nestjs/common";
758
- function _ts_decorate6(decorators, target, key, desc) {
836
+ import { Body as Body3, Controller as Controller5, Inject as Inject7, Post as Post3, Req as Req4 } from "@nestjs/common";
837
+ function _ts_decorate7(decorators, target, key, desc) {
759
838
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
760
839
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
761
840
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
762
841
  return c > 3 && r && Object.defineProperty(target, key, r), r;
763
842
  }
764
- __name(_ts_decorate6, "_ts_decorate");
765
- function _ts_metadata6(k, v) {
843
+ __name(_ts_decorate7, "_ts_decorate");
844
+ function _ts_metadata7(k, v) {
766
845
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
767
846
  }
768
- __name(_ts_metadata6, "_ts_metadata");
769
- function _ts_param6(paramIndex, decorator) {
847
+ __name(_ts_metadata7, "_ts_metadata");
848
+ function _ts_param7(paramIndex, decorator) {
770
849
  return function(target, key) {
771
850
  decorator(target, key, paramIndex);
772
851
  };
773
852
  }
774
- __name(_ts_param6, "_ts_param");
853
+ __name(_ts_param7, "_ts_param");
775
854
  var ToolCallController = class {
776
855
  static {
777
856
  __name(this, "ToolCallController");
@@ -797,41 +876,41 @@ var ToolCallController = class {
797
876
  };
798
877
  }
799
878
  };
800
- _ts_decorate6([
879
+ _ts_decorate7([
801
880
  Post3("approve"),
802
- _ts_param6(0, Req4()),
803
- _ts_param6(1, Body3()),
804
- _ts_metadata6("design:type", Function),
805
- _ts_metadata6("design:paramtypes", [
881
+ _ts_param7(0, Req4()),
882
+ _ts_param7(1, Body3()),
883
+ _ts_metadata7("design:type", Function),
884
+ _ts_metadata7("design:paramtypes", [
806
885
  typeof Request === "undefined" ? Object : Request,
807
886
  typeof ApproveBody === "undefined" ? Object : ApproveBody
808
887
  ]),
809
- _ts_metadata6("design:returntype", Promise)
888
+ _ts_metadata7("design:returntype", Promise)
810
889
  ], ToolCallController.prototype, "approve", null);
811
- _ts_decorate6([
890
+ _ts_decorate7([
812
891
  Post3("reject"),
813
- _ts_param6(0, Req4()),
814
- _ts_param6(1, Body3()),
815
- _ts_metadata6("design:type", Function),
816
- _ts_metadata6("design:paramtypes", [
892
+ _ts_param7(0, Req4()),
893
+ _ts_param7(1, Body3()),
894
+ _ts_metadata7("design:type", Function),
895
+ _ts_metadata7("design:paramtypes", [
817
896
  typeof Request === "undefined" ? Object : Request,
818
897
  typeof RejectBody === "undefined" ? Object : RejectBody
819
898
  ]),
820
- _ts_metadata6("design:returntype", Promise)
899
+ _ts_metadata7("design:returntype", Promise)
821
900
  ], ToolCallController.prototype, "reject", null);
822
- ToolCallController = _ts_decorate6([
823
- Controller4("tool-call"),
824
- _ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER4)),
825
- _ts_metadata6("design:type", Function),
826
- _ts_metadata6("design:paramtypes", [
901
+ ToolCallController = _ts_decorate7([
902
+ Controller5("tool-call"),
903
+ _ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER4)),
904
+ _ts_metadata7("design:type", Function),
905
+ _ts_metadata7("design:paramtypes", [
827
906
  typeof AgentService === "undefined" ? Object : AgentService,
828
907
  typeof ActorResolver === "undefined" ? Object : ActorResolver
829
908
  ])
830
909
  ], ToolCallController);
831
910
 
832
911
  // src/discovery/agent-discovery.service.ts
833
- import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
834
- import { Inject as Inject7, Injectable as Injectable3, Logger } from "@nestjs/common";
912
+ import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
913
+ import { Inject as Inject8, Injectable as Injectable3, Logger } from "@nestjs/common";
835
914
  import { DiscoveryService, MetadataScanner } from "@nestjs/core";
836
915
 
837
916
  // src/decorator/agent.decorator.ts
@@ -866,23 +945,23 @@ function SystemPromptContributor() {
866
945
  __name(SystemPromptContributor, "SystemPromptContributor");
867
946
 
868
947
  // src/discovery/agent-discovery.service.ts
869
- function _ts_decorate7(decorators, target, key, desc) {
948
+ function _ts_decorate8(decorators, target, key, desc) {
870
949
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
871
950
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
872
951
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
873
952
  return c > 3 && r && Object.defineProperty(target, key, r), r;
874
953
  }
875
- __name(_ts_decorate7, "_ts_decorate");
876
- function _ts_metadata7(k, v) {
954
+ __name(_ts_decorate8, "_ts_decorate");
955
+ function _ts_metadata8(k, v) {
877
956
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
878
957
  }
879
- __name(_ts_metadata7, "_ts_metadata");
880
- function _ts_param7(paramIndex, decorator) {
958
+ __name(_ts_metadata8, "_ts_metadata");
959
+ function _ts_param8(paramIndex, decorator) {
881
960
  return function(target, key) {
882
961
  decorator(target, key, paramIndex);
883
962
  };
884
963
  }
885
- __name(_ts_param7, "_ts_param");
964
+ __name(_ts_param8, "_ts_param");
886
965
  var AgentDiscoveryService = class _AgentDiscoveryService {
887
966
  static {
888
967
  __name(this, "AgentDiscoveryService");
@@ -917,6 +996,9 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
917
996
  const systemPrompt = promptMethod !== void 0 ? (ctx) => promptMethod(ctx) : meta.systemPrompt ?? "You are a helpful assistant.";
918
997
  return {
919
998
  name: meta.name,
999
+ ...meta.description !== void 0 ? {
1000
+ description: meta.description
1001
+ } : {},
920
1002
  systemPrompt,
921
1003
  ...meta.tools !== void 0 ? {
922
1004
  tools: meta.tools
@@ -976,22 +1058,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
976
1058
  return (ctx) => candidate.call(instance, ctx);
977
1059
  }
978
1060
  };
979
- AgentDiscoveryService = _ts_decorate7([
1061
+ AgentDiscoveryService = _ts_decorate8([
980
1062
  Injectable3(),
981
- _ts_param7(2, Inject7(AGENT_REGISTRY2)),
982
- _ts_param7(3, Inject7(AGENT_PROMPT_CONTRIBUTORS2)),
983
- _ts_metadata7("design:type", Function),
984
- _ts_metadata7("design:paramtypes", [
1063
+ _ts_param8(2, Inject8(AGENT_REGISTRY3)),
1064
+ _ts_param8(3, Inject8(AGENT_PROMPT_CONTRIBUTORS2)),
1065
+ _ts_metadata8("design:type", Function),
1066
+ _ts_metadata8("design:paramtypes", [
985
1067
  typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
986
1068
  typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
987
- typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
1069
+ typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4,
988
1070
  Array
989
1071
  ])
990
1072
  ], AgentDiscoveryService);
991
1073
 
992
1074
  // src/discovery/ai-tool-discovery.service.ts
993
- import { AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_REGISTRY as AGENT_REGISTRY3, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2 } from "@dudousxd/nestjs-agent-core";
994
- import { Inject as Inject8, Injectable as Injectable4, Logger as Logger2 } from "@nestjs/common";
1075
+ import { AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_REGISTRY as AGENT_REGISTRY4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2 } from "@dudousxd/nestjs-agent-core";
1076
+ import { Inject as Inject9, Injectable as Injectable4, Logger as Logger2 } from "@nestjs/common";
995
1077
  import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
996
1078
  import { z } from "zod";
997
1079
 
@@ -1040,23 +1122,23 @@ function provideAgentTool(factoryOrTool, inject) {
1040
1122
  __name(provideAgentTool, "provideAgentTool");
1041
1123
 
1042
1124
  // src/discovery/ai-tool-discovery.service.ts
1043
- function _ts_decorate8(decorators, target, key, desc) {
1125
+ function _ts_decorate9(decorators, target, key, desc) {
1044
1126
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1045
1127
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1046
1128
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1047
1129
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1048
1130
  }
1049
- __name(_ts_decorate8, "_ts_decorate");
1050
- function _ts_metadata8(k, v) {
1131
+ __name(_ts_decorate9, "_ts_decorate");
1132
+ function _ts_metadata9(k, v) {
1051
1133
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1052
1134
  }
1053
- __name(_ts_metadata8, "_ts_metadata");
1054
- function _ts_param8(paramIndex, decorator) {
1135
+ __name(_ts_metadata9, "_ts_metadata");
1136
+ function _ts_param9(paramIndex, decorator) {
1055
1137
  return function(target, key) {
1056
1138
  decorator(target, key, paramIndex);
1057
1139
  };
1058
1140
  }
1059
- __name(_ts_param8, "_ts_param");
1141
+ __name(_ts_param9, "_ts_param");
1060
1142
  var AiToolDiscoveryService = class _AiToolDiscoveryService {
1061
1143
  static {
1062
1144
  __name(this, "AiToolDiscoveryService");
@@ -1163,13 +1245,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
1163
1245
  return true;
1164
1246
  }
1165
1247
  };
1166
- AiToolDiscoveryService = _ts_decorate8([
1248
+ AiToolDiscoveryService = _ts_decorate9([
1167
1249
  Injectable4(),
1168
- _ts_param8(1, Inject8(AGENT_TOOL_REGISTRY2)),
1169
- _ts_param8(2, Inject8(AGENT_REGISTRY3)),
1170
- _ts_param8(3, Inject8(AGENT_OPTIONS2)),
1171
- _ts_metadata8("design:type", Function),
1172
- _ts_metadata8("design:paramtypes", [
1250
+ _ts_param9(1, Inject9(AGENT_TOOL_REGISTRY2)),
1251
+ _ts_param9(2, Inject9(AGENT_REGISTRY4)),
1252
+ _ts_param9(3, Inject9(AGENT_OPTIONS2)),
1253
+ _ts_metadata9("design:type", Function),
1254
+ _ts_metadata9("design:paramtypes", [
1173
1255
  typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
1174
1256
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
1175
1257
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -1269,25 +1351,25 @@ var LedgerQuotaStore = class {
1269
1351
  };
1270
1352
 
1271
1353
  // src/runner/inline-agent-runner.ts
1272
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_STORE as AGENT_STORE3, QuotaExceededError, publishAgentRunFailed, runAgentLoop } from "@dudousxd/nestjs-agent-core";
1273
- import { Inject as Inject9, Injectable as Injectable5, Logger as Logger3 } from "@nestjs/common";
1274
- function _ts_decorate9(decorators, target, key, desc) {
1354
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_STORE as AGENT_STORE3, QuotaExceededError, publishAgentRunFailed, runAgentLoop } from "@dudousxd/nestjs-agent-core";
1355
+ import { Inject as Inject10, Injectable as Injectable5, Logger as Logger3 } from "@nestjs/common";
1356
+ function _ts_decorate10(decorators, target, key, desc) {
1275
1357
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1276
1358
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1277
1359
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1278
1360
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1279
1361
  }
1280
- __name(_ts_decorate9, "_ts_decorate");
1281
- function _ts_metadata9(k, v) {
1362
+ __name(_ts_decorate10, "_ts_decorate");
1363
+ function _ts_metadata10(k, v) {
1282
1364
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1283
1365
  }
1284
- __name(_ts_metadata9, "_ts_metadata");
1285
- function _ts_param9(paramIndex, decorator) {
1366
+ __name(_ts_metadata10, "_ts_metadata");
1367
+ function _ts_param10(paramIndex, decorator) {
1286
1368
  return function(target, key) {
1287
1369
  decorator(target, key, paramIndex);
1288
1370
  };
1289
1371
  }
1290
- __name(_ts_param9, "_ts_param");
1372
+ __name(_ts_param10, "_ts_param");
1291
1373
  var InlineAgentRunner = class _InlineAgentRunner {
1292
1374
  static {
1293
1375
  __name(this, "InlineAgentRunner");
@@ -1388,25 +1470,25 @@ var InlineAgentRunner = class _InlineAgentRunner {
1388
1470
  }, hooks);
1389
1471
  }
1390
1472
  };
1391
- InlineAgentRunner = _ts_decorate9([
1473
+ InlineAgentRunner = _ts_decorate10([
1392
1474
  Injectable5(),
1393
- _ts_param9(0, Inject9(AGENT_DEPS_FACTORY2)),
1394
- _ts_param9(1, Inject9(AGENT_STORE3)),
1395
- _ts_metadata9("design:type", Function),
1396
- _ts_metadata9("design:paramtypes", [
1475
+ _ts_param10(0, Inject10(AGENT_DEPS_FACTORY3)),
1476
+ _ts_param10(1, Inject10(AGENT_STORE3)),
1477
+ _ts_metadata10("design:type", Function),
1478
+ _ts_metadata10("design:paramtypes", [
1397
1479
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
1398
1480
  typeof AgentStore === "undefined" ? Object : AgentStore
1399
1481
  ])
1400
1482
  ], InlineAgentRunner);
1401
1483
 
1402
1484
  // src/agent.module.ts
1403
- function _ts_decorate10(decorators, target, key, desc) {
1485
+ function _ts_decorate11(decorators, target, key, desc) {
1404
1486
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1405
1487
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1406
1488
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1407
1489
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1408
1490
  }
1409
- __name(_ts_decorate10, "_ts_decorate");
1491
+ __name(_ts_decorate11, "_ts_decorate");
1410
1492
  var DEFAULT_PATH = "agent";
1411
1493
  function sharedProviders(durable, includeStore) {
1412
1494
  const providers = [
@@ -1416,8 +1498,8 @@ function sharedProviders(durable, includeStore) {
1416
1498
  },
1417
1499
  // Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
1418
1500
  {
1419
- provide: AGENT_REGISTRY4,
1420
- useFactory: /* @__PURE__ */ __name(() => new AgentRegistry4(), "useFactory")
1501
+ provide: AGENT_REGISTRY5,
1502
+ useFactory: /* @__PURE__ */ __name(() => new AgentRegistry5(), "useFactory")
1421
1503
  },
1422
1504
  // A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
1423
1505
  {
@@ -1465,7 +1547,7 @@ function sharedProviders(durable, includeStore) {
1465
1547
  },
1466
1548
  AgentDepsFactory2,
1467
1549
  {
1468
- provide: AGENT_DEPS_FACTORY3,
1550
+ provide: AGENT_DEPS_FACTORY4,
1469
1551
  useExisting: AgentDepsFactory2
1470
1552
  },
1471
1553
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -1513,7 +1595,7 @@ function exportsFor(includeStore) {
1513
1595
  return [
1514
1596
  AGENT_OPTIONS3,
1515
1597
  AGENT_TOOL_REGISTRY3,
1516
- AGENT_REGISTRY4,
1598
+ AGENT_REGISTRY5,
1517
1599
  AGENT_SINK2,
1518
1600
  AGENT_ROLES_POLICY2,
1519
1601
  AGENT_ACTOR_RESOLVER5,
@@ -1523,7 +1605,7 @@ function exportsFor(includeStore) {
1523
1605
  ] : [],
1524
1606
  AGENT_QUOTA_STORE3,
1525
1607
  AGENT_PROMPT_CONTRIBUTORS3,
1526
- AGENT_DEPS_FACTORY3,
1608
+ AGENT_DEPS_FACTORY4,
1527
1609
  AgentDepsFactory2,
1528
1610
  AgentService,
1529
1611
  InlineAgentRunner
@@ -1534,7 +1616,8 @@ var CONTROLLERS = [
1534
1616
  ChatController,
1535
1617
  ThreadsController,
1536
1618
  ToolCallController,
1537
- QuotaController
1619
+ QuotaController,
1620
+ AgentsController
1538
1621
  ];
1539
1622
  function routerFor(path) {
1540
1623
  return RouterModule.register([
@@ -1572,6 +1655,7 @@ var AgentModule = class _AgentModule {
1572
1655
  }
1573
1656
  static forRootAsync(options) {
1574
1657
  const path = options.path ?? DEFAULT_PATH;
1658
+ const includeStore = options.externalStore !== true;
1575
1659
  return {
1576
1660
  module: _AgentModule,
1577
1661
  global: true,
@@ -1587,15 +1671,13 @@ var AgentModule = class _AgentModule {
1587
1671
  useFactory: options.useFactory,
1588
1672
  inject: options.inject ?? []
1589
1673
  },
1590
- // The async factory resolves too late to inspect `store`, so we always bind AGENT_STORE here
1591
- // (its factory reads the resolved options). Omit-and-import-a-store-module is a `forRoot` path.
1592
- ...sharedProviders(options.durable ?? false, true)
1674
+ ...sharedProviders(options.durable ?? false, includeStore)
1593
1675
  ],
1594
- exports: exportsFor(true)
1676
+ exports: exportsFor(includeStore)
1595
1677
  };
1596
1678
  }
1597
1679
  };
1598
- AgentModule = _ts_decorate10([
1680
+ AgentModule = _ts_decorate11([
1599
1681
  Global(),
1600
1682
  Module({})
1601
1683
  ], AgentModule);