@dudousxd/nestjs-agent 0.3.3 → 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-D4KyREOv.d.cts → agent-deps.factory-BM_RB6br.d.cts} +54 -4
- package/dist/{agent-deps.factory-D4KyREOv.d.ts → agent-deps.factory-BM_RB6br.d.ts} +54 -4
- package/dist/durable/index.cjs +492 -264
- 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 +447 -219
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +494 -263
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -5
- package/dist/index.d.ts +51 -5
- package/dist/index.js +446 -218
- package/dist/index.js.map +1 -1
- package/package.json +10 -3
package/dist/index.js
CHANGED
|
@@ -2,14 +2,14 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/agent.module.ts
|
|
5
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
5
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_DURABLE_RUNNER, 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_STORE4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry5, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
6
6
|
import { Global, Module } from "@nestjs/common";
|
|
7
7
|
import { DiscoveryModule, RouterModule } from "@nestjs/core";
|
|
8
8
|
|
|
9
9
|
// src/agent-deps.factory.ts
|
|
10
|
-
import { AGENT_MODEL, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK, AGENT_STORE, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2 } from "@dudousxd/nestjs-agent-core";
|
|
10
|
+
import { AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK, AGENT_STORE, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2 } from "@dudousxd/nestjs-agent-core";
|
|
11
11
|
import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
|
|
12
|
-
import { Inject, Injectable } from "@nestjs/common";
|
|
12
|
+
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
13
13
|
function _ts_decorate(decorators, target, key, desc) {
|
|
14
14
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
15
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -44,7 +44,8 @@ var AgentDepsFactory2 = class {
|
|
|
44
44
|
agents;
|
|
45
45
|
promptContributors;
|
|
46
46
|
quota;
|
|
47
|
-
|
|
47
|
+
pricingStore;
|
|
48
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, quota, pricingStore) {
|
|
48
49
|
this.options = options;
|
|
49
50
|
this.model = model;
|
|
50
51
|
this.store = store;
|
|
@@ -54,6 +55,7 @@ var AgentDepsFactory2 = class {
|
|
|
54
55
|
this.agents = agents;
|
|
55
56
|
this.promptContributors = promptContributors;
|
|
56
57
|
this.quota = quota;
|
|
58
|
+
this.pricingStore = pricingStore;
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
61
|
* The agent a turn uses when the caller names none: the explicit `defaultAgent` option, else the
|
|
@@ -100,6 +102,9 @@ var AgentDepsFactory2 = class {
|
|
|
100
102
|
...this.quota !== void 0 ? {
|
|
101
103
|
quota: this.quota
|
|
102
104
|
} : {},
|
|
105
|
+
...this.pricingStore !== void 0 ? {
|
|
106
|
+
pricingStore: this.pricingStore
|
|
107
|
+
} : {},
|
|
103
108
|
...toolAllowList !== void 0 ? {
|
|
104
109
|
toolAllowList
|
|
105
110
|
} : {},
|
|
@@ -140,6 +145,8 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
140
145
|
_ts_param(6, Inject(AGENT_REGISTRY)),
|
|
141
146
|
_ts_param(7, Inject(AGENT_PROMPT_CONTRIBUTORS)),
|
|
142
147
|
_ts_param(8, Inject(AGENT_QUOTA_STORE)),
|
|
148
|
+
_ts_param(9, Optional()),
|
|
149
|
+
_ts_param(9, Inject(AGENT_PRICING_STORE)),
|
|
143
150
|
_ts_metadata("design:type", Function),
|
|
144
151
|
_ts_metadata("design:paramtypes", [
|
|
145
152
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -150,13 +157,14 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
150
157
|
typeof ToolRegistry2 === "undefined" ? Object : ToolRegistry2,
|
|
151
158
|
typeof AgentRegistry2 === "undefined" ? Object : AgentRegistry2,
|
|
152
159
|
Array,
|
|
160
|
+
Object,
|
|
153
161
|
Object
|
|
154
162
|
])
|
|
155
163
|
], AgentDepsFactory2);
|
|
156
164
|
|
|
157
165
|
// src/agent.service.ts
|
|
158
166
|
import { AGENT_DEPS_FACTORY, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE2 } from "@dudousxd/nestjs-agent-core";
|
|
159
|
-
import { BadRequestException, ForbiddenException, Inject as Inject2, Injectable as Injectable2, NotFoundException } from "@nestjs/common";
|
|
167
|
+
import { BadRequestException, ForbiddenException, Inject as Inject2, Injectable as Injectable2, NotFoundException, NotImplementedException } from "@nestjs/common";
|
|
160
168
|
|
|
161
169
|
// src/agent-deps.ts
|
|
162
170
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -207,7 +215,7 @@ var AgentService = class {
|
|
|
207
215
|
this.quota = quota;
|
|
208
216
|
}
|
|
209
217
|
async chat(params) {
|
|
210
|
-
const agentName = params.agentName
|
|
218
|
+
const agentName = await this.resolveAgentName(params.agentName, params.threadId);
|
|
211
219
|
let threadId = params.threadId;
|
|
212
220
|
if (threadId === void 0) {
|
|
213
221
|
if (params.regenerate === true) {
|
|
@@ -268,12 +276,14 @@ var AgentService = class {
|
|
|
268
276
|
await this.assertOwnsActiveStream(actor, runId);
|
|
269
277
|
return this.runner.cancel(runId);
|
|
270
278
|
}
|
|
271
|
-
listThreads(actorRef) {
|
|
272
|
-
|
|
279
|
+
async listThreads(actorRef) {
|
|
280
|
+
const threads = await this.store.listThreads(actorRef);
|
|
281
|
+
return Promise.all(threads.map((thread) => this.toSummaryView(thread)));
|
|
273
282
|
}
|
|
274
283
|
async getThread(actor, threadId) {
|
|
275
284
|
await this.assertOwnsThread(actor, threadId);
|
|
276
|
-
|
|
285
|
+
const thread = await this.store.getThread(threadId);
|
|
286
|
+
return thread === null ? null : this.toDetailView(thread);
|
|
277
287
|
}
|
|
278
288
|
async deleteThread(actor, threadId) {
|
|
279
289
|
await this.assertOwnsThread(actor, threadId);
|
|
@@ -283,7 +293,38 @@ var AgentService = class {
|
|
|
283
293
|
await this.assertOwnsThread(actor, threadId);
|
|
284
294
|
return this.store.forkThread(threadId, fromMessageId);
|
|
285
295
|
}
|
|
296
|
+
/** Kept for source compatibility — a thin wrapper over the more general `updateThread`. */
|
|
286
297
|
async renameThread(actor, threadId, title) {
|
|
298
|
+
return this.updateThread(actor, threadId, {
|
|
299
|
+
title
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Rename a thread and/or set its default agent. Title-only patches work against ANY store (via
|
|
304
|
+
* the required `setTitle`); a `defaultAgent` change requires the bound store to implement the
|
|
305
|
+
* optional `updateThread` — 501 with a clear message when it doesn't, rather than silently
|
|
306
|
+
* dropping the field.
|
|
307
|
+
*/
|
|
308
|
+
async updateThread(actor, threadId, patch) {
|
|
309
|
+
const title = patch.title !== void 0 ? this.validateTitle(patch.title) : void 0;
|
|
310
|
+
await this.assertOwnsThread(actor, threadId);
|
|
311
|
+
if (patch.defaultAgent === void 0) {
|
|
312
|
+
if (title !== void 0) {
|
|
313
|
+
await this.store.setTitle(threadId, title);
|
|
314
|
+
}
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
if (this.store.updateThread === void 0) {
|
|
318
|
+
throw new NotImplementedException("Setting a thread's defaultAgent requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
319
|
+
}
|
|
320
|
+
await this.store.updateThread(threadId, {
|
|
321
|
+
...title !== void 0 ? {
|
|
322
|
+
title
|
|
323
|
+
} : {},
|
|
324
|
+
defaultAgent: patch.defaultAgent
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
validateTitle(title) {
|
|
287
328
|
const trimmed = title.trim();
|
|
288
329
|
if (trimmed.length === 0) {
|
|
289
330
|
throw new BadRequestException("title must not be empty");
|
|
@@ -291,8 +332,41 @@ var AgentService = class {
|
|
|
291
332
|
if (trimmed.length > 200) {
|
|
292
333
|
throw new BadRequestException("title must be at most 200 characters");
|
|
293
334
|
}
|
|
294
|
-
|
|
295
|
-
|
|
335
|
+
return trimmed;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Agent-selection precedence for a `chat()` call with no explicit `agentName`: the thread's own
|
|
339
|
+
* `defaultAgent` (if the thread exists and one is set) wins over the module's configured default.
|
|
340
|
+
* Skips the thread lookup entirely when the caller already named an agent or there's no thread yet.
|
|
341
|
+
*/
|
|
342
|
+
async resolveAgentName(agentName, threadId) {
|
|
343
|
+
if (agentName !== void 0) {
|
|
344
|
+
return agentName;
|
|
345
|
+
}
|
|
346
|
+
if (threadId !== void 0) {
|
|
347
|
+
const thread = await this.store.getThread(threadId);
|
|
348
|
+
if (thread?.defaultAgent !== void 0 && thread.defaultAgent !== null) {
|
|
349
|
+
return thread.defaultAgent;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return this.deps.defaultAgentName();
|
|
353
|
+
}
|
|
354
|
+
async toSummaryView(thread) {
|
|
355
|
+
return {
|
|
356
|
+
...thread,
|
|
357
|
+
defaultAgent: thread.defaultAgent ?? null,
|
|
358
|
+
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
async toDetailView(thread) {
|
|
362
|
+
const summary = await this.toSummaryView(thread);
|
|
363
|
+
return {
|
|
364
|
+
...summary,
|
|
365
|
+
messages: thread.messages,
|
|
366
|
+
...thread.activeStreamId !== void 0 ? {
|
|
367
|
+
activeStreamId: thread.activeStreamId
|
|
368
|
+
} : {}
|
|
369
|
+
};
|
|
296
370
|
}
|
|
297
371
|
async promoteThread(actor, threadId) {
|
|
298
372
|
await this.assertOwnsThread(actor, threadId);
|
|
@@ -448,9 +522,10 @@ AgentsController = _ts_decorate3([
|
|
|
448
522
|
])
|
|
449
523
|
], AgentsController);
|
|
450
524
|
|
|
451
|
-
// src/controller/
|
|
452
|
-
import { AGENT_ACTOR_RESOLVER,
|
|
453
|
-
import {
|
|
525
|
+
// src/controller/attachments.controller.ts
|
|
526
|
+
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING, AGENT_OPTIONS as AGENT_OPTIONS2 } from "@dudousxd/nestjs-agent-core";
|
|
527
|
+
import { BadRequestException as BadRequestException2, Controller as Controller2, Inject as Inject4, NotImplementedException as NotImplementedException2, Optional as Optional2, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
|
|
528
|
+
import { FileInterceptor } from "@nestjs/platform-express";
|
|
454
529
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
455
530
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
456
531
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -468,6 +543,110 @@ function _ts_param4(paramIndex, decorator) {
|
|
|
468
543
|
};
|
|
469
544
|
}
|
|
470
545
|
__name(_ts_param4, "_ts_param");
|
|
546
|
+
var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
547
|
+
var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
|
|
548
|
+
"image/png",
|
|
549
|
+
"image/jpeg",
|
|
550
|
+
"image/gif",
|
|
551
|
+
"image/webp",
|
|
552
|
+
"application/pdf",
|
|
553
|
+
"text/plain",
|
|
554
|
+
"text/csv"
|
|
555
|
+
];
|
|
556
|
+
var AttachmentsController = class {
|
|
557
|
+
static {
|
|
558
|
+
__name(this, "AttachmentsController");
|
|
559
|
+
}
|
|
560
|
+
options;
|
|
561
|
+
actorResolver;
|
|
562
|
+
staging;
|
|
563
|
+
constructor(options, actorResolver, staging) {
|
|
564
|
+
this.options = options;
|
|
565
|
+
this.actorResolver = actorResolver;
|
|
566
|
+
this.staging = staging;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* `attachments.upload: true` is what mounts this controller at all (see `agent.module.ts`), so by
|
|
570
|
+
* the time an instance exists the host clearly intends uploads to work. Fail boot loudly rather
|
|
571
|
+
* than mounting a controller that would 501 on every single request because nobody bound
|
|
572
|
+
* `AGENT_ATTACHMENT_STAGING`.
|
|
573
|
+
*/
|
|
574
|
+
onModuleInit() {
|
|
575
|
+
if (this.options.attachments?.upload === true && this.staging === void 0) {
|
|
576
|
+
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.");
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
async upload(req, file) {
|
|
580
|
+
if (this.staging === void 0) {
|
|
581
|
+
throw new NotImplementedException2("Attachment upload is not configured on this server.");
|
|
582
|
+
}
|
|
583
|
+
if (file === void 0) {
|
|
584
|
+
throw new BadRequestException2('multipart field "file" is required');
|
|
585
|
+
}
|
|
586
|
+
const allowedContentTypes = this.options.attachments?.allowedContentTypes ?? DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES;
|
|
587
|
+
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
588
|
+
throw new UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
589
|
+
}
|
|
590
|
+
const maxBytes = this.options.attachments?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES;
|
|
591
|
+
if (file.size > maxBytes) {
|
|
592
|
+
throw new PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
593
|
+
}
|
|
594
|
+
const actor = await this.actorResolver.resolve(req);
|
|
595
|
+
return this.staging.stage({
|
|
596
|
+
data: file.buffer,
|
|
597
|
+
filename: file.originalname,
|
|
598
|
+
contentType: file.mimetype,
|
|
599
|
+
sizeBytes: file.size,
|
|
600
|
+
actor
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
_ts_decorate4([
|
|
605
|
+
Post(),
|
|
606
|
+
UseInterceptors(FileInterceptor("file")),
|
|
607
|
+
_ts_param4(0, Req()),
|
|
608
|
+
_ts_param4(1, UploadedFile()),
|
|
609
|
+
_ts_metadata4("design:type", Function),
|
|
610
|
+
_ts_metadata4("design:paramtypes", [
|
|
611
|
+
typeof Request === "undefined" ? Object : Request,
|
|
612
|
+
Object
|
|
613
|
+
]),
|
|
614
|
+
_ts_metadata4("design:returntype", Promise)
|
|
615
|
+
], AttachmentsController.prototype, "upload", null);
|
|
616
|
+
AttachmentsController = _ts_decorate4([
|
|
617
|
+
Controller2("attachments"),
|
|
618
|
+
_ts_param4(0, Inject4(AGENT_OPTIONS2)),
|
|
619
|
+
_ts_param4(1, Inject4(AGENT_ACTOR_RESOLVER)),
|
|
620
|
+
_ts_param4(2, Optional2()),
|
|
621
|
+
_ts_param4(2, Inject4(AGENT_ATTACHMENT_STAGING)),
|
|
622
|
+
_ts_metadata4("design:type", Function),
|
|
623
|
+
_ts_metadata4("design:paramtypes", [
|
|
624
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
625
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
626
|
+
Object
|
|
627
|
+
])
|
|
628
|
+
], AttachmentsController);
|
|
629
|
+
|
|
630
|
+
// src/controller/chat.controller.ts
|
|
631
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError } from "@dudousxd/nestjs-agent-core";
|
|
632
|
+
import { Body, Controller as Controller3, Get as Get2, Inject as Inject5, Param, Post as Post2, Req as Req2, Res } from "@nestjs/common";
|
|
633
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
634
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
635
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
636
|
+
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;
|
|
637
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
638
|
+
}
|
|
639
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
640
|
+
function _ts_metadata5(k, v) {
|
|
641
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
642
|
+
}
|
|
643
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
644
|
+
function _ts_param5(paramIndex, decorator) {
|
|
645
|
+
return function(target, key) {
|
|
646
|
+
decorator(target, key, paramIndex);
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
__name(_ts_param5, "_ts_param");
|
|
471
650
|
var ChatController = class {
|
|
472
651
|
static {
|
|
473
652
|
__name(this, "ChatController");
|
|
@@ -570,71 +749,71 @@ data: ${JSON.stringify(payload)}
|
|
|
570
749
|
res.end();
|
|
571
750
|
}
|
|
572
751
|
};
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
752
|
+
_ts_decorate5([
|
|
753
|
+
Post2("chat"),
|
|
754
|
+
_ts_param5(0, Req2()),
|
|
755
|
+
_ts_param5(1, Res()),
|
|
756
|
+
_ts_param5(2, Body()),
|
|
757
|
+
_ts_metadata5("design:type", Function),
|
|
758
|
+
_ts_metadata5("design:paramtypes", [
|
|
580
759
|
typeof Request === "undefined" ? Object : Request,
|
|
581
760
|
typeof Response === "undefined" ? Object : Response,
|
|
582
761
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
583
762
|
]),
|
|
584
|
-
|
|
763
|
+
_ts_metadata5("design:returntype", Promise)
|
|
585
764
|
], ChatController.prototype, "chat", null);
|
|
586
|
-
|
|
765
|
+
_ts_decorate5([
|
|
587
766
|
Get2("chat/:runId/stream"),
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
767
|
+
_ts_param5(0, Param("runId")),
|
|
768
|
+
_ts_param5(1, Res()),
|
|
769
|
+
_ts_metadata5("design:type", Function),
|
|
770
|
+
_ts_metadata5("design:paramtypes", [
|
|
592
771
|
String,
|
|
593
772
|
typeof Response === "undefined" ? Object : Response
|
|
594
773
|
]),
|
|
595
|
-
|
|
774
|
+
_ts_metadata5("design:returntype", Promise)
|
|
596
775
|
], ChatController.prototype, "stream", null);
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
776
|
+
_ts_decorate5([
|
|
777
|
+
Post2("chat/:runId/cancel"),
|
|
778
|
+
_ts_param5(0, Req2()),
|
|
779
|
+
_ts_param5(1, Param("runId")),
|
|
780
|
+
_ts_metadata5("design:type", Function),
|
|
781
|
+
_ts_metadata5("design:paramtypes", [
|
|
603
782
|
typeof Request === "undefined" ? Object : Request,
|
|
604
783
|
String
|
|
605
784
|
]),
|
|
606
|
-
|
|
785
|
+
_ts_metadata5("design:returntype", Promise)
|
|
607
786
|
], ChatController.prototype, "cancel", null);
|
|
608
|
-
ChatController =
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
787
|
+
ChatController = _ts_decorate5([
|
|
788
|
+
Controller3(),
|
|
789
|
+
_ts_param5(1, Inject5(AGENT_ACTOR_RESOLVER2)),
|
|
790
|
+
_ts_metadata5("design:type", Function),
|
|
791
|
+
_ts_metadata5("design:paramtypes", [
|
|
613
792
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
614
793
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
615
794
|
])
|
|
616
795
|
], ChatController);
|
|
617
796
|
|
|
618
797
|
// src/controller/quota.controller.ts
|
|
619
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
620
|
-
import { Controller as
|
|
621
|
-
function
|
|
798
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3 } from "@dudousxd/nestjs-agent-core";
|
|
799
|
+
import { Controller as Controller4, Get as Get3, Inject as Inject6, Req as Req3 } from "@nestjs/common";
|
|
800
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
622
801
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
623
802
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
624
803
|
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;
|
|
625
804
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
626
805
|
}
|
|
627
|
-
__name(
|
|
628
|
-
function
|
|
806
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
807
|
+
function _ts_metadata6(k, v) {
|
|
629
808
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
630
809
|
}
|
|
631
|
-
__name(
|
|
632
|
-
function
|
|
810
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
811
|
+
function _ts_param6(paramIndex, decorator) {
|
|
633
812
|
return function(target, key) {
|
|
634
813
|
decorator(target, key, paramIndex);
|
|
635
814
|
};
|
|
636
815
|
}
|
|
637
|
-
__name(
|
|
816
|
+
__name(_ts_param6, "_ts_param");
|
|
638
817
|
var QuotaController = class {
|
|
639
818
|
static {
|
|
640
819
|
__name(this, "QuotaController");
|
|
@@ -650,45 +829,45 @@ var QuotaController = class {
|
|
|
650
829
|
return this.agent.quotaToday(actor.id);
|
|
651
830
|
}
|
|
652
831
|
};
|
|
653
|
-
|
|
832
|
+
_ts_decorate6([
|
|
654
833
|
Get3("today"),
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
834
|
+
_ts_param6(0, Req3()),
|
|
835
|
+
_ts_metadata6("design:type", Function),
|
|
836
|
+
_ts_metadata6("design:paramtypes", [
|
|
658
837
|
typeof Request === "undefined" ? Object : Request
|
|
659
838
|
]),
|
|
660
|
-
|
|
839
|
+
_ts_metadata6("design:returntype", Promise)
|
|
661
840
|
], QuotaController.prototype, "today", null);
|
|
662
|
-
QuotaController =
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
841
|
+
QuotaController = _ts_decorate6([
|
|
842
|
+
Controller4("quota"),
|
|
843
|
+
_ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER3)),
|
|
844
|
+
_ts_metadata6("design:type", Function),
|
|
845
|
+
_ts_metadata6("design:paramtypes", [
|
|
667
846
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
668
847
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
669
848
|
])
|
|
670
849
|
], QuotaController);
|
|
671
850
|
|
|
672
851
|
// src/controller/threads.controller.ts
|
|
673
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
674
|
-
import { Body as Body2, Controller as
|
|
675
|
-
function
|
|
852
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4 } from "@dudousxd/nestjs-agent-core";
|
|
853
|
+
import { Body as Body2, Controller as Controller5, Delete, Get as Get4, Inject as Inject7, Param as Param2, Patch, Post as Post3, Req as Req4 } from "@nestjs/common";
|
|
854
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
676
855
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
677
856
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
678
857
|
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;
|
|
679
858
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
680
859
|
}
|
|
681
|
-
__name(
|
|
682
|
-
function
|
|
860
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
861
|
+
function _ts_metadata7(k, v) {
|
|
683
862
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
684
863
|
}
|
|
685
|
-
__name(
|
|
686
|
-
function
|
|
864
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
865
|
+
function _ts_param7(paramIndex, decorator) {
|
|
687
866
|
return function(target, key) {
|
|
688
867
|
decorator(target, key, paramIndex);
|
|
689
868
|
};
|
|
690
869
|
}
|
|
691
|
-
__name(
|
|
870
|
+
__name(_ts_param7, "_ts_param");
|
|
692
871
|
var ThreadsController = class {
|
|
693
872
|
static {
|
|
694
873
|
__name(this, "ThreadsController");
|
|
@@ -718,9 +897,21 @@ var ThreadsController = class {
|
|
|
718
897
|
const actor = await this.actorResolver.resolve(req);
|
|
719
898
|
return this.agent.forkThread(actor, id, messageId);
|
|
720
899
|
}
|
|
721
|
-
|
|
900
|
+
/**
|
|
901
|
+
* Renames the thread and/or sets its default agent. `defaultAgent` is only present in the request
|
|
902
|
+
* body when the client actually sent the key (JSON has no `undefined`), so `'defaultAgent' in body`
|
|
903
|
+
* distinguishes "leave it alone" from "set it to null" (clear it) unambiguously.
|
|
904
|
+
*/
|
|
905
|
+
async update(req, id, body) {
|
|
722
906
|
const actor = await this.actorResolver.resolve(req);
|
|
723
|
-
await this.agent.
|
|
907
|
+
await this.agent.updateThread(actor, id, {
|
|
908
|
+
...body.title !== void 0 ? {
|
|
909
|
+
title: body.title
|
|
910
|
+
} : {},
|
|
911
|
+
..."defaultAgent" in body ? {
|
|
912
|
+
defaultAgent: body.defaultAgent ?? null
|
|
913
|
+
} : {}
|
|
914
|
+
});
|
|
724
915
|
return {
|
|
725
916
|
ok: true
|
|
726
917
|
};
|
|
@@ -740,117 +931,117 @@ var ThreadsController = class {
|
|
|
740
931
|
};
|
|
741
932
|
}
|
|
742
933
|
};
|
|
743
|
-
|
|
934
|
+
_ts_decorate7([
|
|
744
935
|
Get4(),
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
936
|
+
_ts_param7(0, Req4()),
|
|
937
|
+
_ts_metadata7("design:type", Function),
|
|
938
|
+
_ts_metadata7("design:paramtypes", [
|
|
748
939
|
typeof Request === "undefined" ? Object : Request
|
|
749
940
|
]),
|
|
750
|
-
|
|
941
|
+
_ts_metadata7("design:returntype", Promise)
|
|
751
942
|
], ThreadsController.prototype, "list", null);
|
|
752
|
-
|
|
943
|
+
_ts_decorate7([
|
|
753
944
|
Get4(":id"),
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
945
|
+
_ts_param7(0, Req4()),
|
|
946
|
+
_ts_param7(1, Param2("id")),
|
|
947
|
+
_ts_metadata7("design:type", Function),
|
|
948
|
+
_ts_metadata7("design:paramtypes", [
|
|
758
949
|
typeof Request === "undefined" ? Object : Request,
|
|
759
950
|
String
|
|
760
951
|
]),
|
|
761
|
-
|
|
952
|
+
_ts_metadata7("design:returntype", Promise)
|
|
762
953
|
], ThreadsController.prototype, "detail", null);
|
|
763
|
-
|
|
954
|
+
_ts_decorate7([
|
|
764
955
|
Delete(":id"),
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
956
|
+
_ts_param7(0, Req4()),
|
|
957
|
+
_ts_param7(1, Param2("id")),
|
|
958
|
+
_ts_metadata7("design:type", Function),
|
|
959
|
+
_ts_metadata7("design:paramtypes", [
|
|
769
960
|
typeof Request === "undefined" ? Object : Request,
|
|
770
961
|
String
|
|
771
962
|
]),
|
|
772
|
-
|
|
963
|
+
_ts_metadata7("design:returntype", Promise)
|
|
773
964
|
], ThreadsController.prototype, "remove", null);
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
965
|
+
_ts_decorate7([
|
|
966
|
+
Post3(":id/fork-from/:messageId"),
|
|
967
|
+
_ts_param7(0, Req4()),
|
|
968
|
+
_ts_param7(1, Param2("id")),
|
|
969
|
+
_ts_param7(2, Param2("messageId")),
|
|
970
|
+
_ts_metadata7("design:type", Function),
|
|
971
|
+
_ts_metadata7("design:paramtypes", [
|
|
781
972
|
typeof Request === "undefined" ? Object : Request,
|
|
782
973
|
String,
|
|
783
974
|
String
|
|
784
975
|
]),
|
|
785
|
-
|
|
976
|
+
_ts_metadata7("design:returntype", Promise)
|
|
786
977
|
], ThreadsController.prototype, "fork", null);
|
|
787
|
-
|
|
978
|
+
_ts_decorate7([
|
|
788
979
|
Patch(":id"),
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
980
|
+
_ts_param7(0, Req4()),
|
|
981
|
+
_ts_param7(1, Param2("id")),
|
|
982
|
+
_ts_param7(2, Body2()),
|
|
983
|
+
_ts_metadata7("design:type", Function),
|
|
984
|
+
_ts_metadata7("design:paramtypes", [
|
|
794
985
|
typeof Request === "undefined" ? Object : Request,
|
|
795
986
|
String,
|
|
796
|
-
typeof
|
|
987
|
+
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
797
988
|
]),
|
|
798
|
-
|
|
799
|
-
], ThreadsController.prototype, "
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
989
|
+
_ts_metadata7("design:returntype", Promise)
|
|
990
|
+
], ThreadsController.prototype, "update", null);
|
|
991
|
+
_ts_decorate7([
|
|
992
|
+
Post3(":id/promote"),
|
|
993
|
+
_ts_param7(0, Req4()),
|
|
994
|
+
_ts_param7(1, Param2("id")),
|
|
995
|
+
_ts_metadata7("design:type", Function),
|
|
996
|
+
_ts_metadata7("design:paramtypes", [
|
|
806
997
|
typeof Request === "undefined" ? Object : Request,
|
|
807
998
|
String
|
|
808
999
|
]),
|
|
809
|
-
|
|
1000
|
+
_ts_metadata7("design:returntype", Promise)
|
|
810
1001
|
], ThreadsController.prototype, "promote", null);
|
|
811
|
-
|
|
1002
|
+
_ts_decorate7([
|
|
812
1003
|
Delete(":id/from/:messageId"),
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
1004
|
+
_ts_param7(0, Req4()),
|
|
1005
|
+
_ts_param7(1, Param2("id")),
|
|
1006
|
+
_ts_param7(2, Param2("messageId")),
|
|
1007
|
+
_ts_metadata7("design:type", Function),
|
|
1008
|
+
_ts_metadata7("design:paramtypes", [
|
|
818
1009
|
typeof Request === "undefined" ? Object : Request,
|
|
819
1010
|
String,
|
|
820
1011
|
String
|
|
821
1012
|
]),
|
|
822
|
-
|
|
1013
|
+
_ts_metadata7("design:returntype", Promise)
|
|
823
1014
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
824
|
-
ThreadsController =
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
1015
|
+
ThreadsController = _ts_decorate7([
|
|
1016
|
+
Controller5("threads"),
|
|
1017
|
+
_ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER4)),
|
|
1018
|
+
_ts_metadata7("design:type", Function),
|
|
1019
|
+
_ts_metadata7("design:paramtypes", [
|
|
829
1020
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
830
1021
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
831
1022
|
])
|
|
832
1023
|
], ThreadsController);
|
|
833
1024
|
|
|
834
1025
|
// src/controller/tool-call.controller.ts
|
|
835
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
836
|
-
import { Body as Body3, Controller as
|
|
837
|
-
function
|
|
1026
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
|
|
1027
|
+
import { Body as Body3, Controller as Controller6, Inject as Inject8, Post as Post4, Req as Req5 } from "@nestjs/common";
|
|
1028
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
838
1029
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
839
1030
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
840
1031
|
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;
|
|
841
1032
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
842
1033
|
}
|
|
843
|
-
__name(
|
|
844
|
-
function
|
|
1034
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1035
|
+
function _ts_metadata8(k, v) {
|
|
845
1036
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
846
1037
|
}
|
|
847
|
-
__name(
|
|
848
|
-
function
|
|
1038
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
1039
|
+
function _ts_param8(paramIndex, decorator) {
|
|
849
1040
|
return function(target, key) {
|
|
850
1041
|
decorator(target, key, paramIndex);
|
|
851
1042
|
};
|
|
852
1043
|
}
|
|
853
|
-
__name(
|
|
1044
|
+
__name(_ts_param8, "_ts_param");
|
|
854
1045
|
var ToolCallController = class {
|
|
855
1046
|
static {
|
|
856
1047
|
__name(this, "ToolCallController");
|
|
@@ -876,33 +1067,33 @@ var ToolCallController = class {
|
|
|
876
1067
|
};
|
|
877
1068
|
}
|
|
878
1069
|
};
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
1070
|
+
_ts_decorate8([
|
|
1071
|
+
Post4("approve"),
|
|
1072
|
+
_ts_param8(0, Req5()),
|
|
1073
|
+
_ts_param8(1, Body3()),
|
|
1074
|
+
_ts_metadata8("design:type", Function),
|
|
1075
|
+
_ts_metadata8("design:paramtypes", [
|
|
885
1076
|
typeof Request === "undefined" ? Object : Request,
|
|
886
1077
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
887
1078
|
]),
|
|
888
|
-
|
|
1079
|
+
_ts_metadata8("design:returntype", Promise)
|
|
889
1080
|
], ToolCallController.prototype, "approve", null);
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1081
|
+
_ts_decorate8([
|
|
1082
|
+
Post4("reject"),
|
|
1083
|
+
_ts_param8(0, Req5()),
|
|
1084
|
+
_ts_param8(1, Body3()),
|
|
1085
|
+
_ts_metadata8("design:type", Function),
|
|
1086
|
+
_ts_metadata8("design:paramtypes", [
|
|
896
1087
|
typeof Request === "undefined" ? Object : Request,
|
|
897
1088
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
898
1089
|
]),
|
|
899
|
-
|
|
1090
|
+
_ts_metadata8("design:returntype", Promise)
|
|
900
1091
|
], ToolCallController.prototype, "reject", null);
|
|
901
|
-
ToolCallController =
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1092
|
+
ToolCallController = _ts_decorate8([
|
|
1093
|
+
Controller6("tool-call"),
|
|
1094
|
+
_ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER5)),
|
|
1095
|
+
_ts_metadata8("design:type", Function),
|
|
1096
|
+
_ts_metadata8("design:paramtypes", [
|
|
906
1097
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
907
1098
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
908
1099
|
])
|
|
@@ -910,7 +1101,7 @@ ToolCallController = _ts_decorate7([
|
|
|
910
1101
|
|
|
911
1102
|
// src/discovery/agent-discovery.service.ts
|
|
912
1103
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
|
|
913
|
-
import { Inject as
|
|
1104
|
+
import { Inject as Inject9, Injectable as Injectable3, Logger } from "@nestjs/common";
|
|
914
1105
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
915
1106
|
|
|
916
1107
|
// src/decorator/agent.decorator.ts
|
|
@@ -945,23 +1136,23 @@ function SystemPromptContributor() {
|
|
|
945
1136
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
946
1137
|
|
|
947
1138
|
// src/discovery/agent-discovery.service.ts
|
|
948
|
-
function
|
|
1139
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
949
1140
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
950
1141
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
951
1142
|
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;
|
|
952
1143
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
953
1144
|
}
|
|
954
|
-
__name(
|
|
955
|
-
function
|
|
1145
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1146
|
+
function _ts_metadata9(k, v) {
|
|
956
1147
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
957
1148
|
}
|
|
958
|
-
__name(
|
|
959
|
-
function
|
|
1149
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1150
|
+
function _ts_param9(paramIndex, decorator) {
|
|
960
1151
|
return function(target, key) {
|
|
961
1152
|
decorator(target, key, paramIndex);
|
|
962
1153
|
};
|
|
963
1154
|
}
|
|
964
|
-
__name(
|
|
1155
|
+
__name(_ts_param9, "_ts_param");
|
|
965
1156
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
966
1157
|
static {
|
|
967
1158
|
__name(this, "AgentDiscoveryService");
|
|
@@ -1058,12 +1249,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
1058
1249
|
return (ctx) => candidate.call(instance, ctx);
|
|
1059
1250
|
}
|
|
1060
1251
|
};
|
|
1061
|
-
AgentDiscoveryService =
|
|
1252
|
+
AgentDiscoveryService = _ts_decorate9([
|
|
1062
1253
|
Injectable3(),
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1254
|
+
_ts_param9(2, Inject9(AGENT_REGISTRY3)),
|
|
1255
|
+
_ts_param9(3, Inject9(AGENT_PROMPT_CONTRIBUTORS2)),
|
|
1256
|
+
_ts_metadata9("design:type", Function),
|
|
1257
|
+
_ts_metadata9("design:paramtypes", [
|
|
1067
1258
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
1068
1259
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
1069
1260
|
typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4,
|
|
@@ -1072,8 +1263,8 @@ AgentDiscoveryService = _ts_decorate8([
|
|
|
1072
1263
|
], AgentDiscoveryService);
|
|
1073
1264
|
|
|
1074
1265
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1075
|
-
import { AGENT_OPTIONS as
|
|
1076
|
-
import { Inject as
|
|
1266
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_REGISTRY as AGENT_REGISTRY4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2 } from "@dudousxd/nestjs-agent-core";
|
|
1267
|
+
import { Inject as Inject10, Injectable as Injectable4, Logger as Logger2 } from "@nestjs/common";
|
|
1077
1268
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
1078
1269
|
import { z } from "zod";
|
|
1079
1270
|
|
|
@@ -1122,23 +1313,23 @@ function provideAgentTool(factoryOrTool, inject) {
|
|
|
1122
1313
|
__name(provideAgentTool, "provideAgentTool");
|
|
1123
1314
|
|
|
1124
1315
|
// src/discovery/ai-tool-discovery.service.ts
|
|
1125
|
-
function
|
|
1316
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1126
1317
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1127
1318
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1128
1319
|
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;
|
|
1129
1320
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1130
1321
|
}
|
|
1131
|
-
__name(
|
|
1132
|
-
function
|
|
1322
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1323
|
+
function _ts_metadata10(k, v) {
|
|
1133
1324
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1134
1325
|
}
|
|
1135
|
-
__name(
|
|
1136
|
-
function
|
|
1326
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1327
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1137
1328
|
return function(target, key) {
|
|
1138
1329
|
decorator(target, key, paramIndex);
|
|
1139
1330
|
};
|
|
1140
1331
|
}
|
|
1141
|
-
__name(
|
|
1332
|
+
__name(_ts_param10, "_ts_param");
|
|
1142
1333
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
1143
1334
|
static {
|
|
1144
1335
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -1245,13 +1436,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
1245
1436
|
return true;
|
|
1246
1437
|
}
|
|
1247
1438
|
};
|
|
1248
|
-
AiToolDiscoveryService =
|
|
1439
|
+
AiToolDiscoveryService = _ts_decorate10([
|
|
1249
1440
|
Injectable4(),
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1441
|
+
_ts_param10(1, Inject10(AGENT_TOOL_REGISTRY2)),
|
|
1442
|
+
_ts_param10(2, Inject10(AGENT_REGISTRY4)),
|
|
1443
|
+
_ts_param10(3, Inject10(AGENT_OPTIONS3)),
|
|
1444
|
+
_ts_metadata10("design:type", Function),
|
|
1445
|
+
_ts_metadata10("design:paramtypes", [
|
|
1255
1446
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
1256
1447
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
1257
1448
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -1352,24 +1543,24 @@ var LedgerQuotaStore = class {
|
|
|
1352
1543
|
|
|
1353
1544
|
// src/runner/inline-agent-runner.ts
|
|
1354
1545
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_STORE as AGENT_STORE3, QuotaExceededError, publishAgentRunFailed, runAgentLoop } from "@dudousxd/nestjs-agent-core";
|
|
1355
|
-
import { Inject as
|
|
1356
|
-
function
|
|
1546
|
+
import { Inject as Inject11, Injectable as Injectable5, Logger as Logger3 } from "@nestjs/common";
|
|
1547
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1357
1548
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1358
1549
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1359
1550
|
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;
|
|
1360
1551
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1361
1552
|
}
|
|
1362
|
-
__name(
|
|
1363
|
-
function
|
|
1553
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1554
|
+
function _ts_metadata11(k, v) {
|
|
1364
1555
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1365
1556
|
}
|
|
1366
|
-
__name(
|
|
1367
|
-
function
|
|
1557
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1558
|
+
function _ts_param11(paramIndex, decorator) {
|
|
1368
1559
|
return function(target, key) {
|
|
1369
1560
|
decorator(target, key, paramIndex);
|
|
1370
1561
|
};
|
|
1371
1562
|
}
|
|
1372
|
-
__name(
|
|
1563
|
+
__name(_ts_param11, "_ts_param");
|
|
1373
1564
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
1374
1565
|
static {
|
|
1375
1566
|
__name(this, "InlineAgentRunner");
|
|
@@ -1390,7 +1581,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1390
1581
|
void runAgentLoop({
|
|
1391
1582
|
...deps,
|
|
1392
1583
|
day
|
|
1393
|
-
}, input, hooks).catch(async (error) => {
|
|
1584
|
+
}, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
|
|
1394
1585
|
const message = error instanceof Error ? error.message : String(error);
|
|
1395
1586
|
const code = error instanceof QuotaExceededError ? "quota_exceeded" : "run_failed";
|
|
1396
1587
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
@@ -1399,6 +1590,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1399
1590
|
code,
|
|
1400
1591
|
message
|
|
1401
1592
|
});
|
|
1593
|
+
await this.store.setActiveStream(input.threadId, null);
|
|
1402
1594
|
const writer = await deps.sink.open(runId);
|
|
1403
1595
|
await writer.fail({
|
|
1404
1596
|
code,
|
|
@@ -1456,39 +1648,43 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
1456
1648
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
1457
1649
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested(childName, childTask, actor, day, depth + 1, sinkRunId), "runAgent")
|
|
1458
1650
|
};
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1651
|
+
try {
|
|
1652
|
+
return await runAgentLoop({
|
|
1653
|
+
...deps,
|
|
1654
|
+
day
|
|
1655
|
+
}, {
|
|
1656
|
+
threadId: subThread.id,
|
|
1657
|
+
actor,
|
|
1658
|
+
userText: task,
|
|
1659
|
+
agentName,
|
|
1660
|
+
day,
|
|
1661
|
+
delegationDepth: depth,
|
|
1662
|
+
sinkRunId
|
|
1663
|
+
}, hooks);
|
|
1664
|
+
} finally {
|
|
1665
|
+
await this.store.setActiveStream(subThread.id, null);
|
|
1666
|
+
}
|
|
1471
1667
|
}
|
|
1472
1668
|
};
|
|
1473
|
-
InlineAgentRunner =
|
|
1669
|
+
InlineAgentRunner = _ts_decorate11([
|
|
1474
1670
|
Injectable5(),
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1671
|
+
_ts_param11(0, Inject11(AGENT_DEPS_FACTORY3)),
|
|
1672
|
+
_ts_param11(1, Inject11(AGENT_STORE3)),
|
|
1673
|
+
_ts_metadata11("design:type", Function),
|
|
1674
|
+
_ts_metadata11("design:paramtypes", [
|
|
1479
1675
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1480
1676
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
1481
1677
|
])
|
|
1482
1678
|
], InlineAgentRunner);
|
|
1483
1679
|
|
|
1484
1680
|
// src/agent.module.ts
|
|
1485
|
-
function
|
|
1681
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1486
1682
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1487
1683
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1488
1684
|
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;
|
|
1489
1685
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1490
1686
|
}
|
|
1491
|
-
__name(
|
|
1687
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1492
1688
|
var DEFAULT_PATH = "agent";
|
|
1493
1689
|
function sharedProviders(durable, includeStore) {
|
|
1494
1690
|
const providers = [
|
|
@@ -1510,28 +1706,28 @@ function sharedProviders(durable, includeStore) {
|
|
|
1510
1706
|
provide: AGENT_SINK2,
|
|
1511
1707
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
1512
1708
|
inject: [
|
|
1513
|
-
|
|
1709
|
+
AGENT_OPTIONS4
|
|
1514
1710
|
]
|
|
1515
1711
|
},
|
|
1516
1712
|
{
|
|
1517
1713
|
provide: AGENT_ROLES_POLICY2,
|
|
1518
1714
|
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
1519
1715
|
inject: [
|
|
1520
|
-
|
|
1716
|
+
AGENT_OPTIONS4
|
|
1521
1717
|
]
|
|
1522
1718
|
},
|
|
1523
1719
|
{
|
|
1524
|
-
provide:
|
|
1720
|
+
provide: AGENT_ACTOR_RESOLVER6,
|
|
1525
1721
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
1526
1722
|
inject: [
|
|
1527
|
-
|
|
1723
|
+
AGENT_OPTIONS4
|
|
1528
1724
|
]
|
|
1529
1725
|
},
|
|
1530
1726
|
{
|
|
1531
1727
|
provide: AGENT_MODEL2,
|
|
1532
1728
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
1533
1729
|
inject: [
|
|
1534
|
-
|
|
1730
|
+
AGENT_OPTIONS4
|
|
1535
1731
|
]
|
|
1536
1732
|
},
|
|
1537
1733
|
{
|
|
@@ -1541,7 +1737,7 @@ function sharedProviders(durable, includeStore) {
|
|
|
1541
1737
|
provide: AGENT_QUOTA_STORE3,
|
|
1542
1738
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
1543
1739
|
inject: [
|
|
1544
|
-
|
|
1740
|
+
AGENT_OPTIONS4,
|
|
1545
1741
|
AGENT_STORE4
|
|
1546
1742
|
]
|
|
1547
1743
|
},
|
|
@@ -1562,7 +1758,7 @@ function sharedProviders(durable, includeStore) {
|
|
|
1562
1758
|
provide: AGENT_STORE4,
|
|
1563
1759
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
1564
1760
|
inject: [
|
|
1565
|
-
|
|
1761
|
+
AGENT_OPTIONS4
|
|
1566
1762
|
]
|
|
1567
1763
|
});
|
|
1568
1764
|
}
|
|
@@ -1593,12 +1789,12 @@ function sharedProviders(durable, includeStore) {
|
|
|
1593
1789
|
__name(sharedProviders, "sharedProviders");
|
|
1594
1790
|
function exportsFor(includeStore) {
|
|
1595
1791
|
return [
|
|
1596
|
-
|
|
1792
|
+
AGENT_OPTIONS4,
|
|
1597
1793
|
AGENT_TOOL_REGISTRY3,
|
|
1598
1794
|
AGENT_REGISTRY5,
|
|
1599
1795
|
AGENT_SINK2,
|
|
1600
1796
|
AGENT_ROLES_POLICY2,
|
|
1601
|
-
|
|
1797
|
+
AGENT_ACTOR_RESOLVER6,
|
|
1602
1798
|
AGENT_MODEL2,
|
|
1603
1799
|
...includeStore ? [
|
|
1604
1800
|
AGENT_STORE4
|
|
@@ -1612,13 +1808,38 @@ function exportsFor(includeStore) {
|
|
|
1612
1808
|
];
|
|
1613
1809
|
}
|
|
1614
1810
|
__name(exportsFor, "exportsFor");
|
|
1615
|
-
var
|
|
1811
|
+
var BASE_CONTROLLERS = [
|
|
1616
1812
|
ChatController,
|
|
1617
1813
|
ThreadsController,
|
|
1618
1814
|
ToolCallController,
|
|
1619
1815
|
QuotaController,
|
|
1620
1816
|
AgentsController
|
|
1621
1817
|
];
|
|
1818
|
+
var GUARDABLE_CONTROLLERS = [
|
|
1819
|
+
...BASE_CONTROLLERS,
|
|
1820
|
+
AttachmentsController
|
|
1821
|
+
];
|
|
1822
|
+
function controllersFor(mountAttachments) {
|
|
1823
|
+
return mountAttachments ? [
|
|
1824
|
+
...BASE_CONTROLLERS,
|
|
1825
|
+
AttachmentsController
|
|
1826
|
+
] : BASE_CONTROLLERS;
|
|
1827
|
+
}
|
|
1828
|
+
__name(controllersFor, "controllersFor");
|
|
1829
|
+
var GUARDS_METADATA = "__guards__";
|
|
1830
|
+
function applyGuards(guards) {
|
|
1831
|
+
const resolved = guards ?? [];
|
|
1832
|
+
for (const controller of GUARDABLE_CONTROLLERS) {
|
|
1833
|
+
Reflect.defineMetadata(GUARDS_METADATA, resolved, controller);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
__name(applyGuards, "applyGuards");
|
|
1837
|
+
function guardProviders(guards) {
|
|
1838
|
+
return [
|
|
1839
|
+
...new Set(guards ?? [])
|
|
1840
|
+
];
|
|
1841
|
+
}
|
|
1842
|
+
__name(guardProviders, "guardProviders");
|
|
1622
1843
|
function routerFor(path) {
|
|
1623
1844
|
return RouterModule.register([
|
|
1624
1845
|
{
|
|
@@ -1635,6 +1856,7 @@ var AgentModule = class _AgentModule {
|
|
|
1635
1856
|
static forRoot(options) {
|
|
1636
1857
|
const path = options.path ?? DEFAULT_PATH;
|
|
1637
1858
|
const includeStore = options.store !== void 0;
|
|
1859
|
+
applyGuards(options.guards);
|
|
1638
1860
|
return {
|
|
1639
1861
|
module: _AgentModule,
|
|
1640
1862
|
global: true,
|
|
@@ -1642,13 +1864,14 @@ var AgentModule = class _AgentModule {
|
|
|
1642
1864
|
DiscoveryModule,
|
|
1643
1865
|
routerFor(path)
|
|
1644
1866
|
],
|
|
1645
|
-
controllers:
|
|
1867
|
+
controllers: controllersFor(options.attachments?.upload === true),
|
|
1646
1868
|
providers: [
|
|
1647
1869
|
{
|
|
1648
|
-
provide:
|
|
1870
|
+
provide: AGENT_OPTIONS4,
|
|
1649
1871
|
useValue: options
|
|
1650
1872
|
},
|
|
1651
|
-
...sharedProviders(options.durable ?? false, includeStore)
|
|
1873
|
+
...sharedProviders(options.durable ?? false, includeStore),
|
|
1874
|
+
...guardProviders(options.guards)
|
|
1652
1875
|
],
|
|
1653
1876
|
exports: exportsFor(includeStore)
|
|
1654
1877
|
};
|
|
@@ -1656,6 +1879,7 @@ var AgentModule = class _AgentModule {
|
|
|
1656
1879
|
static forRootAsync(options) {
|
|
1657
1880
|
const path = options.path ?? DEFAULT_PATH;
|
|
1658
1881
|
const includeStore = options.externalStore !== true;
|
|
1882
|
+
applyGuards(options.guards);
|
|
1659
1883
|
return {
|
|
1660
1884
|
module: _AgentModule,
|
|
1661
1885
|
global: true,
|
|
@@ -1664,20 +1888,21 @@ var AgentModule = class _AgentModule {
|
|
|
1664
1888
|
routerFor(path),
|
|
1665
1889
|
...options.imports ?? []
|
|
1666
1890
|
],
|
|
1667
|
-
controllers:
|
|
1891
|
+
controllers: controllersFor(options.attachmentsUpload === true),
|
|
1668
1892
|
providers: [
|
|
1669
1893
|
{
|
|
1670
|
-
provide:
|
|
1894
|
+
provide: AGENT_OPTIONS4,
|
|
1671
1895
|
useFactory: options.useFactory,
|
|
1672
1896
|
inject: options.inject ?? []
|
|
1673
1897
|
},
|
|
1674
|
-
...sharedProviders(options.durable ?? false, includeStore)
|
|
1898
|
+
...sharedProviders(options.durable ?? false, includeStore),
|
|
1899
|
+
...guardProviders(options.guards)
|
|
1675
1900
|
],
|
|
1676
1901
|
exports: exportsFor(includeStore)
|
|
1677
1902
|
};
|
|
1678
1903
|
}
|
|
1679
1904
|
};
|
|
1680
|
-
AgentModule =
|
|
1905
|
+
AgentModule = _ts_decorate12([
|
|
1681
1906
|
Global(),
|
|
1682
1907
|
Module({})
|
|
1683
1908
|
], AgentModule);
|
|
@@ -1725,6 +1950,9 @@ export {
|
|
|
1725
1950
|
AgentService,
|
|
1726
1951
|
AiTool,
|
|
1727
1952
|
AiToolDiscoveryService,
|
|
1953
|
+
AttachmentsController,
|
|
1954
|
+
DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
|
|
1955
|
+
DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
1728
1956
|
HeaderActorResolver,
|
|
1729
1957
|
InProcessTokenStreamSink,
|
|
1730
1958
|
InlineAgentRunner,
|