@dudousxd/nestjs-agent 0.3.2 → 0.4.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-DpVkZYCy.d.cts → agent-deps.factory-BM_RB6br.d.cts} +65 -4
- package/dist/{agent-deps.factory-DpVkZYCy.d.ts → agent-deps.factory-BM_RB6br.d.ts} +65 -4
- package/dist/durable/index.cjs +529 -272
- 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 +484 -227
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +520 -269
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -5
- package/dist/index.d.ts +53 -5
- package/dist/index.js +472 -224
- 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 +27 -5
package/dist/durable/index.js
CHANGED
|
@@ -84,10 +84,12 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
84
84
|
}, "runAgent")
|
|
85
85
|
};
|
|
86
86
|
try {
|
|
87
|
-
|
|
87
|
+
const result = await runAgentLoop({
|
|
88
88
|
...deps,
|
|
89
89
|
day
|
|
90
90
|
}, input, hooks);
|
|
91
|
+
await ctx.step("deactivate", () => this.store.setActiveStream(input.threadId, null));
|
|
92
|
+
return result;
|
|
91
93
|
} catch (error) {
|
|
92
94
|
if (error instanceof WorkflowSuspended || error instanceof ContinueAsNew) {
|
|
93
95
|
throw error;
|
|
@@ -99,6 +101,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
99
101
|
code,
|
|
100
102
|
message
|
|
101
103
|
});
|
|
104
|
+
await ctx.step("deactivate", () => this.store.setActiveStream(input.threadId, null));
|
|
102
105
|
const writer = await hooks.openSink();
|
|
103
106
|
await writer.fail({
|
|
104
107
|
code,
|
|
@@ -124,7 +127,9 @@ AgentRunWorkflow = _ts_decorate([
|
|
|
124
127
|
], AgentRunWorkflow);
|
|
125
128
|
|
|
126
129
|
// src/durable/durable-agent-runner.ts
|
|
130
|
+
import { randomUUID } from "node:crypto";
|
|
127
131
|
import { WorkflowService } from "@dudousxd/nestjs-durable";
|
|
132
|
+
import { WorkflowSuspended as WorkflowSuspended2 } from "@dudousxd/nestjs-durable-core";
|
|
128
133
|
import { Injectable as Injectable2 } from "@nestjs/common";
|
|
129
134
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
130
135
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -150,9 +155,16 @@ var DurableAgentRunner = class {
|
|
|
150
155
|
...input,
|
|
151
156
|
day: input.day ?? utcDay()
|
|
152
157
|
};
|
|
153
|
-
const
|
|
158
|
+
const runId = randomUUID();
|
|
159
|
+
try {
|
|
160
|
+
await this.workflows.start(AgentRunWorkflow, stamped, runId);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (!(error instanceof WorkflowSuspended2)) {
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
154
166
|
return {
|
|
155
|
-
runId
|
|
167
|
+
runId
|
|
156
168
|
};
|
|
157
169
|
}
|
|
158
170
|
async signal(runId, toolCallId, decision) {
|
|
@@ -215,14 +227,14 @@ AgentDurableModule = _ts_decorate3([
|
|
|
215
227
|
], AgentDurableModule);
|
|
216
228
|
|
|
217
229
|
// src/agent.module.ts
|
|
218
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
230
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE3, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry5, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
219
231
|
import { Global as Global2, Module as Module2 } from "@nestjs/common";
|
|
220
232
|
import { DiscoveryModule, RouterModule } from "@nestjs/core";
|
|
221
233
|
|
|
222
234
|
// src/agent-deps.factory.ts
|
|
223
|
-
import { AGENT_MODEL, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK, AGENT_STORE as AGENT_STORE2, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2 } from "@dudousxd/nestjs-agent-core";
|
|
235
|
+
import { AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK, AGENT_STORE as AGENT_STORE2, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2 } from "@dudousxd/nestjs-agent-core";
|
|
224
236
|
import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
|
|
225
|
-
import { Inject as Inject2, Injectable as Injectable3 } from "@nestjs/common";
|
|
237
|
+
import { Inject as Inject2, Injectable as Injectable3, Optional } from "@nestjs/common";
|
|
226
238
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
227
239
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
228
240
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -257,7 +269,8 @@ var AgentDepsFactory2 = class {
|
|
|
257
269
|
agents;
|
|
258
270
|
promptContributors;
|
|
259
271
|
quota;
|
|
260
|
-
|
|
272
|
+
pricingStore;
|
|
273
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, quota, pricingStore) {
|
|
261
274
|
this.options = options;
|
|
262
275
|
this.model = model;
|
|
263
276
|
this.store = store;
|
|
@@ -267,6 +280,7 @@ var AgentDepsFactory2 = class {
|
|
|
267
280
|
this.agents = agents;
|
|
268
281
|
this.promptContributors = promptContributors;
|
|
269
282
|
this.quota = quota;
|
|
283
|
+
this.pricingStore = pricingStore;
|
|
270
284
|
}
|
|
271
285
|
/**
|
|
272
286
|
* The agent a turn uses when the caller names none: the explicit `defaultAgent` option, else the
|
|
@@ -313,6 +327,9 @@ var AgentDepsFactory2 = class {
|
|
|
313
327
|
...this.quota !== void 0 ? {
|
|
314
328
|
quota: this.quota
|
|
315
329
|
} : {},
|
|
330
|
+
...this.pricingStore !== void 0 ? {
|
|
331
|
+
pricingStore: this.pricingStore
|
|
332
|
+
} : {},
|
|
316
333
|
...toolAllowList !== void 0 ? {
|
|
317
334
|
toolAllowList
|
|
318
335
|
} : {},
|
|
@@ -353,6 +370,8 @@ AgentDepsFactory2 = _ts_decorate4([
|
|
|
353
370
|
_ts_param2(6, Inject2(AGENT_REGISTRY)),
|
|
354
371
|
_ts_param2(7, Inject2(AGENT_PROMPT_CONTRIBUTORS)),
|
|
355
372
|
_ts_param2(8, Inject2(AGENT_QUOTA_STORE)),
|
|
373
|
+
_ts_param2(9, Optional()),
|
|
374
|
+
_ts_param2(9, Inject2(AGENT_PRICING_STORE)),
|
|
356
375
|
_ts_metadata3("design:type", Function),
|
|
357
376
|
_ts_metadata3("design:paramtypes", [
|
|
358
377
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -363,13 +382,14 @@ AgentDepsFactory2 = _ts_decorate4([
|
|
|
363
382
|
typeof ToolRegistry2 === "undefined" ? Object : ToolRegistry2,
|
|
364
383
|
typeof AgentRegistry2 === "undefined" ? Object : AgentRegistry2,
|
|
365
384
|
Array,
|
|
385
|
+
Object,
|
|
366
386
|
Object
|
|
367
387
|
])
|
|
368
388
|
], AgentDepsFactory2);
|
|
369
389
|
|
|
370
390
|
// src/agent.service.ts
|
|
371
391
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE3 } from "@dudousxd/nestjs-agent-core";
|
|
372
|
-
import { BadRequestException, ForbiddenException, Inject as Inject3, Injectable as Injectable4, NotFoundException } from "@nestjs/common";
|
|
392
|
+
import { BadRequestException, ForbiddenException, Inject as Inject3, Injectable as Injectable4, NotFoundException, NotImplementedException } from "@nestjs/common";
|
|
373
393
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
374
394
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
375
395
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -402,7 +422,7 @@ var AgentService = class {
|
|
|
402
422
|
this.quota = quota;
|
|
403
423
|
}
|
|
404
424
|
async chat(params) {
|
|
405
|
-
const agentName = params.agentName
|
|
425
|
+
const agentName = await this.resolveAgentName(params.agentName, params.threadId);
|
|
406
426
|
let threadId = params.threadId;
|
|
407
427
|
if (threadId === void 0) {
|
|
408
428
|
if (params.regenerate === true) {
|
|
@@ -427,6 +447,9 @@ var AgentService = class {
|
|
|
427
447
|
...params.regenerate === true ? {
|
|
428
448
|
regenerate: true
|
|
429
449
|
} : {},
|
|
450
|
+
...params.attachments !== void 0 ? {
|
|
451
|
+
attachments: params.attachments
|
|
452
|
+
} : {},
|
|
430
453
|
...params.pageContext !== void 0 ? {
|
|
431
454
|
pageContext: params.pageContext
|
|
432
455
|
} : {}
|
|
@@ -460,12 +483,14 @@ var AgentService = class {
|
|
|
460
483
|
await this.assertOwnsActiveStream(actor, runId);
|
|
461
484
|
return this.runner.cancel(runId);
|
|
462
485
|
}
|
|
463
|
-
listThreads(actorRef) {
|
|
464
|
-
|
|
486
|
+
async listThreads(actorRef) {
|
|
487
|
+
const threads = await this.store.listThreads(actorRef);
|
|
488
|
+
return Promise.all(threads.map((thread) => this.toSummaryView(thread)));
|
|
465
489
|
}
|
|
466
490
|
async getThread(actor, threadId) {
|
|
467
491
|
await this.assertOwnsThread(actor, threadId);
|
|
468
|
-
|
|
492
|
+
const thread = await this.store.getThread(threadId);
|
|
493
|
+
return thread === null ? null : this.toDetailView(thread);
|
|
469
494
|
}
|
|
470
495
|
async deleteThread(actor, threadId) {
|
|
471
496
|
await this.assertOwnsThread(actor, threadId);
|
|
@@ -475,7 +500,38 @@ var AgentService = class {
|
|
|
475
500
|
await this.assertOwnsThread(actor, threadId);
|
|
476
501
|
return this.store.forkThread(threadId, fromMessageId);
|
|
477
502
|
}
|
|
503
|
+
/** Kept for source compatibility — a thin wrapper over the more general `updateThread`. */
|
|
478
504
|
async renameThread(actor, threadId, title) {
|
|
505
|
+
return this.updateThread(actor, threadId, {
|
|
506
|
+
title
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Rename a thread and/or set its default agent. Title-only patches work against ANY store (via
|
|
511
|
+
* the required `setTitle`); a `defaultAgent` change requires the bound store to implement the
|
|
512
|
+
* optional `updateThread` — 501 with a clear message when it doesn't, rather than silently
|
|
513
|
+
* dropping the field.
|
|
514
|
+
*/
|
|
515
|
+
async updateThread(actor, threadId, patch) {
|
|
516
|
+
const title = patch.title !== void 0 ? this.validateTitle(patch.title) : void 0;
|
|
517
|
+
await this.assertOwnsThread(actor, threadId);
|
|
518
|
+
if (patch.defaultAgent === void 0) {
|
|
519
|
+
if (title !== void 0) {
|
|
520
|
+
await this.store.setTitle(threadId, title);
|
|
521
|
+
}
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (this.store.updateThread === void 0) {
|
|
525
|
+
throw new NotImplementedException("Setting a thread's defaultAgent requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
526
|
+
}
|
|
527
|
+
await this.store.updateThread(threadId, {
|
|
528
|
+
...title !== void 0 ? {
|
|
529
|
+
title
|
|
530
|
+
} : {},
|
|
531
|
+
defaultAgent: patch.defaultAgent
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
validateTitle(title) {
|
|
479
535
|
const trimmed = title.trim();
|
|
480
536
|
if (trimmed.length === 0) {
|
|
481
537
|
throw new BadRequestException("title must not be empty");
|
|
@@ -483,8 +539,41 @@ var AgentService = class {
|
|
|
483
539
|
if (trimmed.length > 200) {
|
|
484
540
|
throw new BadRequestException("title must be at most 200 characters");
|
|
485
541
|
}
|
|
486
|
-
|
|
487
|
-
|
|
542
|
+
return trimmed;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Agent-selection precedence for a `chat()` call with no explicit `agentName`: the thread's own
|
|
546
|
+
* `defaultAgent` (if the thread exists and one is set) wins over the module's configured default.
|
|
547
|
+
* Skips the thread lookup entirely when the caller already named an agent or there's no thread yet.
|
|
548
|
+
*/
|
|
549
|
+
async resolveAgentName(agentName, threadId) {
|
|
550
|
+
if (agentName !== void 0) {
|
|
551
|
+
return agentName;
|
|
552
|
+
}
|
|
553
|
+
if (threadId !== void 0) {
|
|
554
|
+
const thread = await this.store.getThread(threadId);
|
|
555
|
+
if (thread?.defaultAgent !== void 0 && thread.defaultAgent !== null) {
|
|
556
|
+
return thread.defaultAgent;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return this.deps.defaultAgentName();
|
|
560
|
+
}
|
|
561
|
+
async toSummaryView(thread) {
|
|
562
|
+
return {
|
|
563
|
+
...thread,
|
|
564
|
+
defaultAgent: thread.defaultAgent ?? null,
|
|
565
|
+
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
async toDetailView(thread) {
|
|
569
|
+
const summary = await this.toSummaryView(thread);
|
|
570
|
+
return {
|
|
571
|
+
...summary,
|
|
572
|
+
messages: thread.messages,
|
|
573
|
+
...thread.activeStreamId !== void 0 ? {
|
|
574
|
+
activeStreamId: thread.activeStreamId
|
|
575
|
+
} : {}
|
|
576
|
+
};
|
|
488
577
|
}
|
|
489
578
|
async promoteThread(actor, threadId) {
|
|
490
579
|
await this.assertOwnsThread(actor, threadId);
|
|
@@ -640,9 +729,10 @@ AgentsController = _ts_decorate6([
|
|
|
640
729
|
])
|
|
641
730
|
], AgentsController);
|
|
642
731
|
|
|
643
|
-
// src/controller/
|
|
644
|
-
import { AGENT_ACTOR_RESOLVER,
|
|
645
|
-
import {
|
|
732
|
+
// src/controller/attachments.controller.ts
|
|
733
|
+
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING, AGENT_OPTIONS as AGENT_OPTIONS2 } from "@dudousxd/nestjs-agent-core";
|
|
734
|
+
import { BadRequestException as BadRequestException2, Controller as Controller2, Inject as Inject5, NotImplementedException as NotImplementedException2, Optional as Optional2, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
|
|
735
|
+
import { FileInterceptor } from "@nestjs/platform-express";
|
|
646
736
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
647
737
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
648
738
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -660,6 +750,110 @@ function _ts_param5(paramIndex, decorator) {
|
|
|
660
750
|
};
|
|
661
751
|
}
|
|
662
752
|
__name(_ts_param5, "_ts_param");
|
|
753
|
+
var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
754
|
+
var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
|
|
755
|
+
"image/png",
|
|
756
|
+
"image/jpeg",
|
|
757
|
+
"image/gif",
|
|
758
|
+
"image/webp",
|
|
759
|
+
"application/pdf",
|
|
760
|
+
"text/plain",
|
|
761
|
+
"text/csv"
|
|
762
|
+
];
|
|
763
|
+
var AttachmentsController = class {
|
|
764
|
+
static {
|
|
765
|
+
__name(this, "AttachmentsController");
|
|
766
|
+
}
|
|
767
|
+
options;
|
|
768
|
+
actorResolver;
|
|
769
|
+
staging;
|
|
770
|
+
constructor(options, actorResolver, staging) {
|
|
771
|
+
this.options = options;
|
|
772
|
+
this.actorResolver = actorResolver;
|
|
773
|
+
this.staging = staging;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* `attachments.upload: true` is what mounts this controller at all (see `agent.module.ts`), so by
|
|
777
|
+
* the time an instance exists the host clearly intends uploads to work. Fail boot loudly rather
|
|
778
|
+
* than mounting a controller that would 501 on every single request because nobody bound
|
|
779
|
+
* `AGENT_ATTACHMENT_STAGING`.
|
|
780
|
+
*/
|
|
781
|
+
onModuleInit() {
|
|
782
|
+
if (this.options.attachments?.upload === true && this.staging === void 0) {
|
|
783
|
+
throw new Error("AgentModule: attachments.upload is true but no AGENT_ATTACHMENT_STAGING provider is bound. Bind one (e.g. `{ provide: AGENT_ATTACHMENT_STAGING, useClass: MyStagingStore }`) in a module imported alongside AgentModule, or set attachments.upload to false.");
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
async upload(req, file) {
|
|
787
|
+
if (this.staging === void 0) {
|
|
788
|
+
throw new NotImplementedException2("Attachment upload is not configured on this server.");
|
|
789
|
+
}
|
|
790
|
+
if (file === void 0) {
|
|
791
|
+
throw new BadRequestException2('multipart field "file" is required');
|
|
792
|
+
}
|
|
793
|
+
const allowedContentTypes = this.options.attachments?.allowedContentTypes ?? DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES;
|
|
794
|
+
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
795
|
+
throw new UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
796
|
+
}
|
|
797
|
+
const maxBytes = this.options.attachments?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES;
|
|
798
|
+
if (file.size > maxBytes) {
|
|
799
|
+
throw new PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
800
|
+
}
|
|
801
|
+
const actor = await this.actorResolver.resolve(req);
|
|
802
|
+
return this.staging.stage({
|
|
803
|
+
data: file.buffer,
|
|
804
|
+
filename: file.originalname,
|
|
805
|
+
contentType: file.mimetype,
|
|
806
|
+
sizeBytes: file.size,
|
|
807
|
+
actor
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
_ts_decorate7([
|
|
812
|
+
Post(),
|
|
813
|
+
UseInterceptors(FileInterceptor("file")),
|
|
814
|
+
_ts_param5(0, Req()),
|
|
815
|
+
_ts_param5(1, UploadedFile()),
|
|
816
|
+
_ts_metadata6("design:type", Function),
|
|
817
|
+
_ts_metadata6("design:paramtypes", [
|
|
818
|
+
typeof Request === "undefined" ? Object : Request,
|
|
819
|
+
Object
|
|
820
|
+
]),
|
|
821
|
+
_ts_metadata6("design:returntype", Promise)
|
|
822
|
+
], AttachmentsController.prototype, "upload", null);
|
|
823
|
+
AttachmentsController = _ts_decorate7([
|
|
824
|
+
Controller2("attachments"),
|
|
825
|
+
_ts_param5(0, Inject5(AGENT_OPTIONS2)),
|
|
826
|
+
_ts_param5(1, Inject5(AGENT_ACTOR_RESOLVER)),
|
|
827
|
+
_ts_param5(2, Optional2()),
|
|
828
|
+
_ts_param5(2, Inject5(AGENT_ATTACHMENT_STAGING)),
|
|
829
|
+
_ts_metadata6("design:type", Function),
|
|
830
|
+
_ts_metadata6("design:paramtypes", [
|
|
831
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
832
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
833
|
+
Object
|
|
834
|
+
])
|
|
835
|
+
], AttachmentsController);
|
|
836
|
+
|
|
837
|
+
// src/controller/chat.controller.ts
|
|
838
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError } from "@dudousxd/nestjs-agent-core";
|
|
839
|
+
import { Body, Controller as Controller3, Get as Get2, Inject as Inject6, Param, Post as Post2, Req as Req2, Res } from "@nestjs/common";
|
|
840
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
841
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
842
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
843
|
+
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;
|
|
844
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
845
|
+
}
|
|
846
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
847
|
+
function _ts_metadata7(k, v) {
|
|
848
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
849
|
+
}
|
|
850
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
851
|
+
function _ts_param6(paramIndex, decorator) {
|
|
852
|
+
return function(target, key) {
|
|
853
|
+
decorator(target, key, paramIndex);
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
__name(_ts_param6, "_ts_param");
|
|
663
857
|
var ChatController = class {
|
|
664
858
|
static {
|
|
665
859
|
__name(this, "ChatController");
|
|
@@ -681,6 +875,9 @@ var ChatController = class {
|
|
|
681
875
|
...body.agent !== void 0 ? {
|
|
682
876
|
agentName: body.agent
|
|
683
877
|
} : {},
|
|
878
|
+
...body.attachments !== void 0 ? {
|
|
879
|
+
attachments: body.attachments
|
|
880
|
+
} : {},
|
|
684
881
|
...body.pageContext !== void 0 ? {
|
|
685
882
|
pageContext: body.pageContext
|
|
686
883
|
} : {},
|
|
@@ -719,11 +916,26 @@ data: ${JSON.stringify({
|
|
|
719
916
|
|
|
720
917
|
`);
|
|
721
918
|
const decoder = new TextDecoder();
|
|
919
|
+
let buffer = "";
|
|
722
920
|
try {
|
|
723
921
|
for await (const chunk of this.agent.subscribe(runId)) {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
})
|
|
922
|
+
buffer += decoder.decode(chunk, {
|
|
923
|
+
stream: true
|
|
924
|
+
});
|
|
925
|
+
let newline = buffer.indexOf("\n");
|
|
926
|
+
while (newline !== -1) {
|
|
927
|
+
const line = buffer.slice(0, newline);
|
|
928
|
+
buffer = buffer.slice(newline + 1);
|
|
929
|
+
if (line.length > 0) {
|
|
930
|
+
res.write(`data: ${line}
|
|
931
|
+
|
|
932
|
+
`);
|
|
933
|
+
}
|
|
934
|
+
newline = buffer.indexOf("\n");
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
if (buffer.length > 0) {
|
|
938
|
+
res.write(`data: ${buffer}
|
|
727
939
|
|
|
728
940
|
`);
|
|
729
941
|
}
|
|
@@ -744,71 +956,71 @@ data: ${JSON.stringify(payload)}
|
|
|
744
956
|
res.end();
|
|
745
957
|
}
|
|
746
958
|
};
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
959
|
+
_ts_decorate8([
|
|
960
|
+
Post2("chat"),
|
|
961
|
+
_ts_param6(0, Req2()),
|
|
962
|
+
_ts_param6(1, Res()),
|
|
963
|
+
_ts_param6(2, Body()),
|
|
964
|
+
_ts_metadata7("design:type", Function),
|
|
965
|
+
_ts_metadata7("design:paramtypes", [
|
|
754
966
|
typeof Request === "undefined" ? Object : Request,
|
|
755
967
|
typeof Response === "undefined" ? Object : Response,
|
|
756
968
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
757
969
|
]),
|
|
758
|
-
|
|
970
|
+
_ts_metadata7("design:returntype", Promise)
|
|
759
971
|
], ChatController.prototype, "chat", null);
|
|
760
|
-
|
|
972
|
+
_ts_decorate8([
|
|
761
973
|
Get2("chat/:runId/stream"),
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
974
|
+
_ts_param6(0, Param("runId")),
|
|
975
|
+
_ts_param6(1, Res()),
|
|
976
|
+
_ts_metadata7("design:type", Function),
|
|
977
|
+
_ts_metadata7("design:paramtypes", [
|
|
766
978
|
String,
|
|
767
979
|
typeof Response === "undefined" ? Object : Response
|
|
768
980
|
]),
|
|
769
|
-
|
|
981
|
+
_ts_metadata7("design:returntype", Promise)
|
|
770
982
|
], ChatController.prototype, "stream", null);
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
983
|
+
_ts_decorate8([
|
|
984
|
+
Post2("chat/:runId/cancel"),
|
|
985
|
+
_ts_param6(0, Req2()),
|
|
986
|
+
_ts_param6(1, Param("runId")),
|
|
987
|
+
_ts_metadata7("design:type", Function),
|
|
988
|
+
_ts_metadata7("design:paramtypes", [
|
|
777
989
|
typeof Request === "undefined" ? Object : Request,
|
|
778
990
|
String
|
|
779
991
|
]),
|
|
780
|
-
|
|
992
|
+
_ts_metadata7("design:returntype", Promise)
|
|
781
993
|
], ChatController.prototype, "cancel", null);
|
|
782
|
-
ChatController =
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
994
|
+
ChatController = _ts_decorate8([
|
|
995
|
+
Controller3(),
|
|
996
|
+
_ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER2)),
|
|
997
|
+
_ts_metadata7("design:type", Function),
|
|
998
|
+
_ts_metadata7("design:paramtypes", [
|
|
787
999
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
788
1000
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
789
1001
|
])
|
|
790
1002
|
], ChatController);
|
|
791
1003
|
|
|
792
1004
|
// src/controller/quota.controller.ts
|
|
793
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
794
|
-
import { Controller as
|
|
795
|
-
function
|
|
1005
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3 } from "@dudousxd/nestjs-agent-core";
|
|
1006
|
+
import { Controller as Controller4, Get as Get3, Inject as Inject7, Req as Req3 } from "@nestjs/common";
|
|
1007
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
796
1008
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
797
1009
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
798
1010
|
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;
|
|
799
1011
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
800
1012
|
}
|
|
801
|
-
__name(
|
|
802
|
-
function
|
|
1013
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1014
|
+
function _ts_metadata8(k, v) {
|
|
803
1015
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
804
1016
|
}
|
|
805
|
-
__name(
|
|
806
|
-
function
|
|
1017
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
1018
|
+
function _ts_param7(paramIndex, decorator) {
|
|
807
1019
|
return function(target, key) {
|
|
808
1020
|
decorator(target, key, paramIndex);
|
|
809
1021
|
};
|
|
810
1022
|
}
|
|
811
|
-
__name(
|
|
1023
|
+
__name(_ts_param7, "_ts_param");
|
|
812
1024
|
var QuotaController = class {
|
|
813
1025
|
static {
|
|
814
1026
|
__name(this, "QuotaController");
|
|
@@ -824,45 +1036,45 @@ var QuotaController = class {
|
|
|
824
1036
|
return this.agent.quotaToday(actor.id);
|
|
825
1037
|
}
|
|
826
1038
|
};
|
|
827
|
-
|
|
1039
|
+
_ts_decorate9([
|
|
828
1040
|
Get3("today"),
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
1041
|
+
_ts_param7(0, Req3()),
|
|
1042
|
+
_ts_metadata8("design:type", Function),
|
|
1043
|
+
_ts_metadata8("design:paramtypes", [
|
|
832
1044
|
typeof Request === "undefined" ? Object : Request
|
|
833
1045
|
]),
|
|
834
|
-
|
|
1046
|
+
_ts_metadata8("design:returntype", Promise)
|
|
835
1047
|
], QuotaController.prototype, "today", null);
|
|
836
|
-
QuotaController =
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
1048
|
+
QuotaController = _ts_decorate9([
|
|
1049
|
+
Controller4("quota"),
|
|
1050
|
+
_ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER3)),
|
|
1051
|
+
_ts_metadata8("design:type", Function),
|
|
1052
|
+
_ts_metadata8("design:paramtypes", [
|
|
841
1053
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
842
1054
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
843
1055
|
])
|
|
844
1056
|
], QuotaController);
|
|
845
1057
|
|
|
846
1058
|
// src/controller/threads.controller.ts
|
|
847
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
848
|
-
import { Body as Body2, Controller as
|
|
849
|
-
function
|
|
1059
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4 } from "@dudousxd/nestjs-agent-core";
|
|
1060
|
+
import { Body as Body2, Controller as Controller5, Delete, Get as Get4, Inject as Inject8, Param as Param2, Patch, Post as Post3, Req as Req4 } from "@nestjs/common";
|
|
1061
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
850
1062
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
851
1063
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
852
1064
|
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;
|
|
853
1065
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
854
1066
|
}
|
|
855
|
-
__name(
|
|
856
|
-
function
|
|
1067
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1068
|
+
function _ts_metadata9(k, v) {
|
|
857
1069
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
858
1070
|
}
|
|
859
|
-
__name(
|
|
860
|
-
function
|
|
1071
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1072
|
+
function _ts_param8(paramIndex, decorator) {
|
|
861
1073
|
return function(target, key) {
|
|
862
1074
|
decorator(target, key, paramIndex);
|
|
863
1075
|
};
|
|
864
1076
|
}
|
|
865
|
-
__name(
|
|
1077
|
+
__name(_ts_param8, "_ts_param");
|
|
866
1078
|
var ThreadsController = class {
|
|
867
1079
|
static {
|
|
868
1080
|
__name(this, "ThreadsController");
|
|
@@ -892,9 +1104,21 @@ var ThreadsController = class {
|
|
|
892
1104
|
const actor = await this.actorResolver.resolve(req);
|
|
893
1105
|
return this.agent.forkThread(actor, id, messageId);
|
|
894
1106
|
}
|
|
895
|
-
|
|
1107
|
+
/**
|
|
1108
|
+
* Renames the thread and/or sets its default agent. `defaultAgent` is only present in the request
|
|
1109
|
+
* body when the client actually sent the key (JSON has no `undefined`), so `'defaultAgent' in body`
|
|
1110
|
+
* distinguishes "leave it alone" from "set it to null" (clear it) unambiguously.
|
|
1111
|
+
*/
|
|
1112
|
+
async update(req, id, body) {
|
|
896
1113
|
const actor = await this.actorResolver.resolve(req);
|
|
897
|
-
await this.agent.
|
|
1114
|
+
await this.agent.updateThread(actor, id, {
|
|
1115
|
+
...body.title !== void 0 ? {
|
|
1116
|
+
title: body.title
|
|
1117
|
+
} : {},
|
|
1118
|
+
..."defaultAgent" in body ? {
|
|
1119
|
+
defaultAgent: body.defaultAgent ?? null
|
|
1120
|
+
} : {}
|
|
1121
|
+
});
|
|
898
1122
|
return {
|
|
899
1123
|
ok: true
|
|
900
1124
|
};
|
|
@@ -914,117 +1138,117 @@ var ThreadsController = class {
|
|
|
914
1138
|
};
|
|
915
1139
|
}
|
|
916
1140
|
};
|
|
917
|
-
|
|
1141
|
+
_ts_decorate10([
|
|
918
1142
|
Get4(),
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
1143
|
+
_ts_param8(0, Req4()),
|
|
1144
|
+
_ts_metadata9("design:type", Function),
|
|
1145
|
+
_ts_metadata9("design:paramtypes", [
|
|
922
1146
|
typeof Request === "undefined" ? Object : Request
|
|
923
1147
|
]),
|
|
924
|
-
|
|
1148
|
+
_ts_metadata9("design:returntype", Promise)
|
|
925
1149
|
], ThreadsController.prototype, "list", null);
|
|
926
|
-
|
|
1150
|
+
_ts_decorate10([
|
|
927
1151
|
Get4(":id"),
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1152
|
+
_ts_param8(0, Req4()),
|
|
1153
|
+
_ts_param8(1, Param2("id")),
|
|
1154
|
+
_ts_metadata9("design:type", Function),
|
|
1155
|
+
_ts_metadata9("design:paramtypes", [
|
|
932
1156
|
typeof Request === "undefined" ? Object : Request,
|
|
933
1157
|
String
|
|
934
1158
|
]),
|
|
935
|
-
|
|
1159
|
+
_ts_metadata9("design:returntype", Promise)
|
|
936
1160
|
], ThreadsController.prototype, "detail", null);
|
|
937
|
-
|
|
1161
|
+
_ts_decorate10([
|
|
938
1162
|
Delete(":id"),
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1163
|
+
_ts_param8(0, Req4()),
|
|
1164
|
+
_ts_param8(1, Param2("id")),
|
|
1165
|
+
_ts_metadata9("design:type", Function),
|
|
1166
|
+
_ts_metadata9("design:paramtypes", [
|
|
943
1167
|
typeof Request === "undefined" ? Object : Request,
|
|
944
1168
|
String
|
|
945
1169
|
]),
|
|
946
|
-
|
|
1170
|
+
_ts_metadata9("design:returntype", Promise)
|
|
947
1171
|
], ThreadsController.prototype, "remove", null);
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1172
|
+
_ts_decorate10([
|
|
1173
|
+
Post3(":id/fork-from/:messageId"),
|
|
1174
|
+
_ts_param8(0, Req4()),
|
|
1175
|
+
_ts_param8(1, Param2("id")),
|
|
1176
|
+
_ts_param8(2, Param2("messageId")),
|
|
1177
|
+
_ts_metadata9("design:type", Function),
|
|
1178
|
+
_ts_metadata9("design:paramtypes", [
|
|
955
1179
|
typeof Request === "undefined" ? Object : Request,
|
|
956
1180
|
String,
|
|
957
1181
|
String
|
|
958
1182
|
]),
|
|
959
|
-
|
|
1183
|
+
_ts_metadata9("design:returntype", Promise)
|
|
960
1184
|
], ThreadsController.prototype, "fork", null);
|
|
961
|
-
|
|
1185
|
+
_ts_decorate10([
|
|
962
1186
|
Patch(":id"),
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1187
|
+
_ts_param8(0, Req4()),
|
|
1188
|
+
_ts_param8(1, Param2("id")),
|
|
1189
|
+
_ts_param8(2, Body2()),
|
|
1190
|
+
_ts_metadata9("design:type", Function),
|
|
1191
|
+
_ts_metadata9("design:paramtypes", [
|
|
968
1192
|
typeof Request === "undefined" ? Object : Request,
|
|
969
1193
|
String,
|
|
970
|
-
typeof
|
|
1194
|
+
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
971
1195
|
]),
|
|
972
|
-
|
|
973
|
-
], ThreadsController.prototype, "
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1196
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1197
|
+
], ThreadsController.prototype, "update", null);
|
|
1198
|
+
_ts_decorate10([
|
|
1199
|
+
Post3(":id/promote"),
|
|
1200
|
+
_ts_param8(0, Req4()),
|
|
1201
|
+
_ts_param8(1, Param2("id")),
|
|
1202
|
+
_ts_metadata9("design:type", Function),
|
|
1203
|
+
_ts_metadata9("design:paramtypes", [
|
|
980
1204
|
typeof Request === "undefined" ? Object : Request,
|
|
981
1205
|
String
|
|
982
1206
|
]),
|
|
983
|
-
|
|
1207
|
+
_ts_metadata9("design:returntype", Promise)
|
|
984
1208
|
], ThreadsController.prototype, "promote", null);
|
|
985
|
-
|
|
1209
|
+
_ts_decorate10([
|
|
986
1210
|
Delete(":id/from/:messageId"),
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1211
|
+
_ts_param8(0, Req4()),
|
|
1212
|
+
_ts_param8(1, Param2("id")),
|
|
1213
|
+
_ts_param8(2, Param2("messageId")),
|
|
1214
|
+
_ts_metadata9("design:type", Function),
|
|
1215
|
+
_ts_metadata9("design:paramtypes", [
|
|
992
1216
|
typeof Request === "undefined" ? Object : Request,
|
|
993
1217
|
String,
|
|
994
1218
|
String
|
|
995
1219
|
]),
|
|
996
|
-
|
|
1220
|
+
_ts_metadata9("design:returntype", Promise)
|
|
997
1221
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
998
|
-
ThreadsController =
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1222
|
+
ThreadsController = _ts_decorate10([
|
|
1223
|
+
Controller5("threads"),
|
|
1224
|
+
_ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER4)),
|
|
1225
|
+
_ts_metadata9("design:type", Function),
|
|
1226
|
+
_ts_metadata9("design:paramtypes", [
|
|
1003
1227
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1004
1228
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1005
1229
|
])
|
|
1006
1230
|
], ThreadsController);
|
|
1007
1231
|
|
|
1008
1232
|
// src/controller/tool-call.controller.ts
|
|
1009
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
1010
|
-
import { Body as Body3, Controller as
|
|
1011
|
-
function
|
|
1233
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
|
|
1234
|
+
import { Body as Body3, Controller as Controller6, Inject as Inject9, Post as Post4, Req as Req5 } from "@nestjs/common";
|
|
1235
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1012
1236
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1013
1237
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1014
1238
|
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;
|
|
1015
1239
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1016
1240
|
}
|
|
1017
|
-
__name(
|
|
1018
|
-
function
|
|
1241
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1242
|
+
function _ts_metadata10(k, v) {
|
|
1019
1243
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1020
1244
|
}
|
|
1021
|
-
__name(
|
|
1022
|
-
function
|
|
1245
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1246
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1023
1247
|
return function(target, key) {
|
|
1024
1248
|
decorator(target, key, paramIndex);
|
|
1025
1249
|
};
|
|
1026
1250
|
}
|
|
1027
|
-
__name(
|
|
1251
|
+
__name(_ts_param9, "_ts_param");
|
|
1028
1252
|
var ToolCallController = class {
|
|
1029
1253
|
static {
|
|
1030
1254
|
__name(this, "ToolCallController");
|
|
@@ -1050,33 +1274,33 @@ var ToolCallController = class {
|
|
|
1050
1274
|
};
|
|
1051
1275
|
}
|
|
1052
1276
|
};
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1277
|
+
_ts_decorate11([
|
|
1278
|
+
Post4("approve"),
|
|
1279
|
+
_ts_param9(0, Req5()),
|
|
1280
|
+
_ts_param9(1, Body3()),
|
|
1281
|
+
_ts_metadata10("design:type", Function),
|
|
1282
|
+
_ts_metadata10("design:paramtypes", [
|
|
1059
1283
|
typeof Request === "undefined" ? Object : Request,
|
|
1060
1284
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
1061
1285
|
]),
|
|
1062
|
-
|
|
1286
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1063
1287
|
], ToolCallController.prototype, "approve", null);
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1288
|
+
_ts_decorate11([
|
|
1289
|
+
Post4("reject"),
|
|
1290
|
+
_ts_param9(0, Req5()),
|
|
1291
|
+
_ts_param9(1, Body3()),
|
|
1292
|
+
_ts_metadata10("design:type", Function),
|
|
1293
|
+
_ts_metadata10("design:paramtypes", [
|
|
1070
1294
|
typeof Request === "undefined" ? Object : Request,
|
|
1071
1295
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
1072
1296
|
]),
|
|
1073
|
-
|
|
1297
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1074
1298
|
], ToolCallController.prototype, "reject", null);
|
|
1075
|
-
ToolCallController =
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1299
|
+
ToolCallController = _ts_decorate11([
|
|
1300
|
+
Controller6("tool-call"),
|
|
1301
|
+
_ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER5)),
|
|
1302
|
+
_ts_metadata10("design:type", Function),
|
|
1303
|
+
_ts_metadata10("design:paramtypes", [
|
|
1080
1304
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1081
1305
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1082
1306
|
])
|
|
@@ -1084,7 +1308,7 @@ ToolCallController = _ts_decorate10([
|
|
|
1084
1308
|
|
|
1085
1309
|
// src/discovery/agent-discovery.service.ts
|
|
1086
1310
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
|
|
1087
|
-
import { Inject as
|
|
1311
|
+
import { Inject as Inject10, Injectable as Injectable5, Logger } from "@nestjs/common";
|
|
1088
1312
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
1089
1313
|
|
|
1090
1314
|
// src/decorator/agent.decorator.ts
|
|
@@ -1101,23 +1325,23 @@ var SYSTEM_PROMPT_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt");
|
|
|
1101
1325
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
1102
1326
|
|
|
1103
1327
|
// src/discovery/agent-discovery.service.ts
|
|
1104
|
-
function
|
|
1328
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1105
1329
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1106
1330
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1107
1331
|
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;
|
|
1108
1332
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1109
1333
|
}
|
|
1110
|
-
__name(
|
|
1111
|
-
function
|
|
1334
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1335
|
+
function _ts_metadata11(k, v) {
|
|
1112
1336
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1113
1337
|
}
|
|
1114
|
-
__name(
|
|
1115
|
-
function
|
|
1338
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1339
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1116
1340
|
return function(target, key) {
|
|
1117
1341
|
decorator(target, key, paramIndex);
|
|
1118
1342
|
};
|
|
1119
1343
|
}
|
|
1120
|
-
__name(
|
|
1344
|
+
__name(_ts_param10, "_ts_param");
|
|
1121
1345
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
1122
1346
|
static {
|
|
1123
1347
|
__name(this, "AgentDiscoveryService");
|
|
@@ -1214,12 +1438,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
1214
1438
|
return (ctx) => candidate.call(instance, ctx);
|
|
1215
1439
|
}
|
|
1216
1440
|
};
|
|
1217
|
-
AgentDiscoveryService =
|
|
1441
|
+
AgentDiscoveryService = _ts_decorate12([
|
|
1218
1442
|
Injectable5(),
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1443
|
+
_ts_param10(2, Inject10(AGENT_REGISTRY3)),
|
|
1444
|
+
_ts_param10(3, Inject10(AGENT_PROMPT_CONTRIBUTORS2)),
|
|
1445
|
+
_ts_metadata11("design:type", Function),
|
|
1446
|
+
_ts_metadata11("design:paramtypes", [
|
|
1223
1447
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
1224
1448
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
1225
1449
|
typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4,
|
|
@@ -1228,8 +1452,8 @@ AgentDiscoveryService = _ts_decorate11([
|
|
|
1228
1452
|
], AgentDiscoveryService);
|
|
1229
1453
|
|
|
1230
1454
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1231
|
-
import { AGENT_OPTIONS as
|
|
1232
|
-
import { Inject as
|
|
1455
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_REGISTRY as AGENT_REGISTRY4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2 } from "@dudousxd/nestjs-agent-core";
|
|
1456
|
+
import { Inject as Inject11, Injectable as Injectable6, Logger as Logger2 } from "@nestjs/common";
|
|
1233
1457
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
1234
1458
|
import { z } from "zod";
|
|
1235
1459
|
|
|
@@ -1249,23 +1473,23 @@ function isBrandedFunctionalTool(value) {
|
|
|
1249
1473
|
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
1250
1474
|
|
|
1251
1475
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1252
|
-
function
|
|
1476
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
1253
1477
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1254
1478
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1255
1479
|
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;
|
|
1256
1480
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1257
1481
|
}
|
|
1258
|
-
__name(
|
|
1259
|
-
function
|
|
1482
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
1483
|
+
function _ts_metadata12(k, v) {
|
|
1260
1484
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1261
1485
|
}
|
|
1262
|
-
__name(
|
|
1263
|
-
function
|
|
1486
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
1487
|
+
function _ts_param11(paramIndex, decorator) {
|
|
1264
1488
|
return function(target, key) {
|
|
1265
1489
|
decorator(target, key, paramIndex);
|
|
1266
1490
|
};
|
|
1267
1491
|
}
|
|
1268
|
-
__name(
|
|
1492
|
+
__name(_ts_param11, "_ts_param");
|
|
1269
1493
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
1270
1494
|
static {
|
|
1271
1495
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -1372,13 +1596,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
1372
1596
|
return true;
|
|
1373
1597
|
}
|
|
1374
1598
|
};
|
|
1375
|
-
AiToolDiscoveryService =
|
|
1599
|
+
AiToolDiscoveryService = _ts_decorate13([
|
|
1376
1600
|
Injectable6(),
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1601
|
+
_ts_param11(1, Inject11(AGENT_TOOL_REGISTRY2)),
|
|
1602
|
+
_ts_param11(2, Inject11(AGENT_REGISTRY4)),
|
|
1603
|
+
_ts_param11(3, Inject11(AGENT_OPTIONS3)),
|
|
1604
|
+
_ts_metadata12("design:type", Function),
|
|
1605
|
+
_ts_metadata12("design:paramtypes", [
|
|
1382
1606
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
1383
1607
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
1384
1608
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -1479,24 +1703,24 @@ var LedgerQuotaStore = class {
|
|
|
1479
1703
|
|
|
1480
1704
|
// src/runner/inline-agent-runner.ts
|
|
1481
1705
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_STORE as AGENT_STORE4, QuotaExceededError as QuotaExceededError2, publishAgentRunFailed as publishAgentRunFailed2, runAgentLoop as runAgentLoop2 } from "@dudousxd/nestjs-agent-core";
|
|
1482
|
-
import { Inject as
|
|
1483
|
-
function
|
|
1706
|
+
import { Inject as Inject12, Injectable as Injectable7, Logger as Logger3 } from "@nestjs/common";
|
|
1707
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
1484
1708
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1485
1709
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1486
1710
|
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;
|
|
1487
1711
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1488
1712
|
}
|
|
1489
|
-
__name(
|
|
1490
|
-
function
|
|
1713
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
1714
|
+
function _ts_metadata13(k, v) {
|
|
1491
1715
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1492
1716
|
}
|
|
1493
|
-
__name(
|
|
1494
|
-
function
|
|
1717
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
1718
|
+
function _ts_param12(paramIndex, decorator) {
|
|
1495
1719
|
return function(target, key) {
|
|
1496
1720
|
decorator(target, key, paramIndex);
|
|
1497
1721
|
};
|
|
1498
1722
|
}
|
|
1499
|
-
__name(
|
|
1723
|
+
__name(_ts_param12, "_ts_param");
|
|
1500
1724
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
1501
1725
|
static {
|
|
1502
1726
|
__name(this, "InlineAgentRunner");
|
|
@@ -1517,7 +1741,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1517
1741
|
void runAgentLoop2({
|
|
1518
1742
|
...deps,
|
|
1519
1743
|
day
|
|
1520
|
-
}, input, hooks).catch(async (error) => {
|
|
1744
|
+
}, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
|
|
1521
1745
|
const message = error instanceof Error ? error.message : String(error);
|
|
1522
1746
|
const code = error instanceof QuotaExceededError2 ? "quota_exceeded" : "run_failed";
|
|
1523
1747
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
@@ -1526,6 +1750,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1526
1750
|
code,
|
|
1527
1751
|
message
|
|
1528
1752
|
});
|
|
1753
|
+
await this.store.setActiveStream(input.threadId, null);
|
|
1529
1754
|
const writer = await deps.sink.open(runId);
|
|
1530
1755
|
await writer.fail({
|
|
1531
1756
|
code,
|
|
@@ -1583,39 +1808,43 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1583
1808
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
1584
1809
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested(childName, childTask, actor, day, depth + 1, sinkRunId), "runAgent")
|
|
1585
1810
|
};
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1811
|
+
try {
|
|
1812
|
+
return await runAgentLoop2({
|
|
1813
|
+
...deps,
|
|
1814
|
+
day
|
|
1815
|
+
}, {
|
|
1816
|
+
threadId: subThread.id,
|
|
1817
|
+
actor,
|
|
1818
|
+
userText: task,
|
|
1819
|
+
agentName,
|
|
1820
|
+
day,
|
|
1821
|
+
delegationDepth: depth,
|
|
1822
|
+
sinkRunId
|
|
1823
|
+
}, hooks);
|
|
1824
|
+
} finally {
|
|
1825
|
+
await this.store.setActiveStream(subThread.id, null);
|
|
1826
|
+
}
|
|
1598
1827
|
}
|
|
1599
1828
|
};
|
|
1600
|
-
InlineAgentRunner =
|
|
1829
|
+
InlineAgentRunner = _ts_decorate14([
|
|
1601
1830
|
Injectable7(),
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1831
|
+
_ts_param12(0, Inject12(AGENT_DEPS_FACTORY4)),
|
|
1832
|
+
_ts_param12(1, Inject12(AGENT_STORE4)),
|
|
1833
|
+
_ts_metadata13("design:type", Function),
|
|
1834
|
+
_ts_metadata13("design:paramtypes", [
|
|
1606
1835
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1607
1836
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
1608
1837
|
])
|
|
1609
1838
|
], InlineAgentRunner);
|
|
1610
1839
|
|
|
1611
1840
|
// src/agent.module.ts
|
|
1612
|
-
function
|
|
1841
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
1613
1842
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1614
1843
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1615
1844
|
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;
|
|
1616
1845
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1617
1846
|
}
|
|
1618
|
-
__name(
|
|
1847
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
1619
1848
|
var DEFAULT_PATH = "agent";
|
|
1620
1849
|
function sharedProviders(durable, includeStore) {
|
|
1621
1850
|
const providers = [
|
|
@@ -1637,28 +1866,28 @@ function sharedProviders(durable, includeStore) {
|
|
|
1637
1866
|
provide: AGENT_SINK2,
|
|
1638
1867
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
1639
1868
|
inject: [
|
|
1640
|
-
|
|
1869
|
+
AGENT_OPTIONS4
|
|
1641
1870
|
]
|
|
1642
1871
|
},
|
|
1643
1872
|
{
|
|
1644
1873
|
provide: AGENT_ROLES_POLICY2,
|
|
1645
1874
|
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
1646
1875
|
inject: [
|
|
1647
|
-
|
|
1876
|
+
AGENT_OPTIONS4
|
|
1648
1877
|
]
|
|
1649
1878
|
},
|
|
1650
1879
|
{
|
|
1651
|
-
provide:
|
|
1880
|
+
provide: AGENT_ACTOR_RESOLVER6,
|
|
1652
1881
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
1653
1882
|
inject: [
|
|
1654
|
-
|
|
1883
|
+
AGENT_OPTIONS4
|
|
1655
1884
|
]
|
|
1656
1885
|
},
|
|
1657
1886
|
{
|
|
1658
1887
|
provide: AGENT_MODEL2,
|
|
1659
1888
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
1660
1889
|
inject: [
|
|
1661
|
-
|
|
1890
|
+
AGENT_OPTIONS4
|
|
1662
1891
|
]
|
|
1663
1892
|
},
|
|
1664
1893
|
{
|
|
@@ -1668,7 +1897,7 @@ function sharedProviders(durable, includeStore) {
|
|
|
1668
1897
|
provide: AGENT_QUOTA_STORE3,
|
|
1669
1898
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
1670
1899
|
inject: [
|
|
1671
|
-
|
|
1900
|
+
AGENT_OPTIONS4,
|
|
1672
1901
|
AGENT_STORE5
|
|
1673
1902
|
]
|
|
1674
1903
|
},
|
|
@@ -1689,7 +1918,7 @@ function sharedProviders(durable, includeStore) {
|
|
|
1689
1918
|
provide: AGENT_STORE5,
|
|
1690
1919
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
1691
1920
|
inject: [
|
|
1692
|
-
|
|
1921
|
+
AGENT_OPTIONS4
|
|
1693
1922
|
]
|
|
1694
1923
|
});
|
|
1695
1924
|
}
|
|
@@ -1720,12 +1949,12 @@ function sharedProviders(durable, includeStore) {
|
|
|
1720
1949
|
__name(sharedProviders, "sharedProviders");
|
|
1721
1950
|
function exportsFor(includeStore) {
|
|
1722
1951
|
return [
|
|
1723
|
-
|
|
1952
|
+
AGENT_OPTIONS4,
|
|
1724
1953
|
AGENT_TOOL_REGISTRY3,
|
|
1725
1954
|
AGENT_REGISTRY5,
|
|
1726
1955
|
AGENT_SINK2,
|
|
1727
1956
|
AGENT_ROLES_POLICY2,
|
|
1728
|
-
|
|
1957
|
+
AGENT_ACTOR_RESOLVER6,
|
|
1729
1958
|
AGENT_MODEL2,
|
|
1730
1959
|
...includeStore ? [
|
|
1731
1960
|
AGENT_STORE5
|
|
@@ -1739,13 +1968,38 @@ function exportsFor(includeStore) {
|
|
|
1739
1968
|
];
|
|
1740
1969
|
}
|
|
1741
1970
|
__name(exportsFor, "exportsFor");
|
|
1742
|
-
var
|
|
1971
|
+
var BASE_CONTROLLERS = [
|
|
1743
1972
|
ChatController,
|
|
1744
1973
|
ThreadsController,
|
|
1745
1974
|
ToolCallController,
|
|
1746
1975
|
QuotaController,
|
|
1747
1976
|
AgentsController
|
|
1748
1977
|
];
|
|
1978
|
+
var GUARDABLE_CONTROLLERS = [
|
|
1979
|
+
...BASE_CONTROLLERS,
|
|
1980
|
+
AttachmentsController
|
|
1981
|
+
];
|
|
1982
|
+
function controllersFor(mountAttachments) {
|
|
1983
|
+
return mountAttachments ? [
|
|
1984
|
+
...BASE_CONTROLLERS,
|
|
1985
|
+
AttachmentsController
|
|
1986
|
+
] : BASE_CONTROLLERS;
|
|
1987
|
+
}
|
|
1988
|
+
__name(controllersFor, "controllersFor");
|
|
1989
|
+
var GUARDS_METADATA = "__guards__";
|
|
1990
|
+
function applyGuards(guards) {
|
|
1991
|
+
const resolved = guards ?? [];
|
|
1992
|
+
for (const controller of GUARDABLE_CONTROLLERS) {
|
|
1993
|
+
Reflect.defineMetadata(GUARDS_METADATA, resolved, controller);
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
__name(applyGuards, "applyGuards");
|
|
1997
|
+
function guardProviders(guards) {
|
|
1998
|
+
return [
|
|
1999
|
+
...new Set(guards ?? [])
|
|
2000
|
+
];
|
|
2001
|
+
}
|
|
2002
|
+
__name(guardProviders, "guardProviders");
|
|
1749
2003
|
function routerFor(path) {
|
|
1750
2004
|
return RouterModule.register([
|
|
1751
2005
|
{
|
|
@@ -1762,6 +2016,7 @@ var AgentModule = class _AgentModule {
|
|
|
1762
2016
|
static forRoot(options) {
|
|
1763
2017
|
const path = options.path ?? DEFAULT_PATH;
|
|
1764
2018
|
const includeStore = options.store !== void 0;
|
|
2019
|
+
applyGuards(options.guards);
|
|
1765
2020
|
return {
|
|
1766
2021
|
module: _AgentModule,
|
|
1767
2022
|
global: true,
|
|
@@ -1769,19 +2024,22 @@ var AgentModule = class _AgentModule {
|
|
|
1769
2024
|
DiscoveryModule,
|
|
1770
2025
|
routerFor(path)
|
|
1771
2026
|
],
|
|
1772
|
-
controllers:
|
|
2027
|
+
controllers: controllersFor(options.attachments?.upload === true),
|
|
1773
2028
|
providers: [
|
|
1774
2029
|
{
|
|
1775
|
-
provide:
|
|
2030
|
+
provide: AGENT_OPTIONS4,
|
|
1776
2031
|
useValue: options
|
|
1777
2032
|
},
|
|
1778
|
-
...sharedProviders(options.durable ?? false, includeStore)
|
|
2033
|
+
...sharedProviders(options.durable ?? false, includeStore),
|
|
2034
|
+
...guardProviders(options.guards)
|
|
1779
2035
|
],
|
|
1780
2036
|
exports: exportsFor(includeStore)
|
|
1781
2037
|
};
|
|
1782
2038
|
}
|
|
1783
2039
|
static forRootAsync(options) {
|
|
1784
2040
|
const path = options.path ?? DEFAULT_PATH;
|
|
2041
|
+
const includeStore = options.externalStore !== true;
|
|
2042
|
+
applyGuards(options.guards);
|
|
1785
2043
|
return {
|
|
1786
2044
|
module: _AgentModule,
|
|
1787
2045
|
global: true,
|
|
@@ -1790,22 +2048,21 @@ var AgentModule = class _AgentModule {
|
|
|
1790
2048
|
routerFor(path),
|
|
1791
2049
|
...options.imports ?? []
|
|
1792
2050
|
],
|
|
1793
|
-
controllers:
|
|
2051
|
+
controllers: controllersFor(options.attachmentsUpload === true),
|
|
1794
2052
|
providers: [
|
|
1795
2053
|
{
|
|
1796
|
-
provide:
|
|
2054
|
+
provide: AGENT_OPTIONS4,
|
|
1797
2055
|
useFactory: options.useFactory,
|
|
1798
2056
|
inject: options.inject ?? []
|
|
1799
2057
|
},
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
...sharedProviders(options.durable ?? false, true)
|
|
2058
|
+
...sharedProviders(options.durable ?? false, includeStore),
|
|
2059
|
+
...guardProviders(options.guards)
|
|
1803
2060
|
],
|
|
1804
|
-
exports: exportsFor(
|
|
2061
|
+
exports: exportsFor(includeStore)
|
|
1805
2062
|
};
|
|
1806
2063
|
}
|
|
1807
2064
|
};
|
|
1808
|
-
AgentModule =
|
|
2065
|
+
AgentModule = _ts_decorate15([
|
|
1809
2066
|
Global2(),
|
|
1810
2067
|
Module2({})
|
|
1811
2068
|
], AgentModule);
|