@dudousxd/nestjs-agent 1.11.0 → 1.12.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/README.md +21 -14
- package/dist/{agent-deps.factory-BRTBu0lV.d.cts → agent-deps.factory-pqv_qTmJ.d.cts} +22 -50
- package/dist/{agent-deps.factory-BRTBu0lV.d.ts → agent-deps.factory-pqv_qTmJ.d.ts} +22 -50
- package/dist/durable/index.cjs +669 -654
- 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 +569 -554
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +682 -663
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -47
- package/dist/index.d.ts +40 -47
- package/dist/index.js +570 -553
- package/dist/index.js.map +1 -1
- package/dist/media/index.cjs +11 -2
- package/dist/media/index.cjs.map +1 -1
- package/dist/media/index.d.cts +5 -1
- package/dist/media/index.d.ts +5 -1
- package/dist/media/index.js +11 -2
- package/dist/media/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -36,13 +36,14 @@ __export(index_exports, {
|
|
|
36
36
|
AiToolDiscoveryService: () => AiToolDiscoveryService,
|
|
37
37
|
AnonymousActorResolver: () => AnonymousActorResolver,
|
|
38
38
|
AttachmentsController: () => AttachmentsController,
|
|
39
|
+
ConfigController: () => ConfigController,
|
|
39
40
|
DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES: () => DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
|
|
40
41
|
DEFAULT_MAX_ATTACHMENT_BYTES: () => DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
41
42
|
HeaderActorResolver: () => HeaderActorResolver,
|
|
42
43
|
InProcessTokenStreamSink: () => InProcessTokenStreamSink,
|
|
43
44
|
InlineAgentRunner: () => InlineAgentRunner,
|
|
44
45
|
LedgerQuotaProvider: () => LedgerQuotaProvider,
|
|
45
|
-
|
|
46
|
+
MAX_ATTACHMENTS_PER_MESSAGE: () => MAX_ATTACHMENTS_PER_MESSAGE,
|
|
46
47
|
MemoriesController: () => MemoriesController,
|
|
47
48
|
MessagesController: () => MessagesController,
|
|
48
49
|
ModelsController: () => ModelsController,
|
|
@@ -55,6 +56,7 @@ __export(index_exports, {
|
|
|
55
56
|
SystemPrompt: () => SystemPrompt,
|
|
56
57
|
SystemPromptContributor: () => SystemPromptContributor,
|
|
57
58
|
ToolsController: () => ToolsController,
|
|
59
|
+
attachmentLimits: () => attachmentLimits,
|
|
58
60
|
declaredSkillProvider: () => declaredSkillProvider,
|
|
59
61
|
defaultRequestUserMapper: () => defaultRequestUserMapper,
|
|
60
62
|
delegateToolName: () => delegateToolName,
|
|
@@ -72,8 +74,8 @@ __export(index_exports, {
|
|
|
72
74
|
module.exports = __toCommonJS(index_exports);
|
|
73
75
|
|
|
74
76
|
// src/agent.module.ts
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
78
|
+
var import_common20 = require("@nestjs/common");
|
|
77
79
|
var import_core4 = require("@nestjs/core");
|
|
78
80
|
|
|
79
81
|
// src/agent-deps.factory.ts
|
|
@@ -123,11 +125,10 @@ var AgentDepsFactory2 = class {
|
|
|
123
125
|
registry;
|
|
124
126
|
agents;
|
|
125
127
|
promptContributors;
|
|
126
|
-
quota;
|
|
127
128
|
pricingStore;
|
|
128
129
|
skills;
|
|
129
130
|
memory;
|
|
130
|
-
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors,
|
|
131
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory) {
|
|
131
132
|
this.options = options;
|
|
132
133
|
this.model = model;
|
|
133
134
|
this.store = store;
|
|
@@ -136,7 +137,6 @@ var AgentDepsFactory2 = class {
|
|
|
136
137
|
this.registry = registry;
|
|
137
138
|
this.agents = agents;
|
|
138
139
|
this.promptContributors = promptContributors;
|
|
139
|
-
this.quota = quota;
|
|
140
140
|
this.pricingStore = pricingStore;
|
|
141
141
|
this.skills = skills;
|
|
142
142
|
this.memory = memory;
|
|
@@ -208,9 +208,6 @@ var AgentDepsFactory2 = class {
|
|
|
208
208
|
...definition?.modelId !== void 0 ? {
|
|
209
209
|
modelId: definition.modelId
|
|
210
210
|
} : {},
|
|
211
|
-
...this.quota !== void 0 ? {
|
|
212
|
-
quota: this.quota
|
|
213
|
-
} : {},
|
|
214
211
|
...this.pricingStore !== void 0 ? {
|
|
215
212
|
pricingStore: this.pricingStore
|
|
216
213
|
} : {},
|
|
@@ -317,13 +314,12 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
317
314
|
_ts_param(5, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_TOOL_REGISTRY)),
|
|
318
315
|
_ts_param(6, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_REGISTRY)),
|
|
319
316
|
_ts_param(7, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_PROMPT_CONTRIBUTORS)),
|
|
320
|
-
_ts_param(8, (0, import_common.
|
|
317
|
+
_ts_param(8, (0, import_common.Optional)()),
|
|
318
|
+
_ts_param(8, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_PRICING_STORE)),
|
|
321
319
|
_ts_param(9, (0, import_common.Optional)()),
|
|
322
|
-
_ts_param(9, (0, import_common.Inject)(import_nestjs_agent_core.
|
|
320
|
+
_ts_param(9, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_SKILLS)),
|
|
323
321
|
_ts_param(10, (0, import_common.Optional)()),
|
|
324
|
-
_ts_param(10, (0, import_common.Inject)(import_nestjs_agent_core.
|
|
325
|
-
_ts_param(11, (0, import_common.Optional)()),
|
|
326
|
-
_ts_param(11, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_MEMORY)),
|
|
322
|
+
_ts_param(10, (0, import_common.Inject)(import_nestjs_agent_core.AGENT_MEMORY)),
|
|
327
323
|
_ts_metadata("design:type", Function),
|
|
328
324
|
_ts_metadata("design:paramtypes", [
|
|
329
325
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -336,7 +332,6 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
336
332
|
Array,
|
|
337
333
|
Object,
|
|
338
334
|
Object,
|
|
339
|
-
Object,
|
|
340
335
|
Object
|
|
341
336
|
])
|
|
342
337
|
], AgentDepsFactory2);
|
|
@@ -395,16 +390,14 @@ var AgentService = class {
|
|
|
395
390
|
runner;
|
|
396
391
|
store;
|
|
397
392
|
deps;
|
|
398
|
-
quota;
|
|
399
393
|
staging;
|
|
400
394
|
models;
|
|
401
395
|
quotaProvider;
|
|
402
396
|
options;
|
|
403
|
-
constructor(runner, store, deps,
|
|
397
|
+
constructor(runner, store, deps, staging, models, quotaProvider, options) {
|
|
404
398
|
this.runner = runner;
|
|
405
399
|
this.store = store;
|
|
406
400
|
this.deps = deps;
|
|
407
|
-
this.quota = quota;
|
|
408
401
|
this.staging = staging;
|
|
409
402
|
this.models = models;
|
|
410
403
|
this.quotaProvider = quotaProvider;
|
|
@@ -420,33 +413,23 @@ var AgentService = class {
|
|
|
420
413
|
actor
|
|
421
414
|
});
|
|
422
415
|
}
|
|
423
|
-
const
|
|
416
|
+
const { usedTokens, costUsd } = await this.store.quotaToday(actor.id, utcDay());
|
|
424
417
|
return {
|
|
425
418
|
windows: [
|
|
426
419
|
{
|
|
427
420
|
period: "day",
|
|
428
|
-
usedTokens
|
|
429
|
-
|
|
430
|
-
limitTokens: today.limitTokens
|
|
431
|
-
} : {},
|
|
432
|
-
usedUsd: today.costUsd
|
|
433
|
-
}
|
|
434
|
-
],
|
|
435
|
-
...today.withinLimit ? {} : {
|
|
436
|
-
blocked: {
|
|
437
|
-
period: "day"
|
|
421
|
+
usedTokens,
|
|
422
|
+
usedUsd: costUsd
|
|
438
423
|
}
|
|
439
|
-
|
|
424
|
+
]
|
|
440
425
|
};
|
|
441
426
|
}
|
|
442
427
|
/**
|
|
443
428
|
* Refuse a turn the actor's budget no longer covers — only when the host configured one
|
|
444
|
-
* (`
|
|
445
|
-
* quota the loop enforces keeps working as it always has.
|
|
429
|
+
* (`quota`): the default report is informational.
|
|
446
430
|
*/
|
|
447
431
|
async assertWithinQuota(actor) {
|
|
448
|
-
|
|
449
|
-
if (!gated || this.quotaProvider === void 0) {
|
|
432
|
+
if (this.options?.quota === void 0 || this.quotaProvider === void 0) {
|
|
450
433
|
return;
|
|
451
434
|
}
|
|
452
435
|
const { blocked } = await this.quotaProvider.report({
|
|
@@ -697,7 +680,7 @@ var AgentService = class {
|
|
|
697
680
|
async getThread(actor, threadId) {
|
|
698
681
|
await this.assertOwnsThread(actor, threadId);
|
|
699
682
|
const thread = await this.store.getThread(threadId);
|
|
700
|
-
return thread === null ? null : this.toDetailView(thread);
|
|
683
|
+
return thread === null ? null : this.toDetailView(thread, actor);
|
|
701
684
|
}
|
|
702
685
|
async deleteThread(actor, threadId) {
|
|
703
686
|
await this.assertOwnsThread(actor, threadId);
|
|
@@ -789,19 +772,46 @@ var AgentService = class {
|
|
|
789
772
|
...thread,
|
|
790
773
|
defaultAgent: thread.defaultAgent ?? null,
|
|
791
774
|
model: thread.model ?? null,
|
|
792
|
-
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
|
|
775
|
+
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? thread.activeRunId ?? null
|
|
793
776
|
};
|
|
794
777
|
}
|
|
795
|
-
async toDetailView(thread) {
|
|
778
|
+
async toDetailView(thread, actor) {
|
|
796
779
|
const summary = await this.toSummaryView(thread);
|
|
797
780
|
return {
|
|
798
781
|
...summary,
|
|
799
|
-
messages: thread.messages,
|
|
800
|
-
...thread.activeStreamId !== void 0 ? {
|
|
801
|
-
activeStreamId: thread.activeStreamId
|
|
802
|
-
} : {}
|
|
782
|
+
messages: await this.freshAttachmentUrls(thread.messages, actor)
|
|
803
783
|
};
|
|
804
784
|
}
|
|
785
|
+
/**
|
|
786
|
+
* Re-mint each replayed attachment's url from the staging store, by `mediaId`: the url persisted
|
|
787
|
+
* with the message was minted for THAT turn (a presigned url with an expiry), so an old turn would
|
|
788
|
+
* otherwise show a dead link. The store's own access check applies — an attachment it will not
|
|
789
|
+
* resolve for this actor keeps the url it was stored with.
|
|
790
|
+
*/
|
|
791
|
+
async freshAttachmentUrls(messages, actor) {
|
|
792
|
+
const staging = this.staging;
|
|
793
|
+
if (staging === void 0 || !messages.some((message) => message.attachments?.length)) {
|
|
794
|
+
return messages;
|
|
795
|
+
}
|
|
796
|
+
return Promise.all(messages.map(async (message) => {
|
|
797
|
+
if (message.attachments === void 0 || message.attachments.length === 0) return message;
|
|
798
|
+
const attachments = await Promise.all(message.attachments.map(async (attachment) => {
|
|
799
|
+
try {
|
|
800
|
+
const fresh = await staging.resolve({
|
|
801
|
+
mediaId: attachment.mediaId,
|
|
802
|
+
actor
|
|
803
|
+
});
|
|
804
|
+
return fresh ?? attachment;
|
|
805
|
+
} catch {
|
|
806
|
+
return attachment;
|
|
807
|
+
}
|
|
808
|
+
}));
|
|
809
|
+
return {
|
|
810
|
+
...message,
|
|
811
|
+
attachments
|
|
812
|
+
};
|
|
813
|
+
}));
|
|
814
|
+
}
|
|
805
815
|
async promoteThread(actor, threadId) {
|
|
806
816
|
await this.assertOwnsThread(actor, threadId);
|
|
807
817
|
return this.store.promoteThread(threadId);
|
|
@@ -911,30 +921,6 @@ var AgentService = class {
|
|
|
911
921
|
return list;
|
|
912
922
|
}
|
|
913
923
|
/**
|
|
914
|
-
* The day's usage for the badge: tokens + summed USD cost from the store, and the configured
|
|
915
|
-
* limit from the quota store (null → unlimited). `withinLimit` comes from the quota store so it
|
|
916
|
-
* can never drift from what enforcement uses.
|
|
917
|
-
*/
|
|
918
|
-
async quotaToday(actorRef) {
|
|
919
|
-
const day = utcDay();
|
|
920
|
-
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, day);
|
|
921
|
-
if (this.quota === void 0) {
|
|
922
|
-
return {
|
|
923
|
-
usedTokens,
|
|
924
|
-
costUsd,
|
|
925
|
-
limitTokens: null,
|
|
926
|
-
withinLimit: true
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
|
-
const state = await this.quota.check(actorRef, day);
|
|
930
|
-
return {
|
|
931
|
-
usedTokens: state.usedTokens,
|
|
932
|
-
costUsd,
|
|
933
|
-
limitTokens: state.limitTokens,
|
|
934
|
-
withinLimit: state.withinLimit
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
/**
|
|
938
924
|
* Authorization seam for thread-scoped endpoints: the caller must own the thread. A missing
|
|
939
925
|
* thread is a 404; someone else's thread is a 403 — one actor never touches another's thread.
|
|
940
926
|
*/
|
|
@@ -1053,21 +1039,19 @@ AgentService = _ts_decorate2([
|
|
|
1053
1039
|
_ts_param2(0, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_RUNNER)),
|
|
1054
1040
|
_ts_param2(1, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_STORE)),
|
|
1055
1041
|
_ts_param2(2, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_DEPS_FACTORY)),
|
|
1056
|
-
_ts_param2(3, (0, import_common2.
|
|
1042
|
+
_ts_param2(3, (0, import_common2.Optional)()),
|
|
1043
|
+
_ts_param2(3, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_ATTACHMENT_STAGING)),
|
|
1057
1044
|
_ts_param2(4, (0, import_common2.Optional)()),
|
|
1058
|
-
_ts_param2(4, (0, import_common2.Inject)(import_nestjs_agent_core3.
|
|
1045
|
+
_ts_param2(4, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_MODEL_CATALOG)),
|
|
1059
1046
|
_ts_param2(5, (0, import_common2.Optional)()),
|
|
1060
|
-
_ts_param2(5, (0, import_common2.Inject)(import_nestjs_agent_core3.
|
|
1047
|
+
_ts_param2(5, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_QUOTA_PROVIDER)),
|
|
1061
1048
|
_ts_param2(6, (0, import_common2.Optional)()),
|
|
1062
|
-
_ts_param2(6, (0, import_common2.Inject)(import_nestjs_agent_core3.
|
|
1063
|
-
_ts_param2(7, (0, import_common2.Optional)()),
|
|
1064
|
-
_ts_param2(7, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_OPTIONS)),
|
|
1049
|
+
_ts_param2(6, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_OPTIONS)),
|
|
1065
1050
|
_ts_metadata2("design:type", Function),
|
|
1066
1051
|
_ts_metadata2("design:paramtypes", [
|
|
1067
1052
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
1068
1053
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1069
1054
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1070
|
-
Object,
|
|
1071
1055
|
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
1072
1056
|
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
1073
1057
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
@@ -1213,6 +1197,33 @@ AgentsController = _ts_decorate4([
|
|
|
1213
1197
|
var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
|
|
1214
1198
|
var import_common5 = require("@nestjs/common");
|
|
1215
1199
|
var import_platform_express = require("@nestjs/platform-express");
|
|
1200
|
+
|
|
1201
|
+
// src/attachment-limits.ts
|
|
1202
|
+
var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
1203
|
+
var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
|
|
1204
|
+
"image/png",
|
|
1205
|
+
"image/jpeg",
|
|
1206
|
+
"image/gif",
|
|
1207
|
+
"image/webp",
|
|
1208
|
+
"application/pdf",
|
|
1209
|
+
"text/plain",
|
|
1210
|
+
"text/csv"
|
|
1211
|
+
];
|
|
1212
|
+
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
1213
|
+
function attachmentLimits(options, staging) {
|
|
1214
|
+
const declared = staging?.describe?.();
|
|
1215
|
+
const own = options?.attachments;
|
|
1216
|
+
return {
|
|
1217
|
+
enabled: staging !== void 0,
|
|
1218
|
+
upload: staging === void 0 ? null : declared?.upload ?? "multipart",
|
|
1219
|
+
maxBytes: declared?.maxBytes ?? own?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
1220
|
+
allowedContentTypes: declared?.allowedContentTypes ?? own?.allowedContentTypes ?? DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
|
|
1221
|
+
maxPerMessage: MAX_ATTACHMENTS_PER_MESSAGE
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
__name(attachmentLimits, "attachmentLimits");
|
|
1225
|
+
|
|
1226
|
+
// src/controller/attachments.controller.ts
|
|
1216
1227
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1217
1228
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1218
1229
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1239,18 +1250,8 @@ function _ts_param4(paramIndex, decorator) {
|
|
|
1239
1250
|
};
|
|
1240
1251
|
}
|
|
1241
1252
|
__name(_ts_param4, "_ts_param");
|
|
1242
|
-
var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
1243
1253
|
var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
1244
1254
|
var ATTACHMENT_PAGE_SIZE = 50;
|
|
1245
|
-
var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
|
|
1246
|
-
"image/png",
|
|
1247
|
-
"image/jpeg",
|
|
1248
|
-
"image/gif",
|
|
1249
|
-
"image/webp",
|
|
1250
|
-
"application/pdf",
|
|
1251
|
-
"text/plain",
|
|
1252
|
-
"text/csv"
|
|
1253
|
-
];
|
|
1254
1255
|
var AttachmentsController = class {
|
|
1255
1256
|
static {
|
|
1256
1257
|
__name(this, "AttachmentsController");
|
|
@@ -1266,17 +1267,6 @@ var AttachmentsController = class {
|
|
|
1266
1267
|
this.staging = staging;
|
|
1267
1268
|
}
|
|
1268
1269
|
/**
|
|
1269
|
-
* `attachments.upload: true` is what mounts this controller at all (see `agent.module.ts`), so by
|
|
1270
|
-
* the time an instance exists the host clearly intends uploads to work. Fail boot loudly rather
|
|
1271
|
-
* than mounting a controller that would 501 on every single request because nobody bound
|
|
1272
|
-
* `AGENT_ATTACHMENT_STAGING`.
|
|
1273
|
-
*/
|
|
1274
|
-
onModuleInit() {
|
|
1275
|
-
if (this.options.attachments?.upload === true && this.staging === void 0) {
|
|
1276
|
-
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.");
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
/**
|
|
1280
1270
|
* The caller's own staged files, newest first — the one question `GET /agent/threads/:id` cannot
|
|
1281
1271
|
* answer, since an upload that was never sent belongs to no thread.
|
|
1282
1272
|
*
|
|
@@ -1293,16 +1283,15 @@ var AttachmentsController = class {
|
|
|
1293
1283
|
}
|
|
1294
1284
|
async upload(req, file) {
|
|
1295
1285
|
if (this.staging === void 0) {
|
|
1296
|
-
throw new import_common5.NotImplementedException("Attachment upload is not configured on this server.");
|
|
1286
|
+
throw new import_common5.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
1297
1287
|
}
|
|
1298
1288
|
if (file === void 0) {
|
|
1299
1289
|
throw new import_common5.BadRequestException('multipart field "file" is required');
|
|
1300
1290
|
}
|
|
1301
|
-
const allowedContentTypes = this.options.
|
|
1291
|
+
const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
|
|
1302
1292
|
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
1303
1293
|
throw new import_common5.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
1304
1294
|
}
|
|
1305
|
-
const maxBytes = this.options.attachments?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES;
|
|
1306
1295
|
if (file.size > maxBytes) {
|
|
1307
1296
|
throw new import_common5.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
1308
1297
|
}
|
|
@@ -1385,7 +1374,6 @@ function _ts_param5(paramIndex, decorator) {
|
|
|
1385
1374
|
};
|
|
1386
1375
|
}
|
|
1387
1376
|
__name(_ts_param5, "_ts_param");
|
|
1388
|
-
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
1389
1377
|
function attachmentRefs(claimed) {
|
|
1390
1378
|
if (claimed === void 0) {
|
|
1391
1379
|
return [];
|
|
@@ -1400,6 +1388,9 @@ function attachmentRefs(claimed) {
|
|
|
1400
1388
|
if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
|
|
1401
1389
|
throw new import_common6.BadRequestException("each attachment must be an object with a mediaId");
|
|
1402
1390
|
}
|
|
1391
|
+
if (Object.keys(entry).some((key) => key !== "mediaId")) {
|
|
1392
|
+
throw new import_common6.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
|
|
1393
|
+
}
|
|
1403
1394
|
const { mediaId } = entry;
|
|
1404
1395
|
if (typeof mediaId !== "string" || mediaId.length === 0) {
|
|
1405
1396
|
throw new import_common6.BadRequestException("each attachment must carry a non-empty string mediaId");
|
|
@@ -1595,9 +1586,98 @@ function parseCursor(raw) {
|
|
|
1595
1586
|
}
|
|
1596
1587
|
__name(parseCursor, "parseCursor");
|
|
1597
1588
|
|
|
1598
|
-
// src/controller/
|
|
1589
|
+
// src/controller/config.controller.ts
|
|
1599
1590
|
var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
|
|
1600
1591
|
var import_common7 = require("@nestjs/common");
|
|
1592
|
+
|
|
1593
|
+
// src/resolver/anonymous-actor-resolver.ts
|
|
1594
|
+
var import_node_crypto = require("crypto");
|
|
1595
|
+
var TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
1596
|
+
var MINTED = /* @__PURE__ */ Symbol("nestjs-agent:anonymous-token");
|
|
1597
|
+
function readCookie(req, name) {
|
|
1598
|
+
const header = req.headers?.cookie;
|
|
1599
|
+
const raw = Array.isArray(header) ? header.join("; ") : header;
|
|
1600
|
+
if (raw === void 0) return void 0;
|
|
1601
|
+
for (const pair of raw.split(";")) {
|
|
1602
|
+
const index = pair.indexOf("=");
|
|
1603
|
+
if (index === -1) continue;
|
|
1604
|
+
if (pair.slice(0, index).trim() === name) {
|
|
1605
|
+
try {
|
|
1606
|
+
return decodeURIComponent(pair.slice(index + 1).trim());
|
|
1607
|
+
} catch {
|
|
1608
|
+
return void 0;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
return void 0;
|
|
1613
|
+
}
|
|
1614
|
+
__name(readCookie, "readCookie");
|
|
1615
|
+
function isHttps(req) {
|
|
1616
|
+
if (req.secure === true) return true;
|
|
1617
|
+
const forwarded = req.headers?.["x-forwarded-proto"];
|
|
1618
|
+
const proto = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
1619
|
+
return proto?.split(",")[0]?.trim() === "https";
|
|
1620
|
+
}
|
|
1621
|
+
__name(isHttps, "isHttps");
|
|
1622
|
+
var AnonymousActorResolver = class {
|
|
1623
|
+
static {
|
|
1624
|
+
__name(this, "AnonymousActorResolver");
|
|
1625
|
+
}
|
|
1626
|
+
options;
|
|
1627
|
+
cookieName;
|
|
1628
|
+
roles;
|
|
1629
|
+
constructor(options = {}) {
|
|
1630
|
+
this.options = options;
|
|
1631
|
+
this.cookieName = options.cookieName ?? "agent_anon";
|
|
1632
|
+
this.roles = options.roles ?? [
|
|
1633
|
+
"anonymous"
|
|
1634
|
+
];
|
|
1635
|
+
}
|
|
1636
|
+
resolve(request) {
|
|
1637
|
+
const req = typeof request === "object" && request !== null ? request : {};
|
|
1638
|
+
let token = req[MINTED] ?? readCookie(req, this.cookieName);
|
|
1639
|
+
if (token === void 0 || !TOKEN_PATTERN.test(token)) {
|
|
1640
|
+
token = (0, import_node_crypto.randomBytes)(32).toString("base64url");
|
|
1641
|
+
req[MINTED] = token;
|
|
1642
|
+
this.setCookie(req, token);
|
|
1643
|
+
}
|
|
1644
|
+
const digest = (0, import_node_crypto.createHash)("sha256").update(token).digest("base64url").slice(0, 32);
|
|
1645
|
+
return {
|
|
1646
|
+
id: `anon:${digest}`,
|
|
1647
|
+
roles: [
|
|
1648
|
+
...this.roles
|
|
1649
|
+
]
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
setCookie(req, token) {
|
|
1653
|
+
const res = req.res;
|
|
1654
|
+
if (res?.setHeader === void 0 || res.headersSent === true) return;
|
|
1655
|
+
const sameSite = this.options.sameSite ?? "lax";
|
|
1656
|
+
const secureOption = this.options.secure ?? "auto";
|
|
1657
|
+
const secure = sameSite === "none" || (secureOption === "auto" ? isHttps(req) : secureOption);
|
|
1658
|
+
const maxAge = Math.round((this.options.maxAgeDays ?? 365) * 24 * 60 * 60);
|
|
1659
|
+
const cookie = [
|
|
1660
|
+
`${this.cookieName}=${token}`,
|
|
1661
|
+
`Path=${this.options.path ?? "/"}`,
|
|
1662
|
+
`Max-Age=${maxAge}`,
|
|
1663
|
+
"HttpOnly",
|
|
1664
|
+
`SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`,
|
|
1665
|
+
...secure ? [
|
|
1666
|
+
"Secure"
|
|
1667
|
+
] : []
|
|
1668
|
+
].join("; ");
|
|
1669
|
+
const existing = res.getHeader?.("Set-Cookie");
|
|
1670
|
+
const list = Array.isArray(existing) ? existing.map(String) : existing !== void 0 ? [
|
|
1671
|
+
String(existing)
|
|
1672
|
+
] : [];
|
|
1673
|
+
res.setHeader("Set-Cookie", [
|
|
1674
|
+
...list,
|
|
1675
|
+
cookie
|
|
1676
|
+
]);
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
|
|
1680
|
+
// src/controller/config.controller.ts
|
|
1601
1681
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
1602
1682
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1603
1683
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1624,6 +1704,91 @@ function _ts_param6(paramIndex, decorator) {
|
|
|
1624
1704
|
};
|
|
1625
1705
|
}
|
|
1626
1706
|
__name(_ts_param6, "_ts_param");
|
|
1707
|
+
var ConfigController = class {
|
|
1708
|
+
static {
|
|
1709
|
+
__name(this, "ConfigController");
|
|
1710
|
+
}
|
|
1711
|
+
options;
|
|
1712
|
+
actorResolver;
|
|
1713
|
+
staging;
|
|
1714
|
+
models;
|
|
1715
|
+
constructor(options, actorResolver, staging, models) {
|
|
1716
|
+
this.options = options;
|
|
1717
|
+
this.actorResolver = actorResolver;
|
|
1718
|
+
this.staging = staging;
|
|
1719
|
+
this.models = models;
|
|
1720
|
+
}
|
|
1721
|
+
async config(req) {
|
|
1722
|
+
await this.actorResolver.resolve(req);
|
|
1723
|
+
return {
|
|
1724
|
+
attachments: attachmentLimits(this.options, this.staging),
|
|
1725
|
+
models: {
|
|
1726
|
+
enabled: this.models !== void 0
|
|
1727
|
+
},
|
|
1728
|
+
quota: {
|
|
1729
|
+
enforced: this.options.quota !== void 0
|
|
1730
|
+
},
|
|
1731
|
+
identity: {
|
|
1732
|
+
anonymous: this.actorResolver instanceof AnonymousActorResolver
|
|
1733
|
+
}
|
|
1734
|
+
};
|
|
1735
|
+
}
|
|
1736
|
+
};
|
|
1737
|
+
_ts_decorate7([
|
|
1738
|
+
(0, import_common7.Get)(),
|
|
1739
|
+
_ts_param6(0, (0, import_common7.Req)()),
|
|
1740
|
+
_ts_metadata7("design:type", Function),
|
|
1741
|
+
_ts_metadata7("design:paramtypes", [
|
|
1742
|
+
typeof Request === "undefined" ? Object : Request
|
|
1743
|
+
]),
|
|
1744
|
+
_ts_metadata7("design:returntype", Promise)
|
|
1745
|
+
], ConfigController.prototype, "config", null);
|
|
1746
|
+
ConfigController = _ts_decorate7([
|
|
1747
|
+
(0, import_common7.Controller)("config"),
|
|
1748
|
+
_ts_param6(0, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_OPTIONS)),
|
|
1749
|
+
_ts_param6(1, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_ACTOR_RESOLVER)),
|
|
1750
|
+
_ts_param6(2, (0, import_common7.Optional)()),
|
|
1751
|
+
_ts_param6(2, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_ATTACHMENT_STAGING)),
|
|
1752
|
+
_ts_param6(3, (0, import_common7.Optional)()),
|
|
1753
|
+
_ts_param6(3, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_MODEL_CATALOG)),
|
|
1754
|
+
_ts_metadata7("design:type", Function),
|
|
1755
|
+
_ts_metadata7("design:paramtypes", [
|
|
1756
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
1757
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1758
|
+
Object,
|
|
1759
|
+
Object
|
|
1760
|
+
])
|
|
1761
|
+
], ConfigController);
|
|
1762
|
+
|
|
1763
|
+
// src/controller/memories.controller.ts
|
|
1764
|
+
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
1765
|
+
var import_common8 = require("@nestjs/common");
|
|
1766
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1767
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1768
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1769
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1770
|
+
} else {
|
|
1771
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1772
|
+
if (d = decorators[i]) {
|
|
1773
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1778
|
+
}
|
|
1779
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1780
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
1781
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1782
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
1786
|
+
function _ts_param7(paramIndex, decorator) {
|
|
1787
|
+
return function(target, key) {
|
|
1788
|
+
decorator(target, key, paramIndex);
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
__name(_ts_param7, "_ts_param");
|
|
1627
1792
|
var MemoriesController = class {
|
|
1628
1793
|
static {
|
|
1629
1794
|
__name(this, "MemoriesController");
|
|
@@ -1657,20 +1822,20 @@ var MemoriesController = class {
|
|
|
1657
1822
|
*/
|
|
1658
1823
|
async forget(req, id) {
|
|
1659
1824
|
if (this.memory === void 0) {
|
|
1660
|
-
throw new
|
|
1825
|
+
throw new import_common8.NotFoundException("No memory is configured in this deployment.");
|
|
1661
1826
|
}
|
|
1662
1827
|
const actor = await this.actorResolver.resolve(req);
|
|
1663
1828
|
const digest = await this.unbounded("", actor);
|
|
1664
1829
|
const entry = digest.entries.find((candidate) => candidate.id === id);
|
|
1665
1830
|
if (entry === void 0) {
|
|
1666
|
-
throw new
|
|
1831
|
+
throw new import_common8.NotFoundException(`No memory with id "${id}".`);
|
|
1667
1832
|
}
|
|
1668
|
-
const verdict = (0,
|
|
1833
|
+
const verdict = (0, import_nestjs_agent_core8.memoryForgetVerdict)({
|
|
1669
1834
|
record: entry,
|
|
1670
1835
|
actor
|
|
1671
1836
|
});
|
|
1672
1837
|
if (!verdict.allowed) {
|
|
1673
|
-
throw new
|
|
1838
|
+
throw new import_common8.ForbiddenException(verdict.reason);
|
|
1674
1839
|
}
|
|
1675
1840
|
return {
|
|
1676
1841
|
forgotten: await this.memory.provider.forget({
|
|
@@ -1684,7 +1849,7 @@ var MemoriesController = class {
|
|
|
1684
1849
|
}
|
|
1685
1850
|
async unbounded(threadId, actor) {
|
|
1686
1851
|
const config = this.memory;
|
|
1687
|
-
return await (0,
|
|
1852
|
+
return await (0, import_nestjs_agent_core8.offerMemories)({
|
|
1688
1853
|
config: {
|
|
1689
1854
|
...config,
|
|
1690
1855
|
maxMemories: Number.POSITIVE_INFINITY
|
|
@@ -1696,44 +1861,44 @@ var MemoriesController = class {
|
|
|
1696
1861
|
});
|
|
1697
1862
|
}
|
|
1698
1863
|
};
|
|
1699
|
-
|
|
1700
|
-
(0,
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1864
|
+
_ts_decorate8([
|
|
1865
|
+
(0, import_common8.Get)(),
|
|
1866
|
+
_ts_param7(0, (0, import_common8.Req)()),
|
|
1867
|
+
_ts_param7(1, (0, import_common8.Query)("threadId")),
|
|
1868
|
+
_ts_metadata8("design:type", Function),
|
|
1869
|
+
_ts_metadata8("design:paramtypes", [
|
|
1705
1870
|
typeof Request === "undefined" ? Object : Request,
|
|
1706
1871
|
String
|
|
1707
1872
|
]),
|
|
1708
|
-
|
|
1873
|
+
_ts_metadata8("design:returntype", Promise)
|
|
1709
1874
|
], MemoriesController.prototype, "list", null);
|
|
1710
|
-
|
|
1711
|
-
(0,
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1875
|
+
_ts_decorate8([
|
|
1876
|
+
(0, import_common8.Delete)(":id"),
|
|
1877
|
+
_ts_param7(0, (0, import_common8.Req)()),
|
|
1878
|
+
_ts_param7(1, (0, import_common8.Param)("id")),
|
|
1879
|
+
_ts_metadata8("design:type", Function),
|
|
1880
|
+
_ts_metadata8("design:paramtypes", [
|
|
1716
1881
|
typeof Request === "undefined" ? Object : Request,
|
|
1717
1882
|
String
|
|
1718
1883
|
]),
|
|
1719
|
-
|
|
1884
|
+
_ts_metadata8("design:returntype", Promise)
|
|
1720
1885
|
], MemoriesController.prototype, "forget", null);
|
|
1721
|
-
MemoriesController =
|
|
1722
|
-
(0,
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1886
|
+
MemoriesController = _ts_decorate8([
|
|
1887
|
+
(0, import_common8.Controller)("memories"),
|
|
1888
|
+
_ts_param7(0, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_ACTOR_RESOLVER)),
|
|
1889
|
+
_ts_param7(1, (0, import_common8.Optional)()),
|
|
1890
|
+
_ts_param7(1, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_MEMORY)),
|
|
1891
|
+
_ts_metadata8("design:type", Function),
|
|
1892
|
+
_ts_metadata8("design:paramtypes", [
|
|
1728
1893
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1729
1894
|
Object
|
|
1730
1895
|
])
|
|
1731
1896
|
], MemoriesController);
|
|
1732
1897
|
|
|
1733
1898
|
// src/controller/messages.controller.ts
|
|
1734
|
-
var
|
|
1735
|
-
var
|
|
1736
|
-
function
|
|
1899
|
+
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
1900
|
+
var import_common9 = require("@nestjs/common");
|
|
1901
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1737
1902
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1738
1903
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1739
1904
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1746,19 +1911,19 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
1746
1911
|
}
|
|
1747
1912
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1748
1913
|
}
|
|
1749
|
-
__name(
|
|
1750
|
-
function
|
|
1914
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1915
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
1751
1916
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1752
1917
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1753
1918
|
}
|
|
1754
1919
|
}
|
|
1755
|
-
__name(
|
|
1756
|
-
function
|
|
1920
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1921
|
+
function _ts_param8(paramIndex, decorator) {
|
|
1757
1922
|
return function(target, key) {
|
|
1758
1923
|
decorator(target, key, paramIndex);
|
|
1759
1924
|
};
|
|
1760
1925
|
}
|
|
1761
|
-
__name(
|
|
1926
|
+
__name(_ts_param8, "_ts_param");
|
|
1762
1927
|
var MessagesController = class {
|
|
1763
1928
|
static {
|
|
1764
1929
|
__name(this, "MessagesController");
|
|
@@ -1786,34 +1951,34 @@ var MessagesController = class {
|
|
|
1786
1951
|
};
|
|
1787
1952
|
}
|
|
1788
1953
|
};
|
|
1789
|
-
|
|
1790
|
-
(0,
|
|
1791
|
-
(0,
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1954
|
+
_ts_decorate9([
|
|
1955
|
+
(0, import_common9.Post)(":id/feedback"),
|
|
1956
|
+
(0, import_common9.HttpCode)(200),
|
|
1957
|
+
_ts_param8(0, (0, import_common9.Req)()),
|
|
1958
|
+
_ts_param8(1, (0, import_common9.Param)("id")),
|
|
1959
|
+
_ts_param8(2, (0, import_common9.Body)()),
|
|
1960
|
+
_ts_metadata9("design:type", Function),
|
|
1961
|
+
_ts_metadata9("design:paramtypes", [
|
|
1797
1962
|
typeof Request === "undefined" ? Object : Request,
|
|
1798
1963
|
String,
|
|
1799
1964
|
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
1800
1965
|
]),
|
|
1801
|
-
|
|
1966
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1802
1967
|
], MessagesController.prototype, "feedback", null);
|
|
1803
|
-
MessagesController =
|
|
1804
|
-
(0,
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1968
|
+
MessagesController = _ts_decorate9([
|
|
1969
|
+
(0, import_common9.Controller)("messages"),
|
|
1970
|
+
_ts_param8(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
|
|
1971
|
+
_ts_metadata9("design:type", Function),
|
|
1972
|
+
_ts_metadata9("design:paramtypes", [
|
|
1808
1973
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1809
1974
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1810
1975
|
])
|
|
1811
1976
|
], MessagesController);
|
|
1812
1977
|
|
|
1813
1978
|
// src/controller/models.controller.ts
|
|
1814
|
-
var
|
|
1815
|
-
var
|
|
1816
|
-
function
|
|
1979
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
1980
|
+
var import_common10 = require("@nestjs/common");
|
|
1981
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1817
1982
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1818
1983
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1819
1984
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1826,19 +1991,19 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
1826
1991
|
}
|
|
1827
1992
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1828
1993
|
}
|
|
1829
|
-
__name(
|
|
1830
|
-
function
|
|
1994
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1995
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
1831
1996
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1832
1997
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1833
1998
|
}
|
|
1834
1999
|
}
|
|
1835
|
-
__name(
|
|
1836
|
-
function
|
|
2000
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2001
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1837
2002
|
return function(target, key) {
|
|
1838
2003
|
decorator(target, key, paramIndex);
|
|
1839
2004
|
};
|
|
1840
2005
|
}
|
|
1841
|
-
__name(
|
|
2006
|
+
__name(_ts_param9, "_ts_param");
|
|
1842
2007
|
var ModelsController = class {
|
|
1843
2008
|
static {
|
|
1844
2009
|
__name(this, "ModelsController");
|
|
@@ -1858,31 +2023,31 @@ var ModelsController = class {
|
|
|
1858
2023
|
return this.agent.listModels(actor, agent);
|
|
1859
2024
|
}
|
|
1860
2025
|
};
|
|
1861
|
-
|
|
1862
|
-
(0,
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
2026
|
+
_ts_decorate10([
|
|
2027
|
+
(0, import_common10.Get)(),
|
|
2028
|
+
_ts_param9(0, (0, import_common10.Req)()),
|
|
2029
|
+
_ts_param9(1, (0, import_common10.Query)("agent")),
|
|
2030
|
+
_ts_metadata10("design:type", Function),
|
|
2031
|
+
_ts_metadata10("design:paramtypes", [
|
|
1867
2032
|
typeof Request === "undefined" ? Object : Request,
|
|
1868
2033
|
String
|
|
1869
2034
|
]),
|
|
1870
|
-
|
|
2035
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1871
2036
|
], ModelsController.prototype, "list", null);
|
|
1872
|
-
ModelsController =
|
|
1873
|
-
(0,
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
2037
|
+
ModelsController = _ts_decorate10([
|
|
2038
|
+
(0, import_common10.Controller)("models"),
|
|
2039
|
+
_ts_param9(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
|
|
2040
|
+
_ts_metadata10("design:type", Function),
|
|
2041
|
+
_ts_metadata10("design:paramtypes", [
|
|
1877
2042
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1878
2043
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1879
2044
|
])
|
|
1880
2045
|
], ModelsController);
|
|
1881
2046
|
|
|
1882
2047
|
// src/controller/quota.controller.ts
|
|
1883
|
-
var
|
|
1884
|
-
var
|
|
1885
|
-
function
|
|
2048
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
2049
|
+
var import_common11 = require("@nestjs/common");
|
|
2050
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1886
2051
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1887
2052
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1888
2053
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1895,19 +2060,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
1895
2060
|
}
|
|
1896
2061
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1897
2062
|
}
|
|
1898
|
-
__name(
|
|
1899
|
-
function
|
|
2063
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
2064
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
1900
2065
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1901
2066
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1902
2067
|
}
|
|
1903
2068
|
}
|
|
1904
|
-
__name(
|
|
1905
|
-
function
|
|
2069
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2070
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1906
2071
|
return function(target, key) {
|
|
1907
2072
|
decorator(target, key, paramIndex);
|
|
1908
2073
|
};
|
|
1909
2074
|
}
|
|
1910
|
-
__name(
|
|
2075
|
+
__name(_ts_param10, "_ts_param");
|
|
1911
2076
|
var QuotaController = class {
|
|
1912
2077
|
static {
|
|
1913
2078
|
__name(this, "QuotaController");
|
|
@@ -1926,43 +2091,30 @@ var QuotaController = class {
|
|
|
1926
2091
|
const actor = await this.actorResolver.resolve(req);
|
|
1927
2092
|
return this.agent.quotaReport(actor);
|
|
1928
2093
|
}
|
|
1929
|
-
async today(req) {
|
|
1930
|
-
const actor = await this.actorResolver.resolve(req);
|
|
1931
|
-
return this.agent.quotaToday(actor.id);
|
|
1932
|
-
}
|
|
1933
2094
|
};
|
|
1934
|
-
|
|
1935
|
-
(0,
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
2095
|
+
_ts_decorate11([
|
|
2096
|
+
(0, import_common11.Get)(),
|
|
2097
|
+
_ts_param10(0, (0, import_common11.Req)()),
|
|
2098
|
+
_ts_metadata11("design:type", Function),
|
|
2099
|
+
_ts_metadata11("design:paramtypes", [
|
|
1939
2100
|
typeof Request === "undefined" ? Object : Request
|
|
1940
2101
|
]),
|
|
1941
|
-
|
|
2102
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1942
2103
|
], QuotaController.prototype, "report", null);
|
|
1943
|
-
|
|
1944
|
-
(0,
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
typeof Request === "undefined" ? Object : Request
|
|
1949
|
-
]),
|
|
1950
|
-
_ts_metadata10("design:returntype", Promise)
|
|
1951
|
-
], QuotaController.prototype, "today", null);
|
|
1952
|
-
QuotaController = _ts_decorate10([
|
|
1953
|
-
(0, import_common10.Controller)("quota"),
|
|
1954
|
-
_ts_param9(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
|
|
1955
|
-
_ts_metadata10("design:type", Function),
|
|
1956
|
-
_ts_metadata10("design:paramtypes", [
|
|
2104
|
+
QuotaController = _ts_decorate11([
|
|
2105
|
+
(0, import_common11.Controller)("quota"),
|
|
2106
|
+
_ts_param10(1, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
|
|
2107
|
+
_ts_metadata11("design:type", Function),
|
|
2108
|
+
_ts_metadata11("design:paramtypes", [
|
|
1957
2109
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1958
2110
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1959
2111
|
])
|
|
1960
2112
|
], QuotaController);
|
|
1961
2113
|
|
|
1962
2114
|
// src/controller/skills.controller.ts
|
|
1963
|
-
var
|
|
1964
|
-
var
|
|
1965
|
-
function
|
|
2115
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
2116
|
+
var import_common12 = require("@nestjs/common");
|
|
2117
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1966
2118
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1967
2119
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1968
2120
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1975,19 +2127,19 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
1975
2127
|
}
|
|
1976
2128
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1977
2129
|
}
|
|
1978
|
-
__name(
|
|
1979
|
-
function
|
|
2130
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2131
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
1980
2132
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1981
2133
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1982
2134
|
}
|
|
1983
2135
|
}
|
|
1984
|
-
__name(
|
|
1985
|
-
function
|
|
2136
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
2137
|
+
function _ts_param11(paramIndex, decorator) {
|
|
1986
2138
|
return function(target, key) {
|
|
1987
2139
|
decorator(target, key, paramIndex);
|
|
1988
2140
|
};
|
|
1989
2141
|
}
|
|
1990
|
-
__name(
|
|
2142
|
+
__name(_ts_param11, "_ts_param");
|
|
1991
2143
|
var SkillsController = class {
|
|
1992
2144
|
static {
|
|
1993
2145
|
__name(this, "SkillsController");
|
|
@@ -2003,40 +2155,40 @@ var SkillsController = class {
|
|
|
2003
2155
|
return [];
|
|
2004
2156
|
}
|
|
2005
2157
|
const actor = await this.actorResolver.resolve(req);
|
|
2006
|
-
const offer = await (0,
|
|
2158
|
+
const offer = await (0, import_nestjs_agent_core12.offerSkills)(this.skills, {
|
|
2007
2159
|
actor,
|
|
2008
2160
|
threadId: threadId ?? ""
|
|
2009
2161
|
});
|
|
2010
2162
|
return offer.entries;
|
|
2011
2163
|
}
|
|
2012
2164
|
};
|
|
2013
|
-
|
|
2014
|
-
(0,
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2165
|
+
_ts_decorate12([
|
|
2166
|
+
(0, import_common12.Get)(),
|
|
2167
|
+
_ts_param11(0, (0, import_common12.Req)()),
|
|
2168
|
+
_ts_param11(1, (0, import_common12.Query)("threadId")),
|
|
2169
|
+
_ts_metadata12("design:type", Function),
|
|
2170
|
+
_ts_metadata12("design:paramtypes", [
|
|
2019
2171
|
typeof Request === "undefined" ? Object : Request,
|
|
2020
2172
|
String
|
|
2021
2173
|
]),
|
|
2022
|
-
|
|
2174
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2023
2175
|
], SkillsController.prototype, "list", null);
|
|
2024
|
-
SkillsController =
|
|
2025
|
-
(0,
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2176
|
+
SkillsController = _ts_decorate12([
|
|
2177
|
+
(0, import_common12.Controller)("skills"),
|
|
2178
|
+
_ts_param11(0, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
|
|
2179
|
+
_ts_param11(1, (0, import_common12.Optional)()),
|
|
2180
|
+
_ts_param11(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_SKILLS)),
|
|
2181
|
+
_ts_metadata12("design:type", Function),
|
|
2182
|
+
_ts_metadata12("design:paramtypes", [
|
|
2031
2183
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2032
2184
|
Object
|
|
2033
2185
|
])
|
|
2034
2186
|
], SkillsController);
|
|
2035
2187
|
|
|
2036
2188
|
// src/controller/threads.controller.ts
|
|
2037
|
-
var
|
|
2038
|
-
var
|
|
2039
|
-
function
|
|
2189
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
2190
|
+
var import_common13 = require("@nestjs/common");
|
|
2191
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
2040
2192
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2041
2193
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2042
2194
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2049,19 +2201,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
2049
2201
|
}
|
|
2050
2202
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2051
2203
|
}
|
|
2052
|
-
__name(
|
|
2053
|
-
function
|
|
2204
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2205
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
2054
2206
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2055
2207
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2056
2208
|
}
|
|
2057
2209
|
}
|
|
2058
|
-
__name(
|
|
2059
|
-
function
|
|
2210
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2211
|
+
function _ts_param12(paramIndex, decorator) {
|
|
2060
2212
|
return function(target, key) {
|
|
2061
2213
|
decorator(target, key, paramIndex);
|
|
2062
2214
|
};
|
|
2063
2215
|
}
|
|
2064
|
-
__name(
|
|
2216
|
+
__name(_ts_param12, "_ts_param");
|
|
2065
2217
|
var ThreadsController = class {
|
|
2066
2218
|
static {
|
|
2067
2219
|
__name(this, "ThreadsController");
|
|
@@ -2128,101 +2280,101 @@ var ThreadsController = class {
|
|
|
2128
2280
|
};
|
|
2129
2281
|
}
|
|
2130
2282
|
};
|
|
2131
|
-
|
|
2132
|
-
(0,
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2283
|
+
_ts_decorate13([
|
|
2284
|
+
(0, import_common13.Get)(),
|
|
2285
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2286
|
+
_ts_metadata13("design:type", Function),
|
|
2287
|
+
_ts_metadata13("design:paramtypes", [
|
|
2136
2288
|
typeof Request === "undefined" ? Object : Request
|
|
2137
2289
|
]),
|
|
2138
|
-
|
|
2290
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2139
2291
|
], ThreadsController.prototype, "list", null);
|
|
2140
|
-
|
|
2141
|
-
(0,
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2292
|
+
_ts_decorate13([
|
|
2293
|
+
(0, import_common13.Get)(":id"),
|
|
2294
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2295
|
+
_ts_param12(1, (0, import_common13.Param)("id")),
|
|
2296
|
+
_ts_metadata13("design:type", Function),
|
|
2297
|
+
_ts_metadata13("design:paramtypes", [
|
|
2146
2298
|
typeof Request === "undefined" ? Object : Request,
|
|
2147
2299
|
String
|
|
2148
2300
|
]),
|
|
2149
|
-
|
|
2301
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2150
2302
|
], ThreadsController.prototype, "detail", null);
|
|
2151
|
-
|
|
2152
|
-
(0,
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2303
|
+
_ts_decorate13([
|
|
2304
|
+
(0, import_common13.Delete)(":id"),
|
|
2305
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2306
|
+
_ts_param12(1, (0, import_common13.Param)("id")),
|
|
2307
|
+
_ts_metadata13("design:type", Function),
|
|
2308
|
+
_ts_metadata13("design:paramtypes", [
|
|
2157
2309
|
typeof Request === "undefined" ? Object : Request,
|
|
2158
2310
|
String
|
|
2159
2311
|
]),
|
|
2160
|
-
|
|
2312
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2161
2313
|
], ThreadsController.prototype, "remove", null);
|
|
2162
|
-
|
|
2163
|
-
(0,
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2314
|
+
_ts_decorate13([
|
|
2315
|
+
(0, import_common13.Post)(":id/fork-from/:messageId"),
|
|
2316
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2317
|
+
_ts_param12(1, (0, import_common13.Param)("id")),
|
|
2318
|
+
_ts_param12(2, (0, import_common13.Param)("messageId")),
|
|
2319
|
+
_ts_metadata13("design:type", Function),
|
|
2320
|
+
_ts_metadata13("design:paramtypes", [
|
|
2169
2321
|
typeof Request === "undefined" ? Object : Request,
|
|
2170
2322
|
String,
|
|
2171
2323
|
String
|
|
2172
2324
|
]),
|
|
2173
|
-
|
|
2325
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2174
2326
|
], ThreadsController.prototype, "fork", null);
|
|
2175
|
-
|
|
2176
|
-
(0,
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2327
|
+
_ts_decorate13([
|
|
2328
|
+
(0, import_common13.Patch)(":id"),
|
|
2329
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2330
|
+
_ts_param12(1, (0, import_common13.Param)("id")),
|
|
2331
|
+
_ts_param12(2, (0, import_common13.Body)()),
|
|
2332
|
+
_ts_metadata13("design:type", Function),
|
|
2333
|
+
_ts_metadata13("design:paramtypes", [
|
|
2182
2334
|
typeof Request === "undefined" ? Object : Request,
|
|
2183
2335
|
String,
|
|
2184
2336
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
2185
2337
|
]),
|
|
2186
|
-
|
|
2338
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2187
2339
|
], ThreadsController.prototype, "update", null);
|
|
2188
|
-
|
|
2189
|
-
(0,
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2340
|
+
_ts_decorate13([
|
|
2341
|
+
(0, import_common13.Post)(":id/promote"),
|
|
2342
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2343
|
+
_ts_param12(1, (0, import_common13.Param)("id")),
|
|
2344
|
+
_ts_metadata13("design:type", Function),
|
|
2345
|
+
_ts_metadata13("design:paramtypes", [
|
|
2194
2346
|
typeof Request === "undefined" ? Object : Request,
|
|
2195
2347
|
String
|
|
2196
2348
|
]),
|
|
2197
|
-
|
|
2349
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2198
2350
|
], ThreadsController.prototype, "promote", null);
|
|
2199
|
-
|
|
2200
|
-
(0,
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2351
|
+
_ts_decorate13([
|
|
2352
|
+
(0, import_common13.Delete)(":id/from/:messageId"),
|
|
2353
|
+
_ts_param12(0, (0, import_common13.Req)()),
|
|
2354
|
+
_ts_param12(1, (0, import_common13.Param)("id")),
|
|
2355
|
+
_ts_param12(2, (0, import_common13.Param)("messageId")),
|
|
2356
|
+
_ts_metadata13("design:type", Function),
|
|
2357
|
+
_ts_metadata13("design:paramtypes", [
|
|
2206
2358
|
typeof Request === "undefined" ? Object : Request,
|
|
2207
2359
|
String,
|
|
2208
2360
|
String
|
|
2209
2361
|
]),
|
|
2210
|
-
|
|
2362
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2211
2363
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
2212
|
-
ThreadsController =
|
|
2213
|
-
(0,
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2364
|
+
ThreadsController = _ts_decorate13([
|
|
2365
|
+
(0, import_common13.Controller)("threads"),
|
|
2366
|
+
_ts_param12(1, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
|
|
2367
|
+
_ts_metadata13("design:type", Function),
|
|
2368
|
+
_ts_metadata13("design:paramtypes", [
|
|
2217
2369
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2218
2370
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2219
2371
|
])
|
|
2220
2372
|
], ThreadsController);
|
|
2221
2373
|
|
|
2222
2374
|
// src/controller/tool-call.controller.ts
|
|
2223
|
-
var
|
|
2224
|
-
var
|
|
2225
|
-
function
|
|
2375
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
2376
|
+
var import_common14 = require("@nestjs/common");
|
|
2377
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2226
2378
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2227
2379
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2228
2380
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2235,19 +2387,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
2235
2387
|
}
|
|
2236
2388
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2237
2389
|
}
|
|
2238
|
-
__name(
|
|
2239
|
-
function
|
|
2390
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2391
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2240
2392
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2241
2393
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2242
2394
|
}
|
|
2243
2395
|
}
|
|
2244
|
-
__name(
|
|
2245
|
-
function
|
|
2396
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2397
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2246
2398
|
return function(target, key) {
|
|
2247
2399
|
decorator(target, key, paramIndex);
|
|
2248
2400
|
};
|
|
2249
2401
|
}
|
|
2250
|
-
__name(
|
|
2402
|
+
__name(_ts_param13, "_ts_param");
|
|
2251
2403
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
2252
2404
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
2253
2405
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -2256,7 +2408,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
2256
2408
|
var DEFAULT_VIA = "web";
|
|
2257
2409
|
function toolCallId(claimed) {
|
|
2258
2410
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
2259
|
-
throw new
|
|
2411
|
+
throw new import_common14.BadRequestException("toolCallId must be a non-empty string");
|
|
2260
2412
|
}
|
|
2261
2413
|
return claimed;
|
|
2262
2414
|
}
|
|
@@ -2266,10 +2418,10 @@ function rejectReason(claimed) {
|
|
|
2266
2418
|
return void 0;
|
|
2267
2419
|
}
|
|
2268
2420
|
if (typeof claimed !== "string") {
|
|
2269
|
-
throw new
|
|
2421
|
+
throw new import_common14.BadRequestException("reason must be a string");
|
|
2270
2422
|
}
|
|
2271
2423
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
2272
|
-
throw new
|
|
2424
|
+
throw new import_common14.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
2273
2425
|
}
|
|
2274
2426
|
return claimed;
|
|
2275
2427
|
}
|
|
@@ -2279,7 +2431,7 @@ function remember(claimed) {
|
|
|
2279
2431
|
return false;
|
|
2280
2432
|
}
|
|
2281
2433
|
if (typeof claimed !== "boolean") {
|
|
2282
|
-
throw new
|
|
2434
|
+
throw new import_common14.BadRequestException("remember must be a boolean");
|
|
2283
2435
|
}
|
|
2284
2436
|
return claimed;
|
|
2285
2437
|
}
|
|
@@ -2289,7 +2441,7 @@ function via(claimed) {
|
|
|
2289
2441
|
return DEFAULT_VIA;
|
|
2290
2442
|
}
|
|
2291
2443
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
2292
|
-
throw new
|
|
2444
|
+
throw new import_common14.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
2293
2445
|
}
|
|
2294
2446
|
return claimed;
|
|
2295
2447
|
}
|
|
@@ -2299,26 +2451,26 @@ function answers(claimed) {
|
|
|
2299
2451
|
return void 0;
|
|
2300
2452
|
}
|
|
2301
2453
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
2302
|
-
throw new
|
|
2454
|
+
throw new import_common14.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
2303
2455
|
}
|
|
2304
2456
|
const entries = Object.entries(claimed);
|
|
2305
2457
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
2306
|
-
throw new
|
|
2458
|
+
throw new import_common14.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
2307
2459
|
}
|
|
2308
2460
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
2309
2461
|
for (const [questionId, values] of entries) {
|
|
2310
2462
|
if (!Array.isArray(values)) {
|
|
2311
|
-
throw new
|
|
2463
|
+
throw new import_common14.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
2312
2464
|
}
|
|
2313
2465
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
2314
|
-
throw new
|
|
2466
|
+
throw new import_common14.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
2315
2467
|
}
|
|
2316
2468
|
for (const value of values) {
|
|
2317
2469
|
if (typeof value !== "string") {
|
|
2318
|
-
throw new
|
|
2470
|
+
throw new import_common14.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
2319
2471
|
}
|
|
2320
2472
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
2321
|
-
throw new
|
|
2473
|
+
throw new import_common14.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
2322
2474
|
}
|
|
2323
2475
|
}
|
|
2324
2476
|
validated[questionId] = values;
|
|
@@ -2376,64 +2528,64 @@ var ToolCallController = class {
|
|
|
2376
2528
|
};
|
|
2377
2529
|
}
|
|
2378
2530
|
};
|
|
2379
|
-
|
|
2380
|
-
(0,
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2531
|
+
_ts_decorate14([
|
|
2532
|
+
(0, import_common14.Post)("approve"),
|
|
2533
|
+
_ts_param13(0, (0, import_common14.Req)()),
|
|
2534
|
+
_ts_param13(1, (0, import_common14.Body)()),
|
|
2535
|
+
_ts_metadata14("design:type", Function),
|
|
2536
|
+
_ts_metadata14("design:paramtypes", [
|
|
2385
2537
|
typeof Request === "undefined" ? Object : Request,
|
|
2386
2538
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
2387
2539
|
]),
|
|
2388
|
-
|
|
2540
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2389
2541
|
], ToolCallController.prototype, "approve", null);
|
|
2390
|
-
|
|
2391
|
-
(0,
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2542
|
+
_ts_decorate14([
|
|
2543
|
+
(0, import_common14.Post)("reject"),
|
|
2544
|
+
_ts_param13(0, (0, import_common14.Req)()),
|
|
2545
|
+
_ts_param13(1, (0, import_common14.Body)()),
|
|
2546
|
+
_ts_metadata14("design:type", Function),
|
|
2547
|
+
_ts_metadata14("design:paramtypes", [
|
|
2396
2548
|
typeof Request === "undefined" ? Object : Request,
|
|
2397
2549
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
2398
2550
|
]),
|
|
2399
|
-
|
|
2551
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2400
2552
|
], ToolCallController.prototype, "reject", null);
|
|
2401
|
-
|
|
2402
|
-
(0,
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2553
|
+
_ts_decorate14([
|
|
2554
|
+
(0, import_common14.Post)("answer"),
|
|
2555
|
+
_ts_param13(0, (0, import_common14.Req)()),
|
|
2556
|
+
_ts_param13(1, (0, import_common14.Body)()),
|
|
2557
|
+
_ts_metadata14("design:type", Function),
|
|
2558
|
+
_ts_metadata14("design:paramtypes", [
|
|
2407
2559
|
typeof Request === "undefined" ? Object : Request,
|
|
2408
2560
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
2409
2561
|
]),
|
|
2410
|
-
|
|
2562
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2411
2563
|
], ToolCallController.prototype, "answer", null);
|
|
2412
|
-
|
|
2413
|
-
(0,
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2564
|
+
_ts_decorate14([
|
|
2565
|
+
(0, import_common14.Post)("skip"),
|
|
2566
|
+
_ts_param13(0, (0, import_common14.Req)()),
|
|
2567
|
+
_ts_param13(1, (0, import_common14.Body)()),
|
|
2568
|
+
_ts_metadata14("design:type", Function),
|
|
2569
|
+
_ts_metadata14("design:paramtypes", [
|
|
2418
2570
|
typeof Request === "undefined" ? Object : Request,
|
|
2419
2571
|
Object
|
|
2420
2572
|
]),
|
|
2421
|
-
|
|
2573
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2422
2574
|
], ToolCallController.prototype, "skip", null);
|
|
2423
|
-
ToolCallController =
|
|
2424
|
-
(0,
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2575
|
+
ToolCallController = _ts_decorate14([
|
|
2576
|
+
(0, import_common14.Controller)("tool-call"),
|
|
2577
|
+
_ts_param13(1, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
|
|
2578
|
+
_ts_metadata14("design:type", Function),
|
|
2579
|
+
_ts_metadata14("design:paramtypes", [
|
|
2428
2580
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2429
2581
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2430
2582
|
])
|
|
2431
2583
|
], ToolCallController);
|
|
2432
2584
|
|
|
2433
2585
|
// src/controller/tools.controller.ts
|
|
2434
|
-
var
|
|
2435
|
-
var
|
|
2436
|
-
function
|
|
2586
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
2587
|
+
var import_common15 = require("@nestjs/common");
|
|
2588
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2437
2589
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2438
2590
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2439
2591
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2446,19 +2598,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2446
2598
|
}
|
|
2447
2599
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2448
2600
|
}
|
|
2449
|
-
__name(
|
|
2450
|
-
function
|
|
2601
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2602
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2451
2603
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2452
2604
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2453
2605
|
}
|
|
2454
2606
|
}
|
|
2455
|
-
__name(
|
|
2456
|
-
function
|
|
2607
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2608
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2457
2609
|
return function(target, key) {
|
|
2458
2610
|
decorator(target, key, paramIndex);
|
|
2459
2611
|
};
|
|
2460
2612
|
}
|
|
2461
|
-
__name(
|
|
2613
|
+
__name(_ts_param14, "_ts_param");
|
|
2462
2614
|
var ToolsController = class {
|
|
2463
2615
|
static {
|
|
2464
2616
|
__name(this, "ToolsController");
|
|
@@ -2473,7 +2625,7 @@ var ToolsController = class {
|
|
|
2473
2625
|
}
|
|
2474
2626
|
async list(req, agent) {
|
|
2475
2627
|
if (agent !== void 0 && this.agents.get(agent) === void 0) {
|
|
2476
|
-
throw new
|
|
2628
|
+
throw new import_common15.NotFoundException(`No agent named "${agent}"`);
|
|
2477
2629
|
}
|
|
2478
2630
|
const actor = await this.actorResolver.resolve(req);
|
|
2479
2631
|
const deps = this.depsFactory.forAgent(agent);
|
|
@@ -2487,33 +2639,33 @@ var ToolsController = class {
|
|
|
2487
2639
|
}));
|
|
2488
2640
|
}
|
|
2489
2641
|
};
|
|
2490
|
-
|
|
2491
|
-
(0,
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2642
|
+
_ts_decorate15([
|
|
2643
|
+
(0, import_common15.Get)(),
|
|
2644
|
+
_ts_param14(0, (0, import_common15.Req)()),
|
|
2645
|
+
_ts_param14(1, (0, import_common15.Query)("agent")),
|
|
2646
|
+
_ts_metadata15("design:type", Function),
|
|
2647
|
+
_ts_metadata15("design:paramtypes", [
|
|
2496
2648
|
typeof Request === "undefined" ? Object : Request,
|
|
2497
2649
|
String
|
|
2498
2650
|
]),
|
|
2499
|
-
|
|
2651
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2500
2652
|
], ToolsController.prototype, "list", null);
|
|
2501
|
-
ToolsController =
|
|
2502
|
-
(0,
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2653
|
+
ToolsController = _ts_decorate15([
|
|
2654
|
+
(0, import_common15.Controller)("tools"),
|
|
2655
|
+
_ts_param14(0, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
|
|
2656
|
+
_ts_param14(1, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_DEPS_FACTORY)),
|
|
2657
|
+
_ts_param14(2, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_REGISTRY)),
|
|
2658
|
+
_ts_metadata15("design:type", Function),
|
|
2659
|
+
_ts_metadata15("design:paramtypes", [
|
|
2508
2660
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2509
2661
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2510
|
-
typeof
|
|
2662
|
+
typeof import_nestjs_agent_core15.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core15.AgentRegistry
|
|
2511
2663
|
])
|
|
2512
2664
|
], ToolsController);
|
|
2513
2665
|
|
|
2514
2666
|
// src/discovery/agent-discovery.service.ts
|
|
2515
|
-
var
|
|
2516
|
-
var
|
|
2667
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
2668
|
+
var import_common16 = require("@nestjs/common");
|
|
2517
2669
|
var import_core = require("@nestjs/core");
|
|
2518
2670
|
|
|
2519
2671
|
// src/decorator/agent.decorator.ts
|
|
@@ -2548,7 +2700,7 @@ function SystemPromptContributor() {
|
|
|
2548
2700
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
2549
2701
|
|
|
2550
2702
|
// src/discovery/agent-discovery.service.ts
|
|
2551
|
-
function
|
|
2703
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2552
2704
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2553
2705
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2554
2706
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2561,19 +2713,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2561
2713
|
}
|
|
2562
2714
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2563
2715
|
}
|
|
2564
|
-
__name(
|
|
2565
|
-
function
|
|
2716
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2717
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2566
2718
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2567
2719
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2568
2720
|
}
|
|
2569
2721
|
}
|
|
2570
|
-
__name(
|
|
2571
|
-
function
|
|
2722
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2723
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2572
2724
|
return function(target, key) {
|
|
2573
2725
|
decorator(target, key, paramIndex);
|
|
2574
2726
|
};
|
|
2575
2727
|
}
|
|
2576
|
-
__name(
|
|
2728
|
+
__name(_ts_param15, "_ts_param");
|
|
2577
2729
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
2578
2730
|
static {
|
|
2579
2731
|
__name(this, "AgentDiscoveryService");
|
|
@@ -2582,7 +2734,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2582
2734
|
scanner;
|
|
2583
2735
|
registry;
|
|
2584
2736
|
contributors;
|
|
2585
|
-
logger = new
|
|
2737
|
+
logger = new import_common16.Logger(_AgentDiscoveryService.name);
|
|
2586
2738
|
constructor(discovery, scanner, registry, contributors) {
|
|
2587
2739
|
this.discovery = discovery;
|
|
2588
2740
|
this.scanner = scanner;
|
|
@@ -2700,22 +2852,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2700
2852
|
return (ctx) => candidate.call(instance, ctx);
|
|
2701
2853
|
}
|
|
2702
2854
|
};
|
|
2703
|
-
AgentDiscoveryService =
|
|
2704
|
-
(0,
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2855
|
+
AgentDiscoveryService = _ts_decorate16([
|
|
2856
|
+
(0, import_common16.Injectable)(),
|
|
2857
|
+
_ts_param15(2, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_REGISTRY)),
|
|
2858
|
+
_ts_param15(3, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_PROMPT_CONTRIBUTORS)),
|
|
2859
|
+
_ts_metadata16("design:type", Function),
|
|
2860
|
+
_ts_metadata16("design:paramtypes", [
|
|
2709
2861
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
2710
2862
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
2711
|
-
typeof
|
|
2863
|
+
typeof import_nestjs_agent_core16.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core16.AgentRegistry,
|
|
2712
2864
|
Array
|
|
2713
2865
|
])
|
|
2714
2866
|
], AgentDiscoveryService);
|
|
2715
2867
|
|
|
2716
2868
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2717
|
-
var
|
|
2718
|
-
var
|
|
2869
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
2870
|
+
var import_common17 = require("@nestjs/common");
|
|
2719
2871
|
var import_core2 = require("@nestjs/core");
|
|
2720
2872
|
var import_zod = require("zod");
|
|
2721
2873
|
|
|
@@ -2786,7 +2938,7 @@ function provideAgentTools(factory, inject) {
|
|
|
2786
2938
|
__name(provideAgentTools, "provideAgentTools");
|
|
2787
2939
|
|
|
2788
2940
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2789
|
-
function
|
|
2941
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2790
2942
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2791
2943
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2792
2944
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2799,19 +2951,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2799
2951
|
}
|
|
2800
2952
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2801
2953
|
}
|
|
2802
|
-
__name(
|
|
2803
|
-
function
|
|
2954
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2955
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2804
2956
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2805
2957
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2806
2958
|
}
|
|
2807
2959
|
}
|
|
2808
|
-
__name(
|
|
2809
|
-
function
|
|
2960
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
2961
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2810
2962
|
return function(target, key) {
|
|
2811
2963
|
decorator(target, key, paramIndex);
|
|
2812
2964
|
};
|
|
2813
2965
|
}
|
|
2814
|
-
__name(
|
|
2966
|
+
__name(_ts_param16, "_ts_param");
|
|
2815
2967
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
2816
2968
|
static {
|
|
2817
2969
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -2820,7 +2972,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2820
2972
|
registry;
|
|
2821
2973
|
agents;
|
|
2822
2974
|
options;
|
|
2823
|
-
logger = new
|
|
2975
|
+
logger = new import_common17.Logger(_AiToolDiscoveryService.name);
|
|
2824
2976
|
constructor(discovery, registry, agents, options) {
|
|
2825
2977
|
this.discovery = discovery;
|
|
2826
2978
|
this.registry = registry;
|
|
@@ -2905,7 +3057,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2905
3057
|
let delegates = 0;
|
|
2906
3058
|
for (const definition of this.agents.list()) {
|
|
2907
3059
|
for (const edge of definition.delegatesTo ?? []) {
|
|
2908
|
-
const { agent: target, detached } = (0,
|
|
3060
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core17.normalizeDelegation)(edge);
|
|
2909
3061
|
const targetDefinition = this.agents.get(target);
|
|
2910
3062
|
if (targetDefinition === void 0) {
|
|
2911
3063
|
throw new Error(`Agent "${definition.name}" hands off to "${target}", which is not a registered @Agent. Declare it as an @Agent provider or fix the reference.`);
|
|
@@ -2955,13 +3107,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2955
3107
|
return true;
|
|
2956
3108
|
}
|
|
2957
3109
|
};
|
|
2958
|
-
AiToolDiscoveryService =
|
|
2959
|
-
(0,
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
3110
|
+
AiToolDiscoveryService = _ts_decorate17([
|
|
3111
|
+
(0, import_common17.Injectable)(),
|
|
3112
|
+
_ts_param16(1, (0, import_common17.Inject)(import_nestjs_agent_core17.AGENT_TOOL_REGISTRY)),
|
|
3113
|
+
_ts_param16(2, (0, import_common17.Inject)(import_nestjs_agent_core17.AGENT_REGISTRY)),
|
|
3114
|
+
_ts_param16(3, (0, import_common17.Inject)(import_nestjs_agent_core17.AGENT_OPTIONS)),
|
|
3115
|
+
_ts_metadata17("design:type", Function),
|
|
3116
|
+
_ts_metadata17("design:paramtypes", [
|
|
2965
3117
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
2966
3118
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
2967
3119
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -2970,13 +3122,13 @@ AiToolDiscoveryService = _ts_decorate16([
|
|
|
2970
3122
|
], AiToolDiscoveryService);
|
|
2971
3123
|
|
|
2972
3124
|
// src/discovery/skill-discovery.service.ts
|
|
2973
|
-
var
|
|
2974
|
-
var
|
|
3125
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
3126
|
+
var import_common18 = require("@nestjs/common");
|
|
2975
3127
|
var import_core3 = require("@nestjs/core");
|
|
2976
3128
|
|
|
2977
3129
|
// src/decorator/skill.decorator.ts
|
|
2978
3130
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
2979
|
-
var
|
|
3131
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
2980
3132
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
2981
3133
|
function Skill(options) {
|
|
2982
3134
|
return (target) => {
|
|
@@ -2989,12 +3141,12 @@ function readSkillMetadata(target) {
|
|
|
2989
3141
|
}
|
|
2990
3142
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
2991
3143
|
function skillScope(options) {
|
|
2992
|
-
return options.scope ??
|
|
3144
|
+
return options.scope ?? import_nestjs_agent_core18.GLOBAL_SCOPE;
|
|
2993
3145
|
}
|
|
2994
3146
|
__name(skillScope, "skillScope");
|
|
2995
3147
|
|
|
2996
3148
|
// src/discovery/skill-discovery.service.ts
|
|
2997
|
-
function
|
|
3149
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2998
3150
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2999
3151
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3000
3152
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3007,26 +3159,26 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
3007
3159
|
}
|
|
3008
3160
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3009
3161
|
}
|
|
3010
|
-
__name(
|
|
3011
|
-
function
|
|
3162
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3163
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
3012
3164
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3013
3165
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3014
3166
|
}
|
|
3015
3167
|
}
|
|
3016
|
-
__name(
|
|
3017
|
-
function
|
|
3168
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3169
|
+
function _ts_param17(paramIndex, decorator) {
|
|
3018
3170
|
return function(target, key) {
|
|
3019
3171
|
decorator(target, key, paramIndex);
|
|
3020
3172
|
};
|
|
3021
3173
|
}
|
|
3022
|
-
__name(
|
|
3174
|
+
__name(_ts_param17, "_ts_param");
|
|
3023
3175
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
3024
3176
|
static {
|
|
3025
3177
|
__name(this, "SkillDiscoveryService");
|
|
3026
3178
|
}
|
|
3027
3179
|
discovery;
|
|
3028
3180
|
declared;
|
|
3029
|
-
logger = new
|
|
3181
|
+
logger = new import_common18.Logger(_SkillDiscoveryService.name);
|
|
3030
3182
|
constructor(discovery, declared) {
|
|
3031
3183
|
this.discovery = discovery;
|
|
3032
3184
|
this.declared = declared;
|
|
@@ -3063,18 +3215,18 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
3063
3215
|
return flat === void 0 ? void 0 : () => flat;
|
|
3064
3216
|
}
|
|
3065
3217
|
};
|
|
3066
|
-
SkillDiscoveryService =
|
|
3067
|
-
(0,
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3218
|
+
SkillDiscoveryService = _ts_decorate18([
|
|
3219
|
+
(0, import_common18.Injectable)(),
|
|
3220
|
+
_ts_param17(1, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_SKILL_SOURCES)),
|
|
3221
|
+
_ts_metadata18("design:type", Function),
|
|
3222
|
+
_ts_metadata18("design:paramtypes", [
|
|
3071
3223
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
3072
3224
|
Array
|
|
3073
3225
|
])
|
|
3074
3226
|
], SkillDiscoveryService);
|
|
3075
3227
|
|
|
3076
3228
|
// src/in-process-sink.ts
|
|
3077
|
-
var
|
|
3229
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
3078
3230
|
var InProcessTokenStreamSink = class {
|
|
3079
3231
|
static {
|
|
3080
3232
|
__name(this, "InProcessTokenStreamSink");
|
|
@@ -3129,7 +3281,7 @@ var InProcessTokenStreamSink = class {
|
|
|
3129
3281
|
}
|
|
3130
3282
|
if (buf.ended) {
|
|
3131
3283
|
if (buf.failure !== void 0) {
|
|
3132
|
-
throw new
|
|
3284
|
+
throw new import_nestjs_agent_core20.AgentStreamError(buf.failure);
|
|
3133
3285
|
}
|
|
3134
3286
|
return;
|
|
3135
3287
|
}
|
|
@@ -3142,17 +3294,15 @@ var InProcessTokenStreamSink = class {
|
|
|
3142
3294
|
};
|
|
3143
3295
|
|
|
3144
3296
|
// src/ledger-quota-provider.ts
|
|
3145
|
-
var
|
|
3297
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
3146
3298
|
var LedgerQuotaProvider = class {
|
|
3147
3299
|
static {
|
|
3148
3300
|
__name(this, "LedgerQuotaProvider");
|
|
3149
3301
|
}
|
|
3150
3302
|
store;
|
|
3151
|
-
quota;
|
|
3152
3303
|
limits;
|
|
3153
|
-
constructor(store,
|
|
3304
|
+
constructor(store, limits = {}) {
|
|
3154
3305
|
this.store = store;
|
|
3155
|
-
this.quota = quota;
|
|
3156
3306
|
this.limits = limits;
|
|
3157
3307
|
}
|
|
3158
3308
|
async report(query) {
|
|
@@ -3162,11 +3312,11 @@ var LedgerQuotaProvider = class {
|
|
|
3162
3312
|
await this.dayWindow(actorRef, now)
|
|
3163
3313
|
];
|
|
3164
3314
|
if (this.store.usageBetween !== void 0) {
|
|
3165
|
-
const range = (0,
|
|
3315
|
+
const range = (0, import_nestjs_agent_core21.quotaPeriodRange)("month", now);
|
|
3166
3316
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
3167
3317
|
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
3168
3318
|
}
|
|
3169
|
-
const blocked = (0,
|
|
3319
|
+
const blocked = (0, import_nestjs_agent_core21.exhaustedWindow)(windows);
|
|
3170
3320
|
return {
|
|
3171
3321
|
windows,
|
|
3172
3322
|
...blocked !== void 0 ? {
|
|
@@ -3175,17 +3325,9 @@ var LedgerQuotaProvider = class {
|
|
|
3175
3325
|
};
|
|
3176
3326
|
}
|
|
3177
3327
|
async dayWindow(actorRef, now) {
|
|
3178
|
-
const range = (0,
|
|
3328
|
+
const range = (0, import_nestjs_agent_core21.quotaPeriodRange)("day", now);
|
|
3179
3329
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
3180
|
-
|
|
3181
|
-
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
3182
|
-
}
|
|
3183
|
-
const state = await this.quota.check(actorRef, range.fromDay);
|
|
3184
|
-
const window = this.window("day", state.usedTokens, costUsd, range.resetsAt);
|
|
3185
|
-
if (window.limitTokens === void 0) {
|
|
3186
|
-
window.limitTokens = state.limitTokens;
|
|
3187
|
-
}
|
|
3188
|
-
return window;
|
|
3330
|
+
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
3189
3331
|
}
|
|
3190
3332
|
window(period, usedTokens, usedUsd, resetsAt) {
|
|
3191
3333
|
const limits = this.limits[period] ?? {};
|
|
@@ -3204,120 +3346,10 @@ var LedgerQuotaProvider = class {
|
|
|
3204
3346
|
}
|
|
3205
3347
|
};
|
|
3206
3348
|
|
|
3207
|
-
// src/ledger-quota-store.ts
|
|
3208
|
-
var LedgerQuotaStore = class {
|
|
3209
|
-
static {
|
|
3210
|
-
__name(this, "LedgerQuotaStore");
|
|
3211
|
-
}
|
|
3212
|
-
store;
|
|
3213
|
-
limitTokens;
|
|
3214
|
-
constructor(store, limitTokens) {
|
|
3215
|
-
this.store = store;
|
|
3216
|
-
this.limitTokens = limitTokens;
|
|
3217
|
-
}
|
|
3218
|
-
async check(actorRef, day) {
|
|
3219
|
-
const { usedTokens } = await this.store.quotaToday(actorRef, day);
|
|
3220
|
-
return {
|
|
3221
|
-
usedTokens,
|
|
3222
|
-
limitTokens: this.limitTokens,
|
|
3223
|
-
withinLimit: usedTokens < this.limitTokens
|
|
3224
|
-
};
|
|
3225
|
-
}
|
|
3226
|
-
async bump(_actorRef, _day, _tokens) {
|
|
3227
|
-
}
|
|
3228
|
-
};
|
|
3229
|
-
|
|
3230
|
-
// src/resolver/anonymous-actor-resolver.ts
|
|
3231
|
-
var import_node_crypto = require("crypto");
|
|
3232
|
-
var TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
3233
|
-
var MINTED = /* @__PURE__ */ Symbol("nestjs-agent:anonymous-token");
|
|
3234
|
-
function readCookie(req, name) {
|
|
3235
|
-
const header = req.headers?.cookie;
|
|
3236
|
-
const raw = Array.isArray(header) ? header.join("; ") : header;
|
|
3237
|
-
if (raw === void 0) return void 0;
|
|
3238
|
-
for (const pair of raw.split(";")) {
|
|
3239
|
-
const index = pair.indexOf("=");
|
|
3240
|
-
if (index === -1) continue;
|
|
3241
|
-
if (pair.slice(0, index).trim() === name) {
|
|
3242
|
-
try {
|
|
3243
|
-
return decodeURIComponent(pair.slice(index + 1).trim());
|
|
3244
|
-
} catch {
|
|
3245
|
-
return void 0;
|
|
3246
|
-
}
|
|
3247
|
-
}
|
|
3248
|
-
}
|
|
3249
|
-
return void 0;
|
|
3250
|
-
}
|
|
3251
|
-
__name(readCookie, "readCookie");
|
|
3252
|
-
function isHttps(req) {
|
|
3253
|
-
if (req.secure === true) return true;
|
|
3254
|
-
const forwarded = req.headers?.["x-forwarded-proto"];
|
|
3255
|
-
const proto = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
3256
|
-
return proto?.split(",")[0]?.trim() === "https";
|
|
3257
|
-
}
|
|
3258
|
-
__name(isHttps, "isHttps");
|
|
3259
|
-
var AnonymousActorResolver = class {
|
|
3260
|
-
static {
|
|
3261
|
-
__name(this, "AnonymousActorResolver");
|
|
3262
|
-
}
|
|
3263
|
-
options;
|
|
3264
|
-
cookieName;
|
|
3265
|
-
roles;
|
|
3266
|
-
constructor(options = {}) {
|
|
3267
|
-
this.options = options;
|
|
3268
|
-
this.cookieName = options.cookieName ?? "agent_anon";
|
|
3269
|
-
this.roles = options.roles ?? [
|
|
3270
|
-
"anonymous"
|
|
3271
|
-
];
|
|
3272
|
-
}
|
|
3273
|
-
resolve(request) {
|
|
3274
|
-
const req = typeof request === "object" && request !== null ? request : {};
|
|
3275
|
-
let token = req[MINTED] ?? readCookie(req, this.cookieName);
|
|
3276
|
-
if (token === void 0 || !TOKEN_PATTERN.test(token)) {
|
|
3277
|
-
token = (0, import_node_crypto.randomBytes)(32).toString("base64url");
|
|
3278
|
-
req[MINTED] = token;
|
|
3279
|
-
this.setCookie(req, token);
|
|
3280
|
-
}
|
|
3281
|
-
const digest = (0, import_node_crypto.createHash)("sha256").update(token).digest("base64url").slice(0, 32);
|
|
3282
|
-
return {
|
|
3283
|
-
id: `anon:${digest}`,
|
|
3284
|
-
roles: [
|
|
3285
|
-
...this.roles
|
|
3286
|
-
]
|
|
3287
|
-
};
|
|
3288
|
-
}
|
|
3289
|
-
setCookie(req, token) {
|
|
3290
|
-
const res = req.res;
|
|
3291
|
-
if (res?.setHeader === void 0 || res.headersSent === true) return;
|
|
3292
|
-
const sameSite = this.options.sameSite ?? "lax";
|
|
3293
|
-
const secureOption = this.options.secure ?? "auto";
|
|
3294
|
-
const secure = sameSite === "none" || (secureOption === "auto" ? isHttps(req) : secureOption);
|
|
3295
|
-
const maxAge = Math.round((this.options.maxAgeDays ?? 365) * 24 * 60 * 60);
|
|
3296
|
-
const cookie = [
|
|
3297
|
-
`${this.cookieName}=${token}`,
|
|
3298
|
-
`Path=${this.options.path ?? "/"}`,
|
|
3299
|
-
`Max-Age=${maxAge}`,
|
|
3300
|
-
"HttpOnly",
|
|
3301
|
-
`SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`,
|
|
3302
|
-
...secure ? [
|
|
3303
|
-
"Secure"
|
|
3304
|
-
] : []
|
|
3305
|
-
].join("; ");
|
|
3306
|
-
const existing = res.getHeader?.("Set-Cookie");
|
|
3307
|
-
const list = Array.isArray(existing) ? existing.map(String) : existing !== void 0 ? [
|
|
3308
|
-
String(existing)
|
|
3309
|
-
] : [];
|
|
3310
|
-
res.setHeader("Set-Cookie", [
|
|
3311
|
-
...list,
|
|
3312
|
-
cookie
|
|
3313
|
-
]);
|
|
3314
|
-
}
|
|
3315
|
-
};
|
|
3316
|
-
|
|
3317
3349
|
// src/runner/inline-agent-runner.ts
|
|
3318
|
-
var
|
|
3319
|
-
var
|
|
3320
|
-
function
|
|
3350
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
3351
|
+
var import_common19 = require("@nestjs/common");
|
|
3352
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3321
3353
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3322
3354
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3323
3355
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3330,26 +3362,26 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3330
3362
|
}
|
|
3331
3363
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3332
3364
|
}
|
|
3333
|
-
__name(
|
|
3334
|
-
function
|
|
3365
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3366
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3335
3367
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3336
3368
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3337
3369
|
}
|
|
3338
3370
|
}
|
|
3339
|
-
__name(
|
|
3340
|
-
function
|
|
3371
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3372
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3341
3373
|
return function(target, key) {
|
|
3342
3374
|
decorator(target, key, paramIndex);
|
|
3343
3375
|
};
|
|
3344
3376
|
}
|
|
3345
|
-
__name(
|
|
3377
|
+
__name(_ts_param18, "_ts_param");
|
|
3346
3378
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
3347
3379
|
static {
|
|
3348
3380
|
__name(this, "InlineAgentRunner");
|
|
3349
3381
|
}
|
|
3350
3382
|
factory;
|
|
3351
3383
|
store;
|
|
3352
|
-
logger = new
|
|
3384
|
+
logger = new import_common19.Logger(_InlineAgentRunner.name);
|
|
3353
3385
|
pending = /* @__PURE__ */ new Map();
|
|
3354
3386
|
/**
|
|
3355
3387
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -3378,18 +3410,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3378
3410
|
] : []
|
|
3379
3411
|
]
|
|
3380
3412
|
});
|
|
3381
|
-
void (0,
|
|
3413
|
+
void (0, import_nestjs_agent_core22.runAgentLoop)({
|
|
3382
3414
|
...deps,
|
|
3383
3415
|
day
|
|
3384
3416
|
}, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
|
|
3385
|
-
if (error instanceof
|
|
3417
|
+
if (error instanceof import_nestjs_agent_core22.RunCancelledError) {
|
|
3386
3418
|
await this.settleCancelled(runId, input.threadId, deps);
|
|
3387
3419
|
return;
|
|
3388
3420
|
}
|
|
3389
3421
|
const message = error instanceof Error ? error.message : String(error);
|
|
3390
|
-
const code = (0,
|
|
3422
|
+
const code = (0, import_nestjs_agent_core22.agentFailureCode)(error);
|
|
3391
3423
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
3392
|
-
(0,
|
|
3424
|
+
(0, import_nestjs_agent_core22.publishAgentRunFailed)({
|
|
3393
3425
|
runId,
|
|
3394
3426
|
code,
|
|
3395
3427
|
message
|
|
@@ -3438,7 +3470,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3438
3470
|
for (const [key, waiter] of this.pending) {
|
|
3439
3471
|
if (key.startsWith(`${runId}:`)) {
|
|
3440
3472
|
this.pending.delete(key);
|
|
3441
|
-
waiter.reject(new
|
|
3473
|
+
waiter.reject(new import_nestjs_agent_core22.RunCancelledError());
|
|
3442
3474
|
}
|
|
3443
3475
|
}
|
|
3444
3476
|
await Promise.resolve();
|
|
@@ -3453,7 +3485,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3453
3485
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
3454
3486
|
await this.store.setActiveStream(threadId, null);
|
|
3455
3487
|
const writer = await deps.sink.open(runId);
|
|
3456
|
-
await writer.write((0,
|
|
3488
|
+
await writer.write((0, import_nestjs_agent_core22.encodeStreamEvent)({
|
|
3457
3489
|
kind: "cancelled"
|
|
3458
3490
|
}));
|
|
3459
3491
|
await writer.end();
|
|
@@ -3514,7 +3546,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3514
3546
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3515
3547
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3516
3548
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3517
|
-
parallel:
|
|
3549
|
+
parallel: import_nestjs_agent_core22.settleAll,
|
|
3518
3550
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
3519
3551
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
3520
3552
|
agentName,
|
|
@@ -3565,7 +3597,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3565
3597
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3566
3598
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3567
3599
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3568
|
-
parallel:
|
|
3600
|
+
parallel: import_nestjs_agent_core22.settleAll,
|
|
3569
3601
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
3570
3602
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
3571
3603
|
agentName: childName,
|
|
@@ -3598,7 +3630,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3598
3630
|
}
|
|
3599
3631
|
}), "startAgent")
|
|
3600
3632
|
};
|
|
3601
|
-
void (0,
|
|
3633
|
+
void (0, import_nestjs_agent_core22.runAgentLoop)({
|
|
3602
3634
|
...deps,
|
|
3603
3635
|
day
|
|
3604
3636
|
}, {
|
|
@@ -3612,13 +3644,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3612
3644
|
parentRunId,
|
|
3613
3645
|
deliverTo
|
|
3614
3646
|
}, hooks).catch(async (error) => {
|
|
3615
|
-
const cancelled = error instanceof
|
|
3647
|
+
const cancelled = error instanceof import_nestjs_agent_core22.RunCancelledError;
|
|
3616
3648
|
const message = error instanceof Error ? error.message : String(error);
|
|
3617
3649
|
if (!cancelled) {
|
|
3618
3650
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
3619
|
-
(0,
|
|
3651
|
+
(0, import_nestjs_agent_core22.publishAgentRunFailed)({
|
|
3620
3652
|
runId,
|
|
3621
|
-
code: (0,
|
|
3653
|
+
code: (0, import_nestjs_agent_core22.agentFailureCode)(error),
|
|
3622
3654
|
message
|
|
3623
3655
|
});
|
|
3624
3656
|
}
|
|
@@ -3626,11 +3658,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3626
3658
|
runId,
|
|
3627
3659
|
status: cancelled ? "cancelled" : "failed",
|
|
3628
3660
|
...cancelled ? {} : {
|
|
3629
|
-
errorCode: (0,
|
|
3661
|
+
errorCode: (0, import_nestjs_agent_core22.agentFailureCode)(error),
|
|
3630
3662
|
errorMessage: message
|
|
3631
3663
|
}
|
|
3632
3664
|
});
|
|
3633
|
-
await (0,
|
|
3665
|
+
await (0, import_nestjs_agent_core22.settleUnsettledDelegation)({
|
|
3634
3666
|
store: this.store,
|
|
3635
3667
|
delivery: deliverTo,
|
|
3636
3668
|
agent: agentName,
|
|
@@ -3669,7 +3701,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3669
3701
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3670
3702
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3671
3703
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3672
|
-
parallel:
|
|
3704
|
+
parallel: import_nestjs_agent_core22.settleAll,
|
|
3673
3705
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
3674
3706
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
3675
3707
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -3704,7 +3736,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3704
3736
|
}), "startAgent")
|
|
3705
3737
|
};
|
|
3706
3738
|
try {
|
|
3707
|
-
return await (0,
|
|
3739
|
+
return await (0, import_nestjs_agent_core22.runAgentLoop)({
|
|
3708
3740
|
...deps,
|
|
3709
3741
|
day
|
|
3710
3742
|
}, {
|
|
@@ -3723,19 +3755,19 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3723
3755
|
}
|
|
3724
3756
|
}
|
|
3725
3757
|
};
|
|
3726
|
-
InlineAgentRunner =
|
|
3727
|
-
(0,
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3758
|
+
InlineAgentRunner = _ts_decorate19([
|
|
3759
|
+
(0, import_common19.Injectable)(),
|
|
3760
|
+
_ts_param18(0, (0, import_common19.Inject)(import_nestjs_agent_core22.AGENT_DEPS_FACTORY)),
|
|
3761
|
+
_ts_param18(1, (0, import_common19.Inject)(import_nestjs_agent_core22.AGENT_STORE)),
|
|
3762
|
+
_ts_metadata19("design:type", Function),
|
|
3763
|
+
_ts_metadata19("design:paramtypes", [
|
|
3732
3764
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3733
3765
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
3734
3766
|
])
|
|
3735
3767
|
], InlineAgentRunner);
|
|
3736
3768
|
|
|
3737
3769
|
// src/skills-config.ts
|
|
3738
|
-
var
|
|
3770
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
3739
3771
|
function declaredSkillProvider(declared) {
|
|
3740
3772
|
return {
|
|
3741
3773
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -3761,7 +3793,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3761
3793
|
declaredSkillProvider(declared)
|
|
3762
3794
|
];
|
|
3763
3795
|
return {
|
|
3764
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
3796
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core23.compositeSkillProvider)(providers),
|
|
3765
3797
|
...options.scopes !== void 0 ? {
|
|
3766
3798
|
scopes: options.scopes
|
|
3767
3799
|
} : {},
|
|
@@ -3773,7 +3805,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3773
3805
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3774
3806
|
|
|
3775
3807
|
// src/agent.module.ts
|
|
3776
|
-
function
|
|
3808
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3777
3809
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3778
3810
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3779
3811
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3786,13 +3818,13 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
3786
3818
|
}
|
|
3787
3819
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3788
3820
|
}
|
|
3789
|
-
__name(
|
|
3821
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3790
3822
|
var DEFAULT_PATH = "agent";
|
|
3791
|
-
var logger = new
|
|
3823
|
+
var logger = new import_common20.Logger("AgentModule");
|
|
3792
3824
|
function externalStoreWrapper(modules) {
|
|
3793
3825
|
for (const module2 of modules.values()) {
|
|
3794
3826
|
if (module2.metatype === AgentModule) continue;
|
|
3795
|
-
const wrapper = module2.providers.get(
|
|
3827
|
+
const wrapper = module2.providers.get(import_nestjs_agent_core24.AGENT_STORE);
|
|
3796
3828
|
if (wrapper !== void 0) return wrapper;
|
|
3797
3829
|
}
|
|
3798
3830
|
return void 0;
|
|
@@ -3823,9 +3855,13 @@ function resolveStore(options, modules) {
|
|
|
3823
3855
|
const external = externalStoreWrapper(modules);
|
|
3824
3856
|
if (external !== void 0) return forwardingStore(external);
|
|
3825
3857
|
logger.warn("No `store` configured and no store module imported \u2014 using the in-memory store. Threads are lost on restart and not shared between processes: not for production. Pass `store`, or import a store module (e.g. MikroOrmAgentStoreModule.forFeature()).");
|
|
3826
|
-
return new
|
|
3858
|
+
return new import_nestjs_agent_core24.InMemoryAgentStore();
|
|
3827
3859
|
}
|
|
3828
3860
|
__name(resolveStore, "resolveStore");
|
|
3861
|
+
function isQuotaProvider(quota) {
|
|
3862
|
+
return quota !== void 0 && typeof quota.report === "function";
|
|
3863
|
+
}
|
|
3864
|
+
__name(isQuotaProvider, "isQuotaProvider");
|
|
3829
3865
|
function resolveCatalog(options) {
|
|
3830
3866
|
if (options.models !== void 0) return options.models;
|
|
3831
3867
|
const carried = options.model.catalog;
|
|
@@ -3835,107 +3871,97 @@ __name(resolveCatalog, "resolveCatalog");
|
|
|
3835
3871
|
function sharedProviders(durable) {
|
|
3836
3872
|
const providers = [
|
|
3837
3873
|
{
|
|
3838
|
-
provide:
|
|
3839
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
3874
|
+
provide: import_nestjs_agent_core24.AGENT_TOOL_REGISTRY,
|
|
3875
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core24.ToolRegistry(), "useFactory")
|
|
3840
3876
|
},
|
|
3841
3877
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
3842
3878
|
{
|
|
3843
|
-
provide:
|
|
3844
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
3879
|
+
provide: import_nestjs_agent_core24.AGENT_REGISTRY,
|
|
3880
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core24.AgentRegistry(), "useFactory")
|
|
3845
3881
|
},
|
|
3846
3882
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
3847
3883
|
{
|
|
3848
|
-
provide:
|
|
3884
|
+
provide: import_nestjs_agent_core24.AGENT_PROMPT_CONTRIBUTORS,
|
|
3849
3885
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
3850
3886
|
},
|
|
3851
3887
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
3852
3888
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
3853
3889
|
{
|
|
3854
|
-
provide:
|
|
3890
|
+
provide: import_nestjs_agent_core24.AGENT_SKILL_SOURCES,
|
|
3855
3891
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
3856
3892
|
},
|
|
3857
3893
|
{
|
|
3858
3894
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
3859
3895
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
3860
3896
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
3861
|
-
provide:
|
|
3897
|
+
provide: import_nestjs_agent_core24.AGENT_SKILLS,
|
|
3862
3898
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3863
3899
|
inject: [
|
|
3864
|
-
|
|
3865
|
-
|
|
3900
|
+
import_nestjs_agent_core24.AGENT_OPTIONS,
|
|
3901
|
+
import_nestjs_agent_core24.AGENT_SKILL_SOURCES
|
|
3866
3902
|
]
|
|
3867
3903
|
},
|
|
3868
3904
|
{
|
|
3869
3905
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
3870
3906
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
3871
|
-
provide:
|
|
3907
|
+
provide: import_nestjs_agent_core24.AGENT_MEMORY,
|
|
3872
3908
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
3873
3909
|
inject: [
|
|
3874
|
-
|
|
3910
|
+
import_nestjs_agent_core24.AGENT_OPTIONS
|
|
3875
3911
|
]
|
|
3876
3912
|
},
|
|
3877
3913
|
{
|
|
3878
|
-
provide:
|
|
3914
|
+
provide: import_nestjs_agent_core24.AGENT_SINK,
|
|
3879
3915
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
3880
3916
|
inject: [
|
|
3881
|
-
|
|
3917
|
+
import_nestjs_agent_core24.AGENT_OPTIONS
|
|
3882
3918
|
]
|
|
3883
3919
|
},
|
|
3884
3920
|
{
|
|
3885
|
-
provide:
|
|
3886
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
3921
|
+
provide: import_nestjs_agent_core24.AGENT_ROLES_POLICY,
|
|
3922
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core24.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
3887
3923
|
inject: [
|
|
3888
|
-
|
|
3924
|
+
import_nestjs_agent_core24.AGENT_OPTIONS
|
|
3889
3925
|
]
|
|
3890
3926
|
},
|
|
3891
3927
|
{
|
|
3892
|
-
provide:
|
|
3928
|
+
provide: import_nestjs_agent_core24.AGENT_ACTOR_RESOLVER,
|
|
3893
3929
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
3894
3930
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
3895
3931
|
logger.warn("No `actorResolver` configured \u2014 the agent endpoints are PUBLIC: every browser gets its own anonymous identity (an HttpOnly cookie). Set `actorResolver: requestUserActorResolver()` (or your own) to require login.");
|
|
3896
3932
|
return new AnonymousActorResolver();
|
|
3897
3933
|
}, "useFactory"),
|
|
3898
3934
|
inject: [
|
|
3899
|
-
|
|
3935
|
+
import_nestjs_agent_core24.AGENT_OPTIONS
|
|
3900
3936
|
]
|
|
3901
3937
|
},
|
|
3902
3938
|
{
|
|
3903
|
-
provide:
|
|
3939
|
+
provide: import_nestjs_agent_core24.AGENT_MODEL,
|
|
3904
3940
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
3905
3941
|
inject: [
|
|
3906
|
-
|
|
3942
|
+
import_nestjs_agent_core24.AGENT_OPTIONS
|
|
3907
3943
|
]
|
|
3908
3944
|
},
|
|
3909
3945
|
{
|
|
3910
|
-
//
|
|
3911
|
-
//
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
3946
|
+
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
3947
|
+
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
3948
|
+
provide: import_nestjs_agent_core24.AGENT_QUOTA_PROVIDER,
|
|
3949
|
+
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits), "useFactory"),
|
|
3915
3950
|
inject: [
|
|
3916
|
-
|
|
3917
|
-
|
|
3951
|
+
import_nestjs_agent_core24.AGENT_OPTIONS,
|
|
3952
|
+
import_nestjs_agent_core24.AGENT_STORE
|
|
3918
3953
|
]
|
|
3919
3954
|
},
|
|
3920
3955
|
{
|
|
3921
|
-
provide:
|
|
3922
|
-
useFactory: /* @__PURE__ */ __name((o, store, quota) => o.quotaProvider ?? new LedgerQuotaProvider(store, quota, o.quotaLimits), "useFactory"),
|
|
3923
|
-
inject: [
|
|
3924
|
-
import_nestjs_agent_core23.AGENT_OPTIONS,
|
|
3925
|
-
import_nestjs_agent_core23.AGENT_STORE,
|
|
3926
|
-
import_nestjs_agent_core23.AGENT_QUOTA_STORE
|
|
3927
|
-
]
|
|
3928
|
-
},
|
|
3929
|
-
{
|
|
3930
|
-
provide: import_nestjs_agent_core23.AGENT_MODEL_CATALOG,
|
|
3956
|
+
provide: import_nestjs_agent_core24.AGENT_MODEL_CATALOG,
|
|
3931
3957
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
3932
3958
|
inject: [
|
|
3933
|
-
|
|
3959
|
+
import_nestjs_agent_core24.AGENT_OPTIONS
|
|
3934
3960
|
]
|
|
3935
3961
|
},
|
|
3936
3962
|
AgentDepsFactory2,
|
|
3937
3963
|
{
|
|
3938
|
-
provide:
|
|
3964
|
+
provide: import_nestjs_agent_core24.AGENT_DEPS_FACTORY,
|
|
3939
3965
|
useExisting: AgentDepsFactory2
|
|
3940
3966
|
},
|
|
3941
3967
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -3949,21 +3975,21 @@ function sharedProviders(durable) {
|
|
|
3949
3975
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
3950
3976
|
AgentApprovalPortAdapter,
|
|
3951
3977
|
{
|
|
3952
|
-
provide:
|
|
3978
|
+
provide: import_nestjs_agent_core24.AGENT_APPROVAL_PORT,
|
|
3953
3979
|
useExisting: AgentApprovalPortAdapter
|
|
3954
3980
|
}
|
|
3955
3981
|
];
|
|
3956
3982
|
providers.push({
|
|
3957
|
-
provide:
|
|
3983
|
+
provide: import_nestjs_agent_core24.AGENT_STORE,
|
|
3958
3984
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
3959
3985
|
inject: [
|
|
3960
|
-
|
|
3986
|
+
import_nestjs_agent_core24.AGENT_OPTIONS,
|
|
3961
3987
|
import_core4.ModulesContainer
|
|
3962
3988
|
]
|
|
3963
3989
|
});
|
|
3964
3990
|
if (durable) {
|
|
3965
3991
|
providers.push({
|
|
3966
|
-
provide:
|
|
3992
|
+
provide: import_nestjs_agent_core24.AGENT_RUNNER,
|
|
3967
3993
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
3968
3994
|
if (durableRunner === void 0) {
|
|
3969
3995
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -3972,14 +3998,14 @@ function sharedProviders(durable) {
|
|
|
3972
3998
|
}, "useFactory"),
|
|
3973
3999
|
inject: [
|
|
3974
4000
|
{
|
|
3975
|
-
token:
|
|
4001
|
+
token: import_nestjs_agent_core24.AGENT_DURABLE_RUNNER,
|
|
3976
4002
|
optional: true
|
|
3977
4003
|
}
|
|
3978
4004
|
]
|
|
3979
4005
|
});
|
|
3980
4006
|
} else {
|
|
3981
4007
|
providers.push({
|
|
3982
|
-
provide:
|
|
4008
|
+
provide: import_nestjs_agent_core24.AGENT_RUNNER,
|
|
3983
4009
|
useExisting: InlineAgentRunner
|
|
3984
4010
|
});
|
|
3985
4011
|
}
|
|
@@ -3988,25 +4014,24 @@ function sharedProviders(durable) {
|
|
|
3988
4014
|
__name(sharedProviders, "sharedProviders");
|
|
3989
4015
|
function exportsFor() {
|
|
3990
4016
|
return [
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
import_nestjs_agent_core23.AGENT_DEPS_FACTORY,
|
|
4017
|
+
import_nestjs_agent_core24.AGENT_OPTIONS,
|
|
4018
|
+
import_nestjs_agent_core24.AGENT_TOOL_REGISTRY,
|
|
4019
|
+
import_nestjs_agent_core24.AGENT_REGISTRY,
|
|
4020
|
+
import_nestjs_agent_core24.AGENT_SINK,
|
|
4021
|
+
import_nestjs_agent_core24.AGENT_ROLES_POLICY,
|
|
4022
|
+
import_nestjs_agent_core24.AGENT_ACTOR_RESOLVER,
|
|
4023
|
+
import_nestjs_agent_core24.AGENT_MODEL,
|
|
4024
|
+
import_nestjs_agent_core24.AGENT_STORE,
|
|
4025
|
+
import_nestjs_agent_core24.AGENT_MODEL_CATALOG,
|
|
4026
|
+
import_nestjs_agent_core24.AGENT_QUOTA_PROVIDER,
|
|
4027
|
+
import_nestjs_agent_core24.AGENT_PROMPT_CONTRIBUTORS,
|
|
4028
|
+
import_nestjs_agent_core24.AGENT_SKILLS,
|
|
4029
|
+
import_nestjs_agent_core24.AGENT_MEMORY,
|
|
4030
|
+
import_nestjs_agent_core24.AGENT_DEPS_FACTORY,
|
|
4006
4031
|
AgentDepsFactory2,
|
|
4007
4032
|
AgentService,
|
|
4008
4033
|
InlineAgentRunner,
|
|
4009
|
-
|
|
4034
|
+
import_nestjs_agent_core24.AGENT_APPROVAL_PORT
|
|
4010
4035
|
];
|
|
4011
4036
|
}
|
|
4012
4037
|
__name(exportsFor, "exportsFor");
|
|
@@ -4020,21 +4045,13 @@ var BASE_CONTROLLERS = [
|
|
|
4020
4045
|
MemoriesController,
|
|
4021
4046
|
ToolsController,
|
|
4022
4047
|
MessagesController,
|
|
4023
|
-
ModelsController
|
|
4024
|
-
|
|
4025
|
-
var GUARDABLE_CONTROLLERS = [
|
|
4026
|
-
...BASE_CONTROLLERS,
|
|
4048
|
+
ModelsController,
|
|
4049
|
+
ConfigController,
|
|
4027
4050
|
AttachmentsController
|
|
4028
4051
|
];
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
AttachmentsController
|
|
4033
|
-
] : BASE_CONTROLLERS;
|
|
4034
|
-
}
|
|
4035
|
-
__name(controllersFor, "controllersFor");
|
|
4036
|
-
function controllersForSurface(surface, mountAttachments) {
|
|
4037
|
-
return surface === "engine" ? [] : controllersFor(mountAttachments);
|
|
4052
|
+
var GUARDABLE_CONTROLLERS = BASE_CONTROLLERS;
|
|
4053
|
+
function controllersForSurface(surface) {
|
|
4054
|
+
return surface === "engine" ? [] : BASE_CONTROLLERS;
|
|
4038
4055
|
}
|
|
4039
4056
|
__name(controllersForSurface, "controllersForSurface");
|
|
4040
4057
|
var GUARDS_METADATA = "__guards__";
|
|
@@ -4074,10 +4091,10 @@ var AgentModule = class _AgentModule {
|
|
|
4074
4091
|
import_core4.DiscoveryModule,
|
|
4075
4092
|
routerFor(path)
|
|
4076
4093
|
],
|
|
4077
|
-
controllers: controllersForSurface(options.surface
|
|
4094
|
+
controllers: controllersForSurface(options.surface),
|
|
4078
4095
|
providers: [
|
|
4079
4096
|
{
|
|
4080
|
-
provide:
|
|
4097
|
+
provide: import_nestjs_agent_core24.AGENT_OPTIONS,
|
|
4081
4098
|
useValue: options
|
|
4082
4099
|
},
|
|
4083
4100
|
...sharedProviders(options.durable ?? false),
|
|
@@ -4097,10 +4114,10 @@ var AgentModule = class _AgentModule {
|
|
|
4097
4114
|
routerFor(path),
|
|
4098
4115
|
...options.imports ?? []
|
|
4099
4116
|
],
|
|
4100
|
-
controllers: controllersForSurface(options.surface
|
|
4117
|
+
controllers: controllersForSurface(options.surface),
|
|
4101
4118
|
providers: [
|
|
4102
4119
|
{
|
|
4103
|
-
provide:
|
|
4120
|
+
provide: import_nestjs_agent_core24.AGENT_OPTIONS,
|
|
4104
4121
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
4105
4122
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
4106
4123
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -4121,13 +4138,13 @@ var AgentModule = class _AgentModule {
|
|
|
4121
4138
|
};
|
|
4122
4139
|
}
|
|
4123
4140
|
};
|
|
4124
|
-
AgentModule =
|
|
4125
|
-
(0,
|
|
4126
|
-
(0,
|
|
4141
|
+
AgentModule = _ts_decorate20([
|
|
4142
|
+
(0, import_common20.Global)(),
|
|
4143
|
+
(0, import_common20.Module)({})
|
|
4127
4144
|
], AgentModule);
|
|
4128
4145
|
|
|
4129
4146
|
// src/resolver/header-actor-resolver.ts
|
|
4130
|
-
var
|
|
4147
|
+
var import_common21 = require("@nestjs/common");
|
|
4131
4148
|
function readHeader(req, name) {
|
|
4132
4149
|
if (typeof req !== "object" || req === null || !("headers" in req)) return void 0;
|
|
4133
4150
|
const { headers } = req;
|
|
@@ -4143,7 +4160,7 @@ var HeaderActorResolver = class {
|
|
|
4143
4160
|
resolve(req) {
|
|
4144
4161
|
const id = readHeader(req, "x-actor-id");
|
|
4145
4162
|
if (id === void 0 || id.length === 0) {
|
|
4146
|
-
throw new
|
|
4163
|
+
throw new import_common21.UnauthorizedException("HeaderActorResolver: missing x-actor-id header. No default actor is fabricated. Send x-actor-id from a trusted gateway, or configure AgentModule.forRoot({ actorResolver }) with a resolver that reads your authenticated principal.");
|
|
4147
4164
|
}
|
|
4148
4165
|
const roles = (readHeader(req, "x-actor-role") ?? "").split(",").map((role) => role.trim()).filter((role) => role.length > 0);
|
|
4149
4166
|
const tenantRef = readHeader(req, "x-tenant-ref");
|
|
@@ -4158,7 +4175,7 @@ var HeaderActorResolver = class {
|
|
|
4158
4175
|
};
|
|
4159
4176
|
|
|
4160
4177
|
// src/resolver/request-user-actor-resolver.ts
|
|
4161
|
-
var
|
|
4178
|
+
var import_common22 = require("@nestjs/common");
|
|
4162
4179
|
function field(user, ...names) {
|
|
4163
4180
|
for (const name of names) {
|
|
4164
4181
|
const value = user[name];
|
|
@@ -4170,7 +4187,7 @@ __name(field, "field");
|
|
|
4170
4187
|
function defaultRequestUserMapper(user) {
|
|
4171
4188
|
const id = field(user, "id", "sub", "_id", "userId");
|
|
4172
4189
|
if (id === void 0) {
|
|
4173
|
-
throw new
|
|
4190
|
+
throw new import_common22.UnauthorizedException("requestUserActorResolver: req.user has no id/sub/_id/userId \u2014 pass a mapper: requestUserActorResolver((user) => ({ id: \u2026, roles: \u2026 }))");
|
|
4174
4191
|
}
|
|
4175
4192
|
const rawRoles = field(user, "roles", "role");
|
|
4176
4193
|
const roles = Array.isArray(rawRoles) ? rawRoles.map(String) : typeof rawRoles === "string" ? [
|
|
@@ -4191,7 +4208,7 @@ function requestUserActorResolver(map) {
|
|
|
4191
4208
|
async resolve(req) {
|
|
4192
4209
|
const user = typeof req === "object" && req !== null ? req.user : void 0;
|
|
4193
4210
|
if (user === void 0 || user === null || user === false) {
|
|
4194
|
-
throw new
|
|
4211
|
+
throw new import_common22.UnauthorizedException("Sign in to use the agent.");
|
|
4195
4212
|
}
|
|
4196
4213
|
if (map !== void 0) return map(user, req);
|
|
4197
4214
|
return defaultRequestUserMapper(user);
|
|
@@ -4218,13 +4235,14 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
|
|
|
4218
4235
|
AiToolDiscoveryService,
|
|
4219
4236
|
AnonymousActorResolver,
|
|
4220
4237
|
AttachmentsController,
|
|
4238
|
+
ConfigController,
|
|
4221
4239
|
DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
|
|
4222
4240
|
DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
4223
4241
|
HeaderActorResolver,
|
|
4224
4242
|
InProcessTokenStreamSink,
|
|
4225
4243
|
InlineAgentRunner,
|
|
4226
4244
|
LedgerQuotaProvider,
|
|
4227
|
-
|
|
4245
|
+
MAX_ATTACHMENTS_PER_MESSAGE,
|
|
4228
4246
|
MemoriesController,
|
|
4229
4247
|
MessagesController,
|
|
4230
4248
|
ModelsController,
|
|
@@ -4237,6 +4255,7 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
|
|
|
4237
4255
|
SystemPrompt,
|
|
4238
4256
|
SystemPromptContributor,
|
|
4239
4257
|
ToolsController,
|
|
4258
|
+
attachmentLimits,
|
|
4240
4259
|
declaredSkillProvider,
|
|
4241
4260
|
defaultRequestUserMapper,
|
|
4242
4261
|
delegateToolName,
|