@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/durable/index.cjs
CHANGED
|
@@ -151,7 +151,9 @@ AgentRunWorkflow = _ts_decorate([
|
|
|
151
151
|
], AgentRunWorkflow);
|
|
152
152
|
|
|
153
153
|
// src/durable/durable-agent-runner.ts
|
|
154
|
+
var import_node_crypto = require("crypto");
|
|
154
155
|
var import_nestjs_durable2 = require("@dudousxd/nestjs-durable");
|
|
156
|
+
var import_nestjs_durable_core2 = require("@dudousxd/nestjs-durable-core");
|
|
155
157
|
var import_common2 = require("@nestjs/common");
|
|
156
158
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
157
159
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -177,9 +179,16 @@ var DurableAgentRunner = class {
|
|
|
177
179
|
...input,
|
|
178
180
|
day: input.day ?? utcDay()
|
|
179
181
|
};
|
|
180
|
-
const
|
|
182
|
+
const runId = (0, import_node_crypto.randomUUID)();
|
|
183
|
+
try {
|
|
184
|
+
await this.workflows.start(AgentRunWorkflow, stamped, runId);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (!(error instanceof import_nestjs_durable_core2.WorkflowSuspended)) {
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
181
190
|
return {
|
|
182
|
-
runId
|
|
191
|
+
runId
|
|
183
192
|
};
|
|
184
193
|
}
|
|
185
194
|
async signal(runId, toolCallId, decision) {
|
|
@@ -242,8 +251,8 @@ AgentDurableModule = _ts_decorate3([
|
|
|
242
251
|
], AgentDurableModule);
|
|
243
252
|
|
|
244
253
|
// src/agent.module.ts
|
|
245
|
-
var
|
|
246
|
-
var
|
|
254
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
255
|
+
var import_common14 = require("@nestjs/common");
|
|
247
256
|
var import_core3 = require("@nestjs/core");
|
|
248
257
|
|
|
249
258
|
// src/agent-deps.factory.ts
|
|
@@ -454,6 +463,9 @@ var AgentService = class {
|
|
|
454
463
|
...params.regenerate === true ? {
|
|
455
464
|
regenerate: true
|
|
456
465
|
} : {},
|
|
466
|
+
...params.attachments !== void 0 ? {
|
|
467
|
+
attachments: params.attachments
|
|
468
|
+
} : {},
|
|
457
469
|
...params.pageContext !== void 0 ? {
|
|
458
470
|
pageContext: params.pageContext
|
|
459
471
|
} : {}
|
|
@@ -609,7 +621,7 @@ AgentService = _ts_decorate5([
|
|
|
609
621
|
])
|
|
610
622
|
], AgentService);
|
|
611
623
|
|
|
612
|
-
// src/controller/
|
|
624
|
+
// src/controller/agents.controller.ts
|
|
613
625
|
var import_nestjs_agent_core6 = require("@dudousxd/nestjs-agent-core");
|
|
614
626
|
var import_common6 = require("@nestjs/common");
|
|
615
627
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
@@ -629,6 +641,64 @@ function _ts_param4(paramIndex, decorator) {
|
|
|
629
641
|
};
|
|
630
642
|
}
|
|
631
643
|
__name(_ts_param4, "_ts_param");
|
|
644
|
+
var AgentsController = class {
|
|
645
|
+
static {
|
|
646
|
+
__name(this, "AgentsController");
|
|
647
|
+
}
|
|
648
|
+
agents;
|
|
649
|
+
depsFactory;
|
|
650
|
+
constructor(agents, depsFactory) {
|
|
651
|
+
this.agents = agents;
|
|
652
|
+
this.depsFactory = depsFactory;
|
|
653
|
+
}
|
|
654
|
+
list() {
|
|
655
|
+
const defaultAgentName = this.depsFactory.defaultAgentName();
|
|
656
|
+
return this.agents.list().map((definition) => ({
|
|
657
|
+
name: definition.name,
|
|
658
|
+
description: definition.description ?? "",
|
|
659
|
+
...definition.name === defaultAgentName ? {
|
|
660
|
+
isDefault: true
|
|
661
|
+
} : {}
|
|
662
|
+
}));
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
_ts_decorate6([
|
|
666
|
+
(0, import_common6.Get)(),
|
|
667
|
+
_ts_metadata5("design:type", Function),
|
|
668
|
+
_ts_metadata5("design:paramtypes", []),
|
|
669
|
+
_ts_metadata5("design:returntype", Array)
|
|
670
|
+
], AgentsController.prototype, "list", null);
|
|
671
|
+
AgentsController = _ts_decorate6([
|
|
672
|
+
(0, import_common6.Controller)("agents"),
|
|
673
|
+
_ts_param4(0, (0, import_common6.Inject)(import_nestjs_agent_core6.AGENT_REGISTRY)),
|
|
674
|
+
_ts_param4(1, (0, import_common6.Inject)(import_nestjs_agent_core6.AGENT_DEPS_FACTORY)),
|
|
675
|
+
_ts_metadata5("design:type", Function),
|
|
676
|
+
_ts_metadata5("design:paramtypes", [
|
|
677
|
+
typeof import_nestjs_agent_core6.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core6.AgentRegistry,
|
|
678
|
+
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
679
|
+
])
|
|
680
|
+
], AgentsController);
|
|
681
|
+
|
|
682
|
+
// src/controller/chat.controller.ts
|
|
683
|
+
var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
|
|
684
|
+
var import_common7 = require("@nestjs/common");
|
|
685
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
686
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
687
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
688
|
+
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;
|
|
689
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
690
|
+
}
|
|
691
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
692
|
+
function _ts_metadata6(k, v) {
|
|
693
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
694
|
+
}
|
|
695
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
696
|
+
function _ts_param5(paramIndex, decorator) {
|
|
697
|
+
return function(target, key) {
|
|
698
|
+
decorator(target, key, paramIndex);
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
__name(_ts_param5, "_ts_param");
|
|
632
702
|
var ChatController = class {
|
|
633
703
|
static {
|
|
634
704
|
__name(this, "ChatController");
|
|
@@ -650,6 +720,9 @@ var ChatController = class {
|
|
|
650
720
|
...body.agent !== void 0 ? {
|
|
651
721
|
agentName: body.agent
|
|
652
722
|
} : {},
|
|
723
|
+
...body.attachments !== void 0 ? {
|
|
724
|
+
attachments: body.attachments
|
|
725
|
+
} : {},
|
|
653
726
|
...body.pageContext !== void 0 ? {
|
|
654
727
|
pageContext: body.pageContext
|
|
655
728
|
} : {},
|
|
@@ -688,17 +761,32 @@ data: ${JSON.stringify({
|
|
|
688
761
|
|
|
689
762
|
`);
|
|
690
763
|
const decoder = new TextDecoder();
|
|
764
|
+
let buffer = "";
|
|
691
765
|
try {
|
|
692
766
|
for await (const chunk of this.agent.subscribe(runId)) {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
})
|
|
767
|
+
buffer += decoder.decode(chunk, {
|
|
768
|
+
stream: true
|
|
769
|
+
});
|
|
770
|
+
let newline = buffer.indexOf("\n");
|
|
771
|
+
while (newline !== -1) {
|
|
772
|
+
const line = buffer.slice(0, newline);
|
|
773
|
+
buffer = buffer.slice(newline + 1);
|
|
774
|
+
if (line.length > 0) {
|
|
775
|
+
res.write(`data: ${line}
|
|
776
|
+
|
|
777
|
+
`);
|
|
778
|
+
}
|
|
779
|
+
newline = buffer.indexOf("\n");
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
if (buffer.length > 0) {
|
|
783
|
+
res.write(`data: ${buffer}
|
|
696
784
|
|
|
697
785
|
`);
|
|
698
786
|
}
|
|
699
787
|
res.write("event: done\ndata: {}\n\n");
|
|
700
788
|
} catch (error) {
|
|
701
|
-
const payload = error instanceof
|
|
789
|
+
const payload = error instanceof import_nestjs_agent_core7.AgentStreamError ? {
|
|
702
790
|
code: error.code,
|
|
703
791
|
message: error.message
|
|
704
792
|
} : {
|
|
@@ -713,71 +801,71 @@ data: ${JSON.stringify(payload)}
|
|
|
713
801
|
res.end();
|
|
714
802
|
}
|
|
715
803
|
};
|
|
716
|
-
|
|
717
|
-
(0,
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
804
|
+
_ts_decorate7([
|
|
805
|
+
(0, import_common7.Post)("chat"),
|
|
806
|
+
_ts_param5(0, (0, import_common7.Req)()),
|
|
807
|
+
_ts_param5(1, (0, import_common7.Res)()),
|
|
808
|
+
_ts_param5(2, (0, import_common7.Body)()),
|
|
809
|
+
_ts_metadata6("design:type", Function),
|
|
810
|
+
_ts_metadata6("design:paramtypes", [
|
|
723
811
|
typeof Request === "undefined" ? Object : Request,
|
|
724
812
|
typeof Response === "undefined" ? Object : Response,
|
|
725
813
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
726
814
|
]),
|
|
727
|
-
|
|
815
|
+
_ts_metadata6("design:returntype", Promise)
|
|
728
816
|
], ChatController.prototype, "chat", null);
|
|
729
|
-
|
|
730
|
-
(0,
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
817
|
+
_ts_decorate7([
|
|
818
|
+
(0, import_common7.Get)("chat/:runId/stream"),
|
|
819
|
+
_ts_param5(0, (0, import_common7.Param)("runId")),
|
|
820
|
+
_ts_param5(1, (0, import_common7.Res)()),
|
|
821
|
+
_ts_metadata6("design:type", Function),
|
|
822
|
+
_ts_metadata6("design:paramtypes", [
|
|
735
823
|
String,
|
|
736
824
|
typeof Response === "undefined" ? Object : Response
|
|
737
825
|
]),
|
|
738
|
-
|
|
826
|
+
_ts_metadata6("design:returntype", Promise)
|
|
739
827
|
], ChatController.prototype, "stream", null);
|
|
740
|
-
|
|
741
|
-
(0,
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
828
|
+
_ts_decorate7([
|
|
829
|
+
(0, import_common7.Post)("chat/:runId/cancel"),
|
|
830
|
+
_ts_param5(0, (0, import_common7.Req)()),
|
|
831
|
+
_ts_param5(1, (0, import_common7.Param)("runId")),
|
|
832
|
+
_ts_metadata6("design:type", Function),
|
|
833
|
+
_ts_metadata6("design:paramtypes", [
|
|
746
834
|
typeof Request === "undefined" ? Object : Request,
|
|
747
835
|
String
|
|
748
836
|
]),
|
|
749
|
-
|
|
837
|
+
_ts_metadata6("design:returntype", Promise)
|
|
750
838
|
], ChatController.prototype, "cancel", null);
|
|
751
|
-
ChatController =
|
|
752
|
-
(0,
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
839
|
+
ChatController = _ts_decorate7([
|
|
840
|
+
(0, import_common7.Controller)(),
|
|
841
|
+
_ts_param5(1, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_ACTOR_RESOLVER)),
|
|
842
|
+
_ts_metadata6("design:type", Function),
|
|
843
|
+
_ts_metadata6("design:paramtypes", [
|
|
756
844
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
757
845
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
758
846
|
])
|
|
759
847
|
], ChatController);
|
|
760
848
|
|
|
761
849
|
// src/controller/quota.controller.ts
|
|
762
|
-
var
|
|
763
|
-
var
|
|
764
|
-
function
|
|
850
|
+
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
851
|
+
var import_common8 = require("@nestjs/common");
|
|
852
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
765
853
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
766
854
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
767
855
|
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;
|
|
768
856
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
769
857
|
}
|
|
770
|
-
__name(
|
|
771
|
-
function
|
|
858
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
859
|
+
function _ts_metadata7(k, v) {
|
|
772
860
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
773
861
|
}
|
|
774
|
-
__name(
|
|
775
|
-
function
|
|
862
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
863
|
+
function _ts_param6(paramIndex, decorator) {
|
|
776
864
|
return function(target, key) {
|
|
777
865
|
decorator(target, key, paramIndex);
|
|
778
866
|
};
|
|
779
867
|
}
|
|
780
|
-
__name(
|
|
868
|
+
__name(_ts_param6, "_ts_param");
|
|
781
869
|
var QuotaController = class {
|
|
782
870
|
static {
|
|
783
871
|
__name(this, "QuotaController");
|
|
@@ -793,45 +881,45 @@ var QuotaController = class {
|
|
|
793
881
|
return this.agent.quotaToday(actor.id);
|
|
794
882
|
}
|
|
795
883
|
};
|
|
796
|
-
|
|
797
|
-
(0,
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
884
|
+
_ts_decorate8([
|
|
885
|
+
(0, import_common8.Get)("today"),
|
|
886
|
+
_ts_param6(0, (0, import_common8.Req)()),
|
|
887
|
+
_ts_metadata7("design:type", Function),
|
|
888
|
+
_ts_metadata7("design:paramtypes", [
|
|
801
889
|
typeof Request === "undefined" ? Object : Request
|
|
802
890
|
]),
|
|
803
|
-
|
|
891
|
+
_ts_metadata7("design:returntype", Promise)
|
|
804
892
|
], QuotaController.prototype, "today", null);
|
|
805
|
-
QuotaController =
|
|
806
|
-
(0,
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
893
|
+
QuotaController = _ts_decorate8([
|
|
894
|
+
(0, import_common8.Controller)("quota"),
|
|
895
|
+
_ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_ACTOR_RESOLVER)),
|
|
896
|
+
_ts_metadata7("design:type", Function),
|
|
897
|
+
_ts_metadata7("design:paramtypes", [
|
|
810
898
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
811
899
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
812
900
|
])
|
|
813
901
|
], QuotaController);
|
|
814
902
|
|
|
815
903
|
// src/controller/threads.controller.ts
|
|
816
|
-
var
|
|
817
|
-
var
|
|
818
|
-
function
|
|
904
|
+
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
905
|
+
var import_common9 = require("@nestjs/common");
|
|
906
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
819
907
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
820
908
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
821
909
|
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;
|
|
822
910
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
823
911
|
}
|
|
824
|
-
__name(
|
|
825
|
-
function
|
|
912
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
913
|
+
function _ts_metadata8(k, v) {
|
|
826
914
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
827
915
|
}
|
|
828
|
-
__name(
|
|
829
|
-
function
|
|
916
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
917
|
+
function _ts_param7(paramIndex, decorator) {
|
|
830
918
|
return function(target, key) {
|
|
831
919
|
decorator(target, key, paramIndex);
|
|
832
920
|
};
|
|
833
921
|
}
|
|
834
|
-
__name(
|
|
922
|
+
__name(_ts_param7, "_ts_param");
|
|
835
923
|
var ThreadsController = class {
|
|
836
924
|
static {
|
|
837
925
|
__name(this, "ThreadsController");
|
|
@@ -883,117 +971,117 @@ var ThreadsController = class {
|
|
|
883
971
|
};
|
|
884
972
|
}
|
|
885
973
|
};
|
|
886
|
-
|
|
887
|
-
(0,
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
974
|
+
_ts_decorate9([
|
|
975
|
+
(0, import_common9.Get)(),
|
|
976
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
977
|
+
_ts_metadata8("design:type", Function),
|
|
978
|
+
_ts_metadata8("design:paramtypes", [
|
|
891
979
|
typeof Request === "undefined" ? Object : Request
|
|
892
980
|
]),
|
|
893
|
-
|
|
981
|
+
_ts_metadata8("design:returntype", Promise)
|
|
894
982
|
], ThreadsController.prototype, "list", null);
|
|
895
|
-
|
|
896
|
-
(0,
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
983
|
+
_ts_decorate9([
|
|
984
|
+
(0, import_common9.Get)(":id"),
|
|
985
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
986
|
+
_ts_param7(1, (0, import_common9.Param)("id")),
|
|
987
|
+
_ts_metadata8("design:type", Function),
|
|
988
|
+
_ts_metadata8("design:paramtypes", [
|
|
901
989
|
typeof Request === "undefined" ? Object : Request,
|
|
902
990
|
String
|
|
903
991
|
]),
|
|
904
|
-
|
|
992
|
+
_ts_metadata8("design:returntype", Promise)
|
|
905
993
|
], ThreadsController.prototype, "detail", null);
|
|
906
|
-
|
|
907
|
-
(0,
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
994
|
+
_ts_decorate9([
|
|
995
|
+
(0, import_common9.Delete)(":id"),
|
|
996
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
997
|
+
_ts_param7(1, (0, import_common9.Param)("id")),
|
|
998
|
+
_ts_metadata8("design:type", Function),
|
|
999
|
+
_ts_metadata8("design:paramtypes", [
|
|
912
1000
|
typeof Request === "undefined" ? Object : Request,
|
|
913
1001
|
String
|
|
914
1002
|
]),
|
|
915
|
-
|
|
1003
|
+
_ts_metadata8("design:returntype", Promise)
|
|
916
1004
|
], ThreadsController.prototype, "remove", null);
|
|
917
|
-
|
|
918
|
-
(0,
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
1005
|
+
_ts_decorate9([
|
|
1006
|
+
(0, import_common9.Post)(":id/fork-from/:messageId"),
|
|
1007
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
1008
|
+
_ts_param7(1, (0, import_common9.Param)("id")),
|
|
1009
|
+
_ts_param7(2, (0, import_common9.Param)("messageId")),
|
|
1010
|
+
_ts_metadata8("design:type", Function),
|
|
1011
|
+
_ts_metadata8("design:paramtypes", [
|
|
924
1012
|
typeof Request === "undefined" ? Object : Request,
|
|
925
1013
|
String,
|
|
926
1014
|
String
|
|
927
1015
|
]),
|
|
928
|
-
|
|
1016
|
+
_ts_metadata8("design:returntype", Promise)
|
|
929
1017
|
], ThreadsController.prototype, "fork", null);
|
|
930
|
-
|
|
931
|
-
(0,
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1018
|
+
_ts_decorate9([
|
|
1019
|
+
(0, import_common9.Patch)(":id"),
|
|
1020
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
1021
|
+
_ts_param7(1, (0, import_common9.Param)("id")),
|
|
1022
|
+
_ts_param7(2, (0, import_common9.Body)()),
|
|
1023
|
+
_ts_metadata8("design:type", Function),
|
|
1024
|
+
_ts_metadata8("design:paramtypes", [
|
|
937
1025
|
typeof Request === "undefined" ? Object : Request,
|
|
938
1026
|
String,
|
|
939
1027
|
typeof RenameThreadBody === "undefined" ? Object : RenameThreadBody
|
|
940
1028
|
]),
|
|
941
|
-
|
|
1029
|
+
_ts_metadata8("design:returntype", Promise)
|
|
942
1030
|
], ThreadsController.prototype, "rename", null);
|
|
943
|
-
|
|
944
|
-
(0,
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1031
|
+
_ts_decorate9([
|
|
1032
|
+
(0, import_common9.Post)(":id/promote"),
|
|
1033
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
1034
|
+
_ts_param7(1, (0, import_common9.Param)("id")),
|
|
1035
|
+
_ts_metadata8("design:type", Function),
|
|
1036
|
+
_ts_metadata8("design:paramtypes", [
|
|
949
1037
|
typeof Request === "undefined" ? Object : Request,
|
|
950
1038
|
String
|
|
951
1039
|
]),
|
|
952
|
-
|
|
1040
|
+
_ts_metadata8("design:returntype", Promise)
|
|
953
1041
|
], ThreadsController.prototype, "promote", null);
|
|
954
|
-
|
|
955
|
-
(0,
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1042
|
+
_ts_decorate9([
|
|
1043
|
+
(0, import_common9.Delete)(":id/from/:messageId"),
|
|
1044
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
1045
|
+
_ts_param7(1, (0, import_common9.Param)("id")),
|
|
1046
|
+
_ts_param7(2, (0, import_common9.Param)("messageId")),
|
|
1047
|
+
_ts_metadata8("design:type", Function),
|
|
1048
|
+
_ts_metadata8("design:paramtypes", [
|
|
961
1049
|
typeof Request === "undefined" ? Object : Request,
|
|
962
1050
|
String,
|
|
963
1051
|
String
|
|
964
1052
|
]),
|
|
965
|
-
|
|
1053
|
+
_ts_metadata8("design:returntype", Promise)
|
|
966
1054
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
967
|
-
ThreadsController =
|
|
968
|
-
(0,
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1055
|
+
ThreadsController = _ts_decorate9([
|
|
1056
|
+
(0, import_common9.Controller)("threads"),
|
|
1057
|
+
_ts_param7(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
|
|
1058
|
+
_ts_metadata8("design:type", Function),
|
|
1059
|
+
_ts_metadata8("design:paramtypes", [
|
|
972
1060
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
973
1061
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
974
1062
|
])
|
|
975
1063
|
], ThreadsController);
|
|
976
1064
|
|
|
977
1065
|
// src/controller/tool-call.controller.ts
|
|
978
|
-
var
|
|
979
|
-
var
|
|
980
|
-
function
|
|
1066
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
1067
|
+
var import_common10 = require("@nestjs/common");
|
|
1068
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
981
1069
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
982
1070
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
983
1071
|
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;
|
|
984
1072
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
985
1073
|
}
|
|
986
|
-
__name(
|
|
987
|
-
function
|
|
1074
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1075
|
+
function _ts_metadata9(k, v) {
|
|
988
1076
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
989
1077
|
}
|
|
990
|
-
__name(
|
|
991
|
-
function
|
|
1078
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1079
|
+
function _ts_param8(paramIndex, decorator) {
|
|
992
1080
|
return function(target, key) {
|
|
993
1081
|
decorator(target, key, paramIndex);
|
|
994
1082
|
};
|
|
995
1083
|
}
|
|
996
|
-
__name(
|
|
1084
|
+
__name(_ts_param8, "_ts_param");
|
|
997
1085
|
var ToolCallController = class {
|
|
998
1086
|
static {
|
|
999
1087
|
__name(this, "ToolCallController");
|
|
@@ -1019,41 +1107,41 @@ var ToolCallController = class {
|
|
|
1019
1107
|
};
|
|
1020
1108
|
}
|
|
1021
1109
|
};
|
|
1022
|
-
|
|
1023
|
-
(0,
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1110
|
+
_ts_decorate10([
|
|
1111
|
+
(0, import_common10.Post)("approve"),
|
|
1112
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
1113
|
+
_ts_param8(1, (0, import_common10.Body)()),
|
|
1114
|
+
_ts_metadata9("design:type", Function),
|
|
1115
|
+
_ts_metadata9("design:paramtypes", [
|
|
1028
1116
|
typeof Request === "undefined" ? Object : Request,
|
|
1029
1117
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
1030
1118
|
]),
|
|
1031
|
-
|
|
1119
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1032
1120
|
], ToolCallController.prototype, "approve", null);
|
|
1033
|
-
|
|
1034
|
-
(0,
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1121
|
+
_ts_decorate10([
|
|
1122
|
+
(0, import_common10.Post)("reject"),
|
|
1123
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
1124
|
+
_ts_param8(1, (0, import_common10.Body)()),
|
|
1125
|
+
_ts_metadata9("design:type", Function),
|
|
1126
|
+
_ts_metadata9("design:paramtypes", [
|
|
1039
1127
|
typeof Request === "undefined" ? Object : Request,
|
|
1040
1128
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
1041
1129
|
]),
|
|
1042
|
-
|
|
1130
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1043
1131
|
], ToolCallController.prototype, "reject", null);
|
|
1044
|
-
ToolCallController =
|
|
1045
|
-
(0,
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1132
|
+
ToolCallController = _ts_decorate10([
|
|
1133
|
+
(0, import_common10.Controller)("tool-call"),
|
|
1134
|
+
_ts_param8(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
|
|
1135
|
+
_ts_metadata9("design:type", Function),
|
|
1136
|
+
_ts_metadata9("design:paramtypes", [
|
|
1049
1137
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1050
1138
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1051
1139
|
])
|
|
1052
1140
|
], ToolCallController);
|
|
1053
1141
|
|
|
1054
1142
|
// src/discovery/agent-discovery.service.ts
|
|
1055
|
-
var
|
|
1056
|
-
var
|
|
1143
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
1144
|
+
var import_common11 = require("@nestjs/common");
|
|
1057
1145
|
var import_core = require("@nestjs/core");
|
|
1058
1146
|
|
|
1059
1147
|
// src/decorator/agent.decorator.ts
|
|
@@ -1070,23 +1158,23 @@ var SYSTEM_PROMPT_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt");
|
|
|
1070
1158
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
1071
1159
|
|
|
1072
1160
|
// src/discovery/agent-discovery.service.ts
|
|
1073
|
-
function
|
|
1161
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1074
1162
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1075
1163
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1076
1164
|
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;
|
|
1077
1165
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1078
1166
|
}
|
|
1079
|
-
__name(
|
|
1080
|
-
function
|
|
1167
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1168
|
+
function _ts_metadata10(k, v) {
|
|
1081
1169
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1082
1170
|
}
|
|
1083
|
-
__name(
|
|
1084
|
-
function
|
|
1171
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1172
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1085
1173
|
return function(target, key) {
|
|
1086
1174
|
decorator(target, key, paramIndex);
|
|
1087
1175
|
};
|
|
1088
1176
|
}
|
|
1089
|
-
__name(
|
|
1177
|
+
__name(_ts_param9, "_ts_param");
|
|
1090
1178
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
1091
1179
|
static {
|
|
1092
1180
|
__name(this, "AgentDiscoveryService");
|
|
@@ -1095,7 +1183,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
1095
1183
|
scanner;
|
|
1096
1184
|
registry;
|
|
1097
1185
|
contributors;
|
|
1098
|
-
logger = new
|
|
1186
|
+
logger = new import_common11.Logger(_AgentDiscoveryService.name);
|
|
1099
1187
|
constructor(discovery, scanner, registry, contributors) {
|
|
1100
1188
|
this.discovery = discovery;
|
|
1101
1189
|
this.scanner = scanner;
|
|
@@ -1121,6 +1209,9 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
1121
1209
|
const systemPrompt = promptMethod !== void 0 ? (ctx) => promptMethod(ctx) : meta.systemPrompt ?? "You are a helpful assistant.";
|
|
1122
1210
|
return {
|
|
1123
1211
|
name: meta.name,
|
|
1212
|
+
...meta.description !== void 0 ? {
|
|
1213
|
+
description: meta.description
|
|
1214
|
+
} : {},
|
|
1124
1215
|
systemPrompt,
|
|
1125
1216
|
...meta.tools !== void 0 ? {
|
|
1126
1217
|
tools: meta.tools
|
|
@@ -1180,22 +1271,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
1180
1271
|
return (ctx) => candidate.call(instance, ctx);
|
|
1181
1272
|
}
|
|
1182
1273
|
};
|
|
1183
|
-
AgentDiscoveryService =
|
|
1184
|
-
(0,
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1274
|
+
AgentDiscoveryService = _ts_decorate11([
|
|
1275
|
+
(0, import_common11.Injectable)(),
|
|
1276
|
+
_ts_param9(2, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_REGISTRY)),
|
|
1277
|
+
_ts_param9(3, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_PROMPT_CONTRIBUTORS)),
|
|
1278
|
+
_ts_metadata10("design:type", Function),
|
|
1279
|
+
_ts_metadata10("design:paramtypes", [
|
|
1189
1280
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
1190
1281
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
1191
|
-
typeof
|
|
1282
|
+
typeof import_nestjs_agent_core11.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core11.AgentRegistry,
|
|
1192
1283
|
Array
|
|
1193
1284
|
])
|
|
1194
1285
|
], AgentDiscoveryService);
|
|
1195
1286
|
|
|
1196
1287
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1197
|
-
var
|
|
1198
|
-
var
|
|
1288
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
1289
|
+
var import_common12 = require("@nestjs/common");
|
|
1199
1290
|
var import_core2 = require("@nestjs/core");
|
|
1200
1291
|
var import_zod = require("zod");
|
|
1201
1292
|
|
|
@@ -1215,23 +1306,23 @@ function isBrandedFunctionalTool(value) {
|
|
|
1215
1306
|
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
1216
1307
|
|
|
1217
1308
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1218
|
-
function
|
|
1309
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1219
1310
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1220
1311
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1221
1312
|
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;
|
|
1222
1313
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1223
1314
|
}
|
|
1224
|
-
__name(
|
|
1225
|
-
function
|
|
1315
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1316
|
+
function _ts_metadata11(k, v) {
|
|
1226
1317
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1227
1318
|
}
|
|
1228
|
-
__name(
|
|
1229
|
-
function
|
|
1319
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1320
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1230
1321
|
return function(target, key) {
|
|
1231
1322
|
decorator(target, key, paramIndex);
|
|
1232
1323
|
};
|
|
1233
1324
|
}
|
|
1234
|
-
__name(
|
|
1325
|
+
__name(_ts_param10, "_ts_param");
|
|
1235
1326
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
1236
1327
|
static {
|
|
1237
1328
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -1240,7 +1331,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
1240
1331
|
registry;
|
|
1241
1332
|
agents;
|
|
1242
1333
|
options;
|
|
1243
|
-
logger = new
|
|
1334
|
+
logger = new import_common12.Logger(_AiToolDiscoveryService.name);
|
|
1244
1335
|
constructor(discovery, registry, agents, options) {
|
|
1245
1336
|
this.discovery = discovery;
|
|
1246
1337
|
this.registry = registry;
|
|
@@ -1338,13 +1429,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
1338
1429
|
return true;
|
|
1339
1430
|
}
|
|
1340
1431
|
};
|
|
1341
|
-
AiToolDiscoveryService =
|
|
1342
|
-
(0,
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1432
|
+
AiToolDiscoveryService = _ts_decorate12([
|
|
1433
|
+
(0, import_common12.Injectable)(),
|
|
1434
|
+
_ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_TOOL_REGISTRY)),
|
|
1435
|
+
_ts_param10(2, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_REGISTRY)),
|
|
1436
|
+
_ts_param10(3, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_OPTIONS)),
|
|
1437
|
+
_ts_metadata11("design:type", Function),
|
|
1438
|
+
_ts_metadata11("design:paramtypes", [
|
|
1348
1439
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
1349
1440
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
1350
1441
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -1353,7 +1444,7 @@ AiToolDiscoveryService = _ts_decorate11([
|
|
|
1353
1444
|
], AiToolDiscoveryService);
|
|
1354
1445
|
|
|
1355
1446
|
// src/in-process-sink.ts
|
|
1356
|
-
var
|
|
1447
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
1357
1448
|
var InProcessTokenStreamSink = class {
|
|
1358
1449
|
static {
|
|
1359
1450
|
__name(this, "InProcessTokenStreamSink");
|
|
@@ -1408,7 +1499,7 @@ var InProcessTokenStreamSink = class {
|
|
|
1408
1499
|
}
|
|
1409
1500
|
if (buf.ended) {
|
|
1410
1501
|
if (buf.failure !== void 0) {
|
|
1411
|
-
throw new
|
|
1502
|
+
throw new import_nestjs_agent_core13.AgentStreamError(buf.failure);
|
|
1412
1503
|
}
|
|
1413
1504
|
return;
|
|
1414
1505
|
}
|
|
@@ -1444,32 +1535,32 @@ var LedgerQuotaStore = class {
|
|
|
1444
1535
|
};
|
|
1445
1536
|
|
|
1446
1537
|
// src/runner/inline-agent-runner.ts
|
|
1447
|
-
var
|
|
1448
|
-
var
|
|
1449
|
-
function
|
|
1538
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
1539
|
+
var import_common13 = require("@nestjs/common");
|
|
1540
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
1450
1541
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1451
1542
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1452
1543
|
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;
|
|
1453
1544
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1454
1545
|
}
|
|
1455
|
-
__name(
|
|
1456
|
-
function
|
|
1546
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
1547
|
+
function _ts_metadata12(k, v) {
|
|
1457
1548
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1458
1549
|
}
|
|
1459
|
-
__name(
|
|
1460
|
-
function
|
|
1550
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
1551
|
+
function _ts_param11(paramIndex, decorator) {
|
|
1461
1552
|
return function(target, key) {
|
|
1462
1553
|
decorator(target, key, paramIndex);
|
|
1463
1554
|
};
|
|
1464
1555
|
}
|
|
1465
|
-
__name(
|
|
1556
|
+
__name(_ts_param11, "_ts_param");
|
|
1466
1557
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
1467
1558
|
static {
|
|
1468
1559
|
__name(this, "InlineAgentRunner");
|
|
1469
1560
|
}
|
|
1470
1561
|
factory;
|
|
1471
1562
|
store;
|
|
1472
|
-
logger = new
|
|
1563
|
+
logger = new import_common13.Logger(_InlineAgentRunner.name);
|
|
1473
1564
|
pending = /* @__PURE__ */ new Map();
|
|
1474
1565
|
constructor(factory, store) {
|
|
1475
1566
|
this.factory = factory;
|
|
@@ -1480,14 +1571,14 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1480
1571
|
const day = input.day ?? utcDay();
|
|
1481
1572
|
const deps = this.factory.forAgent(input.agentName);
|
|
1482
1573
|
const hooks = this.topLevelHooks(runId, deps, input.actor, day);
|
|
1483
|
-
void (0,
|
|
1574
|
+
void (0, import_nestjs_agent_core14.runAgentLoop)({
|
|
1484
1575
|
...deps,
|
|
1485
1576
|
day
|
|
1486
1577
|
}, input, hooks).catch(async (error) => {
|
|
1487
1578
|
const message = error instanceof Error ? error.message : String(error);
|
|
1488
|
-
const code = error instanceof
|
|
1579
|
+
const code = error instanceof import_nestjs_agent_core14.QuotaExceededError ? "quota_exceeded" : "run_failed";
|
|
1489
1580
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
1490
|
-
(0,
|
|
1581
|
+
(0, import_nestjs_agent_core14.publishAgentRunFailed)({
|
|
1491
1582
|
runId,
|
|
1492
1583
|
code,
|
|
1493
1584
|
message
|
|
@@ -1549,7 +1640,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1549
1640
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
1550
1641
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested(childName, childTask, actor, day, depth + 1, sinkRunId), "runAgent")
|
|
1551
1642
|
};
|
|
1552
|
-
return (0,
|
|
1643
|
+
return (0, import_nestjs_agent_core14.runAgentLoop)({
|
|
1553
1644
|
...deps,
|
|
1554
1645
|
day
|
|
1555
1646
|
}, {
|
|
@@ -1563,84 +1654,84 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1563
1654
|
}, hooks);
|
|
1564
1655
|
}
|
|
1565
1656
|
};
|
|
1566
|
-
InlineAgentRunner =
|
|
1567
|
-
(0,
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1657
|
+
InlineAgentRunner = _ts_decorate13([
|
|
1658
|
+
(0, import_common13.Injectable)(),
|
|
1659
|
+
_ts_param11(0, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_DEPS_FACTORY)),
|
|
1660
|
+
_ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_STORE)),
|
|
1661
|
+
_ts_metadata12("design:type", Function),
|
|
1662
|
+
_ts_metadata12("design:paramtypes", [
|
|
1572
1663
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1573
1664
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
1574
1665
|
])
|
|
1575
1666
|
], InlineAgentRunner);
|
|
1576
1667
|
|
|
1577
1668
|
// src/agent.module.ts
|
|
1578
|
-
function
|
|
1669
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
1579
1670
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1580
1671
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1581
1672
|
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;
|
|
1582
1673
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1583
1674
|
}
|
|
1584
|
-
__name(
|
|
1675
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
1585
1676
|
var DEFAULT_PATH = "agent";
|
|
1586
1677
|
function sharedProviders(durable, includeStore) {
|
|
1587
1678
|
const providers = [
|
|
1588
1679
|
{
|
|
1589
|
-
provide:
|
|
1590
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
1680
|
+
provide: import_nestjs_agent_core15.AGENT_TOOL_REGISTRY,
|
|
1681
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core15.ToolRegistry(), "useFactory")
|
|
1591
1682
|
},
|
|
1592
1683
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
1593
1684
|
{
|
|
1594
|
-
provide:
|
|
1595
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
1685
|
+
provide: import_nestjs_agent_core15.AGENT_REGISTRY,
|
|
1686
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core15.AgentRegistry(), "useFactory")
|
|
1596
1687
|
},
|
|
1597
1688
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
1598
1689
|
{
|
|
1599
|
-
provide:
|
|
1690
|
+
provide: import_nestjs_agent_core15.AGENT_PROMPT_CONTRIBUTORS,
|
|
1600
1691
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
1601
1692
|
},
|
|
1602
1693
|
{
|
|
1603
|
-
provide:
|
|
1694
|
+
provide: import_nestjs_agent_core15.AGENT_SINK,
|
|
1604
1695
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
1605
1696
|
inject: [
|
|
1606
|
-
|
|
1697
|
+
import_nestjs_agent_core15.AGENT_OPTIONS
|
|
1607
1698
|
]
|
|
1608
1699
|
},
|
|
1609
1700
|
{
|
|
1610
|
-
provide:
|
|
1611
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
1701
|
+
provide: import_nestjs_agent_core15.AGENT_ROLES_POLICY,
|
|
1702
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core15.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
1612
1703
|
inject: [
|
|
1613
|
-
|
|
1704
|
+
import_nestjs_agent_core15.AGENT_OPTIONS
|
|
1614
1705
|
]
|
|
1615
1706
|
},
|
|
1616
1707
|
{
|
|
1617
|
-
provide:
|
|
1708
|
+
provide: import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER,
|
|
1618
1709
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
1619
1710
|
inject: [
|
|
1620
|
-
|
|
1711
|
+
import_nestjs_agent_core15.AGENT_OPTIONS
|
|
1621
1712
|
]
|
|
1622
1713
|
},
|
|
1623
1714
|
{
|
|
1624
|
-
provide:
|
|
1715
|
+
provide: import_nestjs_agent_core15.AGENT_MODEL,
|
|
1625
1716
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
1626
1717
|
inject: [
|
|
1627
|
-
|
|
1718
|
+
import_nestjs_agent_core15.AGENT_OPTIONS
|
|
1628
1719
|
]
|
|
1629
1720
|
},
|
|
1630
1721
|
{
|
|
1631
1722
|
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
1632
1723
|
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
1633
1724
|
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
1634
|
-
provide:
|
|
1725
|
+
provide: import_nestjs_agent_core15.AGENT_QUOTA_STORE,
|
|
1635
1726
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
1636
1727
|
inject: [
|
|
1637
|
-
|
|
1638
|
-
|
|
1728
|
+
import_nestjs_agent_core15.AGENT_OPTIONS,
|
|
1729
|
+
import_nestjs_agent_core15.AGENT_STORE
|
|
1639
1730
|
]
|
|
1640
1731
|
},
|
|
1641
1732
|
AgentDepsFactory2,
|
|
1642
1733
|
{
|
|
1643
|
-
provide:
|
|
1734
|
+
provide: import_nestjs_agent_core15.AGENT_DEPS_FACTORY,
|
|
1644
1735
|
useExisting: AgentDepsFactory2
|
|
1645
1736
|
},
|
|
1646
1737
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -1652,16 +1743,16 @@ function sharedProviders(durable, includeStore) {
|
|
|
1652
1743
|
];
|
|
1653
1744
|
if (includeStore) {
|
|
1654
1745
|
providers.push({
|
|
1655
|
-
provide:
|
|
1746
|
+
provide: import_nestjs_agent_core15.AGENT_STORE,
|
|
1656
1747
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
1657
1748
|
inject: [
|
|
1658
|
-
|
|
1749
|
+
import_nestjs_agent_core15.AGENT_OPTIONS
|
|
1659
1750
|
]
|
|
1660
1751
|
});
|
|
1661
1752
|
}
|
|
1662
1753
|
if (durable) {
|
|
1663
1754
|
providers.push({
|
|
1664
|
-
provide:
|
|
1755
|
+
provide: import_nestjs_agent_core15.AGENT_RUNNER,
|
|
1665
1756
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
1666
1757
|
if (durableRunner === void 0) {
|
|
1667
1758
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -1670,14 +1761,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
1670
1761
|
}, "useFactory"),
|
|
1671
1762
|
inject: [
|
|
1672
1763
|
{
|
|
1673
|
-
token:
|
|
1764
|
+
token: import_nestjs_agent_core15.AGENT_DURABLE_RUNNER,
|
|
1674
1765
|
optional: true
|
|
1675
1766
|
}
|
|
1676
1767
|
]
|
|
1677
1768
|
});
|
|
1678
1769
|
} else {
|
|
1679
1770
|
providers.push({
|
|
1680
|
-
provide:
|
|
1771
|
+
provide: import_nestjs_agent_core15.AGENT_RUNNER,
|
|
1681
1772
|
useExisting: InlineAgentRunner
|
|
1682
1773
|
});
|
|
1683
1774
|
}
|
|
@@ -1686,19 +1777,19 @@ function sharedProviders(durable, includeStore) {
|
|
|
1686
1777
|
__name(sharedProviders, "sharedProviders");
|
|
1687
1778
|
function exportsFor(includeStore) {
|
|
1688
1779
|
return [
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1780
|
+
import_nestjs_agent_core15.AGENT_OPTIONS,
|
|
1781
|
+
import_nestjs_agent_core15.AGENT_TOOL_REGISTRY,
|
|
1782
|
+
import_nestjs_agent_core15.AGENT_REGISTRY,
|
|
1783
|
+
import_nestjs_agent_core15.AGENT_SINK,
|
|
1784
|
+
import_nestjs_agent_core15.AGENT_ROLES_POLICY,
|
|
1785
|
+
import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER,
|
|
1786
|
+
import_nestjs_agent_core15.AGENT_MODEL,
|
|
1696
1787
|
...includeStore ? [
|
|
1697
|
-
|
|
1788
|
+
import_nestjs_agent_core15.AGENT_STORE
|
|
1698
1789
|
] : [],
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1790
|
+
import_nestjs_agent_core15.AGENT_QUOTA_STORE,
|
|
1791
|
+
import_nestjs_agent_core15.AGENT_PROMPT_CONTRIBUTORS,
|
|
1792
|
+
import_nestjs_agent_core15.AGENT_DEPS_FACTORY,
|
|
1702
1793
|
AgentDepsFactory2,
|
|
1703
1794
|
AgentService,
|
|
1704
1795
|
InlineAgentRunner
|
|
@@ -1709,7 +1800,8 @@ var CONTROLLERS = [
|
|
|
1709
1800
|
ChatController,
|
|
1710
1801
|
ThreadsController,
|
|
1711
1802
|
ToolCallController,
|
|
1712
|
-
QuotaController
|
|
1803
|
+
QuotaController,
|
|
1804
|
+
AgentsController
|
|
1713
1805
|
];
|
|
1714
1806
|
function routerFor(path) {
|
|
1715
1807
|
return import_core3.RouterModule.register([
|
|
@@ -1737,7 +1829,7 @@ var AgentModule = class _AgentModule {
|
|
|
1737
1829
|
controllers: CONTROLLERS,
|
|
1738
1830
|
providers: [
|
|
1739
1831
|
{
|
|
1740
|
-
provide:
|
|
1832
|
+
provide: import_nestjs_agent_core15.AGENT_OPTIONS,
|
|
1741
1833
|
useValue: options
|
|
1742
1834
|
},
|
|
1743
1835
|
...sharedProviders(options.durable ?? false, includeStore)
|
|
@@ -1747,6 +1839,7 @@ var AgentModule = class _AgentModule {
|
|
|
1747
1839
|
}
|
|
1748
1840
|
static forRootAsync(options) {
|
|
1749
1841
|
const path = options.path ?? DEFAULT_PATH;
|
|
1842
|
+
const includeStore = options.externalStore !== true;
|
|
1750
1843
|
return {
|
|
1751
1844
|
module: _AgentModule,
|
|
1752
1845
|
global: true,
|
|
@@ -1758,21 +1851,19 @@ var AgentModule = class _AgentModule {
|
|
|
1758
1851
|
controllers: CONTROLLERS,
|
|
1759
1852
|
providers: [
|
|
1760
1853
|
{
|
|
1761
|
-
provide:
|
|
1854
|
+
provide: import_nestjs_agent_core15.AGENT_OPTIONS,
|
|
1762
1855
|
useFactory: options.useFactory,
|
|
1763
1856
|
inject: options.inject ?? []
|
|
1764
1857
|
},
|
|
1765
|
-
|
|
1766
|
-
// (its factory reads the resolved options). Omit-and-import-a-store-module is a `forRoot` path.
|
|
1767
|
-
...sharedProviders(options.durable ?? false, true)
|
|
1858
|
+
...sharedProviders(options.durable ?? false, includeStore)
|
|
1768
1859
|
],
|
|
1769
|
-
exports: exportsFor(
|
|
1860
|
+
exports: exportsFor(includeStore)
|
|
1770
1861
|
};
|
|
1771
1862
|
}
|
|
1772
1863
|
};
|
|
1773
|
-
AgentModule =
|
|
1774
|
-
(0,
|
|
1775
|
-
(0,
|
|
1864
|
+
AgentModule = _ts_decorate14([
|
|
1865
|
+
(0, import_common14.Global)(),
|
|
1866
|
+
(0, import_common14.Module)({})
|
|
1776
1867
|
], AgentModule);
|
|
1777
1868
|
|
|
1778
1869
|
// src/durable/agent-durable.ts
|