@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/{agent-deps.factory-DpVkZYCy.d.cts → agent-deps.factory-D4KyREOv.d.cts} +11 -0
- package/dist/{agent-deps.factory-DpVkZYCy.d.ts → agent-deps.factory-D4KyREOv.d.ts} +11 -0
- package/dist/durable/index.cjs +336 -245
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +4 -4
- package/dist/durable/index.d.ts +4 -4
- package/dist/durable/index.js +279 -188
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +325 -243
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +268 -186
- package/dist/index.js.map +1 -1
- package/dist/sink-redis/index.cjs +144 -0
- package/dist/sink-redis/index.cjs.map +1 -0
- package/dist/sink-redis/index.d.cts +39 -0
- package/dist/sink-redis/index.d.ts +39 -0
- package/dist/sink-redis/index.js +119 -0
- package/dist/sink-redis/index.js.map +1 -0
- package/package.json +20 -5
package/dist/index.cjs
CHANGED
|
@@ -49,8 +49,8 @@ __export(index_exports, {
|
|
|
49
49
|
module.exports = __toCommonJS(index_exports);
|
|
50
50
|
|
|
51
51
|
// src/agent.module.ts
|
|
52
|
-
var
|
|
53
|
-
var
|
|
52
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
53
|
+
var import_common11 = require("@nestjs/common");
|
|
54
54
|
var import_core3 = require("@nestjs/core");
|
|
55
55
|
|
|
56
56
|
// src/agent-deps.factory.ts
|
|
@@ -279,6 +279,9 @@ var AgentService = class {
|
|
|
279
279
|
...params.regenerate === true ? {
|
|
280
280
|
regenerate: true
|
|
281
281
|
} : {},
|
|
282
|
+
...params.attachments !== void 0 ? {
|
|
283
|
+
attachments: params.attachments
|
|
284
|
+
} : {},
|
|
282
285
|
...params.pageContext !== void 0 ? {
|
|
283
286
|
pageContext: params.pageContext
|
|
284
287
|
} : {}
|
|
@@ -434,7 +437,7 @@ AgentService = _ts_decorate2([
|
|
|
434
437
|
])
|
|
435
438
|
], AgentService);
|
|
436
439
|
|
|
437
|
-
// src/controller/
|
|
440
|
+
// src/controller/agents.controller.ts
|
|
438
441
|
var import_nestjs_agent_core4 = require("@dudousxd/nestjs-agent-core");
|
|
439
442
|
var import_common3 = require("@nestjs/common");
|
|
440
443
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -454,6 +457,64 @@ function _ts_param3(paramIndex, decorator) {
|
|
|
454
457
|
};
|
|
455
458
|
}
|
|
456
459
|
__name(_ts_param3, "_ts_param");
|
|
460
|
+
var AgentsController = class {
|
|
461
|
+
static {
|
|
462
|
+
__name(this, "AgentsController");
|
|
463
|
+
}
|
|
464
|
+
agents;
|
|
465
|
+
depsFactory;
|
|
466
|
+
constructor(agents, depsFactory) {
|
|
467
|
+
this.agents = agents;
|
|
468
|
+
this.depsFactory = depsFactory;
|
|
469
|
+
}
|
|
470
|
+
list() {
|
|
471
|
+
const defaultAgentName = this.depsFactory.defaultAgentName();
|
|
472
|
+
return this.agents.list().map((definition) => ({
|
|
473
|
+
name: definition.name,
|
|
474
|
+
description: definition.description ?? "",
|
|
475
|
+
...definition.name === defaultAgentName ? {
|
|
476
|
+
isDefault: true
|
|
477
|
+
} : {}
|
|
478
|
+
}));
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
_ts_decorate3([
|
|
482
|
+
(0, import_common3.Get)(),
|
|
483
|
+
_ts_metadata3("design:type", Function),
|
|
484
|
+
_ts_metadata3("design:paramtypes", []),
|
|
485
|
+
_ts_metadata3("design:returntype", Array)
|
|
486
|
+
], AgentsController.prototype, "list", null);
|
|
487
|
+
AgentsController = _ts_decorate3([
|
|
488
|
+
(0, import_common3.Controller)("agents"),
|
|
489
|
+
_ts_param3(0, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_REGISTRY)),
|
|
490
|
+
_ts_param3(1, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_DEPS_FACTORY)),
|
|
491
|
+
_ts_metadata3("design:type", Function),
|
|
492
|
+
_ts_metadata3("design:paramtypes", [
|
|
493
|
+
typeof import_nestjs_agent_core4.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core4.AgentRegistry,
|
|
494
|
+
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
495
|
+
])
|
|
496
|
+
], AgentsController);
|
|
497
|
+
|
|
498
|
+
// src/controller/chat.controller.ts
|
|
499
|
+
var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
|
|
500
|
+
var import_common4 = require("@nestjs/common");
|
|
501
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
502
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
503
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
504
|
+
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;
|
|
505
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
506
|
+
}
|
|
507
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
508
|
+
function _ts_metadata4(k, v) {
|
|
509
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
510
|
+
}
|
|
511
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
512
|
+
function _ts_param4(paramIndex, decorator) {
|
|
513
|
+
return function(target, key) {
|
|
514
|
+
decorator(target, key, paramIndex);
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
__name(_ts_param4, "_ts_param");
|
|
457
518
|
var ChatController = class {
|
|
458
519
|
static {
|
|
459
520
|
__name(this, "ChatController");
|
|
@@ -475,6 +536,9 @@ var ChatController = class {
|
|
|
475
536
|
...body.agent !== void 0 ? {
|
|
476
537
|
agentName: body.agent
|
|
477
538
|
} : {},
|
|
539
|
+
...body.attachments !== void 0 ? {
|
|
540
|
+
attachments: body.attachments
|
|
541
|
+
} : {},
|
|
478
542
|
...body.pageContext !== void 0 ? {
|
|
479
543
|
pageContext: body.pageContext
|
|
480
544
|
} : {},
|
|
@@ -513,17 +577,32 @@ data: ${JSON.stringify({
|
|
|
513
577
|
|
|
514
578
|
`);
|
|
515
579
|
const decoder = new TextDecoder();
|
|
580
|
+
let buffer = "";
|
|
516
581
|
try {
|
|
517
582
|
for await (const chunk of this.agent.subscribe(runId)) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
})
|
|
583
|
+
buffer += decoder.decode(chunk, {
|
|
584
|
+
stream: true
|
|
585
|
+
});
|
|
586
|
+
let newline = buffer.indexOf("\n");
|
|
587
|
+
while (newline !== -1) {
|
|
588
|
+
const line = buffer.slice(0, newline);
|
|
589
|
+
buffer = buffer.slice(newline + 1);
|
|
590
|
+
if (line.length > 0) {
|
|
591
|
+
res.write(`data: ${line}
|
|
592
|
+
|
|
593
|
+
`);
|
|
594
|
+
}
|
|
595
|
+
newline = buffer.indexOf("\n");
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
if (buffer.length > 0) {
|
|
599
|
+
res.write(`data: ${buffer}
|
|
521
600
|
|
|
522
601
|
`);
|
|
523
602
|
}
|
|
524
603
|
res.write("event: done\ndata: {}\n\n");
|
|
525
604
|
} catch (error) {
|
|
526
|
-
const payload = error instanceof
|
|
605
|
+
const payload = error instanceof import_nestjs_agent_core5.AgentStreamError ? {
|
|
527
606
|
code: error.code,
|
|
528
607
|
message: error.message
|
|
529
608
|
} : {
|
|
@@ -538,71 +617,71 @@ data: ${JSON.stringify(payload)}
|
|
|
538
617
|
res.end();
|
|
539
618
|
}
|
|
540
619
|
};
|
|
541
|
-
|
|
542
|
-
(0,
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
620
|
+
_ts_decorate4([
|
|
621
|
+
(0, import_common4.Post)("chat"),
|
|
622
|
+
_ts_param4(0, (0, import_common4.Req)()),
|
|
623
|
+
_ts_param4(1, (0, import_common4.Res)()),
|
|
624
|
+
_ts_param4(2, (0, import_common4.Body)()),
|
|
625
|
+
_ts_metadata4("design:type", Function),
|
|
626
|
+
_ts_metadata4("design:paramtypes", [
|
|
548
627
|
typeof Request === "undefined" ? Object : Request,
|
|
549
628
|
typeof Response === "undefined" ? Object : Response,
|
|
550
629
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
551
630
|
]),
|
|
552
|
-
|
|
631
|
+
_ts_metadata4("design:returntype", Promise)
|
|
553
632
|
], ChatController.prototype, "chat", null);
|
|
554
|
-
|
|
555
|
-
(0,
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
633
|
+
_ts_decorate4([
|
|
634
|
+
(0, import_common4.Get)("chat/:runId/stream"),
|
|
635
|
+
_ts_param4(0, (0, import_common4.Param)("runId")),
|
|
636
|
+
_ts_param4(1, (0, import_common4.Res)()),
|
|
637
|
+
_ts_metadata4("design:type", Function),
|
|
638
|
+
_ts_metadata4("design:paramtypes", [
|
|
560
639
|
String,
|
|
561
640
|
typeof Response === "undefined" ? Object : Response
|
|
562
641
|
]),
|
|
563
|
-
|
|
642
|
+
_ts_metadata4("design:returntype", Promise)
|
|
564
643
|
], ChatController.prototype, "stream", null);
|
|
565
|
-
|
|
566
|
-
(0,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
644
|
+
_ts_decorate4([
|
|
645
|
+
(0, import_common4.Post)("chat/:runId/cancel"),
|
|
646
|
+
_ts_param4(0, (0, import_common4.Req)()),
|
|
647
|
+
_ts_param4(1, (0, import_common4.Param)("runId")),
|
|
648
|
+
_ts_metadata4("design:type", Function),
|
|
649
|
+
_ts_metadata4("design:paramtypes", [
|
|
571
650
|
typeof Request === "undefined" ? Object : Request,
|
|
572
651
|
String
|
|
573
652
|
]),
|
|
574
|
-
|
|
653
|
+
_ts_metadata4("design:returntype", Promise)
|
|
575
654
|
], ChatController.prototype, "cancel", null);
|
|
576
|
-
ChatController =
|
|
577
|
-
(0,
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
655
|
+
ChatController = _ts_decorate4([
|
|
656
|
+
(0, import_common4.Controller)(),
|
|
657
|
+
_ts_param4(1, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_ACTOR_RESOLVER)),
|
|
658
|
+
_ts_metadata4("design:type", Function),
|
|
659
|
+
_ts_metadata4("design:paramtypes", [
|
|
581
660
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
582
661
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
583
662
|
])
|
|
584
663
|
], ChatController);
|
|
585
664
|
|
|
586
665
|
// src/controller/quota.controller.ts
|
|
587
|
-
var
|
|
588
|
-
var
|
|
589
|
-
function
|
|
666
|
+
var import_nestjs_agent_core6 = require("@dudousxd/nestjs-agent-core");
|
|
667
|
+
var import_common5 = require("@nestjs/common");
|
|
668
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
590
669
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
591
670
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
592
671
|
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;
|
|
593
672
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
594
673
|
}
|
|
595
|
-
__name(
|
|
596
|
-
function
|
|
674
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
675
|
+
function _ts_metadata5(k, v) {
|
|
597
676
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
598
677
|
}
|
|
599
|
-
__name(
|
|
600
|
-
function
|
|
678
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
679
|
+
function _ts_param5(paramIndex, decorator) {
|
|
601
680
|
return function(target, key) {
|
|
602
681
|
decorator(target, key, paramIndex);
|
|
603
682
|
};
|
|
604
683
|
}
|
|
605
|
-
__name(
|
|
684
|
+
__name(_ts_param5, "_ts_param");
|
|
606
685
|
var QuotaController = class {
|
|
607
686
|
static {
|
|
608
687
|
__name(this, "QuotaController");
|
|
@@ -618,45 +697,45 @@ var QuotaController = class {
|
|
|
618
697
|
return this.agent.quotaToday(actor.id);
|
|
619
698
|
}
|
|
620
699
|
};
|
|
621
|
-
|
|
622
|
-
(0,
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
700
|
+
_ts_decorate5([
|
|
701
|
+
(0, import_common5.Get)("today"),
|
|
702
|
+
_ts_param5(0, (0, import_common5.Req)()),
|
|
703
|
+
_ts_metadata5("design:type", Function),
|
|
704
|
+
_ts_metadata5("design:paramtypes", [
|
|
626
705
|
typeof Request === "undefined" ? Object : Request
|
|
627
706
|
]),
|
|
628
|
-
|
|
707
|
+
_ts_metadata5("design:returntype", Promise)
|
|
629
708
|
], QuotaController.prototype, "today", null);
|
|
630
|
-
QuotaController =
|
|
631
|
-
(0,
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
709
|
+
QuotaController = _ts_decorate5([
|
|
710
|
+
(0, import_common5.Controller)("quota"),
|
|
711
|
+
_ts_param5(1, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_ACTOR_RESOLVER)),
|
|
712
|
+
_ts_metadata5("design:type", Function),
|
|
713
|
+
_ts_metadata5("design:paramtypes", [
|
|
635
714
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
636
715
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
637
716
|
])
|
|
638
717
|
], QuotaController);
|
|
639
718
|
|
|
640
719
|
// src/controller/threads.controller.ts
|
|
641
|
-
var
|
|
642
|
-
var
|
|
643
|
-
function
|
|
720
|
+
var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
|
|
721
|
+
var import_common6 = require("@nestjs/common");
|
|
722
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
644
723
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
645
724
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
646
725
|
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;
|
|
647
726
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
648
727
|
}
|
|
649
|
-
__name(
|
|
650
|
-
function
|
|
728
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
729
|
+
function _ts_metadata6(k, v) {
|
|
651
730
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
652
731
|
}
|
|
653
|
-
__name(
|
|
654
|
-
function
|
|
732
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
733
|
+
function _ts_param6(paramIndex, decorator) {
|
|
655
734
|
return function(target, key) {
|
|
656
735
|
decorator(target, key, paramIndex);
|
|
657
736
|
};
|
|
658
737
|
}
|
|
659
|
-
__name(
|
|
738
|
+
__name(_ts_param6, "_ts_param");
|
|
660
739
|
var ThreadsController = class {
|
|
661
740
|
static {
|
|
662
741
|
__name(this, "ThreadsController");
|
|
@@ -708,117 +787,117 @@ var ThreadsController = class {
|
|
|
708
787
|
};
|
|
709
788
|
}
|
|
710
789
|
};
|
|
711
|
-
|
|
712
|
-
(0,
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
790
|
+
_ts_decorate6([
|
|
791
|
+
(0, import_common6.Get)(),
|
|
792
|
+
_ts_param6(0, (0, import_common6.Req)()),
|
|
793
|
+
_ts_metadata6("design:type", Function),
|
|
794
|
+
_ts_metadata6("design:paramtypes", [
|
|
716
795
|
typeof Request === "undefined" ? Object : Request
|
|
717
796
|
]),
|
|
718
|
-
|
|
797
|
+
_ts_metadata6("design:returntype", Promise)
|
|
719
798
|
], ThreadsController.prototype, "list", null);
|
|
720
|
-
|
|
721
|
-
(0,
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
799
|
+
_ts_decorate6([
|
|
800
|
+
(0, import_common6.Get)(":id"),
|
|
801
|
+
_ts_param6(0, (0, import_common6.Req)()),
|
|
802
|
+
_ts_param6(1, (0, import_common6.Param)("id")),
|
|
803
|
+
_ts_metadata6("design:type", Function),
|
|
804
|
+
_ts_metadata6("design:paramtypes", [
|
|
726
805
|
typeof Request === "undefined" ? Object : Request,
|
|
727
806
|
String
|
|
728
807
|
]),
|
|
729
|
-
|
|
808
|
+
_ts_metadata6("design:returntype", Promise)
|
|
730
809
|
], ThreadsController.prototype, "detail", null);
|
|
731
|
-
|
|
732
|
-
(0,
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
810
|
+
_ts_decorate6([
|
|
811
|
+
(0, import_common6.Delete)(":id"),
|
|
812
|
+
_ts_param6(0, (0, import_common6.Req)()),
|
|
813
|
+
_ts_param6(1, (0, import_common6.Param)("id")),
|
|
814
|
+
_ts_metadata6("design:type", Function),
|
|
815
|
+
_ts_metadata6("design:paramtypes", [
|
|
737
816
|
typeof Request === "undefined" ? Object : Request,
|
|
738
817
|
String
|
|
739
818
|
]),
|
|
740
|
-
|
|
819
|
+
_ts_metadata6("design:returntype", Promise)
|
|
741
820
|
], ThreadsController.prototype, "remove", null);
|
|
742
|
-
|
|
743
|
-
(0,
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
821
|
+
_ts_decorate6([
|
|
822
|
+
(0, import_common6.Post)(":id/fork-from/:messageId"),
|
|
823
|
+
_ts_param6(0, (0, import_common6.Req)()),
|
|
824
|
+
_ts_param6(1, (0, import_common6.Param)("id")),
|
|
825
|
+
_ts_param6(2, (0, import_common6.Param)("messageId")),
|
|
826
|
+
_ts_metadata6("design:type", Function),
|
|
827
|
+
_ts_metadata6("design:paramtypes", [
|
|
749
828
|
typeof Request === "undefined" ? Object : Request,
|
|
750
829
|
String,
|
|
751
830
|
String
|
|
752
831
|
]),
|
|
753
|
-
|
|
832
|
+
_ts_metadata6("design:returntype", Promise)
|
|
754
833
|
], ThreadsController.prototype, "fork", null);
|
|
755
|
-
|
|
756
|
-
(0,
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
834
|
+
_ts_decorate6([
|
|
835
|
+
(0, import_common6.Patch)(":id"),
|
|
836
|
+
_ts_param6(0, (0, import_common6.Req)()),
|
|
837
|
+
_ts_param6(1, (0, import_common6.Param)("id")),
|
|
838
|
+
_ts_param6(2, (0, import_common6.Body)()),
|
|
839
|
+
_ts_metadata6("design:type", Function),
|
|
840
|
+
_ts_metadata6("design:paramtypes", [
|
|
762
841
|
typeof Request === "undefined" ? Object : Request,
|
|
763
842
|
String,
|
|
764
843
|
typeof RenameThreadBody === "undefined" ? Object : RenameThreadBody
|
|
765
844
|
]),
|
|
766
|
-
|
|
845
|
+
_ts_metadata6("design:returntype", Promise)
|
|
767
846
|
], ThreadsController.prototype, "rename", null);
|
|
768
|
-
|
|
769
|
-
(0,
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
847
|
+
_ts_decorate6([
|
|
848
|
+
(0, import_common6.Post)(":id/promote"),
|
|
849
|
+
_ts_param6(0, (0, import_common6.Req)()),
|
|
850
|
+
_ts_param6(1, (0, import_common6.Param)("id")),
|
|
851
|
+
_ts_metadata6("design:type", Function),
|
|
852
|
+
_ts_metadata6("design:paramtypes", [
|
|
774
853
|
typeof Request === "undefined" ? Object : Request,
|
|
775
854
|
String
|
|
776
855
|
]),
|
|
777
|
-
|
|
856
|
+
_ts_metadata6("design:returntype", Promise)
|
|
778
857
|
], ThreadsController.prototype, "promote", null);
|
|
779
|
-
|
|
780
|
-
(0,
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
858
|
+
_ts_decorate6([
|
|
859
|
+
(0, import_common6.Delete)(":id/from/:messageId"),
|
|
860
|
+
_ts_param6(0, (0, import_common6.Req)()),
|
|
861
|
+
_ts_param6(1, (0, import_common6.Param)("id")),
|
|
862
|
+
_ts_param6(2, (0, import_common6.Param)("messageId")),
|
|
863
|
+
_ts_metadata6("design:type", Function),
|
|
864
|
+
_ts_metadata6("design:paramtypes", [
|
|
786
865
|
typeof Request === "undefined" ? Object : Request,
|
|
787
866
|
String,
|
|
788
867
|
String
|
|
789
868
|
]),
|
|
790
|
-
|
|
869
|
+
_ts_metadata6("design:returntype", Promise)
|
|
791
870
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
792
|
-
ThreadsController =
|
|
793
|
-
(0,
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
871
|
+
ThreadsController = _ts_decorate6([
|
|
872
|
+
(0, import_common6.Controller)("threads"),
|
|
873
|
+
_ts_param6(1, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_ACTOR_RESOLVER)),
|
|
874
|
+
_ts_metadata6("design:type", Function),
|
|
875
|
+
_ts_metadata6("design:paramtypes", [
|
|
797
876
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
798
877
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
799
878
|
])
|
|
800
879
|
], ThreadsController);
|
|
801
880
|
|
|
802
881
|
// src/controller/tool-call.controller.ts
|
|
803
|
-
var
|
|
804
|
-
var
|
|
805
|
-
function
|
|
882
|
+
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
883
|
+
var import_common7 = require("@nestjs/common");
|
|
884
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
806
885
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
807
886
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
808
887
|
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;
|
|
809
888
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
810
889
|
}
|
|
811
|
-
__name(
|
|
812
|
-
function
|
|
890
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
891
|
+
function _ts_metadata7(k, v) {
|
|
813
892
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
814
893
|
}
|
|
815
|
-
__name(
|
|
816
|
-
function
|
|
894
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
895
|
+
function _ts_param7(paramIndex, decorator) {
|
|
817
896
|
return function(target, key) {
|
|
818
897
|
decorator(target, key, paramIndex);
|
|
819
898
|
};
|
|
820
899
|
}
|
|
821
|
-
__name(
|
|
900
|
+
__name(_ts_param7, "_ts_param");
|
|
822
901
|
var ToolCallController = class {
|
|
823
902
|
static {
|
|
824
903
|
__name(this, "ToolCallController");
|
|
@@ -844,41 +923,41 @@ var ToolCallController = class {
|
|
|
844
923
|
};
|
|
845
924
|
}
|
|
846
925
|
};
|
|
847
|
-
|
|
848
|
-
(0,
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
926
|
+
_ts_decorate7([
|
|
927
|
+
(0, import_common7.Post)("approve"),
|
|
928
|
+
_ts_param7(0, (0, import_common7.Req)()),
|
|
929
|
+
_ts_param7(1, (0, import_common7.Body)()),
|
|
930
|
+
_ts_metadata7("design:type", Function),
|
|
931
|
+
_ts_metadata7("design:paramtypes", [
|
|
853
932
|
typeof Request === "undefined" ? Object : Request,
|
|
854
933
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
855
934
|
]),
|
|
856
|
-
|
|
935
|
+
_ts_metadata7("design:returntype", Promise)
|
|
857
936
|
], ToolCallController.prototype, "approve", null);
|
|
858
|
-
|
|
859
|
-
(0,
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
937
|
+
_ts_decorate7([
|
|
938
|
+
(0, import_common7.Post)("reject"),
|
|
939
|
+
_ts_param7(0, (0, import_common7.Req)()),
|
|
940
|
+
_ts_param7(1, (0, import_common7.Body)()),
|
|
941
|
+
_ts_metadata7("design:type", Function),
|
|
942
|
+
_ts_metadata7("design:paramtypes", [
|
|
864
943
|
typeof Request === "undefined" ? Object : Request,
|
|
865
944
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
866
945
|
]),
|
|
867
|
-
|
|
946
|
+
_ts_metadata7("design:returntype", Promise)
|
|
868
947
|
], ToolCallController.prototype, "reject", null);
|
|
869
|
-
ToolCallController =
|
|
870
|
-
(0,
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
948
|
+
ToolCallController = _ts_decorate7([
|
|
949
|
+
(0, import_common7.Controller)("tool-call"),
|
|
950
|
+
_ts_param7(1, (0, import_common7.Inject)(import_nestjs_agent_core8.AGENT_ACTOR_RESOLVER)),
|
|
951
|
+
_ts_metadata7("design:type", Function),
|
|
952
|
+
_ts_metadata7("design:paramtypes", [
|
|
874
953
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
875
954
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
876
955
|
])
|
|
877
956
|
], ToolCallController);
|
|
878
957
|
|
|
879
958
|
// src/discovery/agent-discovery.service.ts
|
|
880
|
-
var
|
|
881
|
-
var
|
|
959
|
+
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
960
|
+
var import_common8 = require("@nestjs/common");
|
|
882
961
|
var import_core = require("@nestjs/core");
|
|
883
962
|
|
|
884
963
|
// src/decorator/agent.decorator.ts
|
|
@@ -913,23 +992,23 @@ function SystemPromptContributor() {
|
|
|
913
992
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
914
993
|
|
|
915
994
|
// src/discovery/agent-discovery.service.ts
|
|
916
|
-
function
|
|
995
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
917
996
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
918
997
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
919
998
|
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;
|
|
920
999
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
921
1000
|
}
|
|
922
|
-
__name(
|
|
923
|
-
function
|
|
1001
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1002
|
+
function _ts_metadata8(k, v) {
|
|
924
1003
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
925
1004
|
}
|
|
926
|
-
__name(
|
|
927
|
-
function
|
|
1005
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
1006
|
+
function _ts_param8(paramIndex, decorator) {
|
|
928
1007
|
return function(target, key) {
|
|
929
1008
|
decorator(target, key, paramIndex);
|
|
930
1009
|
};
|
|
931
1010
|
}
|
|
932
|
-
__name(
|
|
1011
|
+
__name(_ts_param8, "_ts_param");
|
|
933
1012
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
934
1013
|
static {
|
|
935
1014
|
__name(this, "AgentDiscoveryService");
|
|
@@ -938,7 +1017,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
938
1017
|
scanner;
|
|
939
1018
|
registry;
|
|
940
1019
|
contributors;
|
|
941
|
-
logger = new
|
|
1020
|
+
logger = new import_common8.Logger(_AgentDiscoveryService.name);
|
|
942
1021
|
constructor(discovery, scanner, registry, contributors) {
|
|
943
1022
|
this.discovery = discovery;
|
|
944
1023
|
this.scanner = scanner;
|
|
@@ -964,6 +1043,9 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
964
1043
|
const systemPrompt = promptMethod !== void 0 ? (ctx) => promptMethod(ctx) : meta.systemPrompt ?? "You are a helpful assistant.";
|
|
965
1044
|
return {
|
|
966
1045
|
name: meta.name,
|
|
1046
|
+
...meta.description !== void 0 ? {
|
|
1047
|
+
description: meta.description
|
|
1048
|
+
} : {},
|
|
967
1049
|
systemPrompt,
|
|
968
1050
|
...meta.tools !== void 0 ? {
|
|
969
1051
|
tools: meta.tools
|
|
@@ -1023,22 +1105,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
1023
1105
|
return (ctx) => candidate.call(instance, ctx);
|
|
1024
1106
|
}
|
|
1025
1107
|
};
|
|
1026
|
-
AgentDiscoveryService =
|
|
1027
|
-
(0,
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1108
|
+
AgentDiscoveryService = _ts_decorate8([
|
|
1109
|
+
(0, import_common8.Injectable)(),
|
|
1110
|
+
_ts_param8(2, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_REGISTRY)),
|
|
1111
|
+
_ts_param8(3, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_PROMPT_CONTRIBUTORS)),
|
|
1112
|
+
_ts_metadata8("design:type", Function),
|
|
1113
|
+
_ts_metadata8("design:paramtypes", [
|
|
1032
1114
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
1033
1115
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
1034
|
-
typeof
|
|
1116
|
+
typeof import_nestjs_agent_core9.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core9.AgentRegistry,
|
|
1035
1117
|
Array
|
|
1036
1118
|
])
|
|
1037
1119
|
], AgentDiscoveryService);
|
|
1038
1120
|
|
|
1039
1121
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1040
|
-
var
|
|
1041
|
-
var
|
|
1122
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
1123
|
+
var import_common9 = require("@nestjs/common");
|
|
1042
1124
|
var import_core2 = require("@nestjs/core");
|
|
1043
1125
|
var import_zod = require("zod");
|
|
1044
1126
|
|
|
@@ -1087,23 +1169,23 @@ function provideAgentTool(factoryOrTool, inject) {
|
|
|
1087
1169
|
__name(provideAgentTool, "provideAgentTool");
|
|
1088
1170
|
|
|
1089
1171
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1090
|
-
function
|
|
1172
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1091
1173
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1092
1174
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1093
1175
|
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;
|
|
1094
1176
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1095
1177
|
}
|
|
1096
|
-
__name(
|
|
1097
|
-
function
|
|
1178
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1179
|
+
function _ts_metadata9(k, v) {
|
|
1098
1180
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1099
1181
|
}
|
|
1100
|
-
__name(
|
|
1101
|
-
function
|
|
1182
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1183
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1102
1184
|
return function(target, key) {
|
|
1103
1185
|
decorator(target, key, paramIndex);
|
|
1104
1186
|
};
|
|
1105
1187
|
}
|
|
1106
|
-
__name(
|
|
1188
|
+
__name(_ts_param9, "_ts_param");
|
|
1107
1189
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
1108
1190
|
static {
|
|
1109
1191
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -1112,7 +1194,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
1112
1194
|
registry;
|
|
1113
1195
|
agents;
|
|
1114
1196
|
options;
|
|
1115
|
-
logger = new
|
|
1197
|
+
logger = new import_common9.Logger(_AiToolDiscoveryService.name);
|
|
1116
1198
|
constructor(discovery, registry, agents, options) {
|
|
1117
1199
|
this.discovery = discovery;
|
|
1118
1200
|
this.registry = registry;
|
|
@@ -1210,13 +1292,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
1210
1292
|
return true;
|
|
1211
1293
|
}
|
|
1212
1294
|
};
|
|
1213
|
-
AiToolDiscoveryService =
|
|
1214
|
-
(0,
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1295
|
+
AiToolDiscoveryService = _ts_decorate9([
|
|
1296
|
+
(0, import_common9.Injectable)(),
|
|
1297
|
+
_ts_param9(1, (0, import_common9.Inject)(import_nestjs_agent_core10.AGENT_TOOL_REGISTRY)),
|
|
1298
|
+
_ts_param9(2, (0, import_common9.Inject)(import_nestjs_agent_core10.AGENT_REGISTRY)),
|
|
1299
|
+
_ts_param9(3, (0, import_common9.Inject)(import_nestjs_agent_core10.AGENT_OPTIONS)),
|
|
1300
|
+
_ts_metadata9("design:type", Function),
|
|
1301
|
+
_ts_metadata9("design:paramtypes", [
|
|
1220
1302
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
1221
1303
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
1222
1304
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -1225,7 +1307,7 @@ AiToolDiscoveryService = _ts_decorate8([
|
|
|
1225
1307
|
], AiToolDiscoveryService);
|
|
1226
1308
|
|
|
1227
1309
|
// src/in-process-sink.ts
|
|
1228
|
-
var
|
|
1310
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
1229
1311
|
var InProcessTokenStreamSink = class {
|
|
1230
1312
|
static {
|
|
1231
1313
|
__name(this, "InProcessTokenStreamSink");
|
|
@@ -1280,7 +1362,7 @@ var InProcessTokenStreamSink = class {
|
|
|
1280
1362
|
}
|
|
1281
1363
|
if (buf.ended) {
|
|
1282
1364
|
if (buf.failure !== void 0) {
|
|
1283
|
-
throw new
|
|
1365
|
+
throw new import_nestjs_agent_core11.AgentStreamError(buf.failure);
|
|
1284
1366
|
}
|
|
1285
1367
|
return;
|
|
1286
1368
|
}
|
|
@@ -1316,32 +1398,32 @@ var LedgerQuotaStore = class {
|
|
|
1316
1398
|
};
|
|
1317
1399
|
|
|
1318
1400
|
// src/runner/inline-agent-runner.ts
|
|
1319
|
-
var
|
|
1320
|
-
var
|
|
1321
|
-
function
|
|
1401
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
1402
|
+
var import_common10 = require("@nestjs/common");
|
|
1403
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1322
1404
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1323
1405
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1324
1406
|
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;
|
|
1325
1407
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1326
1408
|
}
|
|
1327
|
-
__name(
|
|
1328
|
-
function
|
|
1409
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1410
|
+
function _ts_metadata10(k, v) {
|
|
1329
1411
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1330
1412
|
}
|
|
1331
|
-
__name(
|
|
1332
|
-
function
|
|
1413
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1414
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1333
1415
|
return function(target, key) {
|
|
1334
1416
|
decorator(target, key, paramIndex);
|
|
1335
1417
|
};
|
|
1336
1418
|
}
|
|
1337
|
-
__name(
|
|
1419
|
+
__name(_ts_param10, "_ts_param");
|
|
1338
1420
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
1339
1421
|
static {
|
|
1340
1422
|
__name(this, "InlineAgentRunner");
|
|
1341
1423
|
}
|
|
1342
1424
|
factory;
|
|
1343
1425
|
store;
|
|
1344
|
-
logger = new
|
|
1426
|
+
logger = new import_common10.Logger(_InlineAgentRunner.name);
|
|
1345
1427
|
pending = /* @__PURE__ */ new Map();
|
|
1346
1428
|
constructor(factory, store) {
|
|
1347
1429
|
this.factory = factory;
|
|
@@ -1352,14 +1434,14 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1352
1434
|
const day = input.day ?? utcDay();
|
|
1353
1435
|
const deps = this.factory.forAgent(input.agentName);
|
|
1354
1436
|
const hooks = this.topLevelHooks(runId, deps, input.actor, day);
|
|
1355
|
-
void (0,
|
|
1437
|
+
void (0, import_nestjs_agent_core12.runAgentLoop)({
|
|
1356
1438
|
...deps,
|
|
1357
1439
|
day
|
|
1358
1440
|
}, input, hooks).catch(async (error) => {
|
|
1359
1441
|
const message = error instanceof Error ? error.message : String(error);
|
|
1360
|
-
const code = error instanceof
|
|
1442
|
+
const code = error instanceof import_nestjs_agent_core12.QuotaExceededError ? "quota_exceeded" : "run_failed";
|
|
1361
1443
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
1362
|
-
(0,
|
|
1444
|
+
(0, import_nestjs_agent_core12.publishAgentRunFailed)({
|
|
1363
1445
|
runId,
|
|
1364
1446
|
code,
|
|
1365
1447
|
message
|
|
@@ -1421,7 +1503,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1421
1503
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
1422
1504
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested(childName, childTask, actor, day, depth + 1, sinkRunId), "runAgent")
|
|
1423
1505
|
};
|
|
1424
|
-
return (0,
|
|
1506
|
+
return (0, import_nestjs_agent_core12.runAgentLoop)({
|
|
1425
1507
|
...deps,
|
|
1426
1508
|
day
|
|
1427
1509
|
}, {
|
|
@@ -1435,84 +1517,84 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1435
1517
|
}, hooks);
|
|
1436
1518
|
}
|
|
1437
1519
|
};
|
|
1438
|
-
InlineAgentRunner =
|
|
1439
|
-
(0,
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1520
|
+
InlineAgentRunner = _ts_decorate10([
|
|
1521
|
+
(0, import_common10.Injectable)(),
|
|
1522
|
+
_ts_param10(0, (0, import_common10.Inject)(import_nestjs_agent_core12.AGENT_DEPS_FACTORY)),
|
|
1523
|
+
_ts_param10(1, (0, import_common10.Inject)(import_nestjs_agent_core12.AGENT_STORE)),
|
|
1524
|
+
_ts_metadata10("design:type", Function),
|
|
1525
|
+
_ts_metadata10("design:paramtypes", [
|
|
1444
1526
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1445
1527
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
1446
1528
|
])
|
|
1447
1529
|
], InlineAgentRunner);
|
|
1448
1530
|
|
|
1449
1531
|
// src/agent.module.ts
|
|
1450
|
-
function
|
|
1532
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1451
1533
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1452
1534
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1453
1535
|
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;
|
|
1454
1536
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1455
1537
|
}
|
|
1456
|
-
__name(
|
|
1538
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1457
1539
|
var DEFAULT_PATH = "agent";
|
|
1458
1540
|
function sharedProviders(durable, includeStore) {
|
|
1459
1541
|
const providers = [
|
|
1460
1542
|
{
|
|
1461
|
-
provide:
|
|
1462
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
1543
|
+
provide: import_nestjs_agent_core13.AGENT_TOOL_REGISTRY,
|
|
1544
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core13.ToolRegistry(), "useFactory")
|
|
1463
1545
|
},
|
|
1464
1546
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
1465
1547
|
{
|
|
1466
|
-
provide:
|
|
1467
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
1548
|
+
provide: import_nestjs_agent_core13.AGENT_REGISTRY,
|
|
1549
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core13.AgentRegistry(), "useFactory")
|
|
1468
1550
|
},
|
|
1469
1551
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
1470
1552
|
{
|
|
1471
|
-
provide:
|
|
1553
|
+
provide: import_nestjs_agent_core13.AGENT_PROMPT_CONTRIBUTORS,
|
|
1472
1554
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
1473
1555
|
},
|
|
1474
1556
|
{
|
|
1475
|
-
provide:
|
|
1557
|
+
provide: import_nestjs_agent_core13.AGENT_SINK,
|
|
1476
1558
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
1477
1559
|
inject: [
|
|
1478
|
-
|
|
1560
|
+
import_nestjs_agent_core13.AGENT_OPTIONS
|
|
1479
1561
|
]
|
|
1480
1562
|
},
|
|
1481
1563
|
{
|
|
1482
|
-
provide:
|
|
1483
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
1564
|
+
provide: import_nestjs_agent_core13.AGENT_ROLES_POLICY,
|
|
1565
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core13.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
1484
1566
|
inject: [
|
|
1485
|
-
|
|
1567
|
+
import_nestjs_agent_core13.AGENT_OPTIONS
|
|
1486
1568
|
]
|
|
1487
1569
|
},
|
|
1488
1570
|
{
|
|
1489
|
-
provide:
|
|
1571
|
+
provide: import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER,
|
|
1490
1572
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
1491
1573
|
inject: [
|
|
1492
|
-
|
|
1574
|
+
import_nestjs_agent_core13.AGENT_OPTIONS
|
|
1493
1575
|
]
|
|
1494
1576
|
},
|
|
1495
1577
|
{
|
|
1496
|
-
provide:
|
|
1578
|
+
provide: import_nestjs_agent_core13.AGENT_MODEL,
|
|
1497
1579
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
1498
1580
|
inject: [
|
|
1499
|
-
|
|
1581
|
+
import_nestjs_agent_core13.AGENT_OPTIONS
|
|
1500
1582
|
]
|
|
1501
1583
|
},
|
|
1502
1584
|
{
|
|
1503
1585
|
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
1504
1586
|
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
1505
1587
|
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
1506
|
-
provide:
|
|
1588
|
+
provide: import_nestjs_agent_core13.AGENT_QUOTA_STORE,
|
|
1507
1589
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
1508
1590
|
inject: [
|
|
1509
|
-
|
|
1510
|
-
|
|
1591
|
+
import_nestjs_agent_core13.AGENT_OPTIONS,
|
|
1592
|
+
import_nestjs_agent_core13.AGENT_STORE
|
|
1511
1593
|
]
|
|
1512
1594
|
},
|
|
1513
1595
|
AgentDepsFactory2,
|
|
1514
1596
|
{
|
|
1515
|
-
provide:
|
|
1597
|
+
provide: import_nestjs_agent_core13.AGENT_DEPS_FACTORY,
|
|
1516
1598
|
useExisting: AgentDepsFactory2
|
|
1517
1599
|
},
|
|
1518
1600
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -1524,16 +1606,16 @@ function sharedProviders(durable, includeStore) {
|
|
|
1524
1606
|
];
|
|
1525
1607
|
if (includeStore) {
|
|
1526
1608
|
providers.push({
|
|
1527
|
-
provide:
|
|
1609
|
+
provide: import_nestjs_agent_core13.AGENT_STORE,
|
|
1528
1610
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
1529
1611
|
inject: [
|
|
1530
|
-
|
|
1612
|
+
import_nestjs_agent_core13.AGENT_OPTIONS
|
|
1531
1613
|
]
|
|
1532
1614
|
});
|
|
1533
1615
|
}
|
|
1534
1616
|
if (durable) {
|
|
1535
1617
|
providers.push({
|
|
1536
|
-
provide:
|
|
1618
|
+
provide: import_nestjs_agent_core13.AGENT_RUNNER,
|
|
1537
1619
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
1538
1620
|
if (durableRunner === void 0) {
|
|
1539
1621
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -1542,14 +1624,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
1542
1624
|
}, "useFactory"),
|
|
1543
1625
|
inject: [
|
|
1544
1626
|
{
|
|
1545
|
-
token:
|
|
1627
|
+
token: import_nestjs_agent_core13.AGENT_DURABLE_RUNNER,
|
|
1546
1628
|
optional: true
|
|
1547
1629
|
}
|
|
1548
1630
|
]
|
|
1549
1631
|
});
|
|
1550
1632
|
} else {
|
|
1551
1633
|
providers.push({
|
|
1552
|
-
provide:
|
|
1634
|
+
provide: import_nestjs_agent_core13.AGENT_RUNNER,
|
|
1553
1635
|
useExisting: InlineAgentRunner
|
|
1554
1636
|
});
|
|
1555
1637
|
}
|
|
@@ -1558,19 +1640,19 @@ function sharedProviders(durable, includeStore) {
|
|
|
1558
1640
|
__name(sharedProviders, "sharedProviders");
|
|
1559
1641
|
function exportsFor(includeStore) {
|
|
1560
1642
|
return [
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1643
|
+
import_nestjs_agent_core13.AGENT_OPTIONS,
|
|
1644
|
+
import_nestjs_agent_core13.AGENT_TOOL_REGISTRY,
|
|
1645
|
+
import_nestjs_agent_core13.AGENT_REGISTRY,
|
|
1646
|
+
import_nestjs_agent_core13.AGENT_SINK,
|
|
1647
|
+
import_nestjs_agent_core13.AGENT_ROLES_POLICY,
|
|
1648
|
+
import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER,
|
|
1649
|
+
import_nestjs_agent_core13.AGENT_MODEL,
|
|
1568
1650
|
...includeStore ? [
|
|
1569
|
-
|
|
1651
|
+
import_nestjs_agent_core13.AGENT_STORE
|
|
1570
1652
|
] : [],
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1653
|
+
import_nestjs_agent_core13.AGENT_QUOTA_STORE,
|
|
1654
|
+
import_nestjs_agent_core13.AGENT_PROMPT_CONTRIBUTORS,
|
|
1655
|
+
import_nestjs_agent_core13.AGENT_DEPS_FACTORY,
|
|
1574
1656
|
AgentDepsFactory2,
|
|
1575
1657
|
AgentService,
|
|
1576
1658
|
InlineAgentRunner
|
|
@@ -1581,7 +1663,8 @@ var CONTROLLERS = [
|
|
|
1581
1663
|
ChatController,
|
|
1582
1664
|
ThreadsController,
|
|
1583
1665
|
ToolCallController,
|
|
1584
|
-
QuotaController
|
|
1666
|
+
QuotaController,
|
|
1667
|
+
AgentsController
|
|
1585
1668
|
];
|
|
1586
1669
|
function routerFor(path) {
|
|
1587
1670
|
return import_core3.RouterModule.register([
|
|
@@ -1609,7 +1692,7 @@ var AgentModule = class _AgentModule {
|
|
|
1609
1692
|
controllers: CONTROLLERS,
|
|
1610
1693
|
providers: [
|
|
1611
1694
|
{
|
|
1612
|
-
provide:
|
|
1695
|
+
provide: import_nestjs_agent_core13.AGENT_OPTIONS,
|
|
1613
1696
|
useValue: options
|
|
1614
1697
|
},
|
|
1615
1698
|
...sharedProviders(options.durable ?? false, includeStore)
|
|
@@ -1619,6 +1702,7 @@ var AgentModule = class _AgentModule {
|
|
|
1619
1702
|
}
|
|
1620
1703
|
static forRootAsync(options) {
|
|
1621
1704
|
const path = options.path ?? DEFAULT_PATH;
|
|
1705
|
+
const includeStore = options.externalStore !== true;
|
|
1622
1706
|
return {
|
|
1623
1707
|
module: _AgentModule,
|
|
1624
1708
|
global: true,
|
|
@@ -1630,21 +1714,19 @@ var AgentModule = class _AgentModule {
|
|
|
1630
1714
|
controllers: CONTROLLERS,
|
|
1631
1715
|
providers: [
|
|
1632
1716
|
{
|
|
1633
|
-
provide:
|
|
1717
|
+
provide: import_nestjs_agent_core13.AGENT_OPTIONS,
|
|
1634
1718
|
useFactory: options.useFactory,
|
|
1635
1719
|
inject: options.inject ?? []
|
|
1636
1720
|
},
|
|
1637
|
-
|
|
1638
|
-
// (its factory reads the resolved options). Omit-and-import-a-store-module is a `forRoot` path.
|
|
1639
|
-
...sharedProviders(options.durable ?? false, true)
|
|
1721
|
+
...sharedProviders(options.durable ?? false, includeStore)
|
|
1640
1722
|
],
|
|
1641
|
-
exports: exportsFor(
|
|
1723
|
+
exports: exportsFor(includeStore)
|
|
1642
1724
|
};
|
|
1643
1725
|
}
|
|
1644
1726
|
};
|
|
1645
|
-
AgentModule =
|
|
1646
|
-
(0,
|
|
1647
|
-
(0,
|
|
1727
|
+
AgentModule = _ts_decorate11([
|
|
1728
|
+
(0, import_common11.Global)(),
|
|
1729
|
+
(0, import_common11.Module)({})
|
|
1648
1730
|
], AgentModule);
|
|
1649
1731
|
|
|
1650
1732
|
// src/resolver/header-actor-resolver.ts
|