@dudousxd/nestjs-agent 1.11.0 → 1.12.1
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.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
|
|
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
6
|
import { Global, Logger as Logger5, Module } from "@nestjs/common";
|
|
7
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;
|
|
@@ -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,8 +2794,8 @@ 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
|
|
|
@@ -2716,7 +2866,7 @@ function provideAgentTools(factory, inject) {
|
|
|
2716
2866
|
__name(provideAgentTools, "provideAgentTools");
|
|
2717
2867
|
|
|
2718
2868
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2719
|
-
function
|
|
2869
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2720
2870
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2721
2871
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2722
2872
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2729,19 +2879,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2729
2879
|
}
|
|
2730
2880
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2731
2881
|
}
|
|
2732
|
-
__name(
|
|
2733
|
-
function
|
|
2882
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2883
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2734
2884
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2735
2885
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2736
2886
|
}
|
|
2737
2887
|
}
|
|
2738
|
-
__name(
|
|
2739
|
-
function
|
|
2888
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
2889
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2740
2890
|
return function(target, key) {
|
|
2741
2891
|
decorator(target, key, paramIndex);
|
|
2742
2892
|
};
|
|
2743
2893
|
}
|
|
2744
|
-
__name(
|
|
2894
|
+
__name(_ts_param16, "_ts_param");
|
|
2745
2895
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
2746
2896
|
static {
|
|
2747
2897
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -2885,13 +3035,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2885
3035
|
return true;
|
|
2886
3036
|
}
|
|
2887
3037
|
};
|
|
2888
|
-
AiToolDiscoveryService =
|
|
3038
|
+
AiToolDiscoveryService = _ts_decorate17([
|
|
2889
3039
|
Injectable5(),
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
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", [
|
|
2895
3045
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
2896
3046
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
2897
3047
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -2901,7 +3051,7 @@ AiToolDiscoveryService = _ts_decorate16([
|
|
|
2901
3051
|
|
|
2902
3052
|
// src/discovery/skill-discovery.service.ts
|
|
2903
3053
|
import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
|
|
2904
|
-
import { Inject as
|
|
3054
|
+
import { Inject as Inject17, Injectable as Injectable6, Logger as Logger3 } from "@nestjs/common";
|
|
2905
3055
|
import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
|
|
2906
3056
|
|
|
2907
3057
|
// src/decorator/skill.decorator.ts
|
|
@@ -2924,7 +3074,7 @@ function skillScope(options) {
|
|
|
2924
3074
|
__name(skillScope, "skillScope");
|
|
2925
3075
|
|
|
2926
3076
|
// src/discovery/skill-discovery.service.ts
|
|
2927
|
-
function
|
|
3077
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2928
3078
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2929
3079
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2930
3080
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2937,19 +3087,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
2937
3087
|
}
|
|
2938
3088
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2939
3089
|
}
|
|
2940
|
-
__name(
|
|
2941
|
-
function
|
|
3090
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3091
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
2942
3092
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2943
3093
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2944
3094
|
}
|
|
2945
3095
|
}
|
|
2946
|
-
__name(
|
|
2947
|
-
function
|
|
3096
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3097
|
+
function _ts_param17(paramIndex, decorator) {
|
|
2948
3098
|
return function(target, key) {
|
|
2949
3099
|
decorator(target, key, paramIndex);
|
|
2950
3100
|
};
|
|
2951
3101
|
}
|
|
2952
|
-
__name(
|
|
3102
|
+
__name(_ts_param17, "_ts_param");
|
|
2953
3103
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
2954
3104
|
static {
|
|
2955
3105
|
__name(this, "SkillDiscoveryService");
|
|
@@ -2993,11 +3143,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
2993
3143
|
return flat === void 0 ? void 0 : () => flat;
|
|
2994
3144
|
}
|
|
2995
3145
|
};
|
|
2996
|
-
SkillDiscoveryService =
|
|
3146
|
+
SkillDiscoveryService = _ts_decorate18([
|
|
2997
3147
|
Injectable6(),
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3148
|
+
_ts_param17(1, Inject17(AGENT_SKILL_SOURCES)),
|
|
3149
|
+
_ts_metadata18("design:type", Function),
|
|
3150
|
+
_ts_metadata18("design:paramtypes", [
|
|
3001
3151
|
typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
|
|
3002
3152
|
Array
|
|
3003
3153
|
])
|
|
@@ -3078,11 +3228,9 @@ var LedgerQuotaProvider = class {
|
|
|
3078
3228
|
__name(this, "LedgerQuotaProvider");
|
|
3079
3229
|
}
|
|
3080
3230
|
store;
|
|
3081
|
-
quota;
|
|
3082
3231
|
limits;
|
|
3083
|
-
constructor(store,
|
|
3232
|
+
constructor(store, limits = {}) {
|
|
3084
3233
|
this.store = store;
|
|
3085
|
-
this.quota = quota;
|
|
3086
3234
|
this.limits = limits;
|
|
3087
3235
|
}
|
|
3088
3236
|
async report(query) {
|
|
@@ -3107,15 +3255,7 @@ var LedgerQuotaProvider = class {
|
|
|
3107
3255
|
async dayWindow(actorRef, now) {
|
|
3108
3256
|
const range = quotaPeriodRange("day", now);
|
|
3109
3257
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
3110
|
-
|
|
3111
|
-
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
3112
|
-
}
|
|
3113
|
-
const state = await this.quota.check(actorRef, range.fromDay);
|
|
3114
|
-
const window = this.window("day", state.usedTokens, costUsd, range.resetsAt);
|
|
3115
|
-
if (window.limitTokens === void 0) {
|
|
3116
|
-
window.limitTokens = state.limitTokens;
|
|
3117
|
-
}
|
|
3118
|
-
return window;
|
|
3258
|
+
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
3119
3259
|
}
|
|
3120
3260
|
window(period, usedTokens, usedUsd, resetsAt) {
|
|
3121
3261
|
const limits = this.limits[period] ?? {};
|
|
@@ -3134,120 +3274,10 @@ var LedgerQuotaProvider = class {
|
|
|
3134
3274
|
}
|
|
3135
3275
|
};
|
|
3136
3276
|
|
|
3137
|
-
// src/ledger-quota-store.ts
|
|
3138
|
-
var LedgerQuotaStore = class {
|
|
3139
|
-
static {
|
|
3140
|
-
__name(this, "LedgerQuotaStore");
|
|
3141
|
-
}
|
|
3142
|
-
store;
|
|
3143
|
-
limitTokens;
|
|
3144
|
-
constructor(store, limitTokens) {
|
|
3145
|
-
this.store = store;
|
|
3146
|
-
this.limitTokens = limitTokens;
|
|
3147
|
-
}
|
|
3148
|
-
async check(actorRef, day) {
|
|
3149
|
-
const { usedTokens } = await this.store.quotaToday(actorRef, day);
|
|
3150
|
-
return {
|
|
3151
|
-
usedTokens,
|
|
3152
|
-
limitTokens: this.limitTokens,
|
|
3153
|
-
withinLimit: usedTokens < this.limitTokens
|
|
3154
|
-
};
|
|
3155
|
-
}
|
|
3156
|
-
async bump(_actorRef, _day, _tokens) {
|
|
3157
|
-
}
|
|
3158
|
-
};
|
|
3159
|
-
|
|
3160
|
-
// src/resolver/anonymous-actor-resolver.ts
|
|
3161
|
-
import { createHash, randomBytes } from "crypto";
|
|
3162
|
-
var TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
3163
|
-
var MINTED = /* @__PURE__ */ Symbol("nestjs-agent:anonymous-token");
|
|
3164
|
-
function readCookie(req, name) {
|
|
3165
|
-
const header = req.headers?.cookie;
|
|
3166
|
-
const raw = Array.isArray(header) ? header.join("; ") : header;
|
|
3167
|
-
if (raw === void 0) return void 0;
|
|
3168
|
-
for (const pair of raw.split(";")) {
|
|
3169
|
-
const index = pair.indexOf("=");
|
|
3170
|
-
if (index === -1) continue;
|
|
3171
|
-
if (pair.slice(0, index).trim() === name) {
|
|
3172
|
-
try {
|
|
3173
|
-
return decodeURIComponent(pair.slice(index + 1).trim());
|
|
3174
|
-
} catch {
|
|
3175
|
-
return void 0;
|
|
3176
|
-
}
|
|
3177
|
-
}
|
|
3178
|
-
}
|
|
3179
|
-
return void 0;
|
|
3180
|
-
}
|
|
3181
|
-
__name(readCookie, "readCookie");
|
|
3182
|
-
function isHttps(req) {
|
|
3183
|
-
if (req.secure === true) return true;
|
|
3184
|
-
const forwarded = req.headers?.["x-forwarded-proto"];
|
|
3185
|
-
const proto = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
3186
|
-
return proto?.split(",")[0]?.trim() === "https";
|
|
3187
|
-
}
|
|
3188
|
-
__name(isHttps, "isHttps");
|
|
3189
|
-
var AnonymousActorResolver = class {
|
|
3190
|
-
static {
|
|
3191
|
-
__name(this, "AnonymousActorResolver");
|
|
3192
|
-
}
|
|
3193
|
-
options;
|
|
3194
|
-
cookieName;
|
|
3195
|
-
roles;
|
|
3196
|
-
constructor(options = {}) {
|
|
3197
|
-
this.options = options;
|
|
3198
|
-
this.cookieName = options.cookieName ?? "agent_anon";
|
|
3199
|
-
this.roles = options.roles ?? [
|
|
3200
|
-
"anonymous"
|
|
3201
|
-
];
|
|
3202
|
-
}
|
|
3203
|
-
resolve(request) {
|
|
3204
|
-
const req = typeof request === "object" && request !== null ? request : {};
|
|
3205
|
-
let token = req[MINTED] ?? readCookie(req, this.cookieName);
|
|
3206
|
-
if (token === void 0 || !TOKEN_PATTERN.test(token)) {
|
|
3207
|
-
token = randomBytes(32).toString("base64url");
|
|
3208
|
-
req[MINTED] = token;
|
|
3209
|
-
this.setCookie(req, token);
|
|
3210
|
-
}
|
|
3211
|
-
const digest = createHash("sha256").update(token).digest("base64url").slice(0, 32);
|
|
3212
|
-
return {
|
|
3213
|
-
id: `anon:${digest}`,
|
|
3214
|
-
roles: [
|
|
3215
|
-
...this.roles
|
|
3216
|
-
]
|
|
3217
|
-
};
|
|
3218
|
-
}
|
|
3219
|
-
setCookie(req, token) {
|
|
3220
|
-
const res = req.res;
|
|
3221
|
-
if (res?.setHeader === void 0 || res.headersSent === true) return;
|
|
3222
|
-
const sameSite = this.options.sameSite ?? "lax";
|
|
3223
|
-
const secureOption = this.options.secure ?? "auto";
|
|
3224
|
-
const secure = sameSite === "none" || (secureOption === "auto" ? isHttps(req) : secureOption);
|
|
3225
|
-
const maxAge = Math.round((this.options.maxAgeDays ?? 365) * 24 * 60 * 60);
|
|
3226
|
-
const cookie = [
|
|
3227
|
-
`${this.cookieName}=${token}`,
|
|
3228
|
-
`Path=${this.options.path ?? "/"}`,
|
|
3229
|
-
`Max-Age=${maxAge}`,
|
|
3230
|
-
"HttpOnly",
|
|
3231
|
-
`SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`,
|
|
3232
|
-
...secure ? [
|
|
3233
|
-
"Secure"
|
|
3234
|
-
] : []
|
|
3235
|
-
].join("; ");
|
|
3236
|
-
const existing = res.getHeader?.("Set-Cookie");
|
|
3237
|
-
const list = Array.isArray(existing) ? existing.map(String) : existing !== void 0 ? [
|
|
3238
|
-
String(existing)
|
|
3239
|
-
] : [];
|
|
3240
|
-
res.setHeader("Set-Cookie", [
|
|
3241
|
-
...list,
|
|
3242
|
-
cookie
|
|
3243
|
-
]);
|
|
3244
|
-
}
|
|
3245
|
-
};
|
|
3246
|
-
|
|
3247
3277
|
// src/runner/inline-agent-runner.ts
|
|
3248
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";
|
|
3249
|
-
import { Inject as
|
|
3250
|
-
function
|
|
3279
|
+
import { Inject as Inject18, Injectable as Injectable7, Logger as Logger4 } from "@nestjs/common";
|
|
3280
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3251
3281
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3252
3282
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3253
3283
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3260,19 +3290,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3260
3290
|
}
|
|
3261
3291
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3262
3292
|
}
|
|
3263
|
-
__name(
|
|
3264
|
-
function
|
|
3293
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3294
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3265
3295
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3266
3296
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3267
3297
|
}
|
|
3268
3298
|
}
|
|
3269
|
-
__name(
|
|
3270
|
-
function
|
|
3299
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3300
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3271
3301
|
return function(target, key) {
|
|
3272
3302
|
decorator(target, key, paramIndex);
|
|
3273
3303
|
};
|
|
3274
3304
|
}
|
|
3275
|
-
__name(
|
|
3305
|
+
__name(_ts_param18, "_ts_param");
|
|
3276
3306
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
3277
3307
|
static {
|
|
3278
3308
|
__name(this, "InlineAgentRunner");
|
|
@@ -3653,12 +3683,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3653
3683
|
}
|
|
3654
3684
|
}
|
|
3655
3685
|
};
|
|
3656
|
-
InlineAgentRunner =
|
|
3686
|
+
InlineAgentRunner = _ts_decorate19([
|
|
3657
3687
|
Injectable7(),
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
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", [
|
|
3662
3692
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3663
3693
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
3664
3694
|
])
|
|
@@ -3703,7 +3733,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3703
3733
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3704
3734
|
|
|
3705
3735
|
// src/agent.module.ts
|
|
3706
|
-
function
|
|
3736
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3707
3737
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3708
3738
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3709
3739
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3716,7 +3746,7 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
3716
3746
|
}
|
|
3717
3747
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3718
3748
|
}
|
|
3719
|
-
__name(
|
|
3749
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3720
3750
|
var DEFAULT_PATH = "agent";
|
|
3721
3751
|
var logger = new Logger5("AgentModule");
|
|
3722
3752
|
function externalStoreWrapper(modules) {
|
|
@@ -3756,6 +3786,10 @@ function resolveStore(options, modules) {
|
|
|
3756
3786
|
return new InMemoryAgentStore();
|
|
3757
3787
|
}
|
|
3758
3788
|
__name(resolveStore, "resolveStore");
|
|
3789
|
+
function isQuotaProvider(quota) {
|
|
3790
|
+
return quota !== void 0 && typeof quota.report === "function";
|
|
3791
|
+
}
|
|
3792
|
+
__name(isQuotaProvider, "isQuotaProvider");
|
|
3759
3793
|
function resolveCatalog(options) {
|
|
3760
3794
|
if (options.models !== void 0) return options.models;
|
|
3761
3795
|
const carried = options.model.catalog;
|
|
@@ -3791,7 +3825,7 @@ function sharedProviders(durable) {
|
|
|
3791
3825
|
provide: AGENT_SKILLS3,
|
|
3792
3826
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3793
3827
|
inject: [
|
|
3794
|
-
|
|
3828
|
+
AGENT_OPTIONS6,
|
|
3795
3829
|
AGENT_SKILL_SOURCES2
|
|
3796
3830
|
]
|
|
3797
3831
|
},
|
|
@@ -3801,66 +3835,56 @@ function sharedProviders(durable) {
|
|
|
3801
3835
|
provide: AGENT_MEMORY3,
|
|
3802
3836
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
3803
3837
|
inject: [
|
|
3804
|
-
|
|
3838
|
+
AGENT_OPTIONS6
|
|
3805
3839
|
]
|
|
3806
3840
|
},
|
|
3807
3841
|
{
|
|
3808
3842
|
provide: AGENT_SINK2,
|
|
3809
3843
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
3810
3844
|
inject: [
|
|
3811
|
-
|
|
3845
|
+
AGENT_OPTIONS6
|
|
3812
3846
|
]
|
|
3813
3847
|
},
|
|
3814
3848
|
{
|
|
3815
3849
|
provide: AGENT_ROLES_POLICY2,
|
|
3816
3850
|
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
3817
3851
|
inject: [
|
|
3818
|
-
|
|
3852
|
+
AGENT_OPTIONS6
|
|
3819
3853
|
]
|
|
3820
3854
|
},
|
|
3821
3855
|
{
|
|
3822
|
-
provide:
|
|
3856
|
+
provide: AGENT_ACTOR_RESOLVER12,
|
|
3823
3857
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
3824
3858
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
3825
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.");
|
|
3826
3860
|
return new AnonymousActorResolver();
|
|
3827
3861
|
}, "useFactory"),
|
|
3828
3862
|
inject: [
|
|
3829
|
-
|
|
3863
|
+
AGENT_OPTIONS6
|
|
3830
3864
|
]
|
|
3831
3865
|
},
|
|
3832
3866
|
{
|
|
3833
3867
|
provide: AGENT_MODEL2,
|
|
3834
3868
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
3835
3869
|
inject: [
|
|
3836
|
-
|
|
3837
|
-
]
|
|
3838
|
-
},
|
|
3839
|
-
{
|
|
3840
|
-
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
3841
|
-
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
3842
|
-
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
3843
|
-
provide: AGENT_QUOTA_STORE3,
|
|
3844
|
-
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
3845
|
-
inject: [
|
|
3846
|
-
AGENT_OPTIONS5,
|
|
3847
|
-
AGENT_STORE4
|
|
3870
|
+
AGENT_OPTIONS6
|
|
3848
3871
|
]
|
|
3849
3872
|
},
|
|
3850
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.
|
|
3851
3876
|
provide: AGENT_QUOTA_PROVIDER2,
|
|
3852
|
-
useFactory: /* @__PURE__ */ __name((o, store
|
|
3877
|
+
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits), "useFactory"),
|
|
3853
3878
|
inject: [
|
|
3854
|
-
|
|
3855
|
-
AGENT_STORE4
|
|
3856
|
-
AGENT_QUOTA_STORE3
|
|
3879
|
+
AGENT_OPTIONS6,
|
|
3880
|
+
AGENT_STORE4
|
|
3857
3881
|
]
|
|
3858
3882
|
},
|
|
3859
3883
|
{
|
|
3860
|
-
provide:
|
|
3884
|
+
provide: AGENT_MODEL_CATALOG3,
|
|
3861
3885
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
3862
3886
|
inject: [
|
|
3863
|
-
|
|
3887
|
+
AGENT_OPTIONS6
|
|
3864
3888
|
]
|
|
3865
3889
|
},
|
|
3866
3890
|
AgentDepsFactory2,
|
|
@@ -3887,7 +3911,7 @@ function sharedProviders(durable) {
|
|
|
3887
3911
|
provide: AGENT_STORE4,
|
|
3888
3912
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
3889
3913
|
inject: [
|
|
3890
|
-
|
|
3914
|
+
AGENT_OPTIONS6,
|
|
3891
3915
|
ModulesContainer
|
|
3892
3916
|
]
|
|
3893
3917
|
});
|
|
@@ -3918,16 +3942,15 @@ function sharedProviders(durable) {
|
|
|
3918
3942
|
__name(sharedProviders, "sharedProviders");
|
|
3919
3943
|
function exportsFor() {
|
|
3920
3944
|
return [
|
|
3921
|
-
|
|
3945
|
+
AGENT_OPTIONS6,
|
|
3922
3946
|
AGENT_TOOL_REGISTRY3,
|
|
3923
3947
|
AGENT_REGISTRY6,
|
|
3924
3948
|
AGENT_SINK2,
|
|
3925
3949
|
AGENT_ROLES_POLICY2,
|
|
3926
|
-
|
|
3950
|
+
AGENT_ACTOR_RESOLVER12,
|
|
3927
3951
|
AGENT_MODEL2,
|
|
3928
3952
|
AGENT_STORE4,
|
|
3929
|
-
|
|
3930
|
-
AGENT_MODEL_CATALOG2,
|
|
3953
|
+
AGENT_MODEL_CATALOG3,
|
|
3931
3954
|
AGENT_QUOTA_PROVIDER2,
|
|
3932
3955
|
AGENT_PROMPT_CONTRIBUTORS3,
|
|
3933
3956
|
AGENT_SKILLS3,
|
|
@@ -3950,21 +3973,13 @@ var BASE_CONTROLLERS = [
|
|
|
3950
3973
|
MemoriesController,
|
|
3951
3974
|
ToolsController,
|
|
3952
3975
|
MessagesController,
|
|
3953
|
-
ModelsController
|
|
3954
|
-
|
|
3955
|
-
var GUARDABLE_CONTROLLERS = [
|
|
3956
|
-
...BASE_CONTROLLERS,
|
|
3976
|
+
ModelsController,
|
|
3977
|
+
ConfigController,
|
|
3957
3978
|
AttachmentsController
|
|
3958
3979
|
];
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
AttachmentsController
|
|
3963
|
-
] : BASE_CONTROLLERS;
|
|
3964
|
-
}
|
|
3965
|
-
__name(controllersFor, "controllersFor");
|
|
3966
|
-
function controllersForSurface(surface, mountAttachments) {
|
|
3967
|
-
return surface === "engine" ? [] : controllersFor(mountAttachments);
|
|
3980
|
+
var GUARDABLE_CONTROLLERS = BASE_CONTROLLERS;
|
|
3981
|
+
function controllersForSurface(surface) {
|
|
3982
|
+
return surface === "engine" ? [] : BASE_CONTROLLERS;
|
|
3968
3983
|
}
|
|
3969
3984
|
__name(controllersForSurface, "controllersForSurface");
|
|
3970
3985
|
var GUARDS_METADATA = "__guards__";
|
|
@@ -4004,10 +4019,10 @@ var AgentModule = class _AgentModule {
|
|
|
4004
4019
|
DiscoveryModule,
|
|
4005
4020
|
routerFor(path)
|
|
4006
4021
|
],
|
|
4007
|
-
controllers: controllersForSurface(options.surface
|
|
4022
|
+
controllers: controllersForSurface(options.surface),
|
|
4008
4023
|
providers: [
|
|
4009
4024
|
{
|
|
4010
|
-
provide:
|
|
4025
|
+
provide: AGENT_OPTIONS6,
|
|
4011
4026
|
useValue: options
|
|
4012
4027
|
},
|
|
4013
4028
|
...sharedProviders(options.durable ?? false),
|
|
@@ -4027,10 +4042,10 @@ var AgentModule = class _AgentModule {
|
|
|
4027
4042
|
routerFor(path),
|
|
4028
4043
|
...options.imports ?? []
|
|
4029
4044
|
],
|
|
4030
|
-
controllers: controllersForSurface(options.surface
|
|
4045
|
+
controllers: controllersForSurface(options.surface),
|
|
4031
4046
|
providers: [
|
|
4032
4047
|
{
|
|
4033
|
-
provide:
|
|
4048
|
+
provide: AGENT_OPTIONS6,
|
|
4034
4049
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
4035
4050
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
4036
4051
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -4051,7 +4066,7 @@ var AgentModule = class _AgentModule {
|
|
|
4051
4066
|
};
|
|
4052
4067
|
}
|
|
4053
4068
|
};
|
|
4054
|
-
AgentModule =
|
|
4069
|
+
AgentModule = _ts_decorate20([
|
|
4055
4070
|
Global(),
|
|
4056
4071
|
Module({})
|
|
4057
4072
|
], AgentModule);
|
|
@@ -4147,13 +4162,14 @@ export {
|
|
|
4147
4162
|
AiToolDiscoveryService,
|
|
4148
4163
|
AnonymousActorResolver,
|
|
4149
4164
|
AttachmentsController,
|
|
4165
|
+
ConfigController,
|
|
4150
4166
|
DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
|
|
4151
4167
|
DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
4152
4168
|
HeaderActorResolver,
|
|
4153
4169
|
InProcessTokenStreamSink,
|
|
4154
4170
|
InlineAgentRunner,
|
|
4155
4171
|
LedgerQuotaProvider,
|
|
4156
|
-
|
|
4172
|
+
MAX_ATTACHMENTS_PER_MESSAGE,
|
|
4157
4173
|
MemoriesController,
|
|
4158
4174
|
MessagesController,
|
|
4159
4175
|
ModelsController,
|
|
@@ -4166,6 +4182,7 @@ export {
|
|
|
4166
4182
|
SystemPrompt,
|
|
4167
4183
|
SystemPromptContributor,
|
|
4168
4184
|
ToolsController,
|
|
4185
|
+
attachmentLimits,
|
|
4169
4186
|
declaredSkillProvider,
|
|
4170
4187
|
defaultRequestUserMapper,
|
|
4171
4188
|
delegateToolName,
|