@dudousxd/nestjs-agent 1.10.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 +75 -48
- package/dist/{agent-deps.factory-DuTy1UyU.d.cts → agent-deps.factory-pqv_qTmJ.d.cts} +47 -71
- package/dist/{agent-deps.factory-DuTy1UyU.d.ts → agent-deps.factory-pqv_qTmJ.d.ts} +47 -71
- package/dist/durable/index.cjs +729 -584
- 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 +634 -489
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +805 -591
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -55
- package/dist/index.d.ts +137 -55
- package/dist/index.js +699 -491
- 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 +3 -3
package/dist/index.js
CHANGED
|
@@ -2,12 +2,12 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/agent.module.ts
|
|
5
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
6
|
-
import { Global, Module } from "@nestjs/common";
|
|
7
|
-
import { DiscoveryModule, RouterModule } from "@nestjs/core";
|
|
5
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER12, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_DURABLE_RUNNER, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS6, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_REGISTRY as AGENT_REGISTRY6, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK2, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
6
|
+
import { Global, Logger as Logger5, Module } from "@nestjs/common";
|
|
7
|
+
import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
|
|
8
8
|
|
|
9
9
|
// src/agent-deps.factory.ts
|
|
10
|
-
import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS,
|
|
10
|
+
import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK, AGENT_SKILLS, AGENT_STORE, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2, normalizeDelegation, summarizeWithModel, windowHistory } from "@dudousxd/nestjs-agent-core";
|
|
11
11
|
import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
|
|
12
12
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
13
13
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -53,11 +53,10 @@ var AgentDepsFactory2 = class {
|
|
|
53
53
|
registry;
|
|
54
54
|
agents;
|
|
55
55
|
promptContributors;
|
|
56
|
-
quota;
|
|
57
56
|
pricingStore;
|
|
58
57
|
skills;
|
|
59
58
|
memory;
|
|
60
|
-
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors,
|
|
59
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory) {
|
|
61
60
|
this.options = options;
|
|
62
61
|
this.model = model;
|
|
63
62
|
this.store = store;
|
|
@@ -66,7 +65,6 @@ var AgentDepsFactory2 = class {
|
|
|
66
65
|
this.registry = registry;
|
|
67
66
|
this.agents = agents;
|
|
68
67
|
this.promptContributors = promptContributors;
|
|
69
|
-
this.quota = quota;
|
|
70
68
|
this.pricingStore = pricingStore;
|
|
71
69
|
this.skills = skills;
|
|
72
70
|
this.memory = memory;
|
|
@@ -127,7 +125,7 @@ var AgentDepsFactory2 = class {
|
|
|
127
125
|
} : {},
|
|
128
126
|
registry: this.registry,
|
|
129
127
|
promptContributors: this.promptContributors,
|
|
130
|
-
systemPrompt: definition?.systemPrompt ?? "You are a helpful assistant.",
|
|
128
|
+
systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
|
|
131
129
|
maxSteps: definition?.maxSteps ?? 8,
|
|
132
130
|
...definition?.maxDelegationDepth !== void 0 ? {
|
|
133
131
|
maxDelegationDepth: definition.maxDelegationDepth
|
|
@@ -138,9 +136,6 @@ var AgentDepsFactory2 = class {
|
|
|
138
136
|
...definition?.modelId !== void 0 ? {
|
|
139
137
|
modelId: definition.modelId
|
|
140
138
|
} : {},
|
|
141
|
-
...this.quota !== void 0 ? {
|
|
142
|
-
quota: this.quota
|
|
143
|
-
} : {},
|
|
144
139
|
...this.pricingStore !== void 0 ? {
|
|
145
140
|
pricingStore: this.pricingStore
|
|
146
141
|
} : {},
|
|
@@ -247,13 +242,12 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
247
242
|
_ts_param(5, Inject(AGENT_TOOL_REGISTRY)),
|
|
248
243
|
_ts_param(6, Inject(AGENT_REGISTRY)),
|
|
249
244
|
_ts_param(7, Inject(AGENT_PROMPT_CONTRIBUTORS)),
|
|
250
|
-
_ts_param(8,
|
|
245
|
+
_ts_param(8, Optional()),
|
|
246
|
+
_ts_param(8, Inject(AGENT_PRICING_STORE)),
|
|
251
247
|
_ts_param(9, Optional()),
|
|
252
|
-
_ts_param(9, Inject(
|
|
248
|
+
_ts_param(9, Inject(AGENT_SKILLS)),
|
|
253
249
|
_ts_param(10, Optional()),
|
|
254
|
-
_ts_param(10, Inject(
|
|
255
|
-
_ts_param(11, Optional()),
|
|
256
|
-
_ts_param(11, Inject(AGENT_MEMORY)),
|
|
250
|
+
_ts_param(10, Inject(AGENT_MEMORY)),
|
|
257
251
|
_ts_metadata("design:type", Function),
|
|
258
252
|
_ts_metadata("design:paramtypes", [
|
|
259
253
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -266,13 +260,12 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
266
260
|
Array,
|
|
267
261
|
Object,
|
|
268
262
|
Object,
|
|
269
|
-
Object,
|
|
270
263
|
Object
|
|
271
264
|
])
|
|
272
265
|
], AgentDepsFactory2);
|
|
273
266
|
|
|
274
267
|
// src/agent.service.ts
|
|
275
|
-
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_QUOTA_PROVIDER,
|
|
268
|
+
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_QUOTA_PROVIDER, AGENT_RUNNER, AGENT_STORE as AGENT_STORE2, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval, readElicitationQuestions, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
276
269
|
import { BadRequestException, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as Inject2, Injectable as Injectable2, NotFoundException, NotImplementedException, Optional as Optional2 } from "@nestjs/common";
|
|
277
270
|
|
|
278
271
|
// src/agent-deps.ts
|
|
@@ -325,16 +318,14 @@ var AgentService = class {
|
|
|
325
318
|
runner;
|
|
326
319
|
store;
|
|
327
320
|
deps;
|
|
328
|
-
quota;
|
|
329
321
|
staging;
|
|
330
322
|
models;
|
|
331
323
|
quotaProvider;
|
|
332
324
|
options;
|
|
333
|
-
constructor(runner, store, deps,
|
|
325
|
+
constructor(runner, store, deps, staging, models, quotaProvider, options) {
|
|
334
326
|
this.runner = runner;
|
|
335
327
|
this.store = store;
|
|
336
328
|
this.deps = deps;
|
|
337
|
-
this.quota = quota;
|
|
338
329
|
this.staging = staging;
|
|
339
330
|
this.models = models;
|
|
340
331
|
this.quotaProvider = quotaProvider;
|
|
@@ -350,33 +341,23 @@ var AgentService = class {
|
|
|
350
341
|
actor
|
|
351
342
|
});
|
|
352
343
|
}
|
|
353
|
-
const
|
|
344
|
+
const { usedTokens, costUsd } = await this.store.quotaToday(actor.id, utcDay());
|
|
354
345
|
return {
|
|
355
346
|
windows: [
|
|
356
347
|
{
|
|
357
348
|
period: "day",
|
|
358
|
-
usedTokens
|
|
359
|
-
|
|
360
|
-
limitTokens: today.limitTokens
|
|
361
|
-
} : {},
|
|
362
|
-
usedUsd: today.costUsd
|
|
363
|
-
}
|
|
364
|
-
],
|
|
365
|
-
...today.withinLimit ? {} : {
|
|
366
|
-
blocked: {
|
|
367
|
-
period: "day"
|
|
349
|
+
usedTokens,
|
|
350
|
+
usedUsd: costUsd
|
|
368
351
|
}
|
|
369
|
-
|
|
352
|
+
]
|
|
370
353
|
};
|
|
371
354
|
}
|
|
372
355
|
/**
|
|
373
356
|
* Refuse a turn the actor's budget no longer covers — only when the host configured one
|
|
374
|
-
* (`
|
|
375
|
-
* quota the loop enforces keeps working as it always has.
|
|
357
|
+
* (`quota`): the default report is informational.
|
|
376
358
|
*/
|
|
377
359
|
async assertWithinQuota(actor) {
|
|
378
|
-
|
|
379
|
-
if (!gated || this.quotaProvider === void 0) {
|
|
360
|
+
if (this.options?.quota === void 0 || this.quotaProvider === void 0) {
|
|
380
361
|
return;
|
|
381
362
|
}
|
|
382
363
|
const { blocked } = await this.quotaProvider.report({
|
|
@@ -627,7 +608,7 @@ var AgentService = class {
|
|
|
627
608
|
async getThread(actor, threadId) {
|
|
628
609
|
await this.assertOwnsThread(actor, threadId);
|
|
629
610
|
const thread = await this.store.getThread(threadId);
|
|
630
|
-
return thread === null ? null : this.toDetailView(thread);
|
|
611
|
+
return thread === null ? null : this.toDetailView(thread, actor);
|
|
631
612
|
}
|
|
632
613
|
async deleteThread(actor, threadId) {
|
|
633
614
|
await this.assertOwnsThread(actor, threadId);
|
|
@@ -719,19 +700,46 @@ var AgentService = class {
|
|
|
719
700
|
...thread,
|
|
720
701
|
defaultAgent: thread.defaultAgent ?? null,
|
|
721
702
|
model: thread.model ?? null,
|
|
722
|
-
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
|
|
703
|
+
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? thread.activeRunId ?? null
|
|
723
704
|
};
|
|
724
705
|
}
|
|
725
|
-
async toDetailView(thread) {
|
|
706
|
+
async toDetailView(thread, actor) {
|
|
726
707
|
const summary = await this.toSummaryView(thread);
|
|
727
708
|
return {
|
|
728
709
|
...summary,
|
|
729
|
-
messages: thread.messages,
|
|
730
|
-
...thread.activeStreamId !== void 0 ? {
|
|
731
|
-
activeStreamId: thread.activeStreamId
|
|
732
|
-
} : {}
|
|
710
|
+
messages: await this.freshAttachmentUrls(thread.messages, actor)
|
|
733
711
|
};
|
|
734
712
|
}
|
|
713
|
+
/**
|
|
714
|
+
* Re-mint each replayed attachment's url from the staging store, by `mediaId`: the url persisted
|
|
715
|
+
* with the message was minted for THAT turn (a presigned url with an expiry), so an old turn would
|
|
716
|
+
* otherwise show a dead link. The store's own access check applies — an attachment it will not
|
|
717
|
+
* resolve for this actor keeps the url it was stored with.
|
|
718
|
+
*/
|
|
719
|
+
async freshAttachmentUrls(messages, actor) {
|
|
720
|
+
const staging = this.staging;
|
|
721
|
+
if (staging === void 0 || !messages.some((message) => message.attachments?.length)) {
|
|
722
|
+
return messages;
|
|
723
|
+
}
|
|
724
|
+
return Promise.all(messages.map(async (message) => {
|
|
725
|
+
if (message.attachments === void 0 || message.attachments.length === 0) return message;
|
|
726
|
+
const attachments = await Promise.all(message.attachments.map(async (attachment) => {
|
|
727
|
+
try {
|
|
728
|
+
const fresh = await staging.resolve({
|
|
729
|
+
mediaId: attachment.mediaId,
|
|
730
|
+
actor
|
|
731
|
+
});
|
|
732
|
+
return fresh ?? attachment;
|
|
733
|
+
} catch {
|
|
734
|
+
return attachment;
|
|
735
|
+
}
|
|
736
|
+
}));
|
|
737
|
+
return {
|
|
738
|
+
...message,
|
|
739
|
+
attachments
|
|
740
|
+
};
|
|
741
|
+
}));
|
|
742
|
+
}
|
|
735
743
|
async promoteThread(actor, threadId) {
|
|
736
744
|
await this.assertOwnsThread(actor, threadId);
|
|
737
745
|
return this.store.promoteThread(threadId);
|
|
@@ -841,30 +849,6 @@ var AgentService = class {
|
|
|
841
849
|
return list;
|
|
842
850
|
}
|
|
843
851
|
/**
|
|
844
|
-
* The day's usage for the badge: tokens + summed USD cost from the store, and the configured
|
|
845
|
-
* limit from the quota store (null → unlimited). `withinLimit` comes from the quota store so it
|
|
846
|
-
* can never drift from what enforcement uses.
|
|
847
|
-
*/
|
|
848
|
-
async quotaToday(actorRef) {
|
|
849
|
-
const day = utcDay();
|
|
850
|
-
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, day);
|
|
851
|
-
if (this.quota === void 0) {
|
|
852
|
-
return {
|
|
853
|
-
usedTokens,
|
|
854
|
-
costUsd,
|
|
855
|
-
limitTokens: null,
|
|
856
|
-
withinLimit: true
|
|
857
|
-
};
|
|
858
|
-
}
|
|
859
|
-
const state = await this.quota.check(actorRef, day);
|
|
860
|
-
return {
|
|
861
|
-
usedTokens: state.usedTokens,
|
|
862
|
-
costUsd,
|
|
863
|
-
limitTokens: state.limitTokens,
|
|
864
|
-
withinLimit: state.withinLimit
|
|
865
|
-
};
|
|
866
|
-
}
|
|
867
|
-
/**
|
|
868
852
|
* Authorization seam for thread-scoped endpoints: the caller must own the thread. A missing
|
|
869
853
|
* thread is a 404; someone else's thread is a 403 — one actor never touches another's thread.
|
|
870
854
|
*/
|
|
@@ -983,21 +967,19 @@ AgentService = _ts_decorate2([
|
|
|
983
967
|
_ts_param2(0, Inject2(AGENT_RUNNER)),
|
|
984
968
|
_ts_param2(1, Inject2(AGENT_STORE2)),
|
|
985
969
|
_ts_param2(2, Inject2(AGENT_DEPS_FACTORY)),
|
|
986
|
-
_ts_param2(3,
|
|
970
|
+
_ts_param2(3, Optional2()),
|
|
971
|
+
_ts_param2(3, Inject2(AGENT_ATTACHMENT_STAGING)),
|
|
987
972
|
_ts_param2(4, Optional2()),
|
|
988
|
-
_ts_param2(4, Inject2(
|
|
973
|
+
_ts_param2(4, Inject2(AGENT_MODEL_CATALOG)),
|
|
989
974
|
_ts_param2(5, Optional2()),
|
|
990
|
-
_ts_param2(5, Inject2(
|
|
975
|
+
_ts_param2(5, Inject2(AGENT_QUOTA_PROVIDER)),
|
|
991
976
|
_ts_param2(6, Optional2()),
|
|
992
|
-
_ts_param2(6, Inject2(
|
|
993
|
-
_ts_param2(7, Optional2()),
|
|
994
|
-
_ts_param2(7, Inject2(AGENT_OPTIONS2)),
|
|
977
|
+
_ts_param2(6, Inject2(AGENT_OPTIONS2)),
|
|
995
978
|
_ts_metadata2("design:type", Function),
|
|
996
979
|
_ts_metadata2("design:paramtypes", [
|
|
997
980
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
998
981
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
999
982
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1000
|
-
Object,
|
|
1001
983
|
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
1002
984
|
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
1003
985
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
@@ -1143,6 +1125,33 @@ AgentsController = _ts_decorate4([
|
|
|
1143
1125
|
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_OPTIONS as AGENT_OPTIONS3 } from "@dudousxd/nestjs-agent-core";
|
|
1144
1126
|
import { BadRequestException as BadRequestException2, Controller as Controller2, Get as Get2, Inject as Inject4, NotImplementedException as NotImplementedException2, Optional as Optional3, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
|
|
1145
1127
|
import { FileInterceptor } from "@nestjs/platform-express";
|
|
1128
|
+
|
|
1129
|
+
// src/attachment-limits.ts
|
|
1130
|
+
var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
1131
|
+
var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
|
|
1132
|
+
"image/png",
|
|
1133
|
+
"image/jpeg",
|
|
1134
|
+
"image/gif",
|
|
1135
|
+
"image/webp",
|
|
1136
|
+
"application/pdf",
|
|
1137
|
+
"text/plain",
|
|
1138
|
+
"text/csv"
|
|
1139
|
+
];
|
|
1140
|
+
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
1141
|
+
function attachmentLimits(options, staging) {
|
|
1142
|
+
const declared = staging?.describe?.();
|
|
1143
|
+
const own = options?.attachments;
|
|
1144
|
+
return {
|
|
1145
|
+
enabled: staging !== void 0,
|
|
1146
|
+
upload: staging === void 0 ? null : declared?.upload ?? "multipart",
|
|
1147
|
+
maxBytes: declared?.maxBytes ?? own?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
1148
|
+
allowedContentTypes: declared?.allowedContentTypes ?? own?.allowedContentTypes ?? DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
|
|
1149
|
+
maxPerMessage: MAX_ATTACHMENTS_PER_MESSAGE
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
__name(attachmentLimits, "attachmentLimits");
|
|
1153
|
+
|
|
1154
|
+
// src/controller/attachments.controller.ts
|
|
1146
1155
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1147
1156
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1148
1157
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1169,18 +1178,8 @@ function _ts_param4(paramIndex, decorator) {
|
|
|
1169
1178
|
};
|
|
1170
1179
|
}
|
|
1171
1180
|
__name(_ts_param4, "_ts_param");
|
|
1172
|
-
var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
1173
1181
|
var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
1174
1182
|
var ATTACHMENT_PAGE_SIZE = 50;
|
|
1175
|
-
var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
|
|
1176
|
-
"image/png",
|
|
1177
|
-
"image/jpeg",
|
|
1178
|
-
"image/gif",
|
|
1179
|
-
"image/webp",
|
|
1180
|
-
"application/pdf",
|
|
1181
|
-
"text/plain",
|
|
1182
|
-
"text/csv"
|
|
1183
|
-
];
|
|
1184
1183
|
var AttachmentsController = class {
|
|
1185
1184
|
static {
|
|
1186
1185
|
__name(this, "AttachmentsController");
|
|
@@ -1196,17 +1195,6 @@ var AttachmentsController = class {
|
|
|
1196
1195
|
this.staging = staging;
|
|
1197
1196
|
}
|
|
1198
1197
|
/**
|
|
1199
|
-
* `attachments.upload: true` is what mounts this controller at all (see `agent.module.ts`), so by
|
|
1200
|
-
* the time an instance exists the host clearly intends uploads to work. Fail boot loudly rather
|
|
1201
|
-
* than mounting a controller that would 501 on every single request because nobody bound
|
|
1202
|
-
* `AGENT_ATTACHMENT_STAGING`.
|
|
1203
|
-
*/
|
|
1204
|
-
onModuleInit() {
|
|
1205
|
-
if (this.options.attachments?.upload === true && this.staging === void 0) {
|
|
1206
|
-
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.");
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
/**
|
|
1210
1198
|
* The caller's own staged files, newest first — the one question `GET /agent/threads/:id` cannot
|
|
1211
1199
|
* answer, since an upload that was never sent belongs to no thread.
|
|
1212
1200
|
*
|
|
@@ -1223,16 +1211,15 @@ var AttachmentsController = class {
|
|
|
1223
1211
|
}
|
|
1224
1212
|
async upload(req, file) {
|
|
1225
1213
|
if (this.staging === void 0) {
|
|
1226
|
-
throw new NotImplementedException2("Attachment upload is not configured on this server.");
|
|
1214
|
+
throw new NotImplementedException2("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
1227
1215
|
}
|
|
1228
1216
|
if (file === void 0) {
|
|
1229
1217
|
throw new BadRequestException2('multipart field "file" is required');
|
|
1230
1218
|
}
|
|
1231
|
-
const allowedContentTypes = this.options.
|
|
1219
|
+
const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
|
|
1232
1220
|
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
1233
1221
|
throw new UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
1234
1222
|
}
|
|
1235
|
-
const maxBytes = this.options.attachments?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES;
|
|
1236
1223
|
if (file.size > maxBytes) {
|
|
1237
1224
|
throw new PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
1238
1225
|
}
|
|
@@ -1315,7 +1302,6 @@ function _ts_param5(paramIndex, decorator) {
|
|
|
1315
1302
|
};
|
|
1316
1303
|
}
|
|
1317
1304
|
__name(_ts_param5, "_ts_param");
|
|
1318
|
-
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
1319
1305
|
function attachmentRefs(claimed) {
|
|
1320
1306
|
if (claimed === void 0) {
|
|
1321
1307
|
return [];
|
|
@@ -1330,6 +1316,9 @@ function attachmentRefs(claimed) {
|
|
|
1330
1316
|
if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
|
|
1331
1317
|
throw new BadRequestException3("each attachment must be an object with a mediaId");
|
|
1332
1318
|
}
|
|
1319
|
+
if (Object.keys(entry).some((key) => key !== "mediaId")) {
|
|
1320
|
+
throw new BadRequestException3("attachments are { mediaId } refs \u2014 send nothing but the id");
|
|
1321
|
+
}
|
|
1333
1322
|
const { mediaId } = entry;
|
|
1334
1323
|
if (typeof mediaId !== "string" || mediaId.length === 0) {
|
|
1335
1324
|
throw new BadRequestException3("each attachment must carry a non-empty string mediaId");
|
|
@@ -1525,9 +1514,98 @@ function parseCursor(raw) {
|
|
|
1525
1514
|
}
|
|
1526
1515
|
__name(parseCursor, "parseCursor");
|
|
1527
1516
|
|
|
1528
|
-
// src/controller/
|
|
1529
|
-
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3,
|
|
1530
|
-
import { Controller as Controller4,
|
|
1517
|
+
// src/controller/config.controller.ts
|
|
1518
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG2, AGENT_OPTIONS as AGENT_OPTIONS4 } from "@dudousxd/nestjs-agent-core";
|
|
1519
|
+
import { Controller as Controller4, Get as Get4, Inject as Inject6, Optional as Optional4, Req as Req3 } from "@nestjs/common";
|
|
1520
|
+
|
|
1521
|
+
// src/resolver/anonymous-actor-resolver.ts
|
|
1522
|
+
import { createHash, randomBytes } from "crypto";
|
|
1523
|
+
var TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
1524
|
+
var MINTED = /* @__PURE__ */ Symbol("nestjs-agent:anonymous-token");
|
|
1525
|
+
function readCookie(req, name) {
|
|
1526
|
+
const header = req.headers?.cookie;
|
|
1527
|
+
const raw = Array.isArray(header) ? header.join("; ") : header;
|
|
1528
|
+
if (raw === void 0) return void 0;
|
|
1529
|
+
for (const pair of raw.split(";")) {
|
|
1530
|
+
const index = pair.indexOf("=");
|
|
1531
|
+
if (index === -1) continue;
|
|
1532
|
+
if (pair.slice(0, index).trim() === name) {
|
|
1533
|
+
try {
|
|
1534
|
+
return decodeURIComponent(pair.slice(index + 1).trim());
|
|
1535
|
+
} catch {
|
|
1536
|
+
return void 0;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return void 0;
|
|
1541
|
+
}
|
|
1542
|
+
__name(readCookie, "readCookie");
|
|
1543
|
+
function isHttps(req) {
|
|
1544
|
+
if (req.secure === true) return true;
|
|
1545
|
+
const forwarded = req.headers?.["x-forwarded-proto"];
|
|
1546
|
+
const proto = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
1547
|
+
return proto?.split(",")[0]?.trim() === "https";
|
|
1548
|
+
}
|
|
1549
|
+
__name(isHttps, "isHttps");
|
|
1550
|
+
var AnonymousActorResolver = class {
|
|
1551
|
+
static {
|
|
1552
|
+
__name(this, "AnonymousActorResolver");
|
|
1553
|
+
}
|
|
1554
|
+
options;
|
|
1555
|
+
cookieName;
|
|
1556
|
+
roles;
|
|
1557
|
+
constructor(options = {}) {
|
|
1558
|
+
this.options = options;
|
|
1559
|
+
this.cookieName = options.cookieName ?? "agent_anon";
|
|
1560
|
+
this.roles = options.roles ?? [
|
|
1561
|
+
"anonymous"
|
|
1562
|
+
];
|
|
1563
|
+
}
|
|
1564
|
+
resolve(request) {
|
|
1565
|
+
const req = typeof request === "object" && request !== null ? request : {};
|
|
1566
|
+
let token = req[MINTED] ?? readCookie(req, this.cookieName);
|
|
1567
|
+
if (token === void 0 || !TOKEN_PATTERN.test(token)) {
|
|
1568
|
+
token = randomBytes(32).toString("base64url");
|
|
1569
|
+
req[MINTED] = token;
|
|
1570
|
+
this.setCookie(req, token);
|
|
1571
|
+
}
|
|
1572
|
+
const digest = createHash("sha256").update(token).digest("base64url").slice(0, 32);
|
|
1573
|
+
return {
|
|
1574
|
+
id: `anon:${digest}`,
|
|
1575
|
+
roles: [
|
|
1576
|
+
...this.roles
|
|
1577
|
+
]
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
setCookie(req, token) {
|
|
1581
|
+
const res = req.res;
|
|
1582
|
+
if (res?.setHeader === void 0 || res.headersSent === true) return;
|
|
1583
|
+
const sameSite = this.options.sameSite ?? "lax";
|
|
1584
|
+
const secureOption = this.options.secure ?? "auto";
|
|
1585
|
+
const secure = sameSite === "none" || (secureOption === "auto" ? isHttps(req) : secureOption);
|
|
1586
|
+
const maxAge = Math.round((this.options.maxAgeDays ?? 365) * 24 * 60 * 60);
|
|
1587
|
+
const cookie = [
|
|
1588
|
+
`${this.cookieName}=${token}`,
|
|
1589
|
+
`Path=${this.options.path ?? "/"}`,
|
|
1590
|
+
`Max-Age=${maxAge}`,
|
|
1591
|
+
"HttpOnly",
|
|
1592
|
+
`SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`,
|
|
1593
|
+
...secure ? [
|
|
1594
|
+
"Secure"
|
|
1595
|
+
] : []
|
|
1596
|
+
].join("; ");
|
|
1597
|
+
const existing = res.getHeader?.("Set-Cookie");
|
|
1598
|
+
const list = Array.isArray(existing) ? existing.map(String) : existing !== void 0 ? [
|
|
1599
|
+
String(existing)
|
|
1600
|
+
] : [];
|
|
1601
|
+
res.setHeader("Set-Cookie", [
|
|
1602
|
+
...list,
|
|
1603
|
+
cookie
|
|
1604
|
+
]);
|
|
1605
|
+
}
|
|
1606
|
+
};
|
|
1607
|
+
|
|
1608
|
+
// src/controller/config.controller.ts
|
|
1531
1609
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
1532
1610
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1533
1611
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1554,6 +1632,91 @@ function _ts_param6(paramIndex, decorator) {
|
|
|
1554
1632
|
};
|
|
1555
1633
|
}
|
|
1556
1634
|
__name(_ts_param6, "_ts_param");
|
|
1635
|
+
var ConfigController = class {
|
|
1636
|
+
static {
|
|
1637
|
+
__name(this, "ConfigController");
|
|
1638
|
+
}
|
|
1639
|
+
options;
|
|
1640
|
+
actorResolver;
|
|
1641
|
+
staging;
|
|
1642
|
+
models;
|
|
1643
|
+
constructor(options, actorResolver, staging, models) {
|
|
1644
|
+
this.options = options;
|
|
1645
|
+
this.actorResolver = actorResolver;
|
|
1646
|
+
this.staging = staging;
|
|
1647
|
+
this.models = models;
|
|
1648
|
+
}
|
|
1649
|
+
async config(req) {
|
|
1650
|
+
await this.actorResolver.resolve(req);
|
|
1651
|
+
return {
|
|
1652
|
+
attachments: attachmentLimits(this.options, this.staging),
|
|
1653
|
+
models: {
|
|
1654
|
+
enabled: this.models !== void 0
|
|
1655
|
+
},
|
|
1656
|
+
quota: {
|
|
1657
|
+
enforced: this.options.quota !== void 0
|
|
1658
|
+
},
|
|
1659
|
+
identity: {
|
|
1660
|
+
anonymous: this.actorResolver instanceof AnonymousActorResolver
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
_ts_decorate7([
|
|
1666
|
+
Get4(),
|
|
1667
|
+
_ts_param6(0, Req3()),
|
|
1668
|
+
_ts_metadata7("design:type", Function),
|
|
1669
|
+
_ts_metadata7("design:paramtypes", [
|
|
1670
|
+
typeof Request === "undefined" ? Object : Request
|
|
1671
|
+
]),
|
|
1672
|
+
_ts_metadata7("design:returntype", Promise)
|
|
1673
|
+
], ConfigController.prototype, "config", null);
|
|
1674
|
+
ConfigController = _ts_decorate7([
|
|
1675
|
+
Controller4("config"),
|
|
1676
|
+
_ts_param6(0, Inject6(AGENT_OPTIONS4)),
|
|
1677
|
+
_ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER3)),
|
|
1678
|
+
_ts_param6(2, Optional4()),
|
|
1679
|
+
_ts_param6(2, Inject6(AGENT_ATTACHMENT_STAGING3)),
|
|
1680
|
+
_ts_param6(3, Optional4()),
|
|
1681
|
+
_ts_param6(3, Inject6(AGENT_MODEL_CATALOG2)),
|
|
1682
|
+
_ts_metadata7("design:type", Function),
|
|
1683
|
+
_ts_metadata7("design:paramtypes", [
|
|
1684
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
1685
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1686
|
+
Object,
|
|
1687
|
+
Object
|
|
1688
|
+
])
|
|
1689
|
+
], ConfigController);
|
|
1690
|
+
|
|
1691
|
+
// src/controller/memories.controller.ts
|
|
1692
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4, AGENT_MEMORY as AGENT_MEMORY2, memoryForgetVerdict, offerMemories } from "@dudousxd/nestjs-agent-core";
|
|
1693
|
+
import { Controller as Controller5, Delete, ForbiddenException as ForbiddenException2, Get as Get5, Inject as Inject7, NotFoundException as NotFoundException2, Optional as Optional5, Param as Param2, Query as Query2, Req as Req4 } from "@nestjs/common";
|
|
1694
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1695
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1696
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1697
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1698
|
+
} else {
|
|
1699
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1700
|
+
if (d = decorators[i]) {
|
|
1701
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1706
|
+
}
|
|
1707
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1708
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
1709
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1710
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
1714
|
+
function _ts_param7(paramIndex, decorator) {
|
|
1715
|
+
return function(target, key) {
|
|
1716
|
+
decorator(target, key, paramIndex);
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
__name(_ts_param7, "_ts_param");
|
|
1557
1720
|
var MemoriesController = class {
|
|
1558
1721
|
static {
|
|
1559
1722
|
__name(this, "MemoriesController");
|
|
@@ -1626,44 +1789,44 @@ var MemoriesController = class {
|
|
|
1626
1789
|
});
|
|
1627
1790
|
}
|
|
1628
1791
|
};
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1792
|
+
_ts_decorate8([
|
|
1793
|
+
Get5(),
|
|
1794
|
+
_ts_param7(0, Req4()),
|
|
1795
|
+
_ts_param7(1, Query2("threadId")),
|
|
1796
|
+
_ts_metadata8("design:type", Function),
|
|
1797
|
+
_ts_metadata8("design:paramtypes", [
|
|
1635
1798
|
typeof Request === "undefined" ? Object : Request,
|
|
1636
1799
|
String
|
|
1637
1800
|
]),
|
|
1638
|
-
|
|
1801
|
+
_ts_metadata8("design:returntype", Promise)
|
|
1639
1802
|
], MemoriesController.prototype, "list", null);
|
|
1640
|
-
|
|
1803
|
+
_ts_decorate8([
|
|
1641
1804
|
Delete(":id"),
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1805
|
+
_ts_param7(0, Req4()),
|
|
1806
|
+
_ts_param7(1, Param2("id")),
|
|
1807
|
+
_ts_metadata8("design:type", Function),
|
|
1808
|
+
_ts_metadata8("design:paramtypes", [
|
|
1646
1809
|
typeof Request === "undefined" ? Object : Request,
|
|
1647
1810
|
String
|
|
1648
1811
|
]),
|
|
1649
|
-
|
|
1812
|
+
_ts_metadata8("design:returntype", Promise)
|
|
1650
1813
|
], MemoriesController.prototype, "forget", null);
|
|
1651
|
-
MemoriesController =
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1814
|
+
MemoriesController = _ts_decorate8([
|
|
1815
|
+
Controller5("memories"),
|
|
1816
|
+
_ts_param7(0, Inject7(AGENT_ACTOR_RESOLVER4)),
|
|
1817
|
+
_ts_param7(1, Optional5()),
|
|
1818
|
+
_ts_param7(1, Inject7(AGENT_MEMORY2)),
|
|
1819
|
+
_ts_metadata8("design:type", Function),
|
|
1820
|
+
_ts_metadata8("design:paramtypes", [
|
|
1658
1821
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1659
1822
|
Object
|
|
1660
1823
|
])
|
|
1661
1824
|
], MemoriesController);
|
|
1662
1825
|
|
|
1663
1826
|
// src/controller/messages.controller.ts
|
|
1664
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
1665
|
-
import { Body as Body2, Controller as
|
|
1666
|
-
function
|
|
1827
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
|
|
1828
|
+
import { Body as Body2, Controller as Controller6, HttpCode, Inject as Inject8, Param as Param3, Post as Post3, Req as Req5 } from "@nestjs/common";
|
|
1829
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1667
1830
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1668
1831
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1669
1832
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1676,19 +1839,19 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
1676
1839
|
}
|
|
1677
1840
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1678
1841
|
}
|
|
1679
|
-
__name(
|
|
1680
|
-
function
|
|
1842
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1843
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
1681
1844
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1682
1845
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1683
1846
|
}
|
|
1684
1847
|
}
|
|
1685
|
-
__name(
|
|
1686
|
-
function
|
|
1848
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1849
|
+
function _ts_param8(paramIndex, decorator) {
|
|
1687
1850
|
return function(target, key) {
|
|
1688
1851
|
decorator(target, key, paramIndex);
|
|
1689
1852
|
};
|
|
1690
1853
|
}
|
|
1691
|
-
__name(
|
|
1854
|
+
__name(_ts_param8, "_ts_param");
|
|
1692
1855
|
var MessagesController = class {
|
|
1693
1856
|
static {
|
|
1694
1857
|
__name(this, "MessagesController");
|
|
@@ -1716,34 +1879,34 @@ var MessagesController = class {
|
|
|
1716
1879
|
};
|
|
1717
1880
|
}
|
|
1718
1881
|
};
|
|
1719
|
-
|
|
1882
|
+
_ts_decorate9([
|
|
1720
1883
|
Post3(":id/feedback"),
|
|
1721
1884
|
HttpCode(200),
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1885
|
+
_ts_param8(0, Req5()),
|
|
1886
|
+
_ts_param8(1, Param3("id")),
|
|
1887
|
+
_ts_param8(2, Body2()),
|
|
1888
|
+
_ts_metadata9("design:type", Function),
|
|
1889
|
+
_ts_metadata9("design:paramtypes", [
|
|
1727
1890
|
typeof Request === "undefined" ? Object : Request,
|
|
1728
1891
|
String,
|
|
1729
1892
|
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
1730
1893
|
]),
|
|
1731
|
-
|
|
1894
|
+
_ts_metadata9("design:returntype", Promise)
|
|
1732
1895
|
], MessagesController.prototype, "feedback", null);
|
|
1733
|
-
MessagesController =
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1896
|
+
MessagesController = _ts_decorate9([
|
|
1897
|
+
Controller6("messages"),
|
|
1898
|
+
_ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER5)),
|
|
1899
|
+
_ts_metadata9("design:type", Function),
|
|
1900
|
+
_ts_metadata9("design:paramtypes", [
|
|
1738
1901
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1739
1902
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1740
1903
|
])
|
|
1741
1904
|
], MessagesController);
|
|
1742
1905
|
|
|
1743
1906
|
// src/controller/models.controller.ts
|
|
1744
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
1745
|
-
import { Controller as
|
|
1746
|
-
function
|
|
1907
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6 } from "@dudousxd/nestjs-agent-core";
|
|
1908
|
+
import { Controller as Controller7, Get as Get6, Inject as Inject9, Query as Query3, Req as Req6 } from "@nestjs/common";
|
|
1909
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
1747
1910
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1748
1911
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1749
1912
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1756,19 +1919,19 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
1756
1919
|
}
|
|
1757
1920
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1758
1921
|
}
|
|
1759
|
-
__name(
|
|
1760
|
-
function
|
|
1922
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1923
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
1761
1924
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1762
1925
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1763
1926
|
}
|
|
1764
1927
|
}
|
|
1765
|
-
__name(
|
|
1766
|
-
function
|
|
1928
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1929
|
+
function _ts_param9(paramIndex, decorator) {
|
|
1767
1930
|
return function(target, key) {
|
|
1768
1931
|
decorator(target, key, paramIndex);
|
|
1769
1932
|
};
|
|
1770
1933
|
}
|
|
1771
|
-
__name(
|
|
1934
|
+
__name(_ts_param9, "_ts_param");
|
|
1772
1935
|
var ModelsController = class {
|
|
1773
1936
|
static {
|
|
1774
1937
|
__name(this, "ModelsController");
|
|
@@ -1788,31 +1951,31 @@ var ModelsController = class {
|
|
|
1788
1951
|
return this.agent.listModels(actor, agent);
|
|
1789
1952
|
}
|
|
1790
1953
|
};
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1954
|
+
_ts_decorate10([
|
|
1955
|
+
Get6(),
|
|
1956
|
+
_ts_param9(0, Req6()),
|
|
1957
|
+
_ts_param9(1, Query3("agent")),
|
|
1958
|
+
_ts_metadata10("design:type", Function),
|
|
1959
|
+
_ts_metadata10("design:paramtypes", [
|
|
1797
1960
|
typeof Request === "undefined" ? Object : Request,
|
|
1798
1961
|
String
|
|
1799
1962
|
]),
|
|
1800
|
-
|
|
1963
|
+
_ts_metadata10("design:returntype", Promise)
|
|
1801
1964
|
], ModelsController.prototype, "list", null);
|
|
1802
|
-
ModelsController =
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1965
|
+
ModelsController = _ts_decorate10([
|
|
1966
|
+
Controller7("models"),
|
|
1967
|
+
_ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER6)),
|
|
1968
|
+
_ts_metadata10("design:type", Function),
|
|
1969
|
+
_ts_metadata10("design:paramtypes", [
|
|
1807
1970
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1808
1971
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1809
1972
|
])
|
|
1810
1973
|
], ModelsController);
|
|
1811
1974
|
|
|
1812
1975
|
// src/controller/quota.controller.ts
|
|
1813
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
1814
|
-
import { Controller as
|
|
1815
|
-
function
|
|
1976
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER7 } from "@dudousxd/nestjs-agent-core";
|
|
1977
|
+
import { Controller as Controller8, Get as Get7, Inject as Inject10, Req as Req7 } from "@nestjs/common";
|
|
1978
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1816
1979
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1817
1980
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1818
1981
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1825,19 +1988,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
1825
1988
|
}
|
|
1826
1989
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1827
1990
|
}
|
|
1828
|
-
__name(
|
|
1829
|
-
function
|
|
1991
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1992
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
1830
1993
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1831
1994
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1832
1995
|
}
|
|
1833
1996
|
}
|
|
1834
|
-
__name(
|
|
1835
|
-
function
|
|
1997
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1998
|
+
function _ts_param10(paramIndex, decorator) {
|
|
1836
1999
|
return function(target, key) {
|
|
1837
2000
|
decorator(target, key, paramIndex);
|
|
1838
2001
|
};
|
|
1839
2002
|
}
|
|
1840
|
-
__name(
|
|
2003
|
+
__name(_ts_param10, "_ts_param");
|
|
1841
2004
|
var QuotaController = class {
|
|
1842
2005
|
static {
|
|
1843
2006
|
__name(this, "QuotaController");
|
|
@@ -1856,43 +2019,30 @@ var QuotaController = class {
|
|
|
1856
2019
|
const actor = await this.actorResolver.resolve(req);
|
|
1857
2020
|
return this.agent.quotaReport(actor);
|
|
1858
2021
|
}
|
|
1859
|
-
async today(req) {
|
|
1860
|
-
const actor = await this.actorResolver.resolve(req);
|
|
1861
|
-
return this.agent.quotaToday(actor.id);
|
|
1862
|
-
}
|
|
1863
2022
|
};
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
2023
|
+
_ts_decorate11([
|
|
2024
|
+
Get7(),
|
|
2025
|
+
_ts_param10(0, Req7()),
|
|
2026
|
+
_ts_metadata11("design:type", Function),
|
|
2027
|
+
_ts_metadata11("design:paramtypes", [
|
|
1869
2028
|
typeof Request === "undefined" ? Object : Request
|
|
1870
2029
|
]),
|
|
1871
|
-
|
|
2030
|
+
_ts_metadata11("design:returntype", Promise)
|
|
1872
2031
|
], QuotaController.prototype, "report", null);
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
typeof Request === "undefined" ? Object : Request
|
|
1879
|
-
]),
|
|
1880
|
-
_ts_metadata10("design:returntype", Promise)
|
|
1881
|
-
], QuotaController.prototype, "today", null);
|
|
1882
|
-
QuotaController = _ts_decorate10([
|
|
1883
|
-
Controller7("quota"),
|
|
1884
|
-
_ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER6)),
|
|
1885
|
-
_ts_metadata10("design:type", Function),
|
|
1886
|
-
_ts_metadata10("design:paramtypes", [
|
|
2032
|
+
QuotaController = _ts_decorate11([
|
|
2033
|
+
Controller8("quota"),
|
|
2034
|
+
_ts_param10(1, Inject10(AGENT_ACTOR_RESOLVER7)),
|
|
2035
|
+
_ts_metadata11("design:type", Function),
|
|
2036
|
+
_ts_metadata11("design:paramtypes", [
|
|
1887
2037
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
1888
2038
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
1889
2039
|
])
|
|
1890
2040
|
], QuotaController);
|
|
1891
2041
|
|
|
1892
2042
|
// src/controller/skills.controller.ts
|
|
1893
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
1894
|
-
import { Controller as
|
|
1895
|
-
function
|
|
2043
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8, AGENT_SKILLS as AGENT_SKILLS2, offerSkills } from "@dudousxd/nestjs-agent-core";
|
|
2044
|
+
import { Controller as Controller9, Get as Get8, Inject as Inject11, Optional as Optional6, Query as Query4, Req as Req8 } from "@nestjs/common";
|
|
2045
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1896
2046
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1897
2047
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1898
2048
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1905,19 +2055,19 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
1905
2055
|
}
|
|
1906
2056
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1907
2057
|
}
|
|
1908
|
-
__name(
|
|
1909
|
-
function
|
|
2058
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2059
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
1910
2060
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1911
2061
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1912
2062
|
}
|
|
1913
2063
|
}
|
|
1914
|
-
__name(
|
|
1915
|
-
function
|
|
2064
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
2065
|
+
function _ts_param11(paramIndex, decorator) {
|
|
1916
2066
|
return function(target, key) {
|
|
1917
2067
|
decorator(target, key, paramIndex);
|
|
1918
2068
|
};
|
|
1919
2069
|
}
|
|
1920
|
-
__name(
|
|
2070
|
+
__name(_ts_param11, "_ts_param");
|
|
1921
2071
|
var SkillsController = class {
|
|
1922
2072
|
static {
|
|
1923
2073
|
__name(this, "SkillsController");
|
|
@@ -1940,33 +2090,33 @@ var SkillsController = class {
|
|
|
1940
2090
|
return offer.entries;
|
|
1941
2091
|
}
|
|
1942
2092
|
};
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
2093
|
+
_ts_decorate12([
|
|
2094
|
+
Get8(),
|
|
2095
|
+
_ts_param11(0, Req8()),
|
|
2096
|
+
_ts_param11(1, Query4("threadId")),
|
|
2097
|
+
_ts_metadata12("design:type", Function),
|
|
2098
|
+
_ts_metadata12("design:paramtypes", [
|
|
1949
2099
|
typeof Request === "undefined" ? Object : Request,
|
|
1950
2100
|
String
|
|
1951
2101
|
]),
|
|
1952
|
-
|
|
2102
|
+
_ts_metadata12("design:returntype", Promise)
|
|
1953
2103
|
], SkillsController.prototype, "list", null);
|
|
1954
|
-
SkillsController =
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2104
|
+
SkillsController = _ts_decorate12([
|
|
2105
|
+
Controller9("skills"),
|
|
2106
|
+
_ts_param11(0, Inject11(AGENT_ACTOR_RESOLVER8)),
|
|
2107
|
+
_ts_param11(1, Optional6()),
|
|
2108
|
+
_ts_param11(1, Inject11(AGENT_SKILLS2)),
|
|
2109
|
+
_ts_metadata12("design:type", Function),
|
|
2110
|
+
_ts_metadata12("design:paramtypes", [
|
|
1961
2111
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
1962
2112
|
Object
|
|
1963
2113
|
])
|
|
1964
2114
|
], SkillsController);
|
|
1965
2115
|
|
|
1966
2116
|
// src/controller/threads.controller.ts
|
|
1967
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
1968
|
-
import { Body as Body3, Controller as
|
|
1969
|
-
function
|
|
2117
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER9 } from "@dudousxd/nestjs-agent-core";
|
|
2118
|
+
import { Body as Body3, Controller as Controller10, Delete as Delete2, Get as Get9, Inject as Inject12, Param as Param4, Patch, Post as Post4, Req as Req9 } from "@nestjs/common";
|
|
2119
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
1970
2120
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1971
2121
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1972
2122
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1979,19 +2129,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
1979
2129
|
}
|
|
1980
2130
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1981
2131
|
}
|
|
1982
|
-
__name(
|
|
1983
|
-
function
|
|
2132
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2133
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
1984
2134
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1985
2135
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1986
2136
|
}
|
|
1987
2137
|
}
|
|
1988
|
-
__name(
|
|
1989
|
-
function
|
|
2138
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2139
|
+
function _ts_param12(paramIndex, decorator) {
|
|
1990
2140
|
return function(target, key) {
|
|
1991
2141
|
decorator(target, key, paramIndex);
|
|
1992
2142
|
};
|
|
1993
2143
|
}
|
|
1994
|
-
__name(
|
|
2144
|
+
__name(_ts_param12, "_ts_param");
|
|
1995
2145
|
var ThreadsController = class {
|
|
1996
2146
|
static {
|
|
1997
2147
|
__name(this, "ThreadsController");
|
|
@@ -2058,101 +2208,101 @@ var ThreadsController = class {
|
|
|
2058
2208
|
};
|
|
2059
2209
|
}
|
|
2060
2210
|
};
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2211
|
+
_ts_decorate13([
|
|
2212
|
+
Get9(),
|
|
2213
|
+
_ts_param12(0, Req9()),
|
|
2214
|
+
_ts_metadata13("design:type", Function),
|
|
2215
|
+
_ts_metadata13("design:paramtypes", [
|
|
2066
2216
|
typeof Request === "undefined" ? Object : Request
|
|
2067
2217
|
]),
|
|
2068
|
-
|
|
2218
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2069
2219
|
], ThreadsController.prototype, "list", null);
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2220
|
+
_ts_decorate13([
|
|
2221
|
+
Get9(":id"),
|
|
2222
|
+
_ts_param12(0, Req9()),
|
|
2223
|
+
_ts_param12(1, Param4("id")),
|
|
2224
|
+
_ts_metadata13("design:type", Function),
|
|
2225
|
+
_ts_metadata13("design:paramtypes", [
|
|
2076
2226
|
typeof Request === "undefined" ? Object : Request,
|
|
2077
2227
|
String
|
|
2078
2228
|
]),
|
|
2079
|
-
|
|
2229
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2080
2230
|
], ThreadsController.prototype, "detail", null);
|
|
2081
|
-
|
|
2231
|
+
_ts_decorate13([
|
|
2082
2232
|
Delete2(":id"),
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2233
|
+
_ts_param12(0, Req9()),
|
|
2234
|
+
_ts_param12(1, Param4("id")),
|
|
2235
|
+
_ts_metadata13("design:type", Function),
|
|
2236
|
+
_ts_metadata13("design:paramtypes", [
|
|
2087
2237
|
typeof Request === "undefined" ? Object : Request,
|
|
2088
2238
|
String
|
|
2089
2239
|
]),
|
|
2090
|
-
|
|
2240
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2091
2241
|
], ThreadsController.prototype, "remove", null);
|
|
2092
|
-
|
|
2242
|
+
_ts_decorate13([
|
|
2093
2243
|
Post4(":id/fork-from/:messageId"),
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2244
|
+
_ts_param12(0, Req9()),
|
|
2245
|
+
_ts_param12(1, Param4("id")),
|
|
2246
|
+
_ts_param12(2, Param4("messageId")),
|
|
2247
|
+
_ts_metadata13("design:type", Function),
|
|
2248
|
+
_ts_metadata13("design:paramtypes", [
|
|
2099
2249
|
typeof Request === "undefined" ? Object : Request,
|
|
2100
2250
|
String,
|
|
2101
2251
|
String
|
|
2102
2252
|
]),
|
|
2103
|
-
|
|
2253
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2104
2254
|
], ThreadsController.prototype, "fork", null);
|
|
2105
|
-
|
|
2255
|
+
_ts_decorate13([
|
|
2106
2256
|
Patch(":id"),
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2257
|
+
_ts_param12(0, Req9()),
|
|
2258
|
+
_ts_param12(1, Param4("id")),
|
|
2259
|
+
_ts_param12(2, Body3()),
|
|
2260
|
+
_ts_metadata13("design:type", Function),
|
|
2261
|
+
_ts_metadata13("design:paramtypes", [
|
|
2112
2262
|
typeof Request === "undefined" ? Object : Request,
|
|
2113
2263
|
String,
|
|
2114
2264
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
2115
2265
|
]),
|
|
2116
|
-
|
|
2266
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2117
2267
|
], ThreadsController.prototype, "update", null);
|
|
2118
|
-
|
|
2268
|
+
_ts_decorate13([
|
|
2119
2269
|
Post4(":id/promote"),
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2270
|
+
_ts_param12(0, Req9()),
|
|
2271
|
+
_ts_param12(1, Param4("id")),
|
|
2272
|
+
_ts_metadata13("design:type", Function),
|
|
2273
|
+
_ts_metadata13("design:paramtypes", [
|
|
2124
2274
|
typeof Request === "undefined" ? Object : Request,
|
|
2125
2275
|
String
|
|
2126
2276
|
]),
|
|
2127
|
-
|
|
2277
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2128
2278
|
], ThreadsController.prototype, "promote", null);
|
|
2129
|
-
|
|
2279
|
+
_ts_decorate13([
|
|
2130
2280
|
Delete2(":id/from/:messageId"),
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2281
|
+
_ts_param12(0, Req9()),
|
|
2282
|
+
_ts_param12(1, Param4("id")),
|
|
2283
|
+
_ts_param12(2, Param4("messageId")),
|
|
2284
|
+
_ts_metadata13("design:type", Function),
|
|
2285
|
+
_ts_metadata13("design:paramtypes", [
|
|
2136
2286
|
typeof Request === "undefined" ? Object : Request,
|
|
2137
2287
|
String,
|
|
2138
2288
|
String
|
|
2139
2289
|
]),
|
|
2140
|
-
|
|
2290
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2141
2291
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
2142
|
-
ThreadsController =
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2292
|
+
ThreadsController = _ts_decorate13([
|
|
2293
|
+
Controller10("threads"),
|
|
2294
|
+
_ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER9)),
|
|
2295
|
+
_ts_metadata13("design:type", Function),
|
|
2296
|
+
_ts_metadata13("design:paramtypes", [
|
|
2147
2297
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2148
2298
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2149
2299
|
])
|
|
2150
2300
|
], ThreadsController);
|
|
2151
2301
|
|
|
2152
2302
|
// src/controller/tool-call.controller.ts
|
|
2153
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2154
|
-
import { BadRequestException as BadRequestException4, Body as Body4, Controller as
|
|
2155
|
-
function
|
|
2303
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER10 } from "@dudousxd/nestjs-agent-core";
|
|
2304
|
+
import { BadRequestException as BadRequestException4, Body as Body4, Controller as Controller11, Inject as Inject13, Post as Post5, Req as Req10 } from "@nestjs/common";
|
|
2305
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2156
2306
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2157
2307
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2158
2308
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2165,19 +2315,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
2165
2315
|
}
|
|
2166
2316
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2167
2317
|
}
|
|
2168
|
-
__name(
|
|
2169
|
-
function
|
|
2318
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2319
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2170
2320
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2171
2321
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2172
2322
|
}
|
|
2173
2323
|
}
|
|
2174
|
-
__name(
|
|
2175
|
-
function
|
|
2324
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2325
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2176
2326
|
return function(target, key) {
|
|
2177
2327
|
decorator(target, key, paramIndex);
|
|
2178
2328
|
};
|
|
2179
2329
|
}
|
|
2180
|
-
__name(
|
|
2330
|
+
__name(_ts_param13, "_ts_param");
|
|
2181
2331
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
2182
2332
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
2183
2333
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -2306,64 +2456,64 @@ var ToolCallController = class {
|
|
|
2306
2456
|
};
|
|
2307
2457
|
}
|
|
2308
2458
|
};
|
|
2309
|
-
|
|
2459
|
+
_ts_decorate14([
|
|
2310
2460
|
Post5("approve"),
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2461
|
+
_ts_param13(0, Req10()),
|
|
2462
|
+
_ts_param13(1, Body4()),
|
|
2463
|
+
_ts_metadata14("design:type", Function),
|
|
2464
|
+
_ts_metadata14("design:paramtypes", [
|
|
2315
2465
|
typeof Request === "undefined" ? Object : Request,
|
|
2316
2466
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
2317
2467
|
]),
|
|
2318
|
-
|
|
2468
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2319
2469
|
], ToolCallController.prototype, "approve", null);
|
|
2320
|
-
|
|
2470
|
+
_ts_decorate14([
|
|
2321
2471
|
Post5("reject"),
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2472
|
+
_ts_param13(0, Req10()),
|
|
2473
|
+
_ts_param13(1, Body4()),
|
|
2474
|
+
_ts_metadata14("design:type", Function),
|
|
2475
|
+
_ts_metadata14("design:paramtypes", [
|
|
2326
2476
|
typeof Request === "undefined" ? Object : Request,
|
|
2327
2477
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
2328
2478
|
]),
|
|
2329
|
-
|
|
2479
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2330
2480
|
], ToolCallController.prototype, "reject", null);
|
|
2331
|
-
|
|
2481
|
+
_ts_decorate14([
|
|
2332
2482
|
Post5("answer"),
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2483
|
+
_ts_param13(0, Req10()),
|
|
2484
|
+
_ts_param13(1, Body4()),
|
|
2485
|
+
_ts_metadata14("design:type", Function),
|
|
2486
|
+
_ts_metadata14("design:paramtypes", [
|
|
2337
2487
|
typeof Request === "undefined" ? Object : Request,
|
|
2338
2488
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
2339
2489
|
]),
|
|
2340
|
-
|
|
2490
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2341
2491
|
], ToolCallController.prototype, "answer", null);
|
|
2342
|
-
|
|
2492
|
+
_ts_decorate14([
|
|
2343
2493
|
Post5("skip"),
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2494
|
+
_ts_param13(0, Req10()),
|
|
2495
|
+
_ts_param13(1, Body4()),
|
|
2496
|
+
_ts_metadata14("design:type", Function),
|
|
2497
|
+
_ts_metadata14("design:paramtypes", [
|
|
2348
2498
|
typeof Request === "undefined" ? Object : Request,
|
|
2349
2499
|
Object
|
|
2350
2500
|
]),
|
|
2351
|
-
|
|
2501
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2352
2502
|
], ToolCallController.prototype, "skip", null);
|
|
2353
|
-
ToolCallController =
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2503
|
+
ToolCallController = _ts_decorate14([
|
|
2504
|
+
Controller11("tool-call"),
|
|
2505
|
+
_ts_param13(1, Inject13(AGENT_ACTOR_RESOLVER10)),
|
|
2506
|
+
_ts_metadata14("design:type", Function),
|
|
2507
|
+
_ts_metadata14("design:paramtypes", [
|
|
2358
2508
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2359
2509
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2360
2510
|
])
|
|
2361
2511
|
], ToolCallController);
|
|
2362
2512
|
|
|
2363
2513
|
// src/controller/tools.controller.ts
|
|
2364
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2365
|
-
import { Controller as
|
|
2366
|
-
function
|
|
2514
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
|
|
2515
|
+
import { Controller as Controller12, Get as Get10, Inject as Inject14, NotFoundException as NotFoundException3, Query as Query5, Req as Req11 } from "@nestjs/common";
|
|
2516
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2367
2517
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2368
2518
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2369
2519
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2376,19 +2526,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2376
2526
|
}
|
|
2377
2527
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2378
2528
|
}
|
|
2379
|
-
__name(
|
|
2380
|
-
function
|
|
2529
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2530
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2381
2531
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2382
2532
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2383
2533
|
}
|
|
2384
2534
|
}
|
|
2385
|
-
__name(
|
|
2386
|
-
function
|
|
2535
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2536
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2387
2537
|
return function(target, key) {
|
|
2388
2538
|
decorator(target, key, paramIndex);
|
|
2389
2539
|
};
|
|
2390
2540
|
}
|
|
2391
|
-
__name(
|
|
2541
|
+
__name(_ts_param14, "_ts_param");
|
|
2392
2542
|
var ToolsController = class {
|
|
2393
2543
|
static {
|
|
2394
2544
|
__name(this, "ToolsController");
|
|
@@ -2417,24 +2567,24 @@ var ToolsController = class {
|
|
|
2417
2567
|
}));
|
|
2418
2568
|
}
|
|
2419
2569
|
};
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2570
|
+
_ts_decorate15([
|
|
2571
|
+
Get10(),
|
|
2572
|
+
_ts_param14(0, Req11()),
|
|
2573
|
+
_ts_param14(1, Query5("agent")),
|
|
2574
|
+
_ts_metadata15("design:type", Function),
|
|
2575
|
+
_ts_metadata15("design:paramtypes", [
|
|
2426
2576
|
typeof Request === "undefined" ? Object : Request,
|
|
2427
2577
|
String
|
|
2428
2578
|
]),
|
|
2429
|
-
|
|
2579
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2430
2580
|
], ToolsController.prototype, "list", null);
|
|
2431
|
-
ToolsController =
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2581
|
+
ToolsController = _ts_decorate15([
|
|
2582
|
+
Controller12("tools"),
|
|
2583
|
+
_ts_param14(0, Inject14(AGENT_ACTOR_RESOLVER11)),
|
|
2584
|
+
_ts_param14(1, Inject14(AGENT_DEPS_FACTORY3)),
|
|
2585
|
+
_ts_param14(2, Inject14(AGENT_REGISTRY3)),
|
|
2586
|
+
_ts_metadata15("design:type", Function),
|
|
2587
|
+
_ts_metadata15("design:paramtypes", [
|
|
2438
2588
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2439
2589
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2440
2590
|
typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4
|
|
@@ -2443,7 +2593,7 @@ ToolsController = _ts_decorate14([
|
|
|
2443
2593
|
|
|
2444
2594
|
// src/discovery/agent-discovery.service.ts
|
|
2445
2595
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
|
|
2446
|
-
import { Inject as
|
|
2596
|
+
import { Inject as Inject15, Injectable as Injectable4, Logger } from "@nestjs/common";
|
|
2447
2597
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
2448
2598
|
|
|
2449
2599
|
// src/decorator/agent.decorator.ts
|
|
@@ -2478,7 +2628,7 @@ function SystemPromptContributor() {
|
|
|
2478
2628
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
2479
2629
|
|
|
2480
2630
|
// src/discovery/agent-discovery.service.ts
|
|
2481
|
-
function
|
|
2631
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2482
2632
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2483
2633
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2484
2634
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2491,19 +2641,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2491
2641
|
}
|
|
2492
2642
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2493
2643
|
}
|
|
2494
|
-
__name(
|
|
2495
|
-
function
|
|
2644
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2645
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2496
2646
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2497
2647
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2498
2648
|
}
|
|
2499
2649
|
}
|
|
2500
|
-
__name(
|
|
2501
|
-
function
|
|
2650
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2651
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2502
2652
|
return function(target, key) {
|
|
2503
2653
|
decorator(target, key, paramIndex);
|
|
2504
2654
|
};
|
|
2505
2655
|
}
|
|
2506
|
-
__name(
|
|
2656
|
+
__name(_ts_param15, "_ts_param");
|
|
2507
2657
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
2508
2658
|
static {
|
|
2509
2659
|
__name(this, "AgentDiscoveryService");
|
|
@@ -2630,12 +2780,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2630
2780
|
return (ctx) => candidate.call(instance, ctx);
|
|
2631
2781
|
}
|
|
2632
2782
|
};
|
|
2633
|
-
AgentDiscoveryService =
|
|
2783
|
+
AgentDiscoveryService = _ts_decorate16([
|
|
2634
2784
|
Injectable4(),
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2785
|
+
_ts_param15(2, Inject15(AGENT_REGISTRY4)),
|
|
2786
|
+
_ts_param15(3, Inject15(AGENT_PROMPT_CONTRIBUTORS2)),
|
|
2787
|
+
_ts_metadata16("design:type", Function),
|
|
2788
|
+
_ts_metadata16("design:paramtypes", [
|
|
2639
2789
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
2640
2790
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
2641
2791
|
typeof AgentRegistry5 === "undefined" ? Object : AgentRegistry5,
|
|
@@ -2644,17 +2794,31 @@ AgentDiscoveryService = _ts_decorate15([
|
|
|
2644
2794
|
], AgentDiscoveryService);
|
|
2645
2795
|
|
|
2646
2796
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2647
|
-
import { AGENT_OPTIONS as
|
|
2648
|
-
import { Inject as
|
|
2797
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS5, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
2798
|
+
import { Inject as Inject16, Injectable as Injectable5, Logger as Logger2 } from "@nestjs/common";
|
|
2649
2799
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
2650
2800
|
import { z } from "zod";
|
|
2651
2801
|
|
|
2652
2802
|
// src/decorator/ai-tool.decorator.ts
|
|
2653
2803
|
import "reflect-metadata";
|
|
2654
2804
|
var AI_TOOL_METADATA = /* @__PURE__ */ Symbol("nestjs-agent:ai-tool");
|
|
2805
|
+
function toolNameFromClass(className) {
|
|
2806
|
+
const base = className.replace(/Tool$/, "") || className;
|
|
2807
|
+
const leadingCaps = /^[A-Z]+(?=[A-Z][a-z]|$)/.exec(base)?.[0];
|
|
2808
|
+
if (leadingCaps !== void 0 && leadingCaps.length > 1) {
|
|
2809
|
+
return leadingCaps.toLowerCase() + base.slice(leadingCaps.length);
|
|
2810
|
+
}
|
|
2811
|
+
return base.charAt(0).toLowerCase() + base.slice(1);
|
|
2812
|
+
}
|
|
2813
|
+
__name(toolNameFromClass, "toolNameFromClass");
|
|
2655
2814
|
function AiTool(options) {
|
|
2656
2815
|
return (target) => {
|
|
2657
|
-
|
|
2816
|
+
const resolved = {
|
|
2817
|
+
...options,
|
|
2818
|
+
name: options.name ?? toolNameFromClass(target.name),
|
|
2819
|
+
kind: options.kind ?? "read"
|
|
2820
|
+
};
|
|
2821
|
+
Reflect.defineMetadata(AI_TOOL_METADATA, resolved, target);
|
|
2658
2822
|
};
|
|
2659
2823
|
}
|
|
2660
2824
|
__name(AiTool, "AiTool");
|
|
@@ -2702,7 +2866,7 @@ function provideAgentTools(factory, inject) {
|
|
|
2702
2866
|
__name(provideAgentTools, "provideAgentTools");
|
|
2703
2867
|
|
|
2704
2868
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2705
|
-
function
|
|
2869
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2706
2870
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2707
2871
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2708
2872
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2715,19 +2879,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2715
2879
|
}
|
|
2716
2880
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2717
2881
|
}
|
|
2718
|
-
__name(
|
|
2719
|
-
function
|
|
2882
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2883
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2720
2884
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2721
2885
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2722
2886
|
}
|
|
2723
2887
|
}
|
|
2724
|
-
__name(
|
|
2725
|
-
function
|
|
2888
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
2889
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2726
2890
|
return function(target, key) {
|
|
2727
2891
|
decorator(target, key, paramIndex);
|
|
2728
2892
|
};
|
|
2729
2893
|
}
|
|
2730
|
-
__name(
|
|
2894
|
+
__name(_ts_param16, "_ts_param");
|
|
2731
2895
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
2732
2896
|
static {
|
|
2733
2897
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -2871,13 +3035,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2871
3035
|
return true;
|
|
2872
3036
|
}
|
|
2873
3037
|
};
|
|
2874
|
-
AiToolDiscoveryService =
|
|
3038
|
+
AiToolDiscoveryService = _ts_decorate17([
|
|
2875
3039
|
Injectable5(),
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
3040
|
+
_ts_param16(1, Inject16(AGENT_TOOL_REGISTRY2)),
|
|
3041
|
+
_ts_param16(2, Inject16(AGENT_REGISTRY5)),
|
|
3042
|
+
_ts_param16(3, Inject16(AGENT_OPTIONS5)),
|
|
3043
|
+
_ts_metadata17("design:type", Function),
|
|
3044
|
+
_ts_metadata17("design:paramtypes", [
|
|
2881
3045
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
2882
3046
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
2883
3047
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -2887,7 +3051,7 @@ AiToolDiscoveryService = _ts_decorate16([
|
|
|
2887
3051
|
|
|
2888
3052
|
// src/discovery/skill-discovery.service.ts
|
|
2889
3053
|
import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
|
|
2890
|
-
import { Inject as
|
|
3054
|
+
import { Inject as Inject17, Injectable as Injectable6, Logger as Logger3 } from "@nestjs/common";
|
|
2891
3055
|
import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
|
|
2892
3056
|
|
|
2893
3057
|
// src/decorator/skill.decorator.ts
|
|
@@ -2910,7 +3074,7 @@ function skillScope(options) {
|
|
|
2910
3074
|
__name(skillScope, "skillScope");
|
|
2911
3075
|
|
|
2912
3076
|
// src/discovery/skill-discovery.service.ts
|
|
2913
|
-
function
|
|
3077
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2914
3078
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2915
3079
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2916
3080
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2923,19 +3087,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
2923
3087
|
}
|
|
2924
3088
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2925
3089
|
}
|
|
2926
|
-
__name(
|
|
2927
|
-
function
|
|
3090
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3091
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
2928
3092
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2929
3093
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2930
3094
|
}
|
|
2931
3095
|
}
|
|
2932
|
-
__name(
|
|
2933
|
-
function
|
|
3096
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3097
|
+
function _ts_param17(paramIndex, decorator) {
|
|
2934
3098
|
return function(target, key) {
|
|
2935
3099
|
decorator(target, key, paramIndex);
|
|
2936
3100
|
};
|
|
2937
3101
|
}
|
|
2938
|
-
__name(
|
|
3102
|
+
__name(_ts_param17, "_ts_param");
|
|
2939
3103
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
2940
3104
|
static {
|
|
2941
3105
|
__name(this, "SkillDiscoveryService");
|
|
@@ -2979,11 +3143,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
2979
3143
|
return flat === void 0 ? void 0 : () => flat;
|
|
2980
3144
|
}
|
|
2981
3145
|
};
|
|
2982
|
-
SkillDiscoveryService =
|
|
3146
|
+
SkillDiscoveryService = _ts_decorate18([
|
|
2983
3147
|
Injectable6(),
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
3148
|
+
_ts_param17(1, Inject17(AGENT_SKILL_SOURCES)),
|
|
3149
|
+
_ts_metadata18("design:type", Function),
|
|
3150
|
+
_ts_metadata18("design:paramtypes", [
|
|
2987
3151
|
typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
|
|
2988
3152
|
Array
|
|
2989
3153
|
])
|
|
@@ -3064,11 +3228,9 @@ var LedgerQuotaProvider = class {
|
|
|
3064
3228
|
__name(this, "LedgerQuotaProvider");
|
|
3065
3229
|
}
|
|
3066
3230
|
store;
|
|
3067
|
-
quota;
|
|
3068
3231
|
limits;
|
|
3069
|
-
constructor(store,
|
|
3232
|
+
constructor(store, limits = {}) {
|
|
3070
3233
|
this.store = store;
|
|
3071
|
-
this.quota = quota;
|
|
3072
3234
|
this.limits = limits;
|
|
3073
3235
|
}
|
|
3074
3236
|
async report(query) {
|
|
@@ -3093,15 +3255,7 @@ var LedgerQuotaProvider = class {
|
|
|
3093
3255
|
async dayWindow(actorRef, now) {
|
|
3094
3256
|
const range = quotaPeriodRange("day", now);
|
|
3095
3257
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
3096
|
-
|
|
3097
|
-
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
3098
|
-
}
|
|
3099
|
-
const state = await this.quota.check(actorRef, range.fromDay);
|
|
3100
|
-
const window = this.window("day", state.usedTokens, costUsd, range.resetsAt);
|
|
3101
|
-
if (window.limitTokens === void 0) {
|
|
3102
|
-
window.limitTokens = state.limitTokens;
|
|
3103
|
-
}
|
|
3104
|
-
return window;
|
|
3258
|
+
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
3105
3259
|
}
|
|
3106
3260
|
window(period, usedTokens, usedUsd, resetsAt) {
|
|
3107
3261
|
const limits = this.limits[period] ?? {};
|
|
@@ -3120,33 +3274,10 @@ var LedgerQuotaProvider = class {
|
|
|
3120
3274
|
}
|
|
3121
3275
|
};
|
|
3122
3276
|
|
|
3123
|
-
// src/ledger-quota-store.ts
|
|
3124
|
-
var LedgerQuotaStore = class {
|
|
3125
|
-
static {
|
|
3126
|
-
__name(this, "LedgerQuotaStore");
|
|
3127
|
-
}
|
|
3128
|
-
store;
|
|
3129
|
-
limitTokens;
|
|
3130
|
-
constructor(store, limitTokens) {
|
|
3131
|
-
this.store = store;
|
|
3132
|
-
this.limitTokens = limitTokens;
|
|
3133
|
-
}
|
|
3134
|
-
async check(actorRef, day) {
|
|
3135
|
-
const { usedTokens } = await this.store.quotaToday(actorRef, day);
|
|
3136
|
-
return {
|
|
3137
|
-
usedTokens,
|
|
3138
|
-
limitTokens: this.limitTokens,
|
|
3139
|
-
withinLimit: usedTokens < this.limitTokens
|
|
3140
|
-
};
|
|
3141
|
-
}
|
|
3142
|
-
async bump(_actorRef, _day, _tokens) {
|
|
3143
|
-
}
|
|
3144
|
-
};
|
|
3145
|
-
|
|
3146
3277
|
// src/runner/inline-agent-runner.ts
|
|
3147
3278
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_STORE as AGENT_STORE3, RunCancelledError, agentFailureCode, encodeStreamEvent, publishAgentRunFailed, runAgentLoop, settleAll, settleUnsettledDelegation } from "@dudousxd/nestjs-agent-core";
|
|
3148
|
-
import { Inject as
|
|
3149
|
-
function
|
|
3279
|
+
import { Inject as Inject18, Injectable as Injectable7, Logger as Logger4 } from "@nestjs/common";
|
|
3280
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3150
3281
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3151
3282
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3152
3283
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3159,19 +3290,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3159
3290
|
}
|
|
3160
3291
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3161
3292
|
}
|
|
3162
|
-
__name(
|
|
3163
|
-
function
|
|
3293
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3294
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3164
3295
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3165
3296
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3166
3297
|
}
|
|
3167
3298
|
}
|
|
3168
|
-
__name(
|
|
3169
|
-
function
|
|
3299
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3300
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3170
3301
|
return function(target, key) {
|
|
3171
3302
|
decorator(target, key, paramIndex);
|
|
3172
3303
|
};
|
|
3173
3304
|
}
|
|
3174
|
-
__name(
|
|
3305
|
+
__name(_ts_param18, "_ts_param");
|
|
3175
3306
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
3176
3307
|
static {
|
|
3177
3308
|
__name(this, "InlineAgentRunner");
|
|
@@ -3552,12 +3683,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3552
3683
|
}
|
|
3553
3684
|
}
|
|
3554
3685
|
};
|
|
3555
|
-
InlineAgentRunner =
|
|
3686
|
+
InlineAgentRunner = _ts_decorate19([
|
|
3556
3687
|
Injectable7(),
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3688
|
+
_ts_param18(0, Inject18(AGENT_DEPS_FACTORY4)),
|
|
3689
|
+
_ts_param18(1, Inject18(AGENT_STORE3)),
|
|
3690
|
+
_ts_metadata19("design:type", Function),
|
|
3691
|
+
_ts_metadata19("design:paramtypes", [
|
|
3561
3692
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3562
3693
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
3563
3694
|
])
|
|
@@ -3602,7 +3733,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3602
3733
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3603
3734
|
|
|
3604
3735
|
// src/agent.module.ts
|
|
3605
|
-
function
|
|
3736
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3606
3737
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3607
3738
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3608
3739
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3615,9 +3746,57 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
3615
3746
|
}
|
|
3616
3747
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3617
3748
|
}
|
|
3618
|
-
__name(
|
|
3749
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3619
3750
|
var DEFAULT_PATH = "agent";
|
|
3620
|
-
|
|
3751
|
+
var logger = new Logger5("AgentModule");
|
|
3752
|
+
function externalStoreWrapper(modules) {
|
|
3753
|
+
for (const module of modules.values()) {
|
|
3754
|
+
if (module.metatype === AgentModule) continue;
|
|
3755
|
+
const wrapper = module.providers.get(AGENT_STORE4);
|
|
3756
|
+
if (wrapper !== void 0) return wrapper;
|
|
3757
|
+
}
|
|
3758
|
+
return void 0;
|
|
3759
|
+
}
|
|
3760
|
+
__name(externalStoreWrapper, "externalStoreWrapper");
|
|
3761
|
+
function forwardingStore(wrapper) {
|
|
3762
|
+
const target = /* @__PURE__ */ __name(() => {
|
|
3763
|
+
const instance = wrapper.instance;
|
|
3764
|
+
if (instance === void 0 || instance === null) {
|
|
3765
|
+
throw new Error("AgentModule: the AGENT_STORE bound by another module is not ready yet");
|
|
3766
|
+
}
|
|
3767
|
+
return instance;
|
|
3768
|
+
}, "target");
|
|
3769
|
+
return new Proxy({}, {
|
|
3770
|
+
get(_, property) {
|
|
3771
|
+
const store = target();
|
|
3772
|
+
const value = store[property];
|
|
3773
|
+
return typeof value === "function" ? value.bind(store) : value;
|
|
3774
|
+
},
|
|
3775
|
+
has(_, property) {
|
|
3776
|
+
return property in target();
|
|
3777
|
+
}
|
|
3778
|
+
});
|
|
3779
|
+
}
|
|
3780
|
+
__name(forwardingStore, "forwardingStore");
|
|
3781
|
+
function resolveStore(options, modules) {
|
|
3782
|
+
if (options.store !== void 0) return options.store;
|
|
3783
|
+
const external = externalStoreWrapper(modules);
|
|
3784
|
+
if (external !== void 0) return forwardingStore(external);
|
|
3785
|
+
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()).");
|
|
3786
|
+
return new InMemoryAgentStore();
|
|
3787
|
+
}
|
|
3788
|
+
__name(resolveStore, "resolveStore");
|
|
3789
|
+
function isQuotaProvider(quota) {
|
|
3790
|
+
return quota !== void 0 && typeof quota.report === "function";
|
|
3791
|
+
}
|
|
3792
|
+
__name(isQuotaProvider, "isQuotaProvider");
|
|
3793
|
+
function resolveCatalog(options) {
|
|
3794
|
+
if (options.models !== void 0) return options.models;
|
|
3795
|
+
const carried = options.model.catalog;
|
|
3796
|
+
return carried !== void 0 && typeof carried.list === "function" ? carried : void 0;
|
|
3797
|
+
}
|
|
3798
|
+
__name(resolveCatalog, "resolveCatalog");
|
|
3799
|
+
function sharedProviders(durable) {
|
|
3621
3800
|
const providers = [
|
|
3622
3801
|
{
|
|
3623
3802
|
provide: AGENT_TOOL_REGISTRY3,
|
|
@@ -3646,7 +3825,7 @@ function sharedProviders(durable, includeStore) {
|
|
|
3646
3825
|
provide: AGENT_SKILLS3,
|
|
3647
3826
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3648
3827
|
inject: [
|
|
3649
|
-
|
|
3828
|
+
AGENT_OPTIONS6,
|
|
3650
3829
|
AGENT_SKILL_SOURCES2
|
|
3651
3830
|
]
|
|
3652
3831
|
},
|
|
@@ -3656,62 +3835,56 @@ function sharedProviders(durable, includeStore) {
|
|
|
3656
3835
|
provide: AGENT_MEMORY3,
|
|
3657
3836
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
3658
3837
|
inject: [
|
|
3659
|
-
|
|
3838
|
+
AGENT_OPTIONS6
|
|
3660
3839
|
]
|
|
3661
3840
|
},
|
|
3662
3841
|
{
|
|
3663
3842
|
provide: AGENT_SINK2,
|
|
3664
3843
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
3665
3844
|
inject: [
|
|
3666
|
-
|
|
3845
|
+
AGENT_OPTIONS6
|
|
3667
3846
|
]
|
|
3668
3847
|
},
|
|
3669
3848
|
{
|
|
3670
3849
|
provide: AGENT_ROLES_POLICY2,
|
|
3671
3850
|
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
3672
3851
|
inject: [
|
|
3673
|
-
|
|
3852
|
+
AGENT_OPTIONS6
|
|
3674
3853
|
]
|
|
3675
3854
|
},
|
|
3676
3855
|
{
|
|
3677
|
-
provide:
|
|
3678
|
-
useFactory: /* @__PURE__ */ __name((options) =>
|
|
3856
|
+
provide: AGENT_ACTOR_RESOLVER12,
|
|
3857
|
+
useFactory: /* @__PURE__ */ __name((options) => {
|
|
3858
|
+
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
3859
|
+
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.");
|
|
3860
|
+
return new AnonymousActorResolver();
|
|
3861
|
+
}, "useFactory"),
|
|
3679
3862
|
inject: [
|
|
3680
|
-
|
|
3863
|
+
AGENT_OPTIONS6
|
|
3681
3864
|
]
|
|
3682
3865
|
},
|
|
3683
3866
|
{
|
|
3684
3867
|
provide: AGENT_MODEL2,
|
|
3685
3868
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
3686
3869
|
inject: [
|
|
3687
|
-
|
|
3688
|
-
]
|
|
3689
|
-
},
|
|
3690
|
-
{
|
|
3691
|
-
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
3692
|
-
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
3693
|
-
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
3694
|
-
provide: AGENT_QUOTA_STORE3,
|
|
3695
|
-
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
3696
|
-
inject: [
|
|
3697
|
-
AGENT_OPTIONS5,
|
|
3698
|
-
AGENT_STORE4
|
|
3870
|
+
AGENT_OPTIONS6
|
|
3699
3871
|
]
|
|
3700
3872
|
},
|
|
3701
3873
|
{
|
|
3874
|
+
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
3875
|
+
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
3702
3876
|
provide: AGENT_QUOTA_PROVIDER2,
|
|
3703
|
-
useFactory: /* @__PURE__ */ __name((o, store
|
|
3877
|
+
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits), "useFactory"),
|
|
3704
3878
|
inject: [
|
|
3705
|
-
|
|
3706
|
-
AGENT_STORE4
|
|
3707
|
-
AGENT_QUOTA_STORE3
|
|
3879
|
+
AGENT_OPTIONS6,
|
|
3880
|
+
AGENT_STORE4
|
|
3708
3881
|
]
|
|
3709
3882
|
},
|
|
3710
3883
|
{
|
|
3711
|
-
provide:
|
|
3712
|
-
useFactory: /* @__PURE__ */ __name((o) => o
|
|
3884
|
+
provide: AGENT_MODEL_CATALOG3,
|
|
3885
|
+
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
3713
3886
|
inject: [
|
|
3714
|
-
|
|
3887
|
+
AGENT_OPTIONS6
|
|
3715
3888
|
]
|
|
3716
3889
|
},
|
|
3717
3890
|
AgentDepsFactory2,
|
|
@@ -3734,15 +3907,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
3734
3907
|
useExisting: AgentApprovalPortAdapter
|
|
3735
3908
|
}
|
|
3736
3909
|
];
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
}
|
|
3910
|
+
providers.push({
|
|
3911
|
+
provide: AGENT_STORE4,
|
|
3912
|
+
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
3913
|
+
inject: [
|
|
3914
|
+
AGENT_OPTIONS6,
|
|
3915
|
+
ModulesContainer
|
|
3916
|
+
]
|
|
3917
|
+
});
|
|
3746
3918
|
if (durable) {
|
|
3747
3919
|
providers.push({
|
|
3748
3920
|
provide: AGENT_RUNNER2,
|
|
@@ -3768,20 +3940,17 @@ function sharedProviders(durable, includeStore) {
|
|
|
3768
3940
|
return providers;
|
|
3769
3941
|
}
|
|
3770
3942
|
__name(sharedProviders, "sharedProviders");
|
|
3771
|
-
function exportsFor(
|
|
3943
|
+
function exportsFor() {
|
|
3772
3944
|
return [
|
|
3773
|
-
|
|
3945
|
+
AGENT_OPTIONS6,
|
|
3774
3946
|
AGENT_TOOL_REGISTRY3,
|
|
3775
3947
|
AGENT_REGISTRY6,
|
|
3776
3948
|
AGENT_SINK2,
|
|
3777
3949
|
AGENT_ROLES_POLICY2,
|
|
3778
|
-
|
|
3950
|
+
AGENT_ACTOR_RESOLVER12,
|
|
3779
3951
|
AGENT_MODEL2,
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
] : [],
|
|
3783
|
-
AGENT_QUOTA_STORE3,
|
|
3784
|
-
AGENT_MODEL_CATALOG2,
|
|
3952
|
+
AGENT_STORE4,
|
|
3953
|
+
AGENT_MODEL_CATALOG3,
|
|
3785
3954
|
AGENT_QUOTA_PROVIDER2,
|
|
3786
3955
|
AGENT_PROMPT_CONTRIBUTORS3,
|
|
3787
3956
|
AGENT_SKILLS3,
|
|
@@ -3804,21 +3973,13 @@ var BASE_CONTROLLERS = [
|
|
|
3804
3973
|
MemoriesController,
|
|
3805
3974
|
ToolsController,
|
|
3806
3975
|
MessagesController,
|
|
3807
|
-
ModelsController
|
|
3808
|
-
|
|
3809
|
-
var GUARDABLE_CONTROLLERS = [
|
|
3810
|
-
...BASE_CONTROLLERS,
|
|
3976
|
+
ModelsController,
|
|
3977
|
+
ConfigController,
|
|
3811
3978
|
AttachmentsController
|
|
3812
3979
|
];
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
AttachmentsController
|
|
3817
|
-
] : BASE_CONTROLLERS;
|
|
3818
|
-
}
|
|
3819
|
-
__name(controllersFor, "controllersFor");
|
|
3820
|
-
function controllersForSurface(surface, mountAttachments) {
|
|
3821
|
-
return surface === "engine" ? [] : controllersFor(mountAttachments);
|
|
3980
|
+
var GUARDABLE_CONTROLLERS = BASE_CONTROLLERS;
|
|
3981
|
+
function controllersForSurface(surface) {
|
|
3982
|
+
return surface === "engine" ? [] : BASE_CONTROLLERS;
|
|
3822
3983
|
}
|
|
3823
3984
|
__name(controllersForSurface, "controllersForSurface");
|
|
3824
3985
|
var GUARDS_METADATA = "__guards__";
|
|
@@ -3850,7 +4011,6 @@ var AgentModule = class _AgentModule {
|
|
|
3850
4011
|
}
|
|
3851
4012
|
static forRoot(options) {
|
|
3852
4013
|
const path = options.path ?? DEFAULT_PATH;
|
|
3853
|
-
const includeStore = options.store !== void 0;
|
|
3854
4014
|
applyGuards(options.guards);
|
|
3855
4015
|
return {
|
|
3856
4016
|
module: _AgentModule,
|
|
@@ -3859,21 +4019,20 @@ var AgentModule = class _AgentModule {
|
|
|
3859
4019
|
DiscoveryModule,
|
|
3860
4020
|
routerFor(path)
|
|
3861
4021
|
],
|
|
3862
|
-
controllers: controllersForSurface(options.surface
|
|
4022
|
+
controllers: controllersForSurface(options.surface),
|
|
3863
4023
|
providers: [
|
|
3864
4024
|
{
|
|
3865
|
-
provide:
|
|
4025
|
+
provide: AGENT_OPTIONS6,
|
|
3866
4026
|
useValue: options
|
|
3867
4027
|
},
|
|
3868
|
-
...sharedProviders(options.durable ?? false
|
|
4028
|
+
...sharedProviders(options.durable ?? false),
|
|
3869
4029
|
...guardProviders(options.guards)
|
|
3870
4030
|
],
|
|
3871
|
-
exports: exportsFor(
|
|
4031
|
+
exports: exportsFor()
|
|
3872
4032
|
};
|
|
3873
4033
|
}
|
|
3874
4034
|
static forRootAsync(options) {
|
|
3875
4035
|
const path = options.path ?? DEFAULT_PATH;
|
|
3876
|
-
const includeStore = options.externalStore !== true;
|
|
3877
4036
|
applyGuards(options.guards);
|
|
3878
4037
|
return {
|
|
3879
4038
|
module: _AgentModule,
|
|
@@ -3883,10 +4042,10 @@ var AgentModule = class _AgentModule {
|
|
|
3883
4042
|
routerFor(path),
|
|
3884
4043
|
...options.imports ?? []
|
|
3885
4044
|
],
|
|
3886
|
-
controllers: controllersForSurface(options.surface
|
|
4045
|
+
controllers: controllersForSurface(options.surface),
|
|
3887
4046
|
providers: [
|
|
3888
4047
|
{
|
|
3889
|
-
provide:
|
|
4048
|
+
provide: AGENT_OPTIONS6,
|
|
3890
4049
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
3891
4050
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
3892
4051
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -3900,14 +4059,14 @@ var AgentModule = class _AgentModule {
|
|
|
3900
4059
|
}), "useFactory"),
|
|
3901
4060
|
inject: options.inject ?? []
|
|
3902
4061
|
},
|
|
3903
|
-
...sharedProviders(options.durable ?? false
|
|
4062
|
+
...sharedProviders(options.durable ?? false),
|
|
3904
4063
|
...guardProviders(options.guards)
|
|
3905
4064
|
],
|
|
3906
|
-
exports: exportsFor(
|
|
4065
|
+
exports: exportsFor()
|
|
3907
4066
|
};
|
|
3908
4067
|
}
|
|
3909
4068
|
};
|
|
3910
|
-
AgentModule =
|
|
4069
|
+
AgentModule = _ts_decorate20([
|
|
3911
4070
|
Global(),
|
|
3912
4071
|
Module({})
|
|
3913
4072
|
], AgentModule);
|
|
@@ -3943,6 +4102,49 @@ var HeaderActorResolver = class {
|
|
|
3943
4102
|
}
|
|
3944
4103
|
};
|
|
3945
4104
|
|
|
4105
|
+
// src/resolver/request-user-actor-resolver.ts
|
|
4106
|
+
import { UnauthorizedException as UnauthorizedException2 } from "@nestjs/common";
|
|
4107
|
+
function field(user, ...names) {
|
|
4108
|
+
for (const name of names) {
|
|
4109
|
+
const value = user[name];
|
|
4110
|
+
if (value !== void 0 && value !== null && value !== "") return value;
|
|
4111
|
+
}
|
|
4112
|
+
return void 0;
|
|
4113
|
+
}
|
|
4114
|
+
__name(field, "field");
|
|
4115
|
+
function defaultRequestUserMapper(user) {
|
|
4116
|
+
const id = field(user, "id", "sub", "_id", "userId");
|
|
4117
|
+
if (id === void 0) {
|
|
4118
|
+
throw new UnauthorizedException2("requestUserActorResolver: req.user has no id/sub/_id/userId \u2014 pass a mapper: requestUserActorResolver((user) => ({ id: \u2026, roles: \u2026 }))");
|
|
4119
|
+
}
|
|
4120
|
+
const rawRoles = field(user, "roles", "role");
|
|
4121
|
+
const roles = Array.isArray(rawRoles) ? rawRoles.map(String) : typeof rawRoles === "string" ? [
|
|
4122
|
+
rawRoles
|
|
4123
|
+
] : [];
|
|
4124
|
+
const tenant = field(user, "tenantRef", "tenantId", "orgId");
|
|
4125
|
+
return {
|
|
4126
|
+
id: String(id),
|
|
4127
|
+
roles,
|
|
4128
|
+
...tenant !== void 0 ? {
|
|
4129
|
+
tenantRef: String(tenant)
|
|
4130
|
+
} : {}
|
|
4131
|
+
};
|
|
4132
|
+
}
|
|
4133
|
+
__name(defaultRequestUserMapper, "defaultRequestUserMapper");
|
|
4134
|
+
function requestUserActorResolver(map) {
|
|
4135
|
+
return {
|
|
4136
|
+
async resolve(req) {
|
|
4137
|
+
const user = typeof req === "object" && req !== null ? req.user : void 0;
|
|
4138
|
+
if (user === void 0 || user === null || user === false) {
|
|
4139
|
+
throw new UnauthorizedException2("Sign in to use the agent.");
|
|
4140
|
+
}
|
|
4141
|
+
if (map !== void 0) return map(user, req);
|
|
4142
|
+
return defaultRequestUserMapper(user);
|
|
4143
|
+
}
|
|
4144
|
+
};
|
|
4145
|
+
}
|
|
4146
|
+
__name(requestUserActorResolver, "requestUserActorResolver");
|
|
4147
|
+
|
|
3946
4148
|
// src/index.ts
|
|
3947
4149
|
export * from "@dudousxd/nestjs-agent-core";
|
|
3948
4150
|
export {
|
|
@@ -3958,14 +4160,16 @@ export {
|
|
|
3958
4160
|
AgentService,
|
|
3959
4161
|
AiTool,
|
|
3960
4162
|
AiToolDiscoveryService,
|
|
4163
|
+
AnonymousActorResolver,
|
|
3961
4164
|
AttachmentsController,
|
|
4165
|
+
ConfigController,
|
|
3962
4166
|
DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
|
|
3963
4167
|
DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
3964
4168
|
HeaderActorResolver,
|
|
3965
4169
|
InProcessTokenStreamSink,
|
|
3966
4170
|
InlineAgentRunner,
|
|
3967
4171
|
LedgerQuotaProvider,
|
|
3968
|
-
|
|
4172
|
+
MAX_ATTACHMENTS_PER_MESSAGE,
|
|
3969
4173
|
MemoriesController,
|
|
3970
4174
|
MessagesController,
|
|
3971
4175
|
ModelsController,
|
|
@@ -3978,15 +4182,19 @@ export {
|
|
|
3978
4182
|
SystemPrompt,
|
|
3979
4183
|
SystemPromptContributor,
|
|
3980
4184
|
ToolsController,
|
|
4185
|
+
attachmentLimits,
|
|
3981
4186
|
declaredSkillProvider,
|
|
4187
|
+
defaultRequestUserMapper,
|
|
3982
4188
|
delegateToolName,
|
|
3983
4189
|
provideAgentTool,
|
|
3984
4190
|
provideAgentTools,
|
|
3985
4191
|
readAgentMetadata,
|
|
3986
4192
|
readAiToolMetadata,
|
|
3987
4193
|
readSkillMetadata,
|
|
4194
|
+
requestUserActorResolver,
|
|
3988
4195
|
resolveSkillsConfig,
|
|
3989
4196
|
skillScope,
|
|
4197
|
+
toolNameFromClass,
|
|
3990
4198
|
utcDay
|
|
3991
4199
|
};
|
|
3992
4200
|
//# sourceMappingURL=index.js.map
|