@dudousxd/nestjs-agent 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-deps.factory-D9BHJJqm.d.cts → agent-deps.factory-DpVkZYCy.d.cts} +17 -20
- package/dist/{agent-deps.factory-D9BHJJqm.d.ts → agent-deps.factory-DpVkZYCy.d.ts} +17 -20
- package/dist/durable/index.cjs +253 -160
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +1 -1
- package/dist/durable/index.d.ts +1 -1
- package/dist/durable/index.js +210 -117
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +287 -159
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -14
- package/dist/index.d.ts +85 -14
- package/dist/index.js +236 -116
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -22,9 +22,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
// src/index.ts
|
|
23
23
|
var index_exports = {};
|
|
24
24
|
__export(index_exports, {
|
|
25
|
+
AGENT_METADATA: () => AGENT_METADATA,
|
|
25
26
|
AGENT_TOOL_BRAND: () => AGENT_TOOL_BRAND,
|
|
26
27
|
AI_TOOL_METADATA: () => AI_TOOL_METADATA,
|
|
28
|
+
Agent: () => Agent,
|
|
27
29
|
AgentDepsFactory: () => AgentDepsFactory2,
|
|
30
|
+
AgentDiscoveryService: () => AgentDiscoveryService,
|
|
28
31
|
AgentModule: () => AgentModule,
|
|
29
32
|
AgentService: () => AgentService,
|
|
30
33
|
AiTool: () => AiTool,
|
|
@@ -33,17 +36,22 @@ __export(index_exports, {
|
|
|
33
36
|
InProcessTokenStreamSink: () => InProcessTokenStreamSink,
|
|
34
37
|
InlineAgentRunner: () => InlineAgentRunner,
|
|
35
38
|
LedgerQuotaStore: () => LedgerQuotaStore,
|
|
39
|
+
SYSTEM_PROMPT_CONTRIBUTOR_METADATA: () => SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
|
|
40
|
+
SYSTEM_PROMPT_METADATA: () => SYSTEM_PROMPT_METADATA,
|
|
41
|
+
SystemPrompt: () => SystemPrompt,
|
|
42
|
+
SystemPromptContributor: () => SystemPromptContributor,
|
|
36
43
|
delegateToolName: () => delegateToolName,
|
|
37
44
|
provideAgentTool: () => provideAgentTool,
|
|
45
|
+
readAgentMetadata: () => readAgentMetadata,
|
|
38
46
|
readAiToolMetadata: () => readAiToolMetadata,
|
|
39
47
|
utcDay: () => utcDay
|
|
40
48
|
});
|
|
41
49
|
module.exports = __toCommonJS(index_exports);
|
|
42
50
|
|
|
43
51
|
// src/agent.module.ts
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
52
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
53
|
+
var import_common10 = require("@nestjs/common");
|
|
54
|
+
var import_core3 = require("@nestjs/core");
|
|
47
55
|
|
|
48
56
|
// src/agent-deps.factory.ts
|
|
49
57
|
var import_nestjs_agent_core = require("@dudousxd/nestjs-agent-core");
|
|
@@ -81,8 +89,9 @@ var AgentDepsFactory2 = class {
|
|
|
81
89
|
rolesPolicy;
|
|
82
90
|
registry;
|
|
83
91
|
agents;
|
|
92
|
+
promptContributors;
|
|
84
93
|
quota;
|
|
85
|
-
constructor(options, model, store, sink, rolesPolicy, registry, agents, quota) {
|
|
94
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, quota) {
|
|
86
95
|
this.options = options;
|
|
87
96
|
this.model = model;
|
|
88
97
|
this.store = store;
|
|
@@ -90,10 +99,19 @@ var AgentDepsFactory2 = class {
|
|
|
90
99
|
this.rolesPolicy = rolesPolicy;
|
|
91
100
|
this.registry = registry;
|
|
92
101
|
this.agents = agents;
|
|
102
|
+
this.promptContributors = promptContributors;
|
|
93
103
|
this.quota = quota;
|
|
94
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* The agent a turn uses when the caller names none: the explicit `defaultAgent` option, else the
|
|
107
|
+
* sole registered `@Agent` when there is exactly one, else `'default'` (a bare assistant).
|
|
108
|
+
*/
|
|
95
109
|
defaultAgentName() {
|
|
96
|
-
|
|
110
|
+
if (this.options.defaultAgent !== void 0) {
|
|
111
|
+
return this.options.defaultAgent;
|
|
112
|
+
}
|
|
113
|
+
const registered = this.agents.list();
|
|
114
|
+
return registered.length === 1 ? registered[0]?.name ?? "default" : "default";
|
|
97
115
|
}
|
|
98
116
|
effectiveTools(definition) {
|
|
99
117
|
if (definition === void 0) {
|
|
@@ -111,10 +129,6 @@ var AgentDepsFactory2 = class {
|
|
|
111
129
|
forAgent(agentName) {
|
|
112
130
|
const name = agentName ?? this.defaultAgentName();
|
|
113
131
|
const definition = this.agents.get(name);
|
|
114
|
-
const personas = /* @__PURE__ */ new Map();
|
|
115
|
-
for (const persona of definition?.personas ?? []) {
|
|
116
|
-
personas.set(persona.id, persona);
|
|
117
|
-
}
|
|
118
132
|
const toolAllowList = this.effectiveTools(definition);
|
|
119
133
|
const followUpsCount = this.followUpsCount();
|
|
120
134
|
const retrieval = this.options.retrieval;
|
|
@@ -124,10 +138,9 @@ var AgentDepsFactory2 = class {
|
|
|
124
138
|
sink: this.sink,
|
|
125
139
|
rolesPolicy: this.rolesPolicy,
|
|
126
140
|
registry: this.registry,
|
|
141
|
+
promptContributors: this.promptContributors,
|
|
127
142
|
systemPrompt: definition?.systemPrompt ?? "You are a helpful assistant.",
|
|
128
143
|
maxSteps: definition?.maxSteps ?? 8,
|
|
129
|
-
personas,
|
|
130
|
-
defaultPersona: definition?.defaultPersona ?? "default",
|
|
131
144
|
...definition?.modelId !== void 0 ? {
|
|
132
145
|
modelId: definition.modelId
|
|
133
146
|
} : {},
|
|
@@ -172,7 +185,8 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
172
185
|
_ts_param(4, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_ROLES_POLICY)),
|
|
173
186
|
_ts_param(5, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_TOOL_REGISTRY)),
|
|
174
187
|
_ts_param(6, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_REGISTRY)),
|
|
175
|
-
_ts_param(7, (0, import_common.Inject)(import_nestjs_agent_core.
|
|
188
|
+
_ts_param(7, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_PROMPT_CONTRIBUTORS)),
|
|
189
|
+
_ts_param(8, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_QUOTA_STORE)),
|
|
176
190
|
_ts_metadata("design:type", Function),
|
|
177
191
|
_ts_metadata("design:paramtypes", [
|
|
178
192
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -182,6 +196,7 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
182
196
|
typeof RolesPolicy === "undefined" ? Object : RolesPolicy,
|
|
183
197
|
typeof import_nestjs_agent_core.ToolRegistry === "undefined" ? Object : import_nestjs_agent_core.ToolRegistry,
|
|
184
198
|
typeof import_nestjs_agent_core.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core.AgentRegistry,
|
|
199
|
+
Array,
|
|
185
200
|
Object
|
|
186
201
|
])
|
|
187
202
|
], AgentDepsFactory2);
|
|
@@ -244,14 +259,12 @@ var AgentService = class {
|
|
|
244
259
|
throw new import_common2.BadRequestException("regenerate requires an existing threadId");
|
|
245
260
|
}
|
|
246
261
|
const created = await this.store.createThread({
|
|
247
|
-
actor: params.actor
|
|
248
|
-
persona: params.personaId ?? this.deps.forAgent(agentName).defaultPersona
|
|
262
|
+
actor: params.actor
|
|
249
263
|
});
|
|
250
264
|
threadId = created.id;
|
|
251
265
|
} else if (params.regenerate === true) {
|
|
252
266
|
await this.assertOwnsThread(params.actor, threadId);
|
|
253
267
|
}
|
|
254
|
-
const persona = this.resolvePersona(agentName, params.personaId);
|
|
255
268
|
const input = {
|
|
256
269
|
threadId,
|
|
257
270
|
actor: params.actor,
|
|
@@ -261,9 +274,6 @@ var AgentService = class {
|
|
|
261
274
|
...params.regenerate === true ? {
|
|
262
275
|
regenerate: true
|
|
263
276
|
} : {},
|
|
264
|
-
...persona !== void 0 ? {
|
|
265
|
-
persona
|
|
266
|
-
} : {},
|
|
267
277
|
...params.pageContext !== void 0 ? {
|
|
268
278
|
pageContext: params.pageContext
|
|
269
279
|
} : {}
|
|
@@ -297,18 +307,6 @@ var AgentService = class {
|
|
|
297
307
|
await this.assertOwnsActiveStream(actor, runId);
|
|
298
308
|
return this.runner.cancel(runId);
|
|
299
309
|
}
|
|
300
|
-
resolvePersona(agentName, id) {
|
|
301
|
-
const deps = this.deps.forAgent(agentName);
|
|
302
|
-
return deps.personas.get(id ?? deps.defaultPersona);
|
|
303
|
-
}
|
|
304
|
-
personaCatalog(agentName) {
|
|
305
|
-
return [
|
|
306
|
-
...this.deps.forAgent(agentName).personas.values()
|
|
307
|
-
].map((persona) => ({
|
|
308
|
-
id: persona.id,
|
|
309
|
-
label: persona.label
|
|
310
|
-
}));
|
|
311
|
-
}
|
|
312
310
|
listThreads(actorRef) {
|
|
313
311
|
return this.store.listThreads(actorRef);
|
|
314
312
|
}
|
|
@@ -425,9 +423,6 @@ var ChatController = class {
|
|
|
425
423
|
...body.agent !== void 0 ? {
|
|
426
424
|
agentName: body.agent
|
|
427
425
|
} : {},
|
|
428
|
-
...body.persona !== void 0 ? {
|
|
429
|
-
personaId: body.persona
|
|
430
|
-
} : {},
|
|
431
426
|
...body.pageContext !== void 0 ? {
|
|
432
427
|
pageContext: body.pageContext
|
|
433
428
|
} : {},
|
|
@@ -621,9 +616,6 @@ var ThreadsController = class {
|
|
|
621
616
|
const actor = await this.actorResolver.resolve(req);
|
|
622
617
|
return this.agent.listThreads(actor.id);
|
|
623
618
|
}
|
|
624
|
-
personas() {
|
|
625
|
-
return this.agent.personaCatalog();
|
|
626
|
-
}
|
|
627
619
|
async detail(req, id) {
|
|
628
620
|
const actor = await this.actorResolver.resolve(req);
|
|
629
621
|
return this.agent.getThread(actor, id);
|
|
@@ -649,12 +641,6 @@ _ts_decorate5([
|
|
|
649
641
|
]),
|
|
650
642
|
_ts_metadata5("design:returntype", Promise)
|
|
651
643
|
], ThreadsController.prototype, "list", null);
|
|
652
|
-
_ts_decorate5([
|
|
653
|
-
(0, import_common5.Get)("personas/catalog"),
|
|
654
|
-
_ts_metadata5("design:type", Function),
|
|
655
|
-
_ts_metadata5("design:paramtypes", []),
|
|
656
|
-
_ts_metadata5("design:returntype", void 0)
|
|
657
|
-
], ThreadsController.prototype, "personas", null);
|
|
658
644
|
_ts_decorate5([
|
|
659
645
|
(0, import_common5.Get)(":id"),
|
|
660
646
|
_ts_param5(0, (0, import_common5.Req)()),
|
|
@@ -777,14 +763,174 @@ ToolCallController = _ts_decorate6([
|
|
|
777
763
|
])
|
|
778
764
|
], ToolCallController);
|
|
779
765
|
|
|
780
|
-
// src/discovery/
|
|
766
|
+
// src/discovery/agent-discovery.service.ts
|
|
781
767
|
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
782
768
|
var import_common7 = require("@nestjs/common");
|
|
783
769
|
var import_core = require("@nestjs/core");
|
|
770
|
+
|
|
771
|
+
// src/decorator/agent.decorator.ts
|
|
772
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
773
|
+
var AGENT_METADATA = Symbol.for("@dudousxd/nestjs-agent:agent-metadata");
|
|
774
|
+
function Agent(options) {
|
|
775
|
+
return (target) => {
|
|
776
|
+
Reflect.defineMetadata(AGENT_METADATA, options, target);
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
__name(Agent, "Agent");
|
|
780
|
+
function readAgentMetadata(target) {
|
|
781
|
+
return Reflect.getMetadata(AGENT_METADATA, target);
|
|
782
|
+
}
|
|
783
|
+
__name(readAgentMetadata, "readAgentMetadata");
|
|
784
|
+
|
|
785
|
+
// src/decorator/system-prompt.decorator.ts
|
|
786
|
+
var import_reflect_metadata2 = require("reflect-metadata");
|
|
787
|
+
var SYSTEM_PROMPT_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt");
|
|
788
|
+
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
789
|
+
function SystemPrompt() {
|
|
790
|
+
return (target, key) => {
|
|
791
|
+
Reflect.defineMetadata(SYSTEM_PROMPT_METADATA, true, target, key);
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
__name(SystemPrompt, "SystemPrompt");
|
|
795
|
+
function SystemPromptContributor() {
|
|
796
|
+
return (target, key) => {
|
|
797
|
+
Reflect.defineMetadata(SYSTEM_PROMPT_CONTRIBUTOR_METADATA, true, target, key);
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
801
|
+
|
|
802
|
+
// src/discovery/agent-discovery.service.ts
|
|
803
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
804
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
805
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
806
|
+
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;
|
|
807
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
808
|
+
}
|
|
809
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
810
|
+
function _ts_metadata7(k, v) {
|
|
811
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
812
|
+
}
|
|
813
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
814
|
+
function _ts_param7(paramIndex, decorator) {
|
|
815
|
+
return function(target, key) {
|
|
816
|
+
decorator(target, key, paramIndex);
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
__name(_ts_param7, "_ts_param");
|
|
820
|
+
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
821
|
+
static {
|
|
822
|
+
__name(this, "AgentDiscoveryService");
|
|
823
|
+
}
|
|
824
|
+
discovery;
|
|
825
|
+
scanner;
|
|
826
|
+
registry;
|
|
827
|
+
contributors;
|
|
828
|
+
logger = new import_common7.Logger(_AgentDiscoveryService.name);
|
|
829
|
+
constructor(discovery, scanner, registry, contributors) {
|
|
830
|
+
this.discovery = discovery;
|
|
831
|
+
this.scanner = scanner;
|
|
832
|
+
this.registry = registry;
|
|
833
|
+
this.contributors = contributors;
|
|
834
|
+
}
|
|
835
|
+
onModuleInit() {
|
|
836
|
+
for (const wrapper of this.discovery.getProviders()) {
|
|
837
|
+
const instance = wrapper.instance;
|
|
838
|
+
if (instance === null || typeof instance !== "object") {
|
|
839
|
+
continue;
|
|
840
|
+
}
|
|
841
|
+
const meta = readAgentMetadata(instance.constructor);
|
|
842
|
+
if (meta !== void 0) {
|
|
843
|
+
this.registry.register(this.definitionFrom(instance, meta));
|
|
844
|
+
}
|
|
845
|
+
this.collectContributors(instance);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
/** Build the internal {@link AgentDefinition} from an `@Agent` instance and its options. */
|
|
849
|
+
definitionFrom(instance, meta) {
|
|
850
|
+
const promptMethod = this.methodWith(instance, SYSTEM_PROMPT_METADATA);
|
|
851
|
+
const systemPrompt = promptMethod !== void 0 ? (ctx) => promptMethod(ctx) : meta.systemPrompt ?? "You are a helpful assistant.";
|
|
852
|
+
return {
|
|
853
|
+
name: meta.name,
|
|
854
|
+
systemPrompt,
|
|
855
|
+
...meta.tools !== void 0 ? {
|
|
856
|
+
tools: meta.tools
|
|
857
|
+
} : {},
|
|
858
|
+
...meta.model !== void 0 ? {
|
|
859
|
+
modelId: meta.model
|
|
860
|
+
} : {},
|
|
861
|
+
...meta.maxSteps !== void 0 ? {
|
|
862
|
+
maxSteps: meta.maxSteps
|
|
863
|
+
} : {},
|
|
864
|
+
...meta.handoff !== void 0 ? {
|
|
865
|
+
delegatesTo: this.handoffNames(meta)
|
|
866
|
+
} : {}
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
/** Resolve each handoff `@Agent` class to its registered name (skipping non-agent classes). */
|
|
870
|
+
handoffNames(meta) {
|
|
871
|
+
const names = [];
|
|
872
|
+
for (const target of meta.handoff ?? []) {
|
|
873
|
+
const targetMeta = readAgentMetadata(target);
|
|
874
|
+
if (targetMeta === void 0) {
|
|
875
|
+
this.logger.warn(`Agent "${meta.name}" hands off to ${target.name}, which is not an @Agent \u2014 skipped.`);
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
names.push(targetMeta.name);
|
|
879
|
+
}
|
|
880
|
+
return names;
|
|
881
|
+
}
|
|
882
|
+
/** Push every `@SystemPromptContributor()` method on `instance` (bound) into the contributor list. */
|
|
883
|
+
collectContributors(instance) {
|
|
884
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
885
|
+
for (const name of this.scanner.getAllMethodNames(prototype)) {
|
|
886
|
+
if (Reflect.getMetadata(SYSTEM_PROMPT_CONTRIBUTOR_METADATA, prototype, name) === true) {
|
|
887
|
+
const method = this.boundMethod(instance, name);
|
|
888
|
+
if (method !== void 0) {
|
|
889
|
+
this.contributors.push((ctx) => method(ctx));
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
/** The single method on `instance` carrying `metadataKey`, bound to the instance, or undefined. */
|
|
895
|
+
methodWith(instance, metadataKey) {
|
|
896
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
897
|
+
for (const name of this.scanner.getAllMethodNames(prototype)) {
|
|
898
|
+
if (Reflect.getMetadata(metadataKey, prototype, name) === true) {
|
|
899
|
+
return this.boundMethod(instance, name);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return void 0;
|
|
903
|
+
}
|
|
904
|
+
/** Bind a named method to its instance, guarding that it is actually a function. */
|
|
905
|
+
boundMethod(instance, name) {
|
|
906
|
+
const candidate = instance[name];
|
|
907
|
+
if (typeof candidate !== "function") {
|
|
908
|
+
return void 0;
|
|
909
|
+
}
|
|
910
|
+
return (ctx) => candidate.call(instance, ctx);
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
AgentDiscoveryService = _ts_decorate7([
|
|
914
|
+
(0, import_common7.Injectable)(),
|
|
915
|
+
_ts_param7(2, (0, import_common7.Inject)(import_nestjs_agent_core8.AGENT_REGISTRY)),
|
|
916
|
+
_ts_param7(3, (0, import_common7.Inject)(import_nestjs_agent_core8.AGENT_PROMPT_CONTRIBUTORS)),
|
|
917
|
+
_ts_metadata7("design:type", Function),
|
|
918
|
+
_ts_metadata7("design:paramtypes", [
|
|
919
|
+
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
920
|
+
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
921
|
+
typeof import_nestjs_agent_core8.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core8.AgentRegistry,
|
|
922
|
+
Array
|
|
923
|
+
])
|
|
924
|
+
], AgentDiscoveryService);
|
|
925
|
+
|
|
926
|
+
// src/discovery/ai-tool-discovery.service.ts
|
|
927
|
+
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
928
|
+
var import_common8 = require("@nestjs/common");
|
|
929
|
+
var import_core2 = require("@nestjs/core");
|
|
784
930
|
var import_zod = require("zod");
|
|
785
931
|
|
|
786
932
|
// src/decorator/ai-tool.decorator.ts
|
|
787
|
-
var
|
|
933
|
+
var import_reflect_metadata3 = require("reflect-metadata");
|
|
788
934
|
var AI_TOOL_METADATA = Symbol("nestjs-agent:ai-tool");
|
|
789
935
|
function AiTool(options) {
|
|
790
936
|
return (target) => {
|
|
@@ -828,23 +974,23 @@ function provideAgentTool(factoryOrTool, inject) {
|
|
|
828
974
|
__name(provideAgentTool, "provideAgentTool");
|
|
829
975
|
|
|
830
976
|
// src/discovery/ai-tool-discovery.service.ts
|
|
831
|
-
function
|
|
977
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
832
978
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
833
979
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
834
980
|
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;
|
|
835
981
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
836
982
|
}
|
|
837
|
-
__name(
|
|
838
|
-
function
|
|
983
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
984
|
+
function _ts_metadata8(k, v) {
|
|
839
985
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
840
986
|
}
|
|
841
|
-
__name(
|
|
842
|
-
function
|
|
987
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
988
|
+
function _ts_param8(paramIndex, decorator) {
|
|
843
989
|
return function(target, key) {
|
|
844
990
|
decorator(target, key, paramIndex);
|
|
845
991
|
};
|
|
846
992
|
}
|
|
847
|
-
__name(
|
|
993
|
+
__name(_ts_param8, "_ts_param");
|
|
848
994
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
849
995
|
static {
|
|
850
996
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -853,7 +999,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
853
999
|
registry;
|
|
854
1000
|
agents;
|
|
855
1001
|
options;
|
|
856
|
-
logger = new
|
|
1002
|
+
logger = new import_common8.Logger(_AiToolDiscoveryService.name);
|
|
857
1003
|
constructor(discovery, registry, agents, options) {
|
|
858
1004
|
this.discovery = discovery;
|
|
859
1005
|
this.registry = registry;
|
|
@@ -911,7 +1057,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
911
1057
|
for (const target of definition.delegatesTo ?? []) {
|
|
912
1058
|
const targetDefinition = this.agents.get(target);
|
|
913
1059
|
if (targetDefinition === void 0) {
|
|
914
|
-
throw new Error(`Agent "${definition.name}"
|
|
1060
|
+
throw new Error(`Agent "${definition.name}" hands off to "${target}", which is not a registered @Agent. Declare it as an @Agent provider or fix the reference.`);
|
|
915
1061
|
}
|
|
916
1062
|
const name = delegateToolName(target);
|
|
917
1063
|
if (this.registry.has(name)) {
|
|
@@ -951,14 +1097,14 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
951
1097
|
return true;
|
|
952
1098
|
}
|
|
953
1099
|
};
|
|
954
|
-
AiToolDiscoveryService =
|
|
955
|
-
(0,
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
typeof
|
|
1100
|
+
AiToolDiscoveryService = _ts_decorate8([
|
|
1101
|
+
(0, import_common8.Injectable)(),
|
|
1102
|
+
_ts_param8(1, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_TOOL_REGISTRY)),
|
|
1103
|
+
_ts_param8(2, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_REGISTRY)),
|
|
1104
|
+
_ts_param8(3, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_OPTIONS)),
|
|
1105
|
+
_ts_metadata8("design:type", Function),
|
|
1106
|
+
_ts_metadata8("design:paramtypes", [
|
|
1107
|
+
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
962
1108
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
963
1109
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
964
1110
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions
|
|
@@ -966,7 +1112,7 @@ AiToolDiscoveryService = _ts_decorate7([
|
|
|
966
1112
|
], AiToolDiscoveryService);
|
|
967
1113
|
|
|
968
1114
|
// src/in-process-sink.ts
|
|
969
|
-
var
|
|
1115
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
970
1116
|
var InProcessTokenStreamSink = class {
|
|
971
1117
|
static {
|
|
972
1118
|
__name(this, "InProcessTokenStreamSink");
|
|
@@ -1021,7 +1167,7 @@ var InProcessTokenStreamSink = class {
|
|
|
1021
1167
|
}
|
|
1022
1168
|
if (buf.ended) {
|
|
1023
1169
|
if (buf.failure !== void 0) {
|
|
1024
|
-
throw new
|
|
1170
|
+
throw new import_nestjs_agent_core10.AgentStreamError(buf.failure);
|
|
1025
1171
|
}
|
|
1026
1172
|
return;
|
|
1027
1173
|
}
|
|
@@ -1057,32 +1203,32 @@ var LedgerQuotaStore = class {
|
|
|
1057
1203
|
};
|
|
1058
1204
|
|
|
1059
1205
|
// src/runner/inline-agent-runner.ts
|
|
1060
|
-
var
|
|
1061
|
-
var
|
|
1062
|
-
function
|
|
1206
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
1207
|
+
var import_common9 = require("@nestjs/common");
|
|
1208
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1063
1209
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1064
1210
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1065
1211
|
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;
|
|
1066
1212
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1067
1213
|
}
|
|
1068
|
-
__name(
|
|
1069
|
-
function
|
|
1214
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1215
|
+
function _ts_metadata9(k, v) {
|
|
1070
1216
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1071
1217
|
}
|
|
1072
|
-
__name(
|
|
1073
|
-
function
|
|
1218
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1219
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1074
1220
|
return function(target, key) {
|
|
1075
1221
|
decorator(target, key, paramIndex);
|
|
1076
1222
|
};
|
|
1077
1223
|
}
|
|
1078
|
-
__name(
|
|
1224
|
+
__name(_ts_param9, "_ts_param");
|
|
1079
1225
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
1080
1226
|
static {
|
|
1081
1227
|
__name(this, "InlineAgentRunner");
|
|
1082
1228
|
}
|
|
1083
1229
|
factory;
|
|
1084
1230
|
store;
|
|
1085
|
-
logger = new
|
|
1231
|
+
logger = new import_common9.Logger(_InlineAgentRunner.name);
|
|
1086
1232
|
pending = /* @__PURE__ */ new Map();
|
|
1087
1233
|
constructor(factory, store) {
|
|
1088
1234
|
this.factory = factory;
|
|
@@ -1093,14 +1239,14 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1093
1239
|
const day = input.day ?? utcDay();
|
|
1094
1240
|
const deps = this.factory.forAgent(input.agentName);
|
|
1095
1241
|
const hooks = this.topLevelHooks(runId, deps, input.actor, day);
|
|
1096
|
-
void (0,
|
|
1242
|
+
void (0, import_nestjs_agent_core11.runAgentLoop)({
|
|
1097
1243
|
...deps,
|
|
1098
1244
|
day
|
|
1099
1245
|
}, input, hooks).catch(async (error) => {
|
|
1100
1246
|
const message = error instanceof Error ? error.message : String(error);
|
|
1101
|
-
const code = error instanceof
|
|
1247
|
+
const code = error instanceof import_nestjs_agent_core11.QuotaExceededError ? "quota_exceeded" : "run_failed";
|
|
1102
1248
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
1103
|
-
(0,
|
|
1249
|
+
(0, import_nestjs_agent_core11.publishAgentRunFailed)({
|
|
1104
1250
|
runId,
|
|
1105
1251
|
code,
|
|
1106
1252
|
message
|
|
@@ -1147,7 +1293,6 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1147
1293
|
async runNested(agentName, task, actor, day, depth, sinkRunId) {
|
|
1148
1294
|
const subThread = await this.store.createThread({
|
|
1149
1295
|
actor,
|
|
1150
|
-
persona: "default",
|
|
1151
1296
|
transient: true
|
|
1152
1297
|
});
|
|
1153
1298
|
const runId = crypto.randomUUID();
|
|
@@ -1163,7 +1308,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1163
1308
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
1164
1309
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested(childName, childTask, actor, day, depth + 1, sinkRunId), "runAgent")
|
|
1165
1310
|
};
|
|
1166
|
-
return (0,
|
|
1311
|
+
return (0, import_nestjs_agent_core11.runAgentLoop)({
|
|
1167
1312
|
...deps,
|
|
1168
1313
|
day
|
|
1169
1314
|
}, {
|
|
@@ -1177,111 +1322,105 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1177
1322
|
}, hooks);
|
|
1178
1323
|
}
|
|
1179
1324
|
};
|
|
1180
|
-
InlineAgentRunner =
|
|
1181
|
-
(0,
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1325
|
+
InlineAgentRunner = _ts_decorate9([
|
|
1326
|
+
(0, import_common9.Injectable)(),
|
|
1327
|
+
_ts_param9(0, (0, import_common9.Inject)(import_nestjs_agent_core11.AGENT_DEPS_FACTORY)),
|
|
1328
|
+
_ts_param9(1, (0, import_common9.Inject)(import_nestjs_agent_core11.AGENT_STORE)),
|
|
1329
|
+
_ts_metadata9("design:type", Function),
|
|
1330
|
+
_ts_metadata9("design:paramtypes", [
|
|
1186
1331
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1187
1332
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
1188
1333
|
])
|
|
1189
1334
|
], InlineAgentRunner);
|
|
1190
1335
|
|
|
1191
1336
|
// src/agent.module.ts
|
|
1192
|
-
function
|
|
1337
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1193
1338
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1194
1339
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1195
1340
|
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;
|
|
1196
1341
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1197
1342
|
}
|
|
1198
|
-
__name(
|
|
1199
|
-
var FEATURE_INIT = Symbol("nestjs-agent:feature-init");
|
|
1343
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1200
1344
|
var DEFAULT_PATH = "agent";
|
|
1201
|
-
function defaultDefinition(options) {
|
|
1202
|
-
return {
|
|
1203
|
-
name: "default",
|
|
1204
|
-
...options.defaultAgent
|
|
1205
|
-
};
|
|
1206
|
-
}
|
|
1207
|
-
__name(defaultDefinition, "defaultDefinition");
|
|
1208
1345
|
function sharedProviders(durable, includeStore) {
|
|
1209
1346
|
const providers = [
|
|
1210
1347
|
{
|
|
1211
|
-
provide:
|
|
1212
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
1348
|
+
provide: import_nestjs_agent_core12.AGENT_TOOL_REGISTRY,
|
|
1349
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core12.ToolRegistry(), "useFactory")
|
|
1213
1350
|
},
|
|
1351
|
+
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
1214
1352
|
{
|
|
1215
|
-
provide:
|
|
1216
|
-
useFactory: /* @__PURE__ */ __name((
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
import_nestjs_agent_core11.AGENT_OPTIONS
|
|
1223
|
-
]
|
|
1353
|
+
provide: import_nestjs_agent_core12.AGENT_REGISTRY,
|
|
1354
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core12.AgentRegistry(), "useFactory")
|
|
1355
|
+
},
|
|
1356
|
+
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
1357
|
+
{
|
|
1358
|
+
provide: import_nestjs_agent_core12.AGENT_PROMPT_CONTRIBUTORS,
|
|
1359
|
+
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
1224
1360
|
},
|
|
1225
1361
|
{
|
|
1226
|
-
provide:
|
|
1362
|
+
provide: import_nestjs_agent_core12.AGENT_SINK,
|
|
1227
1363
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
1228
1364
|
inject: [
|
|
1229
|
-
|
|
1365
|
+
import_nestjs_agent_core12.AGENT_OPTIONS
|
|
1230
1366
|
]
|
|
1231
1367
|
},
|
|
1232
1368
|
{
|
|
1233
|
-
provide:
|
|
1234
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
1369
|
+
provide: import_nestjs_agent_core12.AGENT_ROLES_POLICY,
|
|
1370
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core12.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
1235
1371
|
inject: [
|
|
1236
|
-
|
|
1372
|
+
import_nestjs_agent_core12.AGENT_OPTIONS
|
|
1237
1373
|
]
|
|
1238
1374
|
},
|
|
1239
1375
|
{
|
|
1240
|
-
provide:
|
|
1376
|
+
provide: import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER,
|
|
1241
1377
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
1242
1378
|
inject: [
|
|
1243
|
-
|
|
1379
|
+
import_nestjs_agent_core12.AGENT_OPTIONS
|
|
1244
1380
|
]
|
|
1245
1381
|
},
|
|
1246
1382
|
{
|
|
1247
|
-
provide:
|
|
1383
|
+
provide: import_nestjs_agent_core12.AGENT_MODEL,
|
|
1248
1384
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
1249
1385
|
inject: [
|
|
1250
|
-
|
|
1386
|
+
import_nestjs_agent_core12.AGENT_OPTIONS
|
|
1251
1387
|
]
|
|
1252
1388
|
},
|
|
1253
1389
|
{
|
|
1254
1390
|
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
1255
1391
|
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
1256
1392
|
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
1257
|
-
provide:
|
|
1393
|
+
provide: import_nestjs_agent_core12.AGENT_QUOTA_STORE,
|
|
1258
1394
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
1259
1395
|
inject: [
|
|
1260
|
-
|
|
1261
|
-
|
|
1396
|
+
import_nestjs_agent_core12.AGENT_OPTIONS,
|
|
1397
|
+
import_nestjs_agent_core12.AGENT_STORE
|
|
1262
1398
|
]
|
|
1263
1399
|
},
|
|
1264
1400
|
AgentDepsFactory2,
|
|
1265
1401
|
{
|
|
1266
|
-
provide:
|
|
1402
|
+
provide: import_nestjs_agent_core12.AGENT_DEPS_FACTORY,
|
|
1267
1403
|
useExisting: AgentDepsFactory2
|
|
1268
1404
|
},
|
|
1405
|
+
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
1406
|
+
// handoff tools (onApplicationBootstrap) reads the registry.
|
|
1407
|
+
AgentDiscoveryService,
|
|
1269
1408
|
AiToolDiscoveryService,
|
|
1270
1409
|
InlineAgentRunner,
|
|
1271
1410
|
AgentService
|
|
1272
1411
|
];
|
|
1273
1412
|
if (includeStore) {
|
|
1274
1413
|
providers.push({
|
|
1275
|
-
provide:
|
|
1414
|
+
provide: import_nestjs_agent_core12.AGENT_STORE,
|
|
1276
1415
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
1277
1416
|
inject: [
|
|
1278
|
-
|
|
1417
|
+
import_nestjs_agent_core12.AGENT_OPTIONS
|
|
1279
1418
|
]
|
|
1280
1419
|
});
|
|
1281
1420
|
}
|
|
1282
1421
|
if (durable) {
|
|
1283
1422
|
providers.push({
|
|
1284
|
-
provide:
|
|
1423
|
+
provide: import_nestjs_agent_core12.AGENT_RUNNER,
|
|
1285
1424
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
1286
1425
|
if (durableRunner === void 0) {
|
|
1287
1426
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -1290,14 +1429,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
1290
1429
|
}, "useFactory"),
|
|
1291
1430
|
inject: [
|
|
1292
1431
|
{
|
|
1293
|
-
token:
|
|
1432
|
+
token: import_nestjs_agent_core12.AGENT_DURABLE_RUNNER,
|
|
1294
1433
|
optional: true
|
|
1295
1434
|
}
|
|
1296
1435
|
]
|
|
1297
1436
|
});
|
|
1298
1437
|
} else {
|
|
1299
1438
|
providers.push({
|
|
1300
|
-
provide:
|
|
1439
|
+
provide: import_nestjs_agent_core12.AGENT_RUNNER,
|
|
1301
1440
|
useExisting: InlineAgentRunner
|
|
1302
1441
|
});
|
|
1303
1442
|
}
|
|
@@ -1306,18 +1445,19 @@ function sharedProviders(durable, includeStore) {
|
|
|
1306
1445
|
__name(sharedProviders, "sharedProviders");
|
|
1307
1446
|
function exportsFor(includeStore) {
|
|
1308
1447
|
return [
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1448
|
+
import_nestjs_agent_core12.AGENT_OPTIONS,
|
|
1449
|
+
import_nestjs_agent_core12.AGENT_TOOL_REGISTRY,
|
|
1450
|
+
import_nestjs_agent_core12.AGENT_REGISTRY,
|
|
1451
|
+
import_nestjs_agent_core12.AGENT_SINK,
|
|
1452
|
+
import_nestjs_agent_core12.AGENT_ROLES_POLICY,
|
|
1453
|
+
import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER,
|
|
1454
|
+
import_nestjs_agent_core12.AGENT_MODEL,
|
|
1316
1455
|
...includeStore ? [
|
|
1317
|
-
|
|
1456
|
+
import_nestjs_agent_core12.AGENT_STORE
|
|
1318
1457
|
] : [],
|
|
1319
|
-
|
|
1320
|
-
|
|
1458
|
+
import_nestjs_agent_core12.AGENT_QUOTA_STORE,
|
|
1459
|
+
import_nestjs_agent_core12.AGENT_PROMPT_CONTRIBUTORS,
|
|
1460
|
+
import_nestjs_agent_core12.AGENT_DEPS_FACTORY,
|
|
1321
1461
|
AgentDepsFactory2,
|
|
1322
1462
|
AgentService,
|
|
1323
1463
|
InlineAgentRunner
|
|
@@ -1331,7 +1471,7 @@ var CONTROLLERS = [
|
|
|
1331
1471
|
QuotaController
|
|
1332
1472
|
];
|
|
1333
1473
|
function routerFor(path) {
|
|
1334
|
-
return
|
|
1474
|
+
return import_core3.RouterModule.register([
|
|
1335
1475
|
{
|
|
1336
1476
|
path,
|
|
1337
1477
|
module: AgentModule
|
|
@@ -1350,13 +1490,13 @@ var AgentModule = class _AgentModule {
|
|
|
1350
1490
|
module: _AgentModule,
|
|
1351
1491
|
global: true,
|
|
1352
1492
|
imports: [
|
|
1353
|
-
|
|
1493
|
+
import_core3.DiscoveryModule,
|
|
1354
1494
|
routerFor(path)
|
|
1355
1495
|
],
|
|
1356
1496
|
controllers: CONTROLLERS,
|
|
1357
1497
|
providers: [
|
|
1358
1498
|
{
|
|
1359
|
-
provide:
|
|
1499
|
+
provide: import_nestjs_agent_core12.AGENT_OPTIONS,
|
|
1360
1500
|
useValue: options
|
|
1361
1501
|
},
|
|
1362
1502
|
...sharedProviders(options.durable ?? false, includeStore)
|
|
@@ -1370,14 +1510,14 @@ var AgentModule = class _AgentModule {
|
|
|
1370
1510
|
module: _AgentModule,
|
|
1371
1511
|
global: true,
|
|
1372
1512
|
imports: [
|
|
1373
|
-
|
|
1513
|
+
import_core3.DiscoveryModule,
|
|
1374
1514
|
routerFor(path),
|
|
1375
1515
|
...options.imports ?? []
|
|
1376
1516
|
],
|
|
1377
1517
|
controllers: CONTROLLERS,
|
|
1378
1518
|
providers: [
|
|
1379
1519
|
{
|
|
1380
|
-
provide:
|
|
1520
|
+
provide: import_nestjs_agent_core12.AGENT_OPTIONS,
|
|
1381
1521
|
useFactory: options.useFactory,
|
|
1382
1522
|
inject: options.inject ?? []
|
|
1383
1523
|
},
|
|
@@ -1388,30 +1528,10 @@ var AgentModule = class _AgentModule {
|
|
|
1388
1528
|
exports: exportsFor(true)
|
|
1389
1529
|
};
|
|
1390
1530
|
}
|
|
1391
|
-
/** Register additional named agents (an orchestrator + its sub-agents). */
|
|
1392
|
-
static forFeature(definitions) {
|
|
1393
|
-
return {
|
|
1394
|
-
module: _AgentModule,
|
|
1395
|
-
providers: [
|
|
1396
|
-
{
|
|
1397
|
-
provide: FEATURE_INIT,
|
|
1398
|
-
useFactory: /* @__PURE__ */ __name((registry) => {
|
|
1399
|
-
for (const definition of definitions) {
|
|
1400
|
-
registry.register(definition);
|
|
1401
|
-
}
|
|
1402
|
-
return true;
|
|
1403
|
-
}, "useFactory"),
|
|
1404
|
-
inject: [
|
|
1405
|
-
import_nestjs_agent_core11.AGENT_REGISTRY
|
|
1406
|
-
]
|
|
1407
|
-
}
|
|
1408
|
-
]
|
|
1409
|
-
};
|
|
1410
|
-
}
|
|
1411
1531
|
};
|
|
1412
|
-
AgentModule =
|
|
1413
|
-
(0,
|
|
1414
|
-
(0,
|
|
1532
|
+
AgentModule = _ts_decorate10([
|
|
1533
|
+
(0, import_common10.Global)(),
|
|
1534
|
+
(0, import_common10.Module)({})
|
|
1415
1535
|
], AgentModule);
|
|
1416
1536
|
|
|
1417
1537
|
// src/resolver/header-actor-resolver.ts
|
|
@@ -1448,9 +1568,12 @@ var HeaderActorResolver = class {
|
|
|
1448
1568
|
__reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports);
|
|
1449
1569
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1450
1570
|
0 && (module.exports = {
|
|
1571
|
+
AGENT_METADATA,
|
|
1451
1572
|
AGENT_TOOL_BRAND,
|
|
1452
1573
|
AI_TOOL_METADATA,
|
|
1574
|
+
Agent,
|
|
1453
1575
|
AgentDepsFactory,
|
|
1576
|
+
AgentDiscoveryService,
|
|
1454
1577
|
AgentModule,
|
|
1455
1578
|
AgentService,
|
|
1456
1579
|
AiTool,
|
|
@@ -1459,8 +1582,13 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
|
|
|
1459
1582
|
InProcessTokenStreamSink,
|
|
1460
1583
|
InlineAgentRunner,
|
|
1461
1584
|
LedgerQuotaStore,
|
|
1585
|
+
SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
|
|
1586
|
+
SYSTEM_PROMPT_METADATA,
|
|
1587
|
+
SystemPrompt,
|
|
1588
|
+
SystemPromptContributor,
|
|
1462
1589
|
delegateToolName,
|
|
1463
1590
|
provideAgentTool,
|
|
1591
|
+
readAgentMetadata,
|
|
1464
1592
|
readAiToolMetadata,
|
|
1465
1593
|
utcDay,
|
|
1466
1594
|
...require("@dudousxd/nestjs-agent-core")
|