@dudousxd/nestjs-agent 1.6.0 → 1.8.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 +54 -0
- package/dist/{agent-deps.factory-CUyVPsa1.d.cts → agent-deps.factory-Cus_RqwJ.d.cts} +49 -2
- package/dist/{agent-deps.factory-CUyVPsa1.d.ts → agent-deps.factory-Cus_RqwJ.d.ts} +49 -2
- package/dist/durable/index.cjs +618 -309
- 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 +533 -224
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +622 -312
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -5
- package/dist/index.d.ts +53 -5
- package/dist/index.js +531 -223
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/durable/index.js
CHANGED
|
@@ -92,7 +92,10 @@ var AgentRunSteps = class {
|
|
|
92
92
|
system: input.system,
|
|
93
93
|
messages: input.messages,
|
|
94
94
|
tools,
|
|
95
|
-
sink: frames.writer
|
|
95
|
+
sink: frames.writer,
|
|
96
|
+
...input.model !== void 0 ? {
|
|
97
|
+
model: input.model
|
|
98
|
+
} : {}
|
|
96
99
|
})), frames.summary());
|
|
97
100
|
const stamped = stampToolKinds(turn, deps);
|
|
98
101
|
return buffer === void 0 ? stamped : {
|
|
@@ -790,7 +793,7 @@ AgentDurableModule = _ts_decorate4([
|
|
|
790
793
|
], AgentDurableModule);
|
|
791
794
|
|
|
792
795
|
// src/agent.module.ts
|
|
793
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
796
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG2, AGENT_OPTIONS as AGENT_OPTIONS5, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE3, AGENT_REGISTRY as AGENT_REGISTRY6, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK3, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE6, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
794
797
|
import { Global as Global2, Module as Module2 } from "@nestjs/common";
|
|
795
798
|
import { DiscoveryModule, RouterModule } from "@nestjs/core";
|
|
796
799
|
|
|
@@ -1060,8 +1063,8 @@ AgentDepsFactory2 = _ts_decorate5([
|
|
|
1060
1063
|
], AgentDepsFactory2);
|
|
1061
1064
|
|
|
1062
1065
|
// src/agent.service.ts
|
|
1063
|
-
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE4, REQUESTER_APPROVER, mayDecideApproval, readElicitationQuestions, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
1064
|
-
import { BadRequestException, ForbiddenException, GoneException, Inject as Inject5, Injectable as Injectable5, NotFoundException, NotImplementedException, Optional as Optional3 } from "@nestjs/common";
|
|
1066
|
+
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_QUOTA_PROVIDER, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE4, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval, readElicitationQuestions, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
1067
|
+
import { BadRequestException, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as Inject5, Injectable as Injectable5, NotFoundException, NotImplementedException, Optional as Optional3 } from "@nestjs/common";
|
|
1065
1068
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
1066
1069
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1067
1070
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1097,15 +1100,128 @@ var AgentService = class {
|
|
|
1097
1100
|
deps;
|
|
1098
1101
|
quota;
|
|
1099
1102
|
staging;
|
|
1100
|
-
|
|
1103
|
+
models;
|
|
1104
|
+
quotaProvider;
|
|
1105
|
+
options;
|
|
1106
|
+
constructor(runner, store, deps, quota, staging, models, quotaProvider, options) {
|
|
1101
1107
|
this.runner = runner;
|
|
1102
1108
|
this.store = store;
|
|
1103
1109
|
this.deps = deps;
|
|
1104
1110
|
this.quota = quota;
|
|
1105
1111
|
this.staging = staging;
|
|
1112
|
+
this.models = models;
|
|
1113
|
+
this.quotaProvider = quotaProvider;
|
|
1114
|
+
this.options = options;
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* The actor's budget across windows (`GET <base>/quota`) — the bound {@link QuotaProvider}'s
|
|
1118
|
+
* report. Without one (a service built outside the module), a day window from the ledger.
|
|
1119
|
+
*/
|
|
1120
|
+
async quotaReport(actor) {
|
|
1121
|
+
if (this.quotaProvider !== void 0) {
|
|
1122
|
+
return this.quotaProvider.report({
|
|
1123
|
+
actor
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
const today = await this.quotaToday(actor.id);
|
|
1127
|
+
return {
|
|
1128
|
+
windows: [
|
|
1129
|
+
{
|
|
1130
|
+
period: "day",
|
|
1131
|
+
usedTokens: today.usedTokens,
|
|
1132
|
+
...today.limitTokens !== null ? {
|
|
1133
|
+
limitTokens: today.limitTokens
|
|
1134
|
+
} : {},
|
|
1135
|
+
usedUsd: today.costUsd
|
|
1136
|
+
}
|
|
1137
|
+
],
|
|
1138
|
+
...today.withinLimit ? {} : {
|
|
1139
|
+
blocked: {
|
|
1140
|
+
period: "day"
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Refuse a turn the actor's budget no longer covers — only when the host configured one
|
|
1147
|
+
* (`quotaProvider` or `quotaLimits`): the default report is informational, and the daily token
|
|
1148
|
+
* quota the loop enforces keeps working as it always has.
|
|
1149
|
+
*/
|
|
1150
|
+
async assertWithinQuota(actor) {
|
|
1151
|
+
const gated = this.options?.quotaProvider !== void 0 || this.options?.quotaLimits !== void 0;
|
|
1152
|
+
if (!gated || this.quotaProvider === void 0) {
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
const { blocked } = await this.quotaProvider.report({
|
|
1156
|
+
actor
|
|
1157
|
+
});
|
|
1158
|
+
if (blocked !== void 0) {
|
|
1159
|
+
throw new HttpException({
|
|
1160
|
+
statusCode: HttpStatus.TOO_MANY_REQUESTS,
|
|
1161
|
+
code: "quota_exceeded",
|
|
1162
|
+
period: blocked.period,
|
|
1163
|
+
message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
|
|
1164
|
+
}, HttpStatus.TOO_MANY_REQUESTS);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* The models `actor` may pick for `agent` (`GET <base>/models`). An empty catalog when none is
|
|
1169
|
+
* bound, so a picker simply has nothing to offer.
|
|
1170
|
+
*/
|
|
1171
|
+
async listModels(actor, agent) {
|
|
1172
|
+
if (this.models === void 0) {
|
|
1173
|
+
return {
|
|
1174
|
+
providers: [],
|
|
1175
|
+
default: null
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
return this.models.list({
|
|
1179
|
+
actor,
|
|
1180
|
+
...agent !== void 0 ? {
|
|
1181
|
+
agent
|
|
1182
|
+
} : {}
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* `model` if the catalog offers it to this actor and agent right now, else a 400 naming why. The
|
|
1187
|
+
* one gate every model choice passes — a send's own, and a thread's pinned one at the moment it is
|
|
1188
|
+
* pinned and again at every turn that runs on it (availability can change in between).
|
|
1189
|
+
*/
|
|
1190
|
+
async assertModelAllowed(actor, agent, model) {
|
|
1191
|
+
if (this.models === void 0) {
|
|
1192
|
+
throw new BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
1193
|
+
}
|
|
1194
|
+
const entry = findCatalogModel(await this.models.list({
|
|
1195
|
+
actor,
|
|
1196
|
+
agent
|
|
1197
|
+
}), model);
|
|
1198
|
+
if (entry === void 0) {
|
|
1199
|
+
throw new BadRequestException(`model "${model}" is not offered`);
|
|
1200
|
+
}
|
|
1201
|
+
if (!entry.available) {
|
|
1202
|
+
throw new BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
1203
|
+
}
|
|
1204
|
+
return entry.id;
|
|
1205
|
+
}
|
|
1206
|
+
/** The model a turn runs on: the send's own, else the thread's pinned one, else none. */
|
|
1207
|
+
async resolveModel(actor, agent, requested, threadId) {
|
|
1208
|
+
const model = requested ?? (threadId !== void 0 ? await this.threadModel(threadId) : null);
|
|
1209
|
+
if (model === null || model === void 0) {
|
|
1210
|
+
return void 0;
|
|
1211
|
+
}
|
|
1212
|
+
return this.assertModelAllowed(actor, agent, model);
|
|
1213
|
+
}
|
|
1214
|
+
async threadModel(threadId) {
|
|
1215
|
+
const projecting = this.store;
|
|
1216
|
+
if (typeof projecting.modelForThread === "function") {
|
|
1217
|
+
return projecting.modelForThread(threadId);
|
|
1218
|
+
}
|
|
1219
|
+
return (await this.store.getThread(threadId))?.model ?? null;
|
|
1106
1220
|
}
|
|
1107
1221
|
async chat(params) {
|
|
1222
|
+
await this.assertWithinQuota(params.actor);
|
|
1108
1223
|
const agentName = await this.resolveAgentName(params.agentName, params.threadId);
|
|
1224
|
+
const model = await this.resolveModel(params.actor, agentName, params.model, params.threadId);
|
|
1109
1225
|
const attachments = await this.resolveAttachments(params.actor, params.attachments ?? []);
|
|
1110
1226
|
let threadId = params.threadId;
|
|
1111
1227
|
if (threadId === void 0) {
|
|
@@ -1136,6 +1252,9 @@ var AgentService = class {
|
|
|
1136
1252
|
} : {},
|
|
1137
1253
|
...params.pageContext !== void 0 ? {
|
|
1138
1254
|
pageContext: params.pageContext
|
|
1255
|
+
} : {},
|
|
1256
|
+
...model !== void 0 ? {
|
|
1257
|
+
model
|
|
1139
1258
|
} : {}
|
|
1140
1259
|
};
|
|
1141
1260
|
const { runId } = await this.runner.start(input);
|
|
@@ -1306,20 +1425,26 @@ var AgentService = class {
|
|
|
1306
1425
|
async updateThread(actor, threadId, patch) {
|
|
1307
1426
|
const title = patch.title !== void 0 ? this.validateTitle(patch.title) : void 0;
|
|
1308
1427
|
await this.assertOwnsThread(actor, threadId);
|
|
1309
|
-
if (patch.defaultAgent === void 0) {
|
|
1428
|
+
if (patch.defaultAgent === void 0 && patch.model === void 0) {
|
|
1310
1429
|
if (title !== void 0) {
|
|
1311
1430
|
await this.store.setTitle(threadId, title);
|
|
1312
1431
|
}
|
|
1313
1432
|
return;
|
|
1314
1433
|
}
|
|
1315
1434
|
if (this.store.updateThread === void 0) {
|
|
1316
|
-
throw new NotImplementedException("Setting a thread's defaultAgent requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
1435
|
+
throw new NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
1317
1436
|
}
|
|
1437
|
+
const model = patch.model === void 0 || patch.model === null ? patch.model : await this.assertModelAllowed(actor, patch.defaultAgent ?? await this.resolveAgentName(void 0, threadId), patch.model);
|
|
1318
1438
|
await this.store.updateThread(threadId, {
|
|
1319
1439
|
...title !== void 0 ? {
|
|
1320
1440
|
title
|
|
1321
1441
|
} : {},
|
|
1322
|
-
|
|
1442
|
+
...patch.defaultAgent !== void 0 ? {
|
|
1443
|
+
defaultAgent: patch.defaultAgent
|
|
1444
|
+
} : {},
|
|
1445
|
+
...model !== void 0 ? {
|
|
1446
|
+
model
|
|
1447
|
+
} : {}
|
|
1323
1448
|
});
|
|
1324
1449
|
}
|
|
1325
1450
|
validateTitle(title) {
|
|
@@ -1366,6 +1491,7 @@ var AgentService = class {
|
|
|
1366
1491
|
return {
|
|
1367
1492
|
...thread,
|
|
1368
1493
|
defaultAgent: thread.defaultAgent ?? null,
|
|
1494
|
+
model: thread.model ?? null,
|
|
1369
1495
|
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
|
|
1370
1496
|
};
|
|
1371
1497
|
}
|
|
@@ -1633,13 +1759,22 @@ AgentService = _ts_decorate6([
|
|
|
1633
1759
|
_ts_param5(3, Inject5(AGENT_QUOTA_STORE2)),
|
|
1634
1760
|
_ts_param5(4, Optional3()),
|
|
1635
1761
|
_ts_param5(4, Inject5(AGENT_ATTACHMENT_STAGING)),
|
|
1762
|
+
_ts_param5(5, Optional3()),
|
|
1763
|
+
_ts_param5(5, Inject5(AGENT_MODEL_CATALOG)),
|
|
1764
|
+
_ts_param5(6, Optional3()),
|
|
1765
|
+
_ts_param5(6, Inject5(AGENT_QUOTA_PROVIDER)),
|
|
1766
|
+
_ts_param5(7, Optional3()),
|
|
1767
|
+
_ts_param5(7, Inject5(AGENT_OPTIONS2)),
|
|
1636
1768
|
_ts_metadata5("design:type", Function),
|
|
1637
1769
|
_ts_metadata5("design:paramtypes", [
|
|
1638
1770
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
1639
1771
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1640
1772
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1641
1773
|
Object,
|
|
1642
|
-
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore
|
|
1774
|
+
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
1775
|
+
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
1776
|
+
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
1777
|
+
typeof Pick === "undefined" ? Object : Pick
|
|
1643
1778
|
])
|
|
1644
1779
|
], AgentService);
|
|
1645
1780
|
|
|
@@ -1778,7 +1913,7 @@ AgentsController = _ts_decorate8([
|
|
|
1778
1913
|
], AgentsController);
|
|
1779
1914
|
|
|
1780
1915
|
// src/controller/attachments.controller.ts
|
|
1781
|
-
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_OPTIONS as
|
|
1916
|
+
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_OPTIONS as AGENT_OPTIONS3 } from "@dudousxd/nestjs-agent-core";
|
|
1782
1917
|
import { BadRequestException as BadRequestException2, Controller as Controller2, Get as Get2, Inject as Inject7, NotImplementedException as NotImplementedException2, Optional as Optional4, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
|
|
1783
1918
|
import { FileInterceptor } from "@nestjs/platform-express";
|
|
1784
1919
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
@@ -1911,7 +2046,7 @@ _ts_decorate9([
|
|
|
1911
2046
|
], AttachmentsController.prototype, "upload", null);
|
|
1912
2047
|
AttachmentsController = _ts_decorate9([
|
|
1913
2048
|
Controller2("attachments"),
|
|
1914
|
-
_ts_param7(0, Inject7(
|
|
2049
|
+
_ts_param7(0, Inject7(AGENT_OPTIONS3)),
|
|
1915
2050
|
_ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER)),
|
|
1916
2051
|
_ts_param7(3, Optional4()),
|
|
1917
2052
|
_ts_param7(3, Inject7(AGENT_ATTACHMENT_STAGING2)),
|
|
@@ -2011,6 +2146,9 @@ var ChatController = class {
|
|
|
2011
2146
|
} : {},
|
|
2012
2147
|
...body.transient === true ? {
|
|
2013
2148
|
transient: true
|
|
2149
|
+
} : {},
|
|
2150
|
+
...typeof body.model === "string" && body.model.length > 0 ? {
|
|
2151
|
+
model: body.model
|
|
2014
2152
|
} : {}
|
|
2015
2153
|
});
|
|
2016
2154
|
await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
|
|
@@ -2375,9 +2513,9 @@ MessagesController = _ts_decorate12([
|
|
|
2375
2513
|
])
|
|
2376
2514
|
], MessagesController);
|
|
2377
2515
|
|
|
2378
|
-
// src/controller/
|
|
2516
|
+
// src/controller/models.controller.ts
|
|
2379
2517
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
|
|
2380
|
-
import { Controller as Controller6, Get as Get5, Inject as Inject11, Req as Req5 } from "@nestjs/common";
|
|
2518
|
+
import { Controller as Controller6, Get as Get5, Inject as Inject11, Query as Query3, Req as Req5 } from "@nestjs/common";
|
|
2381
2519
|
function _ts_decorate13(decorators, target, key, desc) {
|
|
2382
2520
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2383
2521
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2404,9 +2542,9 @@ function _ts_param11(paramIndex, decorator) {
|
|
|
2404
2542
|
};
|
|
2405
2543
|
}
|
|
2406
2544
|
__name(_ts_param11, "_ts_param");
|
|
2407
|
-
var
|
|
2545
|
+
var ModelsController = class {
|
|
2408
2546
|
static {
|
|
2409
|
-
__name(this, "
|
|
2547
|
+
__name(this, "ModelsController");
|
|
2410
2548
|
}
|
|
2411
2549
|
agent;
|
|
2412
2550
|
actorResolver;
|
|
@@ -2414,33 +2552,39 @@ var QuotaController = class {
|
|
|
2414
2552
|
this.agent = agent;
|
|
2415
2553
|
this.actorResolver = actorResolver;
|
|
2416
2554
|
}
|
|
2417
|
-
|
|
2555
|
+
/**
|
|
2556
|
+
* The models the caller may pick for `agent` (the default agent when omitted), grouped by
|
|
2557
|
+
* provider, with badges and availability — the bound `ModelCatalog`'s answer, or an empty one.
|
|
2558
|
+
*/
|
|
2559
|
+
async list(req, agent) {
|
|
2418
2560
|
const actor = await this.actorResolver.resolve(req);
|
|
2419
|
-
return this.agent.
|
|
2561
|
+
return this.agent.listModels(actor, agent);
|
|
2420
2562
|
}
|
|
2421
2563
|
};
|
|
2422
2564
|
_ts_decorate13([
|
|
2423
|
-
Get5(
|
|
2565
|
+
Get5(),
|
|
2424
2566
|
_ts_param11(0, Req5()),
|
|
2567
|
+
_ts_param11(1, Query3("agent")),
|
|
2425
2568
|
_ts_metadata12("design:type", Function),
|
|
2426
2569
|
_ts_metadata12("design:paramtypes", [
|
|
2427
|
-
typeof Request === "undefined" ? Object : Request
|
|
2570
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2571
|
+
String
|
|
2428
2572
|
]),
|
|
2429
2573
|
_ts_metadata12("design:returntype", Promise)
|
|
2430
|
-
],
|
|
2431
|
-
|
|
2432
|
-
Controller6("
|
|
2574
|
+
], ModelsController.prototype, "list", null);
|
|
2575
|
+
ModelsController = _ts_decorate13([
|
|
2576
|
+
Controller6("models"),
|
|
2433
2577
|
_ts_param11(1, Inject11(AGENT_ACTOR_RESOLVER5)),
|
|
2434
2578
|
_ts_metadata12("design:type", Function),
|
|
2435
2579
|
_ts_metadata12("design:paramtypes", [
|
|
2436
2580
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2437
2581
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2438
2582
|
])
|
|
2439
|
-
],
|
|
2583
|
+
], ModelsController);
|
|
2440
2584
|
|
|
2441
|
-
// src/controller/
|
|
2442
|
-
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6
|
|
2443
|
-
import { Controller as Controller7, Get as Get6, Inject as Inject12,
|
|
2585
|
+
// src/controller/quota.controller.ts
|
|
2586
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6 } from "@dudousxd/nestjs-agent-core";
|
|
2587
|
+
import { Controller as Controller7, Get as Get6, Inject as Inject12, Req as Req6 } from "@nestjs/common";
|
|
2444
2588
|
function _ts_decorate14(decorators, target, key, desc) {
|
|
2445
2589
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2446
2590
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2467,6 +2611,86 @@ function _ts_param12(paramIndex, decorator) {
|
|
|
2467
2611
|
};
|
|
2468
2612
|
}
|
|
2469
2613
|
__name(_ts_param12, "_ts_param");
|
|
2614
|
+
var QuotaController = class {
|
|
2615
|
+
static {
|
|
2616
|
+
__name(this, "QuotaController");
|
|
2617
|
+
}
|
|
2618
|
+
agent;
|
|
2619
|
+
actorResolver;
|
|
2620
|
+
constructor(agent, actorResolver) {
|
|
2621
|
+
this.agent = agent;
|
|
2622
|
+
this.actorResolver = actorResolver;
|
|
2623
|
+
}
|
|
2624
|
+
/**
|
|
2625
|
+
* The caller's budget across windows — `{ windows: [{ period, usedTokens, limitTokens?, usedUsd,
|
|
2626
|
+
* limitUsd?, resetsAt? }], blocked?: { period, reason? } }` — from the bound `QuotaProvider`.
|
|
2627
|
+
*/
|
|
2628
|
+
async report(req) {
|
|
2629
|
+
const actor = await this.actorResolver.resolve(req);
|
|
2630
|
+
return this.agent.quotaReport(actor);
|
|
2631
|
+
}
|
|
2632
|
+
async today(req) {
|
|
2633
|
+
const actor = await this.actorResolver.resolve(req);
|
|
2634
|
+
return this.agent.quotaToday(actor.id);
|
|
2635
|
+
}
|
|
2636
|
+
};
|
|
2637
|
+
_ts_decorate14([
|
|
2638
|
+
Get6(),
|
|
2639
|
+
_ts_param12(0, Req6()),
|
|
2640
|
+
_ts_metadata13("design:type", Function),
|
|
2641
|
+
_ts_metadata13("design:paramtypes", [
|
|
2642
|
+
typeof Request === "undefined" ? Object : Request
|
|
2643
|
+
]),
|
|
2644
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2645
|
+
], QuotaController.prototype, "report", null);
|
|
2646
|
+
_ts_decorate14([
|
|
2647
|
+
Get6("today"),
|
|
2648
|
+
_ts_param12(0, Req6()),
|
|
2649
|
+
_ts_metadata13("design:type", Function),
|
|
2650
|
+
_ts_metadata13("design:paramtypes", [
|
|
2651
|
+
typeof Request === "undefined" ? Object : Request
|
|
2652
|
+
]),
|
|
2653
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2654
|
+
], QuotaController.prototype, "today", null);
|
|
2655
|
+
QuotaController = _ts_decorate14([
|
|
2656
|
+
Controller7("quota"),
|
|
2657
|
+
_ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER6)),
|
|
2658
|
+
_ts_metadata13("design:type", Function),
|
|
2659
|
+
_ts_metadata13("design:paramtypes", [
|
|
2660
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2661
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2662
|
+
])
|
|
2663
|
+
], QuotaController);
|
|
2664
|
+
|
|
2665
|
+
// src/controller/skills.controller.ts
|
|
2666
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER7, AGENT_SKILLS as AGENT_SKILLS2, offerSkills } from "@dudousxd/nestjs-agent-core";
|
|
2667
|
+
import { Controller as Controller8, Get as Get7, Inject as Inject13, Optional as Optional6, Query as Query4, Req as Req7 } from "@nestjs/common";
|
|
2668
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2669
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2670
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2671
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2672
|
+
} else {
|
|
2673
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2674
|
+
if (d = decorators[i]) {
|
|
2675
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2680
|
+
}
|
|
2681
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2682
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2683
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2684
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2688
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2689
|
+
return function(target, key) {
|
|
2690
|
+
decorator(target, key, paramIndex);
|
|
2691
|
+
};
|
|
2692
|
+
}
|
|
2693
|
+
__name(_ts_param13, "_ts_param");
|
|
2470
2694
|
var SkillsController = class {
|
|
2471
2695
|
static {
|
|
2472
2696
|
__name(this, "SkillsController");
|
|
@@ -2489,33 +2713,33 @@ var SkillsController = class {
|
|
|
2489
2713
|
return offer.entries;
|
|
2490
2714
|
}
|
|
2491
2715
|
};
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2716
|
+
_ts_decorate15([
|
|
2717
|
+
Get7(),
|
|
2718
|
+
_ts_param13(0, Req7()),
|
|
2719
|
+
_ts_param13(1, Query4("threadId")),
|
|
2720
|
+
_ts_metadata14("design:type", Function),
|
|
2721
|
+
_ts_metadata14("design:paramtypes", [
|
|
2498
2722
|
typeof Request === "undefined" ? Object : Request,
|
|
2499
2723
|
String
|
|
2500
2724
|
]),
|
|
2501
|
-
|
|
2725
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2502
2726
|
], SkillsController.prototype, "list", null);
|
|
2503
|
-
SkillsController =
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2727
|
+
SkillsController = _ts_decorate15([
|
|
2728
|
+
Controller8("skills"),
|
|
2729
|
+
_ts_param13(0, Inject13(AGENT_ACTOR_RESOLVER7)),
|
|
2730
|
+
_ts_param13(1, Optional6()),
|
|
2731
|
+
_ts_param13(1, Inject13(AGENT_SKILLS2)),
|
|
2732
|
+
_ts_metadata14("design:type", Function),
|
|
2733
|
+
_ts_metadata14("design:paramtypes", [
|
|
2510
2734
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2511
2735
|
Object
|
|
2512
2736
|
])
|
|
2513
2737
|
], SkillsController);
|
|
2514
2738
|
|
|
2515
2739
|
// src/controller/threads.controller.ts
|
|
2516
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2517
|
-
import { Body as Body3, Controller as
|
|
2518
|
-
function
|
|
2740
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8 } from "@dudousxd/nestjs-agent-core";
|
|
2741
|
+
import { Body as Body3, Controller as Controller9, Delete as Delete2, Get as Get8, Inject as Inject14, Param as Param4, Patch, Post as Post4, Req as Req8 } from "@nestjs/common";
|
|
2742
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2519
2743
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2520
2744
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2521
2745
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2528,19 +2752,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2528
2752
|
}
|
|
2529
2753
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2530
2754
|
}
|
|
2531
|
-
__name(
|
|
2532
|
-
function
|
|
2755
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2756
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2533
2757
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2534
2758
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2535
2759
|
}
|
|
2536
2760
|
}
|
|
2537
|
-
__name(
|
|
2538
|
-
function
|
|
2761
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2762
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2539
2763
|
return function(target, key) {
|
|
2540
2764
|
decorator(target, key, paramIndex);
|
|
2541
2765
|
};
|
|
2542
2766
|
}
|
|
2543
|
-
__name(
|
|
2767
|
+
__name(_ts_param14, "_ts_param");
|
|
2544
2768
|
var ThreadsController = class {
|
|
2545
2769
|
static {
|
|
2546
2770
|
__name(this, "ThreadsController");
|
|
@@ -2583,6 +2807,9 @@ var ThreadsController = class {
|
|
|
2583
2807
|
} : {},
|
|
2584
2808
|
..."defaultAgent" in body ? {
|
|
2585
2809
|
defaultAgent: body.defaultAgent ?? null
|
|
2810
|
+
} : {},
|
|
2811
|
+
..."model" in body ? {
|
|
2812
|
+
model: body.model ?? null
|
|
2586
2813
|
} : {}
|
|
2587
2814
|
});
|
|
2588
2815
|
return {
|
|
@@ -2604,101 +2831,101 @@ var ThreadsController = class {
|
|
|
2604
2831
|
};
|
|
2605
2832
|
}
|
|
2606
2833
|
};
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2834
|
+
_ts_decorate16([
|
|
2835
|
+
Get8(),
|
|
2836
|
+
_ts_param14(0, Req8()),
|
|
2837
|
+
_ts_metadata15("design:type", Function),
|
|
2838
|
+
_ts_metadata15("design:paramtypes", [
|
|
2612
2839
|
typeof Request === "undefined" ? Object : Request
|
|
2613
2840
|
]),
|
|
2614
|
-
|
|
2841
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2615
2842
|
], ThreadsController.prototype, "list", null);
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2843
|
+
_ts_decorate16([
|
|
2844
|
+
Get8(":id"),
|
|
2845
|
+
_ts_param14(0, Req8()),
|
|
2846
|
+
_ts_param14(1, Param4("id")),
|
|
2847
|
+
_ts_metadata15("design:type", Function),
|
|
2848
|
+
_ts_metadata15("design:paramtypes", [
|
|
2622
2849
|
typeof Request === "undefined" ? Object : Request,
|
|
2623
2850
|
String
|
|
2624
2851
|
]),
|
|
2625
|
-
|
|
2852
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2626
2853
|
], ThreadsController.prototype, "detail", null);
|
|
2627
|
-
|
|
2854
|
+
_ts_decorate16([
|
|
2628
2855
|
Delete2(":id"),
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2856
|
+
_ts_param14(0, Req8()),
|
|
2857
|
+
_ts_param14(1, Param4("id")),
|
|
2858
|
+
_ts_metadata15("design:type", Function),
|
|
2859
|
+
_ts_metadata15("design:paramtypes", [
|
|
2633
2860
|
typeof Request === "undefined" ? Object : Request,
|
|
2634
2861
|
String
|
|
2635
2862
|
]),
|
|
2636
|
-
|
|
2863
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2637
2864
|
], ThreadsController.prototype, "remove", null);
|
|
2638
|
-
|
|
2865
|
+
_ts_decorate16([
|
|
2639
2866
|
Post4(":id/fork-from/:messageId"),
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2867
|
+
_ts_param14(0, Req8()),
|
|
2868
|
+
_ts_param14(1, Param4("id")),
|
|
2869
|
+
_ts_param14(2, Param4("messageId")),
|
|
2870
|
+
_ts_metadata15("design:type", Function),
|
|
2871
|
+
_ts_metadata15("design:paramtypes", [
|
|
2645
2872
|
typeof Request === "undefined" ? Object : Request,
|
|
2646
2873
|
String,
|
|
2647
2874
|
String
|
|
2648
2875
|
]),
|
|
2649
|
-
|
|
2876
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2650
2877
|
], ThreadsController.prototype, "fork", null);
|
|
2651
|
-
|
|
2878
|
+
_ts_decorate16([
|
|
2652
2879
|
Patch(":id"),
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2880
|
+
_ts_param14(0, Req8()),
|
|
2881
|
+
_ts_param14(1, Param4("id")),
|
|
2882
|
+
_ts_param14(2, Body3()),
|
|
2883
|
+
_ts_metadata15("design:type", Function),
|
|
2884
|
+
_ts_metadata15("design:paramtypes", [
|
|
2658
2885
|
typeof Request === "undefined" ? Object : Request,
|
|
2659
2886
|
String,
|
|
2660
2887
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
2661
2888
|
]),
|
|
2662
|
-
|
|
2889
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2663
2890
|
], ThreadsController.prototype, "update", null);
|
|
2664
|
-
|
|
2891
|
+
_ts_decorate16([
|
|
2665
2892
|
Post4(":id/promote"),
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2893
|
+
_ts_param14(0, Req8()),
|
|
2894
|
+
_ts_param14(1, Param4("id")),
|
|
2895
|
+
_ts_metadata15("design:type", Function),
|
|
2896
|
+
_ts_metadata15("design:paramtypes", [
|
|
2670
2897
|
typeof Request === "undefined" ? Object : Request,
|
|
2671
2898
|
String
|
|
2672
2899
|
]),
|
|
2673
|
-
|
|
2900
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2674
2901
|
], ThreadsController.prototype, "promote", null);
|
|
2675
|
-
|
|
2902
|
+
_ts_decorate16([
|
|
2676
2903
|
Delete2(":id/from/:messageId"),
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2904
|
+
_ts_param14(0, Req8()),
|
|
2905
|
+
_ts_param14(1, Param4("id")),
|
|
2906
|
+
_ts_param14(2, Param4("messageId")),
|
|
2907
|
+
_ts_metadata15("design:type", Function),
|
|
2908
|
+
_ts_metadata15("design:paramtypes", [
|
|
2682
2909
|
typeof Request === "undefined" ? Object : Request,
|
|
2683
2910
|
String,
|
|
2684
2911
|
String
|
|
2685
2912
|
]),
|
|
2686
|
-
|
|
2913
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2687
2914
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
2688
|
-
ThreadsController =
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2915
|
+
ThreadsController = _ts_decorate16([
|
|
2916
|
+
Controller9("threads"),
|
|
2917
|
+
_ts_param14(1, Inject14(AGENT_ACTOR_RESOLVER8)),
|
|
2918
|
+
_ts_metadata15("design:type", Function),
|
|
2919
|
+
_ts_metadata15("design:paramtypes", [
|
|
2693
2920
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2694
2921
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2695
2922
|
])
|
|
2696
2923
|
], ThreadsController);
|
|
2697
2924
|
|
|
2698
2925
|
// src/controller/tool-call.controller.ts
|
|
2699
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2700
|
-
import { BadRequestException as BadRequestException4, Body as Body4, Controller as
|
|
2701
|
-
function
|
|
2926
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER9 } from "@dudousxd/nestjs-agent-core";
|
|
2927
|
+
import { BadRequestException as BadRequestException4, Body as Body4, Controller as Controller10, Inject as Inject15, Post as Post5, Req as Req9 } from "@nestjs/common";
|
|
2928
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2702
2929
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2703
2930
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2704
2931
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2711,19 +2938,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2711
2938
|
}
|
|
2712
2939
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2713
2940
|
}
|
|
2714
|
-
__name(
|
|
2715
|
-
function
|
|
2941
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2942
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2716
2943
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2717
2944
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2718
2945
|
}
|
|
2719
2946
|
}
|
|
2720
|
-
__name(
|
|
2721
|
-
function
|
|
2947
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2948
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2722
2949
|
return function(target, key) {
|
|
2723
2950
|
decorator(target, key, paramIndex);
|
|
2724
2951
|
};
|
|
2725
2952
|
}
|
|
2726
|
-
__name(
|
|
2953
|
+
__name(_ts_param15, "_ts_param");
|
|
2727
2954
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
2728
2955
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
2729
2956
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -2852,64 +3079,64 @@ var ToolCallController = class {
|
|
|
2852
3079
|
};
|
|
2853
3080
|
}
|
|
2854
3081
|
};
|
|
2855
|
-
|
|
3082
|
+
_ts_decorate17([
|
|
2856
3083
|
Post5("approve"),
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
3084
|
+
_ts_param15(0, Req9()),
|
|
3085
|
+
_ts_param15(1, Body4()),
|
|
3086
|
+
_ts_metadata16("design:type", Function),
|
|
3087
|
+
_ts_metadata16("design:paramtypes", [
|
|
2861
3088
|
typeof Request === "undefined" ? Object : Request,
|
|
2862
3089
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
2863
3090
|
]),
|
|
2864
|
-
|
|
3091
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2865
3092
|
], ToolCallController.prototype, "approve", null);
|
|
2866
|
-
|
|
3093
|
+
_ts_decorate17([
|
|
2867
3094
|
Post5("reject"),
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
3095
|
+
_ts_param15(0, Req9()),
|
|
3096
|
+
_ts_param15(1, Body4()),
|
|
3097
|
+
_ts_metadata16("design:type", Function),
|
|
3098
|
+
_ts_metadata16("design:paramtypes", [
|
|
2872
3099
|
typeof Request === "undefined" ? Object : Request,
|
|
2873
3100
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
2874
3101
|
]),
|
|
2875
|
-
|
|
3102
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2876
3103
|
], ToolCallController.prototype, "reject", null);
|
|
2877
|
-
|
|
3104
|
+
_ts_decorate17([
|
|
2878
3105
|
Post5("answer"),
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
3106
|
+
_ts_param15(0, Req9()),
|
|
3107
|
+
_ts_param15(1, Body4()),
|
|
3108
|
+
_ts_metadata16("design:type", Function),
|
|
3109
|
+
_ts_metadata16("design:paramtypes", [
|
|
2883
3110
|
typeof Request === "undefined" ? Object : Request,
|
|
2884
3111
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
2885
3112
|
]),
|
|
2886
|
-
|
|
3113
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2887
3114
|
], ToolCallController.prototype, "answer", null);
|
|
2888
|
-
|
|
3115
|
+
_ts_decorate17([
|
|
2889
3116
|
Post5("skip"),
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
3117
|
+
_ts_param15(0, Req9()),
|
|
3118
|
+
_ts_param15(1, Body4()),
|
|
3119
|
+
_ts_metadata16("design:type", Function),
|
|
3120
|
+
_ts_metadata16("design:paramtypes", [
|
|
2894
3121
|
typeof Request === "undefined" ? Object : Request,
|
|
2895
3122
|
Object
|
|
2896
3123
|
]),
|
|
2897
|
-
|
|
3124
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2898
3125
|
], ToolCallController.prototype, "skip", null);
|
|
2899
|
-
ToolCallController =
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
3126
|
+
ToolCallController = _ts_decorate17([
|
|
3127
|
+
Controller10("tool-call"),
|
|
3128
|
+
_ts_param15(1, Inject15(AGENT_ACTOR_RESOLVER9)),
|
|
3129
|
+
_ts_metadata16("design:type", Function),
|
|
3130
|
+
_ts_metadata16("design:paramtypes", [
|
|
2904
3131
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2905
3132
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2906
3133
|
])
|
|
2907
3134
|
], ToolCallController);
|
|
2908
3135
|
|
|
2909
3136
|
// src/controller/tools.controller.ts
|
|
2910
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
2911
|
-
import { Controller as
|
|
2912
|
-
function
|
|
3137
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER10, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
|
|
3138
|
+
import { Controller as Controller11, Get as Get9, Inject as Inject16, NotFoundException as NotFoundException3, Query as Query5, Req as Req10 } from "@nestjs/common";
|
|
3139
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2913
3140
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2914
3141
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2915
3142
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2922,19 +3149,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
2922
3149
|
}
|
|
2923
3150
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2924
3151
|
}
|
|
2925
|
-
__name(
|
|
2926
|
-
function
|
|
3152
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3153
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2927
3154
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2928
3155
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2929
3156
|
}
|
|
2930
3157
|
}
|
|
2931
|
-
__name(
|
|
2932
|
-
function
|
|
3158
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
3159
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2933
3160
|
return function(target, key) {
|
|
2934
3161
|
decorator(target, key, paramIndex);
|
|
2935
3162
|
};
|
|
2936
3163
|
}
|
|
2937
|
-
__name(
|
|
3164
|
+
__name(_ts_param16, "_ts_param");
|
|
2938
3165
|
var ToolsController = class {
|
|
2939
3166
|
static {
|
|
2940
3167
|
__name(this, "ToolsController");
|
|
@@ -2963,24 +3190,24 @@ var ToolsController = class {
|
|
|
2963
3190
|
}));
|
|
2964
3191
|
}
|
|
2965
3192
|
};
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
3193
|
+
_ts_decorate18([
|
|
3194
|
+
Get9(),
|
|
3195
|
+
_ts_param16(0, Req10()),
|
|
3196
|
+
_ts_param16(1, Query5("agent")),
|
|
3197
|
+
_ts_metadata17("design:type", Function),
|
|
3198
|
+
_ts_metadata17("design:paramtypes", [
|
|
2972
3199
|
typeof Request === "undefined" ? Object : Request,
|
|
2973
3200
|
String
|
|
2974
3201
|
]),
|
|
2975
|
-
|
|
3202
|
+
_ts_metadata17("design:returntype", Promise)
|
|
2976
3203
|
], ToolsController.prototype, "list", null);
|
|
2977
|
-
ToolsController =
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3204
|
+
ToolsController = _ts_decorate18([
|
|
3205
|
+
Controller11("tools"),
|
|
3206
|
+
_ts_param16(0, Inject16(AGENT_ACTOR_RESOLVER10)),
|
|
3207
|
+
_ts_param16(1, Inject16(AGENT_DEPS_FACTORY5)),
|
|
3208
|
+
_ts_param16(2, Inject16(AGENT_REGISTRY3)),
|
|
3209
|
+
_ts_metadata17("design:type", Function),
|
|
3210
|
+
_ts_metadata17("design:paramtypes", [
|
|
2984
3211
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2985
3212
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2986
3213
|
typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4
|
|
@@ -2989,7 +3216,7 @@ ToolsController = _ts_decorate17([
|
|
|
2989
3216
|
|
|
2990
3217
|
// src/discovery/agent-discovery.service.ts
|
|
2991
3218
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
|
|
2992
|
-
import { Inject as
|
|
3219
|
+
import { Inject as Inject17, Injectable as Injectable7, Logger as Logger2 } from "@nestjs/common";
|
|
2993
3220
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
2994
3221
|
|
|
2995
3222
|
// src/decorator/agent.decorator.ts
|
|
@@ -3006,7 +3233,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
|
|
|
3006
3233
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
3007
3234
|
|
|
3008
3235
|
// src/discovery/agent-discovery.service.ts
|
|
3009
|
-
function
|
|
3236
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3010
3237
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3011
3238
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3012
3239
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3019,19 +3246,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3019
3246
|
}
|
|
3020
3247
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3021
3248
|
}
|
|
3022
|
-
__name(
|
|
3023
|
-
function
|
|
3249
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3250
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
3024
3251
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3025
3252
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3026
3253
|
}
|
|
3027
3254
|
}
|
|
3028
|
-
__name(
|
|
3029
|
-
function
|
|
3255
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3256
|
+
function _ts_param17(paramIndex, decorator) {
|
|
3030
3257
|
return function(target, key) {
|
|
3031
3258
|
decorator(target, key, paramIndex);
|
|
3032
3259
|
};
|
|
3033
3260
|
}
|
|
3034
|
-
__name(
|
|
3261
|
+
__name(_ts_param17, "_ts_param");
|
|
3035
3262
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
3036
3263
|
static {
|
|
3037
3264
|
__name(this, "AgentDiscoveryService");
|
|
@@ -3158,12 +3385,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
3158
3385
|
return (ctx) => candidate.call(instance, ctx);
|
|
3159
3386
|
}
|
|
3160
3387
|
};
|
|
3161
|
-
AgentDiscoveryService =
|
|
3388
|
+
AgentDiscoveryService = _ts_decorate19([
|
|
3162
3389
|
Injectable7(),
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3390
|
+
_ts_param17(2, Inject17(AGENT_REGISTRY4)),
|
|
3391
|
+
_ts_param17(3, Inject17(AGENT_PROMPT_CONTRIBUTORS2)),
|
|
3392
|
+
_ts_metadata18("design:type", Function),
|
|
3393
|
+
_ts_metadata18("design:paramtypes", [
|
|
3167
3394
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
3168
3395
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
3169
3396
|
typeof AgentRegistry5 === "undefined" ? Object : AgentRegistry5,
|
|
@@ -3172,8 +3399,8 @@ AgentDiscoveryService = _ts_decorate18([
|
|
|
3172
3399
|
], AgentDiscoveryService);
|
|
3173
3400
|
|
|
3174
3401
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3175
|
-
import { AGENT_OPTIONS as
|
|
3176
|
-
import { Inject as
|
|
3402
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
3403
|
+
import { Inject as Inject18, Injectable as Injectable8, Logger as Logger3 } from "@nestjs/common";
|
|
3177
3404
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
3178
3405
|
import { z } from "zod";
|
|
3179
3406
|
|
|
@@ -3193,7 +3420,7 @@ function isBrandedFunctionalTool(value) {
|
|
|
3193
3420
|
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
3194
3421
|
|
|
3195
3422
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3196
|
-
function
|
|
3423
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3197
3424
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3198
3425
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3199
3426
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3206,19 +3433,19 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
3206
3433
|
}
|
|
3207
3434
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3208
3435
|
}
|
|
3209
|
-
__name(
|
|
3210
|
-
function
|
|
3436
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3437
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3211
3438
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3212
3439
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3213
3440
|
}
|
|
3214
3441
|
}
|
|
3215
|
-
__name(
|
|
3216
|
-
function
|
|
3442
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3443
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3217
3444
|
return function(target, key) {
|
|
3218
3445
|
decorator(target, key, paramIndex);
|
|
3219
3446
|
};
|
|
3220
3447
|
}
|
|
3221
|
-
__name(
|
|
3448
|
+
__name(_ts_param18, "_ts_param");
|
|
3222
3449
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
3223
3450
|
static {
|
|
3224
3451
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -3351,13 +3578,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3351
3578
|
return true;
|
|
3352
3579
|
}
|
|
3353
3580
|
};
|
|
3354
|
-
AiToolDiscoveryService =
|
|
3581
|
+
AiToolDiscoveryService = _ts_decorate20([
|
|
3355
3582
|
Injectable8(),
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3583
|
+
_ts_param18(1, Inject18(AGENT_TOOL_REGISTRY2)),
|
|
3584
|
+
_ts_param18(2, Inject18(AGENT_REGISTRY5)),
|
|
3585
|
+
_ts_param18(3, Inject18(AGENT_OPTIONS4)),
|
|
3586
|
+
_ts_metadata19("design:type", Function),
|
|
3587
|
+
_ts_metadata19("design:paramtypes", [
|
|
3361
3588
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
3362
3589
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
3363
3590
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -3367,7 +3594,7 @@ AiToolDiscoveryService = _ts_decorate19([
|
|
|
3367
3594
|
|
|
3368
3595
|
// src/discovery/skill-discovery.service.ts
|
|
3369
3596
|
import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
|
|
3370
|
-
import { Inject as
|
|
3597
|
+
import { Inject as Inject19, Injectable as Injectable9, Logger as Logger4 } from "@nestjs/common";
|
|
3371
3598
|
import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
|
|
3372
3599
|
|
|
3373
3600
|
// src/decorator/skill.decorator.ts
|
|
@@ -3384,7 +3611,7 @@ function skillScope(options) {
|
|
|
3384
3611
|
__name(skillScope, "skillScope");
|
|
3385
3612
|
|
|
3386
3613
|
// src/discovery/skill-discovery.service.ts
|
|
3387
|
-
function
|
|
3614
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
3388
3615
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3389
3616
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3390
3617
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3397,19 +3624,19 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
3397
3624
|
}
|
|
3398
3625
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3399
3626
|
}
|
|
3400
|
-
__name(
|
|
3401
|
-
function
|
|
3627
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3628
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
3402
3629
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3403
3630
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3404
3631
|
}
|
|
3405
3632
|
}
|
|
3406
|
-
__name(
|
|
3407
|
-
function
|
|
3633
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
3634
|
+
function _ts_param19(paramIndex, decorator) {
|
|
3408
3635
|
return function(target, key) {
|
|
3409
3636
|
decorator(target, key, paramIndex);
|
|
3410
3637
|
};
|
|
3411
3638
|
}
|
|
3412
|
-
__name(
|
|
3639
|
+
__name(_ts_param19, "_ts_param");
|
|
3413
3640
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
3414
3641
|
static {
|
|
3415
3642
|
__name(this, "SkillDiscoveryService");
|
|
@@ -3453,16 +3680,79 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
3453
3680
|
return flat === void 0 ? void 0 : () => flat;
|
|
3454
3681
|
}
|
|
3455
3682
|
};
|
|
3456
|
-
SkillDiscoveryService =
|
|
3683
|
+
SkillDiscoveryService = _ts_decorate21([
|
|
3457
3684
|
Injectable9(),
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3685
|
+
_ts_param19(1, Inject19(AGENT_SKILL_SOURCES)),
|
|
3686
|
+
_ts_metadata20("design:type", Function),
|
|
3687
|
+
_ts_metadata20("design:paramtypes", [
|
|
3461
3688
|
typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
|
|
3462
3689
|
Array
|
|
3463
3690
|
])
|
|
3464
3691
|
], SkillDiscoveryService);
|
|
3465
3692
|
|
|
3693
|
+
// src/ledger-quota-provider.ts
|
|
3694
|
+
import { exhaustedWindow, quotaPeriodRange } from "@dudousxd/nestjs-agent-core";
|
|
3695
|
+
var LedgerQuotaProvider = class {
|
|
3696
|
+
static {
|
|
3697
|
+
__name(this, "LedgerQuotaProvider");
|
|
3698
|
+
}
|
|
3699
|
+
store;
|
|
3700
|
+
quota;
|
|
3701
|
+
limits;
|
|
3702
|
+
constructor(store, quota, limits = {}) {
|
|
3703
|
+
this.store = store;
|
|
3704
|
+
this.quota = quota;
|
|
3705
|
+
this.limits = limits;
|
|
3706
|
+
}
|
|
3707
|
+
async report(query) {
|
|
3708
|
+
const now = query.now ?? /* @__PURE__ */ new Date();
|
|
3709
|
+
const actorRef = query.actor.id;
|
|
3710
|
+
const windows = [
|
|
3711
|
+
await this.dayWindow(actorRef, now)
|
|
3712
|
+
];
|
|
3713
|
+
if (this.store.usageBetween !== void 0) {
|
|
3714
|
+
const range = quotaPeriodRange("month", now);
|
|
3715
|
+
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
3716
|
+
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
3717
|
+
}
|
|
3718
|
+
const blocked = exhaustedWindow(windows);
|
|
3719
|
+
return {
|
|
3720
|
+
windows,
|
|
3721
|
+
...blocked !== void 0 ? {
|
|
3722
|
+
blocked
|
|
3723
|
+
} : {}
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
async dayWindow(actorRef, now) {
|
|
3727
|
+
const range = quotaPeriodRange("day", now);
|
|
3728
|
+
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
3729
|
+
if (this.quota === void 0) {
|
|
3730
|
+
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
3731
|
+
}
|
|
3732
|
+
const state = await this.quota.check(actorRef, range.fromDay);
|
|
3733
|
+
const window = this.window("day", state.usedTokens, costUsd, range.resetsAt);
|
|
3734
|
+
if (window.limitTokens === void 0) {
|
|
3735
|
+
window.limitTokens = state.limitTokens;
|
|
3736
|
+
}
|
|
3737
|
+
return window;
|
|
3738
|
+
}
|
|
3739
|
+
window(period, usedTokens, usedUsd, resetsAt) {
|
|
3740
|
+
const limits = this.limits[period] ?? {};
|
|
3741
|
+
return {
|
|
3742
|
+
period,
|
|
3743
|
+
usedTokens,
|
|
3744
|
+
...limits.tokens !== void 0 ? {
|
|
3745
|
+
limitTokens: limits.tokens
|
|
3746
|
+
} : {},
|
|
3747
|
+
usedUsd,
|
|
3748
|
+
...limits.usd !== void 0 ? {
|
|
3749
|
+
limitUsd: limits.usd
|
|
3750
|
+
} : {},
|
|
3751
|
+
resetsAt
|
|
3752
|
+
};
|
|
3753
|
+
}
|
|
3754
|
+
};
|
|
3755
|
+
|
|
3466
3756
|
// src/ledger-quota-store.ts
|
|
3467
3757
|
var LedgerQuotaStore = class {
|
|
3468
3758
|
static {
|
|
@@ -3488,8 +3778,8 @@ var LedgerQuotaStore = class {
|
|
|
3488
3778
|
|
|
3489
3779
|
// src/runner/inline-agent-runner.ts
|
|
3490
3780
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_STORE as AGENT_STORE5, RunCancelledError as RunCancelledError2, agentFailureCode as agentFailureCode2, encodeStreamEvent as encodeStreamEvent3, publishAgentRunFailed as publishAgentRunFailed2, runAgentLoop as runAgentLoop2, settleAll as settleAll2, settleUnsettledDelegation as settleUnsettledDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
3491
|
-
import { Inject as
|
|
3492
|
-
function
|
|
3781
|
+
import { Inject as Inject20, Injectable as Injectable10, Logger as Logger5 } from "@nestjs/common";
|
|
3782
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
3493
3783
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3494
3784
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3495
3785
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3502,19 +3792,19 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
3502
3792
|
}
|
|
3503
3793
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3504
3794
|
}
|
|
3505
|
-
__name(
|
|
3506
|
-
function
|
|
3795
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3796
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
3507
3797
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3508
3798
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3509
3799
|
}
|
|
3510
3800
|
}
|
|
3511
|
-
__name(
|
|
3512
|
-
function
|
|
3801
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
3802
|
+
function _ts_param20(paramIndex, decorator) {
|
|
3513
3803
|
return function(target, key) {
|
|
3514
3804
|
decorator(target, key, paramIndex);
|
|
3515
3805
|
};
|
|
3516
3806
|
}
|
|
3517
|
-
__name(
|
|
3807
|
+
__name(_ts_param20, "_ts_param");
|
|
3518
3808
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
3519
3809
|
static {
|
|
3520
3810
|
__name(this, "InlineAgentRunner");
|
|
@@ -3895,12 +4185,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3895
4185
|
}
|
|
3896
4186
|
}
|
|
3897
4187
|
};
|
|
3898
|
-
InlineAgentRunner =
|
|
4188
|
+
InlineAgentRunner = _ts_decorate22([
|
|
3899
4189
|
Injectable10(),
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
4190
|
+
_ts_param20(0, Inject20(AGENT_DEPS_FACTORY6)),
|
|
4191
|
+
_ts_param20(1, Inject20(AGENT_STORE5)),
|
|
4192
|
+
_ts_metadata21("design:type", Function),
|
|
4193
|
+
_ts_metadata21("design:paramtypes", [
|
|
3904
4194
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3905
4195
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
3906
4196
|
])
|
|
@@ -3945,7 +4235,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3945
4235
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3946
4236
|
|
|
3947
4237
|
// src/agent.module.ts
|
|
3948
|
-
function
|
|
4238
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
3949
4239
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3950
4240
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3951
4241
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3958,7 +4248,7 @@ function _ts_decorate22(decorators, target, key, desc) {
|
|
|
3958
4248
|
}
|
|
3959
4249
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3960
4250
|
}
|
|
3961
|
-
__name(
|
|
4251
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
3962
4252
|
var DEFAULT_PATH = "agent";
|
|
3963
4253
|
function sharedProviders(durable, includeStore) {
|
|
3964
4254
|
const providers = [
|
|
@@ -3989,7 +4279,7 @@ function sharedProviders(durable, includeStore) {
|
|
|
3989
4279
|
provide: AGENT_SKILLS3,
|
|
3990
4280
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3991
4281
|
inject: [
|
|
3992
|
-
|
|
4282
|
+
AGENT_OPTIONS5,
|
|
3993
4283
|
AGENT_SKILL_SOURCES2
|
|
3994
4284
|
]
|
|
3995
4285
|
},
|
|
@@ -3999,35 +4289,35 @@ function sharedProviders(durable, includeStore) {
|
|
|
3999
4289
|
provide: AGENT_MEMORY3,
|
|
4000
4290
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
4001
4291
|
inject: [
|
|
4002
|
-
|
|
4292
|
+
AGENT_OPTIONS5
|
|
4003
4293
|
]
|
|
4004
4294
|
},
|
|
4005
4295
|
{
|
|
4006
4296
|
provide: AGENT_SINK3,
|
|
4007
4297
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
4008
4298
|
inject: [
|
|
4009
|
-
|
|
4299
|
+
AGENT_OPTIONS5
|
|
4010
4300
|
]
|
|
4011
4301
|
},
|
|
4012
4302
|
{
|
|
4013
4303
|
provide: AGENT_ROLES_POLICY2,
|
|
4014
4304
|
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
4015
4305
|
inject: [
|
|
4016
|
-
|
|
4306
|
+
AGENT_OPTIONS5
|
|
4017
4307
|
]
|
|
4018
4308
|
},
|
|
4019
4309
|
{
|
|
4020
|
-
provide:
|
|
4310
|
+
provide: AGENT_ACTOR_RESOLVER11,
|
|
4021
4311
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
4022
4312
|
inject: [
|
|
4023
|
-
|
|
4313
|
+
AGENT_OPTIONS5
|
|
4024
4314
|
]
|
|
4025
4315
|
},
|
|
4026
4316
|
{
|
|
4027
4317
|
provide: AGENT_MODEL2,
|
|
4028
4318
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
4029
4319
|
inject: [
|
|
4030
|
-
|
|
4320
|
+
AGENT_OPTIONS5
|
|
4031
4321
|
]
|
|
4032
4322
|
},
|
|
4033
4323
|
{
|
|
@@ -4037,10 +4327,26 @@ function sharedProviders(durable, includeStore) {
|
|
|
4037
4327
|
provide: AGENT_QUOTA_STORE3,
|
|
4038
4328
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
4039
4329
|
inject: [
|
|
4040
|
-
|
|
4330
|
+
AGENT_OPTIONS5,
|
|
4041
4331
|
AGENT_STORE6
|
|
4042
4332
|
]
|
|
4043
4333
|
},
|
|
4334
|
+
{
|
|
4335
|
+
provide: AGENT_QUOTA_PROVIDER2,
|
|
4336
|
+
useFactory: /* @__PURE__ */ __name((o, store, quota) => o.quotaProvider ?? new LedgerQuotaProvider(store, quota, o.quotaLimits), "useFactory"),
|
|
4337
|
+
inject: [
|
|
4338
|
+
AGENT_OPTIONS5,
|
|
4339
|
+
AGENT_STORE6,
|
|
4340
|
+
AGENT_QUOTA_STORE3
|
|
4341
|
+
]
|
|
4342
|
+
},
|
|
4343
|
+
{
|
|
4344
|
+
provide: AGENT_MODEL_CATALOG2,
|
|
4345
|
+
useFactory: /* @__PURE__ */ __name((o) => o.models, "useFactory"),
|
|
4346
|
+
inject: [
|
|
4347
|
+
AGENT_OPTIONS5
|
|
4348
|
+
]
|
|
4349
|
+
},
|
|
4044
4350
|
AgentDepsFactory2,
|
|
4045
4351
|
{
|
|
4046
4352
|
provide: AGENT_DEPS_FACTORY7,
|
|
@@ -4066,7 +4372,7 @@ function sharedProviders(durable, includeStore) {
|
|
|
4066
4372
|
provide: AGENT_STORE6,
|
|
4067
4373
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
4068
4374
|
inject: [
|
|
4069
|
-
|
|
4375
|
+
AGENT_OPTIONS5
|
|
4070
4376
|
]
|
|
4071
4377
|
});
|
|
4072
4378
|
}
|
|
@@ -4097,17 +4403,19 @@ function sharedProviders(durable, includeStore) {
|
|
|
4097
4403
|
__name(sharedProviders, "sharedProviders");
|
|
4098
4404
|
function exportsFor(includeStore) {
|
|
4099
4405
|
return [
|
|
4100
|
-
|
|
4406
|
+
AGENT_OPTIONS5,
|
|
4101
4407
|
AGENT_TOOL_REGISTRY3,
|
|
4102
4408
|
AGENT_REGISTRY6,
|
|
4103
4409
|
AGENT_SINK3,
|
|
4104
4410
|
AGENT_ROLES_POLICY2,
|
|
4105
|
-
|
|
4411
|
+
AGENT_ACTOR_RESOLVER11,
|
|
4106
4412
|
AGENT_MODEL2,
|
|
4107
4413
|
...includeStore ? [
|
|
4108
4414
|
AGENT_STORE6
|
|
4109
4415
|
] : [],
|
|
4110
4416
|
AGENT_QUOTA_STORE3,
|
|
4417
|
+
AGENT_MODEL_CATALOG2,
|
|
4418
|
+
AGENT_QUOTA_PROVIDER2,
|
|
4111
4419
|
AGENT_PROMPT_CONTRIBUTORS3,
|
|
4112
4420
|
AGENT_SKILLS3,
|
|
4113
4421
|
AGENT_MEMORY3,
|
|
@@ -4128,7 +4436,8 @@ var BASE_CONTROLLERS = [
|
|
|
4128
4436
|
SkillsController,
|
|
4129
4437
|
MemoriesController,
|
|
4130
4438
|
ToolsController,
|
|
4131
|
-
MessagesController
|
|
4439
|
+
MessagesController,
|
|
4440
|
+
ModelsController
|
|
4132
4441
|
];
|
|
4133
4442
|
var GUARDABLE_CONTROLLERS = [
|
|
4134
4443
|
...BASE_CONTROLLERS,
|
|
@@ -4186,7 +4495,7 @@ var AgentModule = class _AgentModule {
|
|
|
4186
4495
|
controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
|
|
4187
4496
|
providers: [
|
|
4188
4497
|
{
|
|
4189
|
-
provide:
|
|
4498
|
+
provide: AGENT_OPTIONS5,
|
|
4190
4499
|
useValue: options
|
|
4191
4500
|
},
|
|
4192
4501
|
...sharedProviders(options.durable ?? false, includeStore),
|
|
@@ -4210,7 +4519,7 @@ var AgentModule = class _AgentModule {
|
|
|
4210
4519
|
controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
|
|
4211
4520
|
providers: [
|
|
4212
4521
|
{
|
|
4213
|
-
provide:
|
|
4522
|
+
provide: AGENT_OPTIONS5,
|
|
4214
4523
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
4215
4524
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
4216
4525
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -4231,7 +4540,7 @@ var AgentModule = class _AgentModule {
|
|
|
4231
4540
|
};
|
|
4232
4541
|
}
|
|
4233
4542
|
};
|
|
4234
|
-
AgentModule =
|
|
4543
|
+
AgentModule = _ts_decorate23([
|
|
4235
4544
|
Global2(),
|
|
4236
4545
|
Module2({})
|
|
4237
4546
|
], AgentModule);
|