@dudousxd/nestjs-agent 1.16.1 → 1.17.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 +15 -0
- package/dist/durable/index.cjs +460 -400
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +1 -0
- package/dist/durable/index.d.ts +1 -0
- package/dist/durable/index.js +107 -47
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +442 -392
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +64 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -49,6 +49,7 @@ __export(index_exports, {
|
|
|
49
49
|
MessagesController: () => MessagesController,
|
|
50
50
|
ModelsController: () => ModelsController,
|
|
51
51
|
QueueController: () => QueueController,
|
|
52
|
+
RunNotActiveException: () => RunNotActiveException,
|
|
52
53
|
SKILL_METADATA: () => SKILL_METADATA,
|
|
53
54
|
SYSTEM_PROMPT_CONTRIBUTOR_METADATA: () => SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
|
|
54
55
|
SYSTEM_PROMPT_METADATA: () => SYSTEM_PROMPT_METADATA,
|
|
@@ -76,8 +77,8 @@ __export(index_exports, {
|
|
|
76
77
|
module.exports = __toCommonJS(index_exports);
|
|
77
78
|
|
|
78
79
|
// src/agent.module.ts
|
|
79
|
-
var
|
|
80
|
-
var
|
|
80
|
+
var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
|
|
81
|
+
var import_common23 = require("@nestjs/common");
|
|
81
82
|
var import_core4 = require("@nestjs/core");
|
|
82
83
|
|
|
83
84
|
// src/agent-deps.factory.ts
|
|
@@ -339,8 +340,8 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
339
340
|
], AgentDepsFactory2);
|
|
340
341
|
|
|
341
342
|
// src/agent.service.ts
|
|
342
|
-
var
|
|
343
|
-
var
|
|
343
|
+
var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
|
|
344
|
+
var import_common4 = require("@nestjs/common");
|
|
344
345
|
|
|
345
346
|
// src/agent-deps.ts
|
|
346
347
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -785,6 +786,24 @@ function queueFrame(items, paused, started) {
|
|
|
785
786
|
}
|
|
786
787
|
__name(queueFrame, "queueFrame");
|
|
787
788
|
|
|
789
|
+
// src/run-not-active.exception.ts
|
|
790
|
+
var import_nestjs_agent_core4 = require("@dudousxd/nestjs-agent-core");
|
|
791
|
+
var import_common3 = require("@nestjs/common");
|
|
792
|
+
var RunNotActiveException = class extends import_common3.ConflictException {
|
|
793
|
+
static {
|
|
794
|
+
__name(this, "RunNotActiveException");
|
|
795
|
+
}
|
|
796
|
+
runId;
|
|
797
|
+
code = import_nestjs_agent_core4.RUN_NOT_ACTIVE_CODE;
|
|
798
|
+
constructor(runId) {
|
|
799
|
+
super({
|
|
800
|
+
statusCode: 409,
|
|
801
|
+
code: import_nestjs_agent_core4.RUN_NOT_ACTIVE_CODE,
|
|
802
|
+
message: import_nestjs_agent_core4.RUN_NOT_ACTIVE_MESSAGE
|
|
803
|
+
}), this.runId = runId;
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
|
|
788
807
|
// src/agent.service.ts
|
|
789
808
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
790
809
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -842,7 +861,7 @@ var AgentService = class {
|
|
|
842
861
|
requireQueue() {
|
|
843
862
|
const queue = this.queueing();
|
|
844
863
|
if (queue === void 0) {
|
|
845
|
-
throw new
|
|
864
|
+
throw new import_common4.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
|
|
846
865
|
}
|
|
847
866
|
return queue;
|
|
848
867
|
}
|
|
@@ -879,12 +898,12 @@ var AgentService = class {
|
|
|
879
898
|
actor
|
|
880
899
|
});
|
|
881
900
|
if (blocked !== void 0) {
|
|
882
|
-
throw new
|
|
883
|
-
statusCode:
|
|
901
|
+
throw new import_common4.HttpException({
|
|
902
|
+
statusCode: import_common4.HttpStatus.TOO_MANY_REQUESTS,
|
|
884
903
|
code: "quota_exceeded",
|
|
885
904
|
period: blocked.period,
|
|
886
905
|
message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
|
|
887
|
-
},
|
|
906
|
+
}, import_common4.HttpStatus.TOO_MANY_REQUESTS);
|
|
888
907
|
}
|
|
889
908
|
}
|
|
890
909
|
/**
|
|
@@ -912,17 +931,17 @@ var AgentService = class {
|
|
|
912
931
|
*/
|
|
913
932
|
async assertModelAllowed(actor, agent, model) {
|
|
914
933
|
if (this.models === void 0) {
|
|
915
|
-
throw new
|
|
934
|
+
throw new import_common4.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
916
935
|
}
|
|
917
|
-
const entry = (0,
|
|
936
|
+
const entry = (0, import_nestjs_agent_core5.findCatalogModel)(await this.models.list({
|
|
918
937
|
actor,
|
|
919
938
|
agent
|
|
920
939
|
}), model);
|
|
921
940
|
if (entry === void 0) {
|
|
922
|
-
throw new
|
|
941
|
+
throw new import_common4.BadRequestException(`model "${model}" is not offered`);
|
|
923
942
|
}
|
|
924
943
|
if (!entry.available) {
|
|
925
|
-
throw new
|
|
944
|
+
throw new import_common4.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
926
945
|
}
|
|
927
946
|
return entry.id;
|
|
928
947
|
}
|
|
@@ -938,7 +957,7 @@ var AgentService = class {
|
|
|
938
957
|
})).locked : void 0;
|
|
939
958
|
if (locked !== void 0) {
|
|
940
959
|
if (requested !== void 0 && requested !== locked.model) {
|
|
941
|
-
throw new
|
|
960
|
+
throw new import_common4.BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
|
|
942
961
|
}
|
|
943
962
|
return locked.model;
|
|
944
963
|
}
|
|
@@ -982,7 +1001,7 @@ var AgentService = class {
|
|
|
982
1001
|
};
|
|
983
1002
|
}
|
|
984
1003
|
await this.requireQueue().publish(result.threadId);
|
|
985
|
-
throw new
|
|
1004
|
+
throw new import_common4.ConflictException({
|
|
986
1005
|
statusCode: 409,
|
|
987
1006
|
code: "run_active",
|
|
988
1007
|
message: `thread ${result.threadId} already has a turn running`
|
|
@@ -1000,7 +1019,7 @@ var AgentService = class {
|
|
|
1000
1019
|
let threadId = params.threadId;
|
|
1001
1020
|
if (threadId === void 0) {
|
|
1002
1021
|
if (params.regenerate === true) {
|
|
1003
|
-
throw new
|
|
1022
|
+
throw new import_common4.BadRequestException("regenerate requires an existing threadId");
|
|
1004
1023
|
}
|
|
1005
1024
|
const created = await this.store.createThread({
|
|
1006
1025
|
actor: params.actor,
|
|
@@ -1042,6 +1061,11 @@ var AgentService = class {
|
|
|
1042
1061
|
}
|
|
1043
1062
|
const mode = params.mode ?? "auto";
|
|
1044
1063
|
const { live, stale } = await queue.holder(threadId, this.runner);
|
|
1064
|
+
if (stale !== null) {
|
|
1065
|
+
await (0, import_nestjs_agent_core5.settleDeadRun)(this.store, {
|
|
1066
|
+
runId: stale
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1045
1069
|
if (live === null && mode !== "queue") {
|
|
1046
1070
|
const runId = crypto.randomUUID();
|
|
1047
1071
|
if (await queue.queueStore().claimActiveStream(threadId, runId, stale !== null ? {
|
|
@@ -1054,7 +1078,7 @@ var AgentService = class {
|
|
|
1054
1078
|
}
|
|
1055
1079
|
}
|
|
1056
1080
|
if (params.regenerate === true) {
|
|
1057
|
-
throw new
|
|
1081
|
+
throw new import_common4.ConflictException({
|
|
1058
1082
|
statusCode: 409,
|
|
1059
1083
|
code: "run_active",
|
|
1060
1084
|
message: "cannot regenerate while a turn is running on this thread"
|
|
@@ -1151,7 +1175,7 @@ var AgentService = class {
|
|
|
1151
1175
|
const store = queue.queueStore();
|
|
1152
1176
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1153
1177
|
if (patch.message !== void 0 && patch.message.trim().length === 0) {
|
|
1154
|
-
throw new
|
|
1178
|
+
throw new import_common4.BadRequestException("message must not be empty");
|
|
1155
1179
|
}
|
|
1156
1180
|
const attachments = patch.attachments === void 0 || patch.attachments === null ? patch.attachments : await this.resolveAttachments(actor, patch.attachments);
|
|
1157
1181
|
if (patch.message !== void 0 || attachments !== void 0) {
|
|
@@ -1164,15 +1188,15 @@ var AgentService = class {
|
|
|
1164
1188
|
} : {}
|
|
1165
1189
|
});
|
|
1166
1190
|
if (updated === null) {
|
|
1167
|
-
throw new
|
|
1191
|
+
throw new import_common4.GoneException(`queued message ${messageId} already started or was removed`);
|
|
1168
1192
|
}
|
|
1169
1193
|
}
|
|
1170
1194
|
if (patch.position !== void 0) {
|
|
1171
1195
|
if (!Number.isInteger(patch.position) || patch.position < 0) {
|
|
1172
|
-
throw new
|
|
1196
|
+
throw new import_common4.BadRequestException("position must be a non-negative integer");
|
|
1173
1197
|
}
|
|
1174
1198
|
if (!await store.moveQueuedMessage(messageId, patch.position)) {
|
|
1175
|
-
throw new
|
|
1199
|
+
throw new import_common4.GoneException(`queued message ${messageId} already started or was removed`);
|
|
1176
1200
|
}
|
|
1177
1201
|
}
|
|
1178
1202
|
return queue.publish(threadId);
|
|
@@ -1182,7 +1206,7 @@ var AgentService = class {
|
|
|
1182
1206
|
const queue = this.requireQueue();
|
|
1183
1207
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1184
1208
|
if (!await queue.queueStore().removeQueuedMessage(messageId)) {
|
|
1185
|
-
throw new
|
|
1209
|
+
throw new import_common4.GoneException(`queued message ${messageId} already started or was removed`);
|
|
1186
1210
|
}
|
|
1187
1211
|
return queue.publish(threadId);
|
|
1188
1212
|
}
|
|
@@ -1201,7 +1225,7 @@ var AgentService = class {
|
|
|
1201
1225
|
const queue = this.requireQueue();
|
|
1202
1226
|
const store = queue.queueStore();
|
|
1203
1227
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1204
|
-
const gone = /* @__PURE__ */ __name(() => new
|
|
1228
|
+
const gone = /* @__PURE__ */ __name(() => new import_common4.GoneException(`queued message ${messageId} already started or was removed`), "gone");
|
|
1205
1229
|
const marked = await store.updateQueuedMessage(messageId, {
|
|
1206
1230
|
interrupt: true
|
|
1207
1231
|
});
|
|
@@ -1209,7 +1233,7 @@ var AgentService = class {
|
|
|
1209
1233
|
throw gone();
|
|
1210
1234
|
}
|
|
1211
1235
|
if (marked.interrupt !== true) {
|
|
1212
|
-
throw new
|
|
1236
|
+
throw new import_common4.NotImplementedException("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
|
|
1213
1237
|
}
|
|
1214
1238
|
if (!await store.moveQueuedMessage(messageId, 0)) {
|
|
1215
1239
|
throw gone();
|
|
@@ -1268,7 +1292,7 @@ var AgentService = class {
|
|
|
1268
1292
|
async assertOwnsQueuedMessage(actor, messageId) {
|
|
1269
1293
|
const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
|
|
1270
1294
|
if (message === null) {
|
|
1271
|
-
throw new
|
|
1295
|
+
throw new import_common4.NotFoundException(`queued message ${messageId} not found`);
|
|
1272
1296
|
}
|
|
1273
1297
|
await this.assertOwnsThread(actor, message.threadId);
|
|
1274
1298
|
return message.threadId;
|
|
@@ -1289,7 +1313,7 @@ var AgentService = class {
|
|
|
1289
1313
|
}
|
|
1290
1314
|
const staging = this.staging;
|
|
1291
1315
|
if (staging === void 0 || typeof staging.resolve !== "function") {
|
|
1292
|
-
throw new
|
|
1316
|
+
throw new import_common4.NotImplementedException("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
|
|
1293
1317
|
}
|
|
1294
1318
|
const resolved = [];
|
|
1295
1319
|
for (const ref of refs) {
|
|
@@ -1298,7 +1322,7 @@ var AgentService = class {
|
|
|
1298
1322
|
actor
|
|
1299
1323
|
});
|
|
1300
1324
|
if (attachment === null) {
|
|
1301
|
-
throw new
|
|
1325
|
+
throw new import_common4.ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
|
|
1302
1326
|
}
|
|
1303
1327
|
resolved.push(attachment);
|
|
1304
1328
|
}
|
|
@@ -1402,8 +1426,29 @@ var AgentService = class {
|
|
|
1402
1426
|
async signalToolCall(toolCallId2, reply) {
|
|
1403
1427
|
await this.assertNotExpired(toolCallId2);
|
|
1404
1428
|
const runId = await this.resolveRunForToolCall(toolCallId2);
|
|
1429
|
+
await this.assertRunWaiting(runId);
|
|
1405
1430
|
return this.runner.signal(runId, toolCallId2, reply);
|
|
1406
1431
|
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Refuse a decision addressed at a run that is over (`409 run_not_active`). The runtime would take
|
|
1434
|
+
* the signal and buffer it for a run that never comes back — the person's "yes" is accepted, the
|
|
1435
|
+
* card says so, and nothing runs. Settles the calls the dead run left awaiting a decision on the
|
|
1436
|
+
* way out, so the card stops asking. A runner that cannot say whether a run is alive is taken at
|
|
1437
|
+
* its word that it is, and so is one that fails to answer.
|
|
1438
|
+
*/
|
|
1439
|
+
async assertRunWaiting(runId) {
|
|
1440
|
+
if (typeof this.runner.isRunActive !== "function") {
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
const active = await this.runner.isRunActive(runId).catch(() => true);
|
|
1444
|
+
if (active) {
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
await (0, import_nestjs_agent_core5.settleDeadRun)(this.store, {
|
|
1448
|
+
runId
|
|
1449
|
+
});
|
|
1450
|
+
throw new RunNotActiveException(runId);
|
|
1451
|
+
}
|
|
1407
1452
|
async cancel(actor, runId) {
|
|
1408
1453
|
await this.assertOwnsActiveStream(actor, runId);
|
|
1409
1454
|
return this.runner.cancel(runId);
|
|
@@ -1447,7 +1492,7 @@ var AgentService = class {
|
|
|
1447
1492
|
return;
|
|
1448
1493
|
}
|
|
1449
1494
|
if (this.store.updateThread === void 0) {
|
|
1450
|
-
throw new
|
|
1495
|
+
throw new import_common4.NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
1451
1496
|
}
|
|
1452
1497
|
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);
|
|
1453
1498
|
await this.store.updateThread(threadId, {
|
|
@@ -1465,10 +1510,10 @@ var AgentService = class {
|
|
|
1465
1510
|
validateTitle(title) {
|
|
1466
1511
|
const trimmed = title.trim();
|
|
1467
1512
|
if (trimmed.length === 0) {
|
|
1468
|
-
throw new
|
|
1513
|
+
throw new import_common4.BadRequestException("title must not be empty");
|
|
1469
1514
|
}
|
|
1470
1515
|
if (trimmed.length > 200) {
|
|
1471
|
-
throw new
|
|
1516
|
+
throw new import_common4.BadRequestException("title must be at most 200 characters");
|
|
1472
1517
|
}
|
|
1473
1518
|
return trimmed;
|
|
1474
1519
|
}
|
|
@@ -1571,21 +1616,21 @@ var AgentService = class {
|
|
|
1571
1616
|
*/
|
|
1572
1617
|
async setMessageFeedback(actor, messageId, input) {
|
|
1573
1618
|
if (input.value !== null && input.value !== "up" && input.value !== "down") {
|
|
1574
|
-
throw new
|
|
1619
|
+
throw new import_common4.BadRequestException("value must be 'up', 'down' or null");
|
|
1575
1620
|
}
|
|
1576
1621
|
if (input.comment !== void 0 && typeof input.comment !== "string") {
|
|
1577
|
-
throw new
|
|
1622
|
+
throw new import_common4.BadRequestException("comment must be a string");
|
|
1578
1623
|
}
|
|
1579
1624
|
const comment = input.comment?.trim();
|
|
1580
1625
|
if (comment !== void 0 && comment.length > 2e3) {
|
|
1581
|
-
throw new
|
|
1626
|
+
throw new import_common4.BadRequestException("comment must be at most 2000 characters");
|
|
1582
1627
|
}
|
|
1583
1628
|
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
1584
|
-
throw new
|
|
1629
|
+
throw new import_common4.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
1585
1630
|
}
|
|
1586
1631
|
const threadId = await this.store.threadOfMessage(messageId);
|
|
1587
1632
|
if (threadId === null) {
|
|
1588
|
-
throw new
|
|
1633
|
+
throw new import_common4.NotFoundException(`message ${messageId} not found`);
|
|
1589
1634
|
}
|
|
1590
1635
|
await this.assertOwnsThread(actor, threadId);
|
|
1591
1636
|
const feedback = input.value === null ? null : {
|
|
@@ -1633,7 +1678,7 @@ var AgentService = class {
|
|
|
1633
1678
|
const list = this.attachmentInventory();
|
|
1634
1679
|
const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
|
|
1635
1680
|
if (referencedMediaIds === void 0) {
|
|
1636
|
-
throw new
|
|
1681
|
+
throw new import_common4.NotImplementedException("Collecting attachments requires an AgentStore that implements referencedMediaIds(); the bound store cannot say which media a message still references, and guessing would delete files that are in use.");
|
|
1637
1682
|
}
|
|
1638
1683
|
const stagedBefore = options.olderThan.toISOString();
|
|
1639
1684
|
const inventory = await list({
|
|
@@ -1655,7 +1700,7 @@ var AgentService = class {
|
|
|
1655
1700
|
attachmentInventory() {
|
|
1656
1701
|
const list = this.staging?.list?.bind(this.staging);
|
|
1657
1702
|
if (list === void 0) {
|
|
1658
|
-
throw new
|
|
1703
|
+
throw new import_common4.NotImplementedException("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
|
|
1659
1704
|
}
|
|
1660
1705
|
return list;
|
|
1661
1706
|
}
|
|
@@ -1666,10 +1711,10 @@ var AgentService = class {
|
|
|
1666
1711
|
async assertOwnsThread(actor, threadId) {
|
|
1667
1712
|
const owner = await this.store.ownerOfThread(threadId);
|
|
1668
1713
|
if (owner === null) {
|
|
1669
|
-
throw new
|
|
1714
|
+
throw new import_common4.NotFoundException(`thread ${threadId} not found`);
|
|
1670
1715
|
}
|
|
1671
1716
|
if (owner !== actor.id) {
|
|
1672
|
-
throw new
|
|
1717
|
+
throw new import_common4.ForbiddenException("thread belongs to another actor");
|
|
1673
1718
|
}
|
|
1674
1719
|
}
|
|
1675
1720
|
/**
|
|
@@ -1680,10 +1725,10 @@ var AgentService = class {
|
|
|
1680
1725
|
async assertOwnsToolCall(actor, toolCallId2) {
|
|
1681
1726
|
const owner = await this.store.ownerOfToolCall(toolCallId2);
|
|
1682
1727
|
if (owner === null) {
|
|
1683
|
-
throw new
|
|
1728
|
+
throw new import_common4.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
1684
1729
|
}
|
|
1685
1730
|
if (owner !== actor.id) {
|
|
1686
|
-
throw new
|
|
1731
|
+
throw new import_common4.ForbiddenException("tool call belongs to another actor");
|
|
1687
1732
|
}
|
|
1688
1733
|
}
|
|
1689
1734
|
/**
|
|
@@ -1698,12 +1743,12 @@ var AgentService = class {
|
|
|
1698
1743
|
if (this.store.toolCallInput === void 0) {
|
|
1699
1744
|
return;
|
|
1700
1745
|
}
|
|
1701
|
-
const questions = (0,
|
|
1746
|
+
const questions = (0, import_nestjs_agent_core5.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
|
|
1702
1747
|
for (const question of questions) {
|
|
1703
1748
|
const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
|
|
1704
|
-
const problem = (0,
|
|
1749
|
+
const problem = (0, import_nestjs_agent_core5.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
|
|
1705
1750
|
if (problem !== null) {
|
|
1706
|
-
throw new
|
|
1751
|
+
throw new import_common4.BadRequestException(`answers["${question.id}"] ${problem}`);
|
|
1707
1752
|
}
|
|
1708
1753
|
}
|
|
1709
1754
|
}
|
|
@@ -1715,21 +1760,21 @@ var AgentService = class {
|
|
|
1715
1760
|
*/
|
|
1716
1761
|
async assertMayDecide(actor, toolCallId2) {
|
|
1717
1762
|
const approval = await this.store.toolCallApproval?.(toolCallId2);
|
|
1718
|
-
const approver = approval?.approver ??
|
|
1719
|
-
if (approver ===
|
|
1763
|
+
const approver = approval?.approver ?? import_nestjs_agent_core5.REQUESTER_APPROVER;
|
|
1764
|
+
if (approver === import_nestjs_agent_core5.REQUESTER_APPROVER) {
|
|
1720
1765
|
return this.assertOwnsToolCall(actor, toolCallId2);
|
|
1721
1766
|
}
|
|
1722
1767
|
const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
|
|
1723
1768
|
if (requesterRef === null) {
|
|
1724
|
-
throw new
|
|
1769
|
+
throw new import_common4.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
1725
1770
|
}
|
|
1726
|
-
const allowed = await (0,
|
|
1771
|
+
const allowed = await (0, import_nestjs_agent_core5.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
|
|
1727
1772
|
toolCallId: toolCallId2,
|
|
1728
1773
|
approver,
|
|
1729
1774
|
requesterRef
|
|
1730
1775
|
});
|
|
1731
1776
|
if (!allowed) {
|
|
1732
|
-
throw new
|
|
1777
|
+
throw new import_common4.ForbiddenException(`this approval is for ${approver}`);
|
|
1733
1778
|
}
|
|
1734
1779
|
}
|
|
1735
1780
|
/**
|
|
@@ -1745,7 +1790,7 @@ var AgentService = class {
|
|
|
1745
1790
|
}
|
|
1746
1791
|
const lapsed = approval.status === "expired" || approval.status === "pending_approval" && approval.expiresAt !== null && Date.parse(approval.expiresAt) <= Date.now();
|
|
1747
1792
|
if (lapsed) {
|
|
1748
|
-
throw new
|
|
1793
|
+
throw new import_common4.GoneException(`the approval request for tool call ${toolCallId2} has expired`);
|
|
1749
1794
|
}
|
|
1750
1795
|
}
|
|
1751
1796
|
/**
|
|
@@ -1758,7 +1803,7 @@ var AgentService = class {
|
|
|
1758
1803
|
async resolveRunForToolCall(toolCallId2) {
|
|
1759
1804
|
const runId = await this.store.runForToolCall(toolCallId2);
|
|
1760
1805
|
if (runId === null) {
|
|
1761
|
-
throw new
|
|
1806
|
+
throw new import_common4.NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
|
|
1762
1807
|
}
|
|
1763
1808
|
return runId;
|
|
1764
1809
|
}
|
|
@@ -1766,27 +1811,27 @@ var AgentService = class {
|
|
|
1766
1811
|
async assertOwnsActiveStream(actor, runId) {
|
|
1767
1812
|
const owner = await this.store.ownerOfActiveStream(runId);
|
|
1768
1813
|
if (owner === null) {
|
|
1769
|
-
throw new
|
|
1814
|
+
throw new import_common4.NotFoundException(`no active run ${runId}`);
|
|
1770
1815
|
}
|
|
1771
1816
|
if (owner !== actor.id) {
|
|
1772
|
-
throw new
|
|
1817
|
+
throw new import_common4.ForbiddenException("run belongs to another actor");
|
|
1773
1818
|
}
|
|
1774
1819
|
}
|
|
1775
1820
|
};
|
|
1776
1821
|
AgentService = _ts_decorate3([
|
|
1777
|
-
(0,
|
|
1778
|
-
_ts_param3(0, (0,
|
|
1779
|
-
_ts_param3(1, (0,
|
|
1780
|
-
_ts_param3(2, (0,
|
|
1781
|
-
_ts_param3(3, (0,
|
|
1782
|
-
_ts_param3(3, (0,
|
|
1783
|
-
_ts_param3(4, (0,
|
|
1784
|
-
_ts_param3(4, (0,
|
|
1785
|
-
_ts_param3(5, (0,
|
|
1786
|
-
_ts_param3(5, (0,
|
|
1787
|
-
_ts_param3(6, (0,
|
|
1788
|
-
_ts_param3(6, (0,
|
|
1789
|
-
_ts_param3(7, (0,
|
|
1822
|
+
(0, import_common4.Injectable)(),
|
|
1823
|
+
_ts_param3(0, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_RUNNER)),
|
|
1824
|
+
_ts_param3(1, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_STORE)),
|
|
1825
|
+
_ts_param3(2, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_DEPS_FACTORY)),
|
|
1826
|
+
_ts_param3(3, (0, import_common4.Optional)()),
|
|
1827
|
+
_ts_param3(3, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_ATTACHMENT_STAGING)),
|
|
1828
|
+
_ts_param3(4, (0, import_common4.Optional)()),
|
|
1829
|
+
_ts_param3(4, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_MODEL_CATALOG)),
|
|
1830
|
+
_ts_param3(5, (0, import_common4.Optional)()),
|
|
1831
|
+
_ts_param3(5, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_QUOTA_PROVIDER)),
|
|
1832
|
+
_ts_param3(6, (0, import_common4.Optional)()),
|
|
1833
|
+
_ts_param3(6, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_OPTIONS)),
|
|
1834
|
+
_ts_param3(7, (0, import_common4.Optional)()),
|
|
1790
1835
|
_ts_metadata3("design:type", Function),
|
|
1791
1836
|
_ts_metadata3("design:paramtypes", [
|
|
1792
1837
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
@@ -1801,7 +1846,7 @@ AgentService = _ts_decorate3([
|
|
|
1801
1846
|
], AgentService);
|
|
1802
1847
|
|
|
1803
1848
|
// src/approval-port.adapter.ts
|
|
1804
|
-
var
|
|
1849
|
+
var import_common5 = require("@nestjs/common");
|
|
1805
1850
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
1806
1851
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1807
1852
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1860,7 +1905,7 @@ var AgentApprovalPortAdapter = class {
|
|
|
1860
1905
|
}
|
|
1861
1906
|
};
|
|
1862
1907
|
AgentApprovalPortAdapter = _ts_decorate4([
|
|
1863
|
-
(0,
|
|
1908
|
+
(0, import_common5.Injectable)(),
|
|
1864
1909
|
_ts_metadata4("design:type", Function),
|
|
1865
1910
|
_ts_metadata4("design:paramtypes", [
|
|
1866
1911
|
typeof AgentService === "undefined" ? Object : AgentService
|
|
@@ -1868,8 +1913,8 @@ AgentApprovalPortAdapter = _ts_decorate4([
|
|
|
1868
1913
|
], AgentApprovalPortAdapter);
|
|
1869
1914
|
|
|
1870
1915
|
// src/controller/agents.controller.ts
|
|
1871
|
-
var
|
|
1872
|
-
var
|
|
1916
|
+
var import_nestjs_agent_core6 = require("@dudousxd/nestjs-agent-core");
|
|
1917
|
+
var import_common6 = require("@nestjs/common");
|
|
1873
1918
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1874
1919
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1875
1920
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1918,25 +1963,25 @@ var AgentsController = class {
|
|
|
1918
1963
|
}
|
|
1919
1964
|
};
|
|
1920
1965
|
_ts_decorate5([
|
|
1921
|
-
(0,
|
|
1966
|
+
(0, import_common6.Get)(),
|
|
1922
1967
|
_ts_metadata5("design:type", Function),
|
|
1923
1968
|
_ts_metadata5("design:paramtypes", []),
|
|
1924
1969
|
_ts_metadata5("design:returntype", Array)
|
|
1925
1970
|
], AgentsController.prototype, "list", null);
|
|
1926
1971
|
AgentsController = _ts_decorate5([
|
|
1927
|
-
(0,
|
|
1928
|
-
_ts_param4(0, (0,
|
|
1929
|
-
_ts_param4(1, (0,
|
|
1972
|
+
(0, import_common6.Controller)("agents"),
|
|
1973
|
+
_ts_param4(0, (0, import_common6.Inject)(import_nestjs_agent_core6.AGENT_REGISTRY)),
|
|
1974
|
+
_ts_param4(1, (0, import_common6.Inject)(import_nestjs_agent_core6.AGENT_DEPS_FACTORY)),
|
|
1930
1975
|
_ts_metadata5("design:type", Function),
|
|
1931
1976
|
_ts_metadata5("design:paramtypes", [
|
|
1932
|
-
typeof
|
|
1977
|
+
typeof import_nestjs_agent_core6.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core6.AgentRegistry,
|
|
1933
1978
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
1934
1979
|
])
|
|
1935
1980
|
], AgentsController);
|
|
1936
1981
|
|
|
1937
1982
|
// src/controller/attachments.controller.ts
|
|
1938
|
-
var
|
|
1939
|
-
var
|
|
1983
|
+
var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
|
|
1984
|
+
var import_common7 = require("@nestjs/common");
|
|
1940
1985
|
var import_platform_express = require("@nestjs/platform-express");
|
|
1941
1986
|
|
|
1942
1987
|
// src/attachment-limits.ts
|
|
@@ -2024,17 +2069,17 @@ var AttachmentsController = class {
|
|
|
2024
2069
|
}
|
|
2025
2070
|
async upload(req, file) {
|
|
2026
2071
|
if (this.staging === void 0) {
|
|
2027
|
-
throw new
|
|
2072
|
+
throw new import_common7.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
2028
2073
|
}
|
|
2029
2074
|
if (file === void 0) {
|
|
2030
|
-
throw new
|
|
2075
|
+
throw new import_common7.BadRequestException('multipart field "file" is required');
|
|
2031
2076
|
}
|
|
2032
2077
|
const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
|
|
2033
2078
|
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
2034
|
-
throw new
|
|
2079
|
+
throw new import_common7.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
2035
2080
|
}
|
|
2036
2081
|
if (file.size > maxBytes) {
|
|
2037
|
-
throw new
|
|
2082
|
+
throw new import_common7.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
2038
2083
|
}
|
|
2039
2084
|
const actor = await this.actorResolver.resolve(req);
|
|
2040
2085
|
return this.staging.stage({
|
|
@@ -2047,8 +2092,8 @@ var AttachmentsController = class {
|
|
|
2047
2092
|
}
|
|
2048
2093
|
};
|
|
2049
2094
|
_ts_decorate6([
|
|
2050
|
-
(0,
|
|
2051
|
-
_ts_param5(0, (0,
|
|
2095
|
+
(0, import_common7.Get)(),
|
|
2096
|
+
_ts_param5(0, (0, import_common7.Req)()),
|
|
2052
2097
|
_ts_metadata6("design:type", Function),
|
|
2053
2098
|
_ts_metadata6("design:paramtypes", [
|
|
2054
2099
|
typeof Request === "undefined" ? Object : Request
|
|
@@ -2056,14 +2101,14 @@ _ts_decorate6([
|
|
|
2056
2101
|
_ts_metadata6("design:returntype", Promise)
|
|
2057
2102
|
], AttachmentsController.prototype, "list", null);
|
|
2058
2103
|
_ts_decorate6([
|
|
2059
|
-
(0,
|
|
2060
|
-
(0,
|
|
2104
|
+
(0, import_common7.Post)(),
|
|
2105
|
+
(0, import_common7.UseInterceptors)((0, import_platform_express.FileInterceptor)("file", {
|
|
2061
2106
|
limits: {
|
|
2062
2107
|
fileSize: HARD_MAX_ATTACHMENT_BYTES
|
|
2063
2108
|
}
|
|
2064
2109
|
})),
|
|
2065
|
-
_ts_param5(0, (0,
|
|
2066
|
-
_ts_param5(1, (0,
|
|
2110
|
+
_ts_param5(0, (0, import_common7.Req)()),
|
|
2111
|
+
_ts_param5(1, (0, import_common7.UploadedFile)()),
|
|
2067
2112
|
_ts_metadata6("design:type", Function),
|
|
2068
2113
|
_ts_metadata6("design:paramtypes", [
|
|
2069
2114
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2072,11 +2117,11 @@ _ts_decorate6([
|
|
|
2072
2117
|
_ts_metadata6("design:returntype", Promise)
|
|
2073
2118
|
], AttachmentsController.prototype, "upload", null);
|
|
2074
2119
|
AttachmentsController = _ts_decorate6([
|
|
2075
|
-
(0,
|
|
2076
|
-
_ts_param5(0, (0,
|
|
2077
|
-
_ts_param5(1, (0,
|
|
2078
|
-
_ts_param5(3, (0,
|
|
2079
|
-
_ts_param5(3, (0,
|
|
2120
|
+
(0, import_common7.Controller)("attachments"),
|
|
2121
|
+
_ts_param5(0, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_OPTIONS)),
|
|
2122
|
+
_ts_param5(1, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_ACTOR_RESOLVER)),
|
|
2123
|
+
_ts_param5(3, (0, import_common7.Optional)()),
|
|
2124
|
+
_ts_param5(3, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_ATTACHMENT_STAGING)),
|
|
2080
2125
|
_ts_metadata6("design:type", Function),
|
|
2081
2126
|
_ts_metadata6("design:paramtypes", [
|
|
2082
2127
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -2087,8 +2132,8 @@ AttachmentsController = _ts_decorate6([
|
|
|
2087
2132
|
], AttachmentsController);
|
|
2088
2133
|
|
|
2089
2134
|
// src/controller/chat.controller.ts
|
|
2090
|
-
var
|
|
2091
|
-
var
|
|
2135
|
+
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
2136
|
+
var import_common8 = require("@nestjs/common");
|
|
2092
2137
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
2093
2138
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2094
2139
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2125,7 +2170,7 @@ function sendMode(body) {
|
|
|
2125
2170
|
if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
|
|
2126
2171
|
return body.mode;
|
|
2127
2172
|
}
|
|
2128
|
-
throw new
|
|
2173
|
+
throw new import_common8.BadRequestException("mode must be 'auto', 'queue' or 'interrupt'");
|
|
2129
2174
|
}
|
|
2130
2175
|
__name(sendMode, "sendMode");
|
|
2131
2176
|
function attachmentRefs(claimed) {
|
|
@@ -2133,21 +2178,21 @@ function attachmentRefs(claimed) {
|
|
|
2133
2178
|
return [];
|
|
2134
2179
|
}
|
|
2135
2180
|
if (!Array.isArray(claimed)) {
|
|
2136
|
-
throw new
|
|
2181
|
+
throw new import_common8.BadRequestException("attachments must be an array of { mediaId }");
|
|
2137
2182
|
}
|
|
2138
2183
|
if (claimed.length > MAX_ATTACHMENTS_PER_MESSAGE) {
|
|
2139
|
-
throw new
|
|
2184
|
+
throw new import_common8.BadRequestException(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
|
|
2140
2185
|
}
|
|
2141
2186
|
return claimed.map((entry) => {
|
|
2142
2187
|
if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
|
|
2143
|
-
throw new
|
|
2188
|
+
throw new import_common8.BadRequestException("each attachment must be an object with a mediaId");
|
|
2144
2189
|
}
|
|
2145
2190
|
if (Object.keys(entry).some((key) => key !== "mediaId")) {
|
|
2146
|
-
throw new
|
|
2191
|
+
throw new import_common8.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
|
|
2147
2192
|
}
|
|
2148
2193
|
const { mediaId } = entry;
|
|
2149
2194
|
if (typeof mediaId !== "string" || mediaId.length === 0) {
|
|
2150
|
-
throw new
|
|
2195
|
+
throw new import_common8.BadRequestException("each attachment must carry a non-empty string mediaId");
|
|
2151
2196
|
}
|
|
2152
2197
|
return {
|
|
2153
2198
|
mediaId
|
|
@@ -2280,13 +2325,10 @@ data: ${line}
|
|
|
2280
2325
|
}
|
|
2281
2326
|
res.write("event: done\ndata: {}\n\n");
|
|
2282
2327
|
} catch (error) {
|
|
2283
|
-
const payload = error instanceof
|
|
2328
|
+
const payload = error instanceof import_nestjs_agent_core8.AgentStreamError ? {
|
|
2284
2329
|
code: error.code,
|
|
2285
2330
|
message: error.message
|
|
2286
|
-
} :
|
|
2287
|
-
code: "run_failed",
|
|
2288
|
-
message: error instanceof Error ? error.message : "stream error"
|
|
2289
|
-
};
|
|
2331
|
+
} : (0, import_nestjs_agent_core8.streamFailure)(error);
|
|
2290
2332
|
res.write(`event: error
|
|
2291
2333
|
data: ${JSON.stringify(payload)}
|
|
2292
2334
|
|
|
@@ -2296,10 +2338,10 @@ data: ${JSON.stringify(payload)}
|
|
|
2296
2338
|
}
|
|
2297
2339
|
};
|
|
2298
2340
|
_ts_decorate7([
|
|
2299
|
-
(0,
|
|
2300
|
-
_ts_param6(0, (0,
|
|
2301
|
-
_ts_param6(1, (0,
|
|
2302
|
-
_ts_param6(2, (0,
|
|
2341
|
+
(0, import_common8.Post)("chat"),
|
|
2342
|
+
_ts_param6(0, (0, import_common8.Req)()),
|
|
2343
|
+
_ts_param6(1, (0, import_common8.Res)()),
|
|
2344
|
+
_ts_param6(2, (0, import_common8.Body)()),
|
|
2303
2345
|
_ts_metadata7("design:type", Function),
|
|
2304
2346
|
_ts_metadata7("design:paramtypes", [
|
|
2305
2347
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2309,11 +2351,11 @@ _ts_decorate7([
|
|
|
2309
2351
|
_ts_metadata7("design:returntype", Promise)
|
|
2310
2352
|
], ChatController.prototype, "chat", null);
|
|
2311
2353
|
_ts_decorate7([
|
|
2312
|
-
(0,
|
|
2313
|
-
_ts_param6(0, (0,
|
|
2314
|
-
_ts_param6(1, (0,
|
|
2315
|
-
_ts_param6(2, (0,
|
|
2316
|
-
_ts_param6(3, (0,
|
|
2354
|
+
(0, import_common8.Get)("chat/:runId/stream"),
|
|
2355
|
+
_ts_param6(0, (0, import_common8.Req)()),
|
|
2356
|
+
_ts_param6(1, (0, import_common8.Param)("runId")),
|
|
2357
|
+
_ts_param6(2, (0, import_common8.Res)()),
|
|
2358
|
+
_ts_param6(3, (0, import_common8.Query)("after")),
|
|
2317
2359
|
_ts_metadata7("design:type", Function),
|
|
2318
2360
|
_ts_metadata7("design:paramtypes", [
|
|
2319
2361
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2324,9 +2366,9 @@ _ts_decorate7([
|
|
|
2324
2366
|
_ts_metadata7("design:returntype", Promise)
|
|
2325
2367
|
], ChatController.prototype, "stream", null);
|
|
2326
2368
|
_ts_decorate7([
|
|
2327
|
-
(0,
|
|
2328
|
-
_ts_param6(0, (0,
|
|
2329
|
-
_ts_param6(1, (0,
|
|
2369
|
+
(0, import_common8.Post)("chat/:runId/cancel"),
|
|
2370
|
+
_ts_param6(0, (0, import_common8.Req)()),
|
|
2371
|
+
_ts_param6(1, (0, import_common8.Param)("runId")),
|
|
2330
2372
|
_ts_metadata7("design:type", Function),
|
|
2331
2373
|
_ts_metadata7("design:paramtypes", [
|
|
2332
2374
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2335,8 +2377,8 @@ _ts_decorate7([
|
|
|
2335
2377
|
_ts_metadata7("design:returntype", Promise)
|
|
2336
2378
|
], ChatController.prototype, "cancel", null);
|
|
2337
2379
|
ChatController = _ts_decorate7([
|
|
2338
|
-
(0,
|
|
2339
|
-
_ts_param6(1, (0,
|
|
2380
|
+
(0, import_common8.Controller)(),
|
|
2381
|
+
_ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_ACTOR_RESOLVER)),
|
|
2340
2382
|
_ts_metadata7("design:type", Function),
|
|
2341
2383
|
_ts_metadata7("design:paramtypes", [
|
|
2342
2384
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -2354,8 +2396,8 @@ function parseCursor(raw) {
|
|
|
2354
2396
|
__name(parseCursor, "parseCursor");
|
|
2355
2397
|
|
|
2356
2398
|
// src/controller/config.controller.ts
|
|
2357
|
-
var
|
|
2358
|
-
var
|
|
2399
|
+
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
2400
|
+
var import_common9 = require("@nestjs/common");
|
|
2359
2401
|
|
|
2360
2402
|
// src/resolver/anonymous-actor-resolver.ts
|
|
2361
2403
|
var import_node_crypto = require("crypto");
|
|
@@ -2502,8 +2544,8 @@ var ConfigController = class {
|
|
|
2502
2544
|
}
|
|
2503
2545
|
};
|
|
2504
2546
|
_ts_decorate8([
|
|
2505
|
-
(0,
|
|
2506
|
-
_ts_param7(0, (0,
|
|
2547
|
+
(0, import_common9.Get)(),
|
|
2548
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
2507
2549
|
_ts_metadata8("design:type", Function),
|
|
2508
2550
|
_ts_metadata8("design:paramtypes", [
|
|
2509
2551
|
typeof Request === "undefined" ? Object : Request
|
|
@@ -2511,13 +2553,13 @@ _ts_decorate8([
|
|
|
2511
2553
|
_ts_metadata8("design:returntype", Promise)
|
|
2512
2554
|
], ConfigController.prototype, "config", null);
|
|
2513
2555
|
ConfigController = _ts_decorate8([
|
|
2514
|
-
(0,
|
|
2515
|
-
_ts_param7(0, (0,
|
|
2516
|
-
_ts_param7(1, (0,
|
|
2517
|
-
_ts_param7(2, (0,
|
|
2518
|
-
_ts_param7(2, (0,
|
|
2519
|
-
_ts_param7(3, (0,
|
|
2520
|
-
_ts_param7(3, (0,
|
|
2556
|
+
(0, import_common9.Controller)("config"),
|
|
2557
|
+
_ts_param7(0, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_OPTIONS)),
|
|
2558
|
+
_ts_param7(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
|
|
2559
|
+
_ts_param7(2, (0, import_common9.Optional)()),
|
|
2560
|
+
_ts_param7(2, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ATTACHMENT_STAGING)),
|
|
2561
|
+
_ts_param7(3, (0, import_common9.Optional)()),
|
|
2562
|
+
_ts_param7(3, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_MODEL_CATALOG)),
|
|
2521
2563
|
_ts_metadata8("design:type", Function),
|
|
2522
2564
|
_ts_metadata8("design:paramtypes", [
|
|
2523
2565
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -2528,8 +2570,8 @@ ConfigController = _ts_decorate8([
|
|
|
2528
2570
|
], ConfigController);
|
|
2529
2571
|
|
|
2530
2572
|
// src/controller/memories.controller.ts
|
|
2531
|
-
var
|
|
2532
|
-
var
|
|
2573
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
2574
|
+
var import_common10 = require("@nestjs/common");
|
|
2533
2575
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
2534
2576
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2535
2577
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2589,20 +2631,20 @@ var MemoriesController = class {
|
|
|
2589
2631
|
*/
|
|
2590
2632
|
async forget(req, id) {
|
|
2591
2633
|
if (this.memory === void 0) {
|
|
2592
|
-
throw new
|
|
2634
|
+
throw new import_common10.NotFoundException("No memory is configured in this deployment.");
|
|
2593
2635
|
}
|
|
2594
2636
|
const actor = await this.actorResolver.resolve(req);
|
|
2595
2637
|
const digest = await this.unbounded("", actor);
|
|
2596
2638
|
const entry = digest.entries.find((candidate) => candidate.id === id);
|
|
2597
2639
|
if (entry === void 0) {
|
|
2598
|
-
throw new
|
|
2640
|
+
throw new import_common10.NotFoundException(`No memory with id "${id}".`);
|
|
2599
2641
|
}
|
|
2600
|
-
const verdict = (0,
|
|
2642
|
+
const verdict = (0, import_nestjs_agent_core10.memoryForgetVerdict)({
|
|
2601
2643
|
record: entry,
|
|
2602
2644
|
actor
|
|
2603
2645
|
});
|
|
2604
2646
|
if (!verdict.allowed) {
|
|
2605
|
-
throw new
|
|
2647
|
+
throw new import_common10.ForbiddenException(verdict.reason);
|
|
2606
2648
|
}
|
|
2607
2649
|
return {
|
|
2608
2650
|
forgotten: await this.memory.provider.forget({
|
|
@@ -2616,7 +2658,7 @@ var MemoriesController = class {
|
|
|
2616
2658
|
}
|
|
2617
2659
|
async unbounded(threadId, actor) {
|
|
2618
2660
|
const config = this.memory;
|
|
2619
|
-
return await (0,
|
|
2661
|
+
return await (0, import_nestjs_agent_core10.offerMemories)({
|
|
2620
2662
|
config: {
|
|
2621
2663
|
...config,
|
|
2622
2664
|
maxMemories: Number.POSITIVE_INFINITY
|
|
@@ -2629,9 +2671,9 @@ var MemoriesController = class {
|
|
|
2629
2671
|
}
|
|
2630
2672
|
};
|
|
2631
2673
|
_ts_decorate9([
|
|
2632
|
-
(0,
|
|
2633
|
-
_ts_param8(0, (0,
|
|
2634
|
-
_ts_param8(1, (0,
|
|
2674
|
+
(0, import_common10.Get)(),
|
|
2675
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
2676
|
+
_ts_param8(1, (0, import_common10.Query)("threadId")),
|
|
2635
2677
|
_ts_metadata9("design:type", Function),
|
|
2636
2678
|
_ts_metadata9("design:paramtypes", [
|
|
2637
2679
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2640,9 +2682,9 @@ _ts_decorate9([
|
|
|
2640
2682
|
_ts_metadata9("design:returntype", Promise)
|
|
2641
2683
|
], MemoriesController.prototype, "list", null);
|
|
2642
2684
|
_ts_decorate9([
|
|
2643
|
-
(0,
|
|
2644
|
-
_ts_param8(0, (0,
|
|
2645
|
-
_ts_param8(1, (0,
|
|
2685
|
+
(0, import_common10.Delete)(":id"),
|
|
2686
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
2687
|
+
_ts_param8(1, (0, import_common10.Param)("id")),
|
|
2646
2688
|
_ts_metadata9("design:type", Function),
|
|
2647
2689
|
_ts_metadata9("design:paramtypes", [
|
|
2648
2690
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2651,10 +2693,10 @@ _ts_decorate9([
|
|
|
2651
2693
|
_ts_metadata9("design:returntype", Promise)
|
|
2652
2694
|
], MemoriesController.prototype, "forget", null);
|
|
2653
2695
|
MemoriesController = _ts_decorate9([
|
|
2654
|
-
(0,
|
|
2655
|
-
_ts_param8(0, (0,
|
|
2656
|
-
_ts_param8(1, (0,
|
|
2657
|
-
_ts_param8(1, (0,
|
|
2696
|
+
(0, import_common10.Controller)("memories"),
|
|
2697
|
+
_ts_param8(0, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
|
|
2698
|
+
_ts_param8(1, (0, import_common10.Optional)()),
|
|
2699
|
+
_ts_param8(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_MEMORY)),
|
|
2658
2700
|
_ts_metadata9("design:type", Function),
|
|
2659
2701
|
_ts_metadata9("design:paramtypes", [
|
|
2660
2702
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
@@ -2663,8 +2705,8 @@ MemoriesController = _ts_decorate9([
|
|
|
2663
2705
|
], MemoriesController);
|
|
2664
2706
|
|
|
2665
2707
|
// src/controller/messages.controller.ts
|
|
2666
|
-
var
|
|
2667
|
-
var
|
|
2708
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
2709
|
+
var import_common11 = require("@nestjs/common");
|
|
2668
2710
|
function _ts_decorate10(decorators, target, key, desc) {
|
|
2669
2711
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2670
2712
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2719,11 +2761,11 @@ var MessagesController = class {
|
|
|
2719
2761
|
}
|
|
2720
2762
|
};
|
|
2721
2763
|
_ts_decorate10([
|
|
2722
|
-
(0,
|
|
2723
|
-
(0,
|
|
2724
|
-
_ts_param9(0, (0,
|
|
2725
|
-
_ts_param9(1, (0,
|
|
2726
|
-
_ts_param9(2, (0,
|
|
2764
|
+
(0, import_common11.Post)(":id/feedback"),
|
|
2765
|
+
(0, import_common11.HttpCode)(200),
|
|
2766
|
+
_ts_param9(0, (0, import_common11.Req)()),
|
|
2767
|
+
_ts_param9(1, (0, import_common11.Param)("id")),
|
|
2768
|
+
_ts_param9(2, (0, import_common11.Body)()),
|
|
2727
2769
|
_ts_metadata10("design:type", Function),
|
|
2728
2770
|
_ts_metadata10("design:paramtypes", [
|
|
2729
2771
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2733,8 +2775,8 @@ _ts_decorate10([
|
|
|
2733
2775
|
_ts_metadata10("design:returntype", Promise)
|
|
2734
2776
|
], MessagesController.prototype, "feedback", null);
|
|
2735
2777
|
MessagesController = _ts_decorate10([
|
|
2736
|
-
(0,
|
|
2737
|
-
_ts_param9(1, (0,
|
|
2778
|
+
(0, import_common11.Controller)("messages"),
|
|
2779
|
+
_ts_param9(1, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
|
|
2738
2780
|
_ts_metadata10("design:type", Function),
|
|
2739
2781
|
_ts_metadata10("design:paramtypes", [
|
|
2740
2782
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -2743,8 +2785,8 @@ MessagesController = _ts_decorate10([
|
|
|
2743
2785
|
], MessagesController);
|
|
2744
2786
|
|
|
2745
2787
|
// src/controller/models.controller.ts
|
|
2746
|
-
var
|
|
2747
|
-
var
|
|
2788
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
2789
|
+
var import_common12 = require("@nestjs/common");
|
|
2748
2790
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
2749
2791
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2750
2792
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2791,9 +2833,9 @@ var ModelsController = class {
|
|
|
2791
2833
|
}
|
|
2792
2834
|
};
|
|
2793
2835
|
_ts_decorate11([
|
|
2794
|
-
(0,
|
|
2795
|
-
_ts_param10(0, (0,
|
|
2796
|
-
_ts_param10(1, (0,
|
|
2836
|
+
(0, import_common12.Get)(),
|
|
2837
|
+
_ts_param10(0, (0, import_common12.Req)()),
|
|
2838
|
+
_ts_param10(1, (0, import_common12.Query)("agent")),
|
|
2797
2839
|
_ts_metadata11("design:type", Function),
|
|
2798
2840
|
_ts_metadata11("design:paramtypes", [
|
|
2799
2841
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2802,8 +2844,8 @@ _ts_decorate11([
|
|
|
2802
2844
|
_ts_metadata11("design:returntype", Promise)
|
|
2803
2845
|
], ModelsController.prototype, "list", null);
|
|
2804
2846
|
ModelsController = _ts_decorate11([
|
|
2805
|
-
(0,
|
|
2806
|
-
_ts_param10(1, (0,
|
|
2847
|
+
(0, import_common12.Controller)("models"),
|
|
2848
|
+
_ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
|
|
2807
2849
|
_ts_metadata11("design:type", Function),
|
|
2808
2850
|
_ts_metadata11("design:paramtypes", [
|
|
2809
2851
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -2812,8 +2854,8 @@ ModelsController = _ts_decorate11([
|
|
|
2812
2854
|
], ModelsController);
|
|
2813
2855
|
|
|
2814
2856
|
// src/controller/queue.controller.ts
|
|
2815
|
-
var
|
|
2816
|
-
var
|
|
2857
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
2858
|
+
var import_common13 = require("@nestjs/common");
|
|
2817
2859
|
function _ts_decorate12(decorators, target, key, desc) {
|
|
2818
2860
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2819
2861
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2863,10 +2905,10 @@ var QueueController = class {
|
|
|
2863
2905
|
async update(req, messageId, body) {
|
|
2864
2906
|
const actor = await this.actorResolver.resolve(req);
|
|
2865
2907
|
if (body.message !== void 0 && typeof body.message !== "string") {
|
|
2866
|
-
throw new
|
|
2908
|
+
throw new import_common13.BadRequestException("message must be a string");
|
|
2867
2909
|
}
|
|
2868
2910
|
if (body.position !== void 0 && typeof body.position !== "number") {
|
|
2869
|
-
throw new
|
|
2911
|
+
throw new import_common13.BadRequestException("position must be a number");
|
|
2870
2912
|
}
|
|
2871
2913
|
const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
|
|
2872
2914
|
return this.agent.updateQueuedMessage(actor, messageId, {
|
|
@@ -2894,9 +2936,9 @@ var QueueController = class {
|
|
|
2894
2936
|
}
|
|
2895
2937
|
};
|
|
2896
2938
|
_ts_decorate12([
|
|
2897
|
-
(0,
|
|
2898
|
-
_ts_param11(0, (0,
|
|
2899
|
-
_ts_param11(1, (0,
|
|
2939
|
+
(0, import_common13.Get)("threads/:id/queue"),
|
|
2940
|
+
_ts_param11(0, (0, import_common13.Req)()),
|
|
2941
|
+
_ts_param11(1, (0, import_common13.Param)("id")),
|
|
2900
2942
|
_ts_metadata12("design:type", Function),
|
|
2901
2943
|
_ts_metadata12("design:paramtypes", [
|
|
2902
2944
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2905,9 +2947,9 @@ _ts_decorate12([
|
|
|
2905
2947
|
_ts_metadata12("design:returntype", Promise)
|
|
2906
2948
|
], QueueController.prototype, "list", null);
|
|
2907
2949
|
_ts_decorate12([
|
|
2908
|
-
(0,
|
|
2909
|
-
_ts_param11(0, (0,
|
|
2910
|
-
_ts_param11(1, (0,
|
|
2950
|
+
(0, import_common13.Delete)("threads/:id/queue"),
|
|
2951
|
+
_ts_param11(0, (0, import_common13.Req)()),
|
|
2952
|
+
_ts_param11(1, (0, import_common13.Param)("id")),
|
|
2911
2953
|
_ts_metadata12("design:type", Function),
|
|
2912
2954
|
_ts_metadata12("design:paramtypes", [
|
|
2913
2955
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2916,9 +2958,9 @@ _ts_decorate12([
|
|
|
2916
2958
|
_ts_metadata12("design:returntype", Promise)
|
|
2917
2959
|
], QueueController.prototype, "clear", null);
|
|
2918
2960
|
_ts_decorate12([
|
|
2919
|
-
(0,
|
|
2920
|
-
_ts_param11(0, (0,
|
|
2921
|
-
_ts_param11(1, (0,
|
|
2961
|
+
(0, import_common13.Post)("threads/:id/queue/resume"),
|
|
2962
|
+
_ts_param11(0, (0, import_common13.Req)()),
|
|
2963
|
+
_ts_param11(1, (0, import_common13.Param)("id")),
|
|
2922
2964
|
_ts_metadata12("design:type", Function),
|
|
2923
2965
|
_ts_metadata12("design:paramtypes", [
|
|
2924
2966
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2927,10 +2969,10 @@ _ts_decorate12([
|
|
|
2927
2969
|
_ts_metadata12("design:returntype", Promise)
|
|
2928
2970
|
], QueueController.prototype, "resume", null);
|
|
2929
2971
|
_ts_decorate12([
|
|
2930
|
-
(0,
|
|
2931
|
-
_ts_param11(0, (0,
|
|
2932
|
-
_ts_param11(1, (0,
|
|
2933
|
-
_ts_param11(2, (0,
|
|
2972
|
+
(0, import_common13.Patch)("queue/:messageId"),
|
|
2973
|
+
_ts_param11(0, (0, import_common13.Req)()),
|
|
2974
|
+
_ts_param11(1, (0, import_common13.Param)("messageId")),
|
|
2975
|
+
_ts_param11(2, (0, import_common13.Body)()),
|
|
2934
2976
|
_ts_metadata12("design:type", Function),
|
|
2935
2977
|
_ts_metadata12("design:paramtypes", [
|
|
2936
2978
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2940,9 +2982,9 @@ _ts_decorate12([
|
|
|
2940
2982
|
_ts_metadata12("design:returntype", Promise)
|
|
2941
2983
|
], QueueController.prototype, "update", null);
|
|
2942
2984
|
_ts_decorate12([
|
|
2943
|
-
(0,
|
|
2944
|
-
_ts_param11(0, (0,
|
|
2945
|
-
_ts_param11(1, (0,
|
|
2985
|
+
(0, import_common13.Post)("queue/:messageId/interrupt"),
|
|
2986
|
+
_ts_param11(0, (0, import_common13.Req)()),
|
|
2987
|
+
_ts_param11(1, (0, import_common13.Param)("messageId")),
|
|
2946
2988
|
_ts_metadata12("design:type", Function),
|
|
2947
2989
|
_ts_metadata12("design:paramtypes", [
|
|
2948
2990
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2951,9 +2993,9 @@ _ts_decorate12([
|
|
|
2951
2993
|
_ts_metadata12("design:returntype", Promise)
|
|
2952
2994
|
], QueueController.prototype, "interrupt", null);
|
|
2953
2995
|
_ts_decorate12([
|
|
2954
|
-
(0,
|
|
2955
|
-
_ts_param11(0, (0,
|
|
2956
|
-
_ts_param11(1, (0,
|
|
2996
|
+
(0, import_common13.Delete)("queue/:messageId"),
|
|
2997
|
+
_ts_param11(0, (0, import_common13.Req)()),
|
|
2998
|
+
_ts_param11(1, (0, import_common13.Param)("messageId")),
|
|
2957
2999
|
_ts_metadata12("design:type", Function),
|
|
2958
3000
|
_ts_metadata12("design:paramtypes", [
|
|
2959
3001
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2962,8 +3004,8 @@ _ts_decorate12([
|
|
|
2962
3004
|
_ts_metadata12("design:returntype", Promise)
|
|
2963
3005
|
], QueueController.prototype, "remove", null);
|
|
2964
3006
|
QueueController = _ts_decorate12([
|
|
2965
|
-
(0,
|
|
2966
|
-
_ts_param11(1, (0,
|
|
3007
|
+
(0, import_common13.Controller)(),
|
|
3008
|
+
_ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
|
|
2967
3009
|
_ts_metadata12("design:type", Function),
|
|
2968
3010
|
_ts_metadata12("design:paramtypes", [
|
|
2969
3011
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -2972,8 +3014,8 @@ QueueController = _ts_decorate12([
|
|
|
2972
3014
|
], QueueController);
|
|
2973
3015
|
|
|
2974
3016
|
// src/controller/quota.controller.ts
|
|
2975
|
-
var
|
|
2976
|
-
var
|
|
3017
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
3018
|
+
var import_common14 = require("@nestjs/common");
|
|
2977
3019
|
function _ts_decorate13(decorators, target, key, desc) {
|
|
2978
3020
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2979
3021
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3020,8 +3062,8 @@ var QuotaController = class {
|
|
|
3020
3062
|
}
|
|
3021
3063
|
};
|
|
3022
3064
|
_ts_decorate13([
|
|
3023
|
-
(0,
|
|
3024
|
-
_ts_param12(0, (0,
|
|
3065
|
+
(0, import_common14.Get)(),
|
|
3066
|
+
_ts_param12(0, (0, import_common14.Req)()),
|
|
3025
3067
|
_ts_metadata13("design:type", Function),
|
|
3026
3068
|
_ts_metadata13("design:paramtypes", [
|
|
3027
3069
|
typeof Request === "undefined" ? Object : Request
|
|
@@ -3029,8 +3071,8 @@ _ts_decorate13([
|
|
|
3029
3071
|
_ts_metadata13("design:returntype", Promise)
|
|
3030
3072
|
], QuotaController.prototype, "report", null);
|
|
3031
3073
|
QuotaController = _ts_decorate13([
|
|
3032
|
-
(0,
|
|
3033
|
-
_ts_param12(1, (0,
|
|
3074
|
+
(0, import_common14.Controller)("quota"),
|
|
3075
|
+
_ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
|
|
3034
3076
|
_ts_metadata13("design:type", Function),
|
|
3035
3077
|
_ts_metadata13("design:paramtypes", [
|
|
3036
3078
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -3039,8 +3081,8 @@ QuotaController = _ts_decorate13([
|
|
|
3039
3081
|
], QuotaController);
|
|
3040
3082
|
|
|
3041
3083
|
// src/controller/skills.controller.ts
|
|
3042
|
-
var
|
|
3043
|
-
var
|
|
3084
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
3085
|
+
var import_common15 = require("@nestjs/common");
|
|
3044
3086
|
function _ts_decorate14(decorators, target, key, desc) {
|
|
3045
3087
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3046
3088
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3082,7 +3124,7 @@ var SkillsController = class {
|
|
|
3082
3124
|
return [];
|
|
3083
3125
|
}
|
|
3084
3126
|
const actor = await this.actorResolver.resolve(req);
|
|
3085
|
-
const offer = await (0,
|
|
3127
|
+
const offer = await (0, import_nestjs_agent_core15.offerSkills)(this.skills, {
|
|
3086
3128
|
actor,
|
|
3087
3129
|
threadId: threadId ?? ""
|
|
3088
3130
|
});
|
|
@@ -3090,9 +3132,9 @@ var SkillsController = class {
|
|
|
3090
3132
|
}
|
|
3091
3133
|
};
|
|
3092
3134
|
_ts_decorate14([
|
|
3093
|
-
(0,
|
|
3094
|
-
_ts_param13(0, (0,
|
|
3095
|
-
_ts_param13(1, (0,
|
|
3135
|
+
(0, import_common15.Get)(),
|
|
3136
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3137
|
+
_ts_param13(1, (0, import_common15.Query)("threadId")),
|
|
3096
3138
|
_ts_metadata14("design:type", Function),
|
|
3097
3139
|
_ts_metadata14("design:paramtypes", [
|
|
3098
3140
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3101,10 +3143,10 @@ _ts_decorate14([
|
|
|
3101
3143
|
_ts_metadata14("design:returntype", Promise)
|
|
3102
3144
|
], SkillsController.prototype, "list", null);
|
|
3103
3145
|
SkillsController = _ts_decorate14([
|
|
3104
|
-
(0,
|
|
3105
|
-
_ts_param13(0, (0,
|
|
3106
|
-
_ts_param13(1, (0,
|
|
3107
|
-
_ts_param13(1, (0,
|
|
3146
|
+
(0, import_common15.Controller)("skills"),
|
|
3147
|
+
_ts_param13(0, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
|
|
3148
|
+
_ts_param13(1, (0, import_common15.Optional)()),
|
|
3149
|
+
_ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_SKILLS)),
|
|
3108
3150
|
_ts_metadata14("design:type", Function),
|
|
3109
3151
|
_ts_metadata14("design:paramtypes", [
|
|
3110
3152
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
@@ -3113,8 +3155,8 @@ SkillsController = _ts_decorate14([
|
|
|
3113
3155
|
], SkillsController);
|
|
3114
3156
|
|
|
3115
3157
|
// src/controller/threads.controller.ts
|
|
3116
|
-
var
|
|
3117
|
-
var
|
|
3158
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
3159
|
+
var import_common16 = require("@nestjs/common");
|
|
3118
3160
|
function _ts_decorate15(decorators, target, key, desc) {
|
|
3119
3161
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3120
3162
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3208,8 +3250,8 @@ var ThreadsController = class {
|
|
|
3208
3250
|
}
|
|
3209
3251
|
};
|
|
3210
3252
|
_ts_decorate15([
|
|
3211
|
-
(0,
|
|
3212
|
-
_ts_param14(0, (0,
|
|
3253
|
+
(0, import_common16.Get)(),
|
|
3254
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
3213
3255
|
_ts_metadata15("design:type", Function),
|
|
3214
3256
|
_ts_metadata15("design:paramtypes", [
|
|
3215
3257
|
typeof Request === "undefined" ? Object : Request
|
|
@@ -3217,9 +3259,9 @@ _ts_decorate15([
|
|
|
3217
3259
|
_ts_metadata15("design:returntype", Promise)
|
|
3218
3260
|
], ThreadsController.prototype, "list", null);
|
|
3219
3261
|
_ts_decorate15([
|
|
3220
|
-
(0,
|
|
3221
|
-
_ts_param14(0, (0,
|
|
3222
|
-
_ts_param14(1, (0,
|
|
3262
|
+
(0, import_common16.Get)(":id"),
|
|
3263
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
3264
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
3223
3265
|
_ts_metadata15("design:type", Function),
|
|
3224
3266
|
_ts_metadata15("design:paramtypes", [
|
|
3225
3267
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3228,9 +3270,9 @@ _ts_decorate15([
|
|
|
3228
3270
|
_ts_metadata15("design:returntype", Promise)
|
|
3229
3271
|
], ThreadsController.prototype, "detail", null);
|
|
3230
3272
|
_ts_decorate15([
|
|
3231
|
-
(0,
|
|
3232
|
-
_ts_param14(0, (0,
|
|
3233
|
-
_ts_param14(1, (0,
|
|
3273
|
+
(0, import_common16.Delete)(":id"),
|
|
3274
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
3275
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
3234
3276
|
_ts_metadata15("design:type", Function),
|
|
3235
3277
|
_ts_metadata15("design:paramtypes", [
|
|
3236
3278
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3239,10 +3281,10 @@ _ts_decorate15([
|
|
|
3239
3281
|
_ts_metadata15("design:returntype", Promise)
|
|
3240
3282
|
], ThreadsController.prototype, "remove", null);
|
|
3241
3283
|
_ts_decorate15([
|
|
3242
|
-
(0,
|
|
3243
|
-
_ts_param14(0, (0,
|
|
3244
|
-
_ts_param14(1, (0,
|
|
3245
|
-
_ts_param14(2, (0,
|
|
3284
|
+
(0, import_common16.Post)(":id/fork-from/:messageId"),
|
|
3285
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
3286
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
3287
|
+
_ts_param14(2, (0, import_common16.Param)("messageId")),
|
|
3246
3288
|
_ts_metadata15("design:type", Function),
|
|
3247
3289
|
_ts_metadata15("design:paramtypes", [
|
|
3248
3290
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3252,10 +3294,10 @@ _ts_decorate15([
|
|
|
3252
3294
|
_ts_metadata15("design:returntype", Promise)
|
|
3253
3295
|
], ThreadsController.prototype, "fork", null);
|
|
3254
3296
|
_ts_decorate15([
|
|
3255
|
-
(0,
|
|
3256
|
-
_ts_param14(0, (0,
|
|
3257
|
-
_ts_param14(1, (0,
|
|
3258
|
-
_ts_param14(2, (0,
|
|
3297
|
+
(0, import_common16.Patch)(":id"),
|
|
3298
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
3299
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
3300
|
+
_ts_param14(2, (0, import_common16.Body)()),
|
|
3259
3301
|
_ts_metadata15("design:type", Function),
|
|
3260
3302
|
_ts_metadata15("design:paramtypes", [
|
|
3261
3303
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3265,9 +3307,9 @@ _ts_decorate15([
|
|
|
3265
3307
|
_ts_metadata15("design:returntype", Promise)
|
|
3266
3308
|
], ThreadsController.prototype, "update", null);
|
|
3267
3309
|
_ts_decorate15([
|
|
3268
|
-
(0,
|
|
3269
|
-
_ts_param14(0, (0,
|
|
3270
|
-
_ts_param14(1, (0,
|
|
3310
|
+
(0, import_common16.Post)(":id/promote"),
|
|
3311
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
3312
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
3271
3313
|
_ts_metadata15("design:type", Function),
|
|
3272
3314
|
_ts_metadata15("design:paramtypes", [
|
|
3273
3315
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3276,10 +3318,10 @@ _ts_decorate15([
|
|
|
3276
3318
|
_ts_metadata15("design:returntype", Promise)
|
|
3277
3319
|
], ThreadsController.prototype, "promote", null);
|
|
3278
3320
|
_ts_decorate15([
|
|
3279
|
-
(0,
|
|
3280
|
-
_ts_param14(0, (0,
|
|
3281
|
-
_ts_param14(1, (0,
|
|
3282
|
-
_ts_param14(2, (0,
|
|
3321
|
+
(0, import_common16.Delete)(":id/from/:messageId"),
|
|
3322
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
3323
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
3324
|
+
_ts_param14(2, (0, import_common16.Param)("messageId")),
|
|
3283
3325
|
_ts_metadata15("design:type", Function),
|
|
3284
3326
|
_ts_metadata15("design:paramtypes", [
|
|
3285
3327
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3289,8 +3331,8 @@ _ts_decorate15([
|
|
|
3289
3331
|
_ts_metadata15("design:returntype", Promise)
|
|
3290
3332
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
3291
3333
|
ThreadsController = _ts_decorate15([
|
|
3292
|
-
(0,
|
|
3293
|
-
_ts_param14(1, (0,
|
|
3334
|
+
(0, import_common16.Controller)("threads"),
|
|
3335
|
+
_ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
|
|
3294
3336
|
_ts_metadata15("design:type", Function),
|
|
3295
3337
|
_ts_metadata15("design:paramtypes", [
|
|
3296
3338
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -3299,8 +3341,8 @@ ThreadsController = _ts_decorate15([
|
|
|
3299
3341
|
], ThreadsController);
|
|
3300
3342
|
|
|
3301
3343
|
// src/controller/tool-call.controller.ts
|
|
3302
|
-
var
|
|
3303
|
-
var
|
|
3344
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
3345
|
+
var import_common17 = require("@nestjs/common");
|
|
3304
3346
|
function _ts_decorate16(decorators, target, key, desc) {
|
|
3305
3347
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3306
3348
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3335,7 +3377,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
3335
3377
|
var DEFAULT_VIA = "web";
|
|
3336
3378
|
function toolCallId(claimed) {
|
|
3337
3379
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
3338
|
-
throw new
|
|
3380
|
+
throw new import_common17.BadRequestException("toolCallId must be a non-empty string");
|
|
3339
3381
|
}
|
|
3340
3382
|
return claimed;
|
|
3341
3383
|
}
|
|
@@ -3345,10 +3387,10 @@ function rejectReason(claimed) {
|
|
|
3345
3387
|
return void 0;
|
|
3346
3388
|
}
|
|
3347
3389
|
if (typeof claimed !== "string") {
|
|
3348
|
-
throw new
|
|
3390
|
+
throw new import_common17.BadRequestException("reason must be a string");
|
|
3349
3391
|
}
|
|
3350
3392
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
3351
|
-
throw new
|
|
3393
|
+
throw new import_common17.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
3352
3394
|
}
|
|
3353
3395
|
return claimed;
|
|
3354
3396
|
}
|
|
@@ -3358,7 +3400,7 @@ function remember(claimed) {
|
|
|
3358
3400
|
return false;
|
|
3359
3401
|
}
|
|
3360
3402
|
if (typeof claimed !== "boolean") {
|
|
3361
|
-
throw new
|
|
3403
|
+
throw new import_common17.BadRequestException("remember must be a boolean");
|
|
3362
3404
|
}
|
|
3363
3405
|
return claimed;
|
|
3364
3406
|
}
|
|
@@ -3368,7 +3410,7 @@ function via(claimed) {
|
|
|
3368
3410
|
return DEFAULT_VIA;
|
|
3369
3411
|
}
|
|
3370
3412
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
3371
|
-
throw new
|
|
3413
|
+
throw new import_common17.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
3372
3414
|
}
|
|
3373
3415
|
return claimed;
|
|
3374
3416
|
}
|
|
@@ -3378,26 +3420,26 @@ function answers(claimed) {
|
|
|
3378
3420
|
return void 0;
|
|
3379
3421
|
}
|
|
3380
3422
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
3381
|
-
throw new
|
|
3423
|
+
throw new import_common17.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
3382
3424
|
}
|
|
3383
3425
|
const entries = Object.entries(claimed);
|
|
3384
3426
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
3385
|
-
throw new
|
|
3427
|
+
throw new import_common17.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
3386
3428
|
}
|
|
3387
3429
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
3388
3430
|
for (const [questionId, values] of entries) {
|
|
3389
3431
|
if (!Array.isArray(values)) {
|
|
3390
|
-
throw new
|
|
3432
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
3391
3433
|
}
|
|
3392
3434
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
3393
|
-
throw new
|
|
3435
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
3394
3436
|
}
|
|
3395
3437
|
for (const value of values) {
|
|
3396
3438
|
if (typeof value !== "string") {
|
|
3397
|
-
throw new
|
|
3439
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
3398
3440
|
}
|
|
3399
3441
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
3400
|
-
throw new
|
|
3442
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
3401
3443
|
}
|
|
3402
3444
|
}
|
|
3403
3445
|
validated[questionId] = values;
|
|
@@ -3460,9 +3502,9 @@ var ToolCallController = class {
|
|
|
3460
3502
|
}
|
|
3461
3503
|
};
|
|
3462
3504
|
_ts_decorate16([
|
|
3463
|
-
(0,
|
|
3464
|
-
_ts_param15(0, (0,
|
|
3465
|
-
_ts_param15(1, (0,
|
|
3505
|
+
(0, import_common17.Post)("approve"),
|
|
3506
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3507
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3466
3508
|
_ts_metadata16("design:type", Function),
|
|
3467
3509
|
_ts_metadata16("design:paramtypes", [
|
|
3468
3510
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3471,9 +3513,9 @@ _ts_decorate16([
|
|
|
3471
3513
|
_ts_metadata16("design:returntype", Promise)
|
|
3472
3514
|
], ToolCallController.prototype, "approve", null);
|
|
3473
3515
|
_ts_decorate16([
|
|
3474
|
-
(0,
|
|
3475
|
-
_ts_param15(0, (0,
|
|
3476
|
-
_ts_param15(1, (0,
|
|
3516
|
+
(0, import_common17.Post)("reject"),
|
|
3517
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3518
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3477
3519
|
_ts_metadata16("design:type", Function),
|
|
3478
3520
|
_ts_metadata16("design:paramtypes", [
|
|
3479
3521
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3482,9 +3524,9 @@ _ts_decorate16([
|
|
|
3482
3524
|
_ts_metadata16("design:returntype", Promise)
|
|
3483
3525
|
], ToolCallController.prototype, "reject", null);
|
|
3484
3526
|
_ts_decorate16([
|
|
3485
|
-
(0,
|
|
3486
|
-
_ts_param15(0, (0,
|
|
3487
|
-
_ts_param15(1, (0,
|
|
3527
|
+
(0, import_common17.Post)("answer"),
|
|
3528
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3529
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3488
3530
|
_ts_metadata16("design:type", Function),
|
|
3489
3531
|
_ts_metadata16("design:paramtypes", [
|
|
3490
3532
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3493,9 +3535,9 @@ _ts_decorate16([
|
|
|
3493
3535
|
_ts_metadata16("design:returntype", Promise)
|
|
3494
3536
|
], ToolCallController.prototype, "answer", null);
|
|
3495
3537
|
_ts_decorate16([
|
|
3496
|
-
(0,
|
|
3497
|
-
_ts_param15(0, (0,
|
|
3498
|
-
_ts_param15(1, (0,
|
|
3538
|
+
(0, import_common17.Post)("skip"),
|
|
3539
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3540
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3499
3541
|
_ts_metadata16("design:type", Function),
|
|
3500
3542
|
_ts_metadata16("design:paramtypes", [
|
|
3501
3543
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3504,8 +3546,8 @@ _ts_decorate16([
|
|
|
3504
3546
|
_ts_metadata16("design:returntype", Promise)
|
|
3505
3547
|
], ToolCallController.prototype, "skip", null);
|
|
3506
3548
|
ToolCallController = _ts_decorate16([
|
|
3507
|
-
(0,
|
|
3508
|
-
_ts_param15(1, (0,
|
|
3549
|
+
(0, import_common17.Controller)("tool-call"),
|
|
3550
|
+
_ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
|
|
3509
3551
|
_ts_metadata16("design:type", Function),
|
|
3510
3552
|
_ts_metadata16("design:paramtypes", [
|
|
3511
3553
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -3514,8 +3556,8 @@ ToolCallController = _ts_decorate16([
|
|
|
3514
3556
|
], ToolCallController);
|
|
3515
3557
|
|
|
3516
3558
|
// src/controller/tools.controller.ts
|
|
3517
|
-
var
|
|
3518
|
-
var
|
|
3559
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
3560
|
+
var import_common18 = require("@nestjs/common");
|
|
3519
3561
|
function _ts_decorate17(decorators, target, key, desc) {
|
|
3520
3562
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3521
3563
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -3555,11 +3597,11 @@ var ToolsController = class {
|
|
|
3555
3597
|
this.agents = agents;
|
|
3556
3598
|
}
|
|
3557
3599
|
async list(req, agent) {
|
|
3558
|
-
if (agent !== void 0 && agent !==
|
|
3559
|
-
throw new
|
|
3600
|
+
if (agent !== void 0 && agent !== import_nestjs_agent_core18.ALL_AGENTS && this.agents.get(agent) === void 0) {
|
|
3601
|
+
throw new import_common18.NotFoundException(`No agent named "${agent}"`);
|
|
3560
3602
|
}
|
|
3561
3603
|
const actor = await this.actorResolver.resolve(req);
|
|
3562
|
-
const names = agent ===
|
|
3604
|
+
const names = agent === import_nestjs_agent_core18.ALL_AGENTS ? [
|
|
3563
3605
|
void 0,
|
|
3564
3606
|
...this.agents.list().map((definition) => definition.name)
|
|
3565
3607
|
] : [
|
|
@@ -3586,9 +3628,9 @@ var ToolsController = class {
|
|
|
3586
3628
|
}
|
|
3587
3629
|
};
|
|
3588
3630
|
_ts_decorate17([
|
|
3589
|
-
(0,
|
|
3590
|
-
_ts_param16(0, (0,
|
|
3591
|
-
_ts_param16(1, (0,
|
|
3631
|
+
(0, import_common18.Get)(),
|
|
3632
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
3633
|
+
_ts_param16(1, (0, import_common18.Query)("agent")),
|
|
3592
3634
|
_ts_metadata17("design:type", Function),
|
|
3593
3635
|
_ts_metadata17("design:paramtypes", [
|
|
3594
3636
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -3597,21 +3639,21 @@ _ts_decorate17([
|
|
|
3597
3639
|
_ts_metadata17("design:returntype", Promise)
|
|
3598
3640
|
], ToolsController.prototype, "list", null);
|
|
3599
3641
|
ToolsController = _ts_decorate17([
|
|
3600
|
-
(0,
|
|
3601
|
-
_ts_param16(0, (0,
|
|
3602
|
-
_ts_param16(1, (0,
|
|
3603
|
-
_ts_param16(2, (0,
|
|
3642
|
+
(0, import_common18.Controller)("tools"),
|
|
3643
|
+
_ts_param16(0, (0, import_common18.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
3644
|
+
_ts_param16(1, (0, import_common18.Inject)(import_nestjs_agent_core18.AGENT_DEPS_FACTORY)),
|
|
3645
|
+
_ts_param16(2, (0, import_common18.Inject)(import_nestjs_agent_core18.AGENT_REGISTRY)),
|
|
3604
3646
|
_ts_metadata17("design:type", Function),
|
|
3605
3647
|
_ts_metadata17("design:paramtypes", [
|
|
3606
3648
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3607
3649
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3608
|
-
typeof
|
|
3650
|
+
typeof import_nestjs_agent_core18.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core18.AgentRegistry
|
|
3609
3651
|
])
|
|
3610
3652
|
], ToolsController);
|
|
3611
3653
|
|
|
3612
3654
|
// src/discovery/agent-discovery.service.ts
|
|
3613
|
-
var
|
|
3614
|
-
var
|
|
3655
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
3656
|
+
var import_common19 = require("@nestjs/common");
|
|
3615
3657
|
var import_core = require("@nestjs/core");
|
|
3616
3658
|
|
|
3617
3659
|
// src/decorator/agent.decorator.ts
|
|
@@ -3680,7 +3722,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
3680
3722
|
scanner;
|
|
3681
3723
|
registry;
|
|
3682
3724
|
contributors;
|
|
3683
|
-
logger = new
|
|
3725
|
+
logger = new import_common19.Logger(_AgentDiscoveryService.name);
|
|
3684
3726
|
constructor(discovery, scanner, registry, contributors) {
|
|
3685
3727
|
this.discovery = discovery;
|
|
3686
3728
|
this.scanner = scanner;
|
|
@@ -3799,21 +3841,21 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
3799
3841
|
}
|
|
3800
3842
|
};
|
|
3801
3843
|
AgentDiscoveryService = _ts_decorate18([
|
|
3802
|
-
(0,
|
|
3803
|
-
_ts_param17(2, (0,
|
|
3804
|
-
_ts_param17(3, (0,
|
|
3844
|
+
(0, import_common19.Injectable)(),
|
|
3845
|
+
_ts_param17(2, (0, import_common19.Inject)(import_nestjs_agent_core19.AGENT_REGISTRY)),
|
|
3846
|
+
_ts_param17(3, (0, import_common19.Inject)(import_nestjs_agent_core19.AGENT_PROMPT_CONTRIBUTORS)),
|
|
3805
3847
|
_ts_metadata18("design:type", Function),
|
|
3806
3848
|
_ts_metadata18("design:paramtypes", [
|
|
3807
3849
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
3808
3850
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
3809
|
-
typeof
|
|
3851
|
+
typeof import_nestjs_agent_core19.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core19.AgentRegistry,
|
|
3810
3852
|
Array
|
|
3811
3853
|
])
|
|
3812
3854
|
], AgentDiscoveryService);
|
|
3813
3855
|
|
|
3814
3856
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3815
|
-
var
|
|
3816
|
-
var
|
|
3857
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
3858
|
+
var import_common20 = require("@nestjs/common");
|
|
3817
3859
|
var import_core2 = require("@nestjs/core");
|
|
3818
3860
|
var import_zod = require("zod");
|
|
3819
3861
|
|
|
@@ -3918,7 +3960,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3918
3960
|
registry;
|
|
3919
3961
|
agents;
|
|
3920
3962
|
options;
|
|
3921
|
-
logger = new
|
|
3963
|
+
logger = new import_common20.Logger(_AiToolDiscoveryService.name);
|
|
3922
3964
|
constructor(discovery, registry, agents, options) {
|
|
3923
3965
|
this.discovery = discovery;
|
|
3924
3966
|
this.registry = registry;
|
|
@@ -4003,7 +4045,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4003
4045
|
let delegates = 0;
|
|
4004
4046
|
for (const definition of this.agents.list()) {
|
|
4005
4047
|
for (const edge of definition.delegatesTo ?? []) {
|
|
4006
|
-
const { agent: target, detached } = (0,
|
|
4048
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core20.normalizeDelegation)(edge);
|
|
4007
4049
|
const targetDefinition = this.agents.get(target);
|
|
4008
4050
|
if (targetDefinition === void 0) {
|
|
4009
4051
|
throw new Error(`Agent "${definition.name}" hands off to "${target}", which is not a registered @Agent. Declare it as an @Agent provider or fix the reference.`);
|
|
@@ -4054,10 +4096,10 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4054
4096
|
}
|
|
4055
4097
|
};
|
|
4056
4098
|
AiToolDiscoveryService = _ts_decorate19([
|
|
4057
|
-
(0,
|
|
4058
|
-
_ts_param18(1, (0,
|
|
4059
|
-
_ts_param18(2, (0,
|
|
4060
|
-
_ts_param18(3, (0,
|
|
4099
|
+
(0, import_common20.Injectable)(),
|
|
4100
|
+
_ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core20.AGENT_TOOL_REGISTRY)),
|
|
4101
|
+
_ts_param18(2, (0, import_common20.Inject)(import_nestjs_agent_core20.AGENT_REGISTRY)),
|
|
4102
|
+
_ts_param18(3, (0, import_common20.Inject)(import_nestjs_agent_core20.AGENT_OPTIONS)),
|
|
4061
4103
|
_ts_metadata19("design:type", Function),
|
|
4062
4104
|
_ts_metadata19("design:paramtypes", [
|
|
4063
4105
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
@@ -4068,13 +4110,13 @@ AiToolDiscoveryService = _ts_decorate19([
|
|
|
4068
4110
|
], AiToolDiscoveryService);
|
|
4069
4111
|
|
|
4070
4112
|
// src/discovery/skill-discovery.service.ts
|
|
4071
|
-
var
|
|
4072
|
-
var
|
|
4113
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
4114
|
+
var import_common21 = require("@nestjs/common");
|
|
4073
4115
|
var import_core3 = require("@nestjs/core");
|
|
4074
4116
|
|
|
4075
4117
|
// src/decorator/skill.decorator.ts
|
|
4076
4118
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
4077
|
-
var
|
|
4119
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
4078
4120
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
4079
4121
|
function Skill(options) {
|
|
4080
4122
|
return (target) => {
|
|
@@ -4087,7 +4129,7 @@ function readSkillMetadata(target) {
|
|
|
4087
4129
|
}
|
|
4088
4130
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
4089
4131
|
function skillScope(options) {
|
|
4090
|
-
return options.scope ??
|
|
4132
|
+
return options.scope ?? import_nestjs_agent_core21.GLOBAL_SCOPE;
|
|
4091
4133
|
}
|
|
4092
4134
|
__name(skillScope, "skillScope");
|
|
4093
4135
|
|
|
@@ -4124,7 +4166,7 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
4124
4166
|
}
|
|
4125
4167
|
discovery;
|
|
4126
4168
|
declared;
|
|
4127
|
-
logger = new
|
|
4169
|
+
logger = new import_common21.Logger(_SkillDiscoveryService.name);
|
|
4128
4170
|
constructor(discovery, declared) {
|
|
4129
4171
|
this.discovery = discovery;
|
|
4130
4172
|
this.declared = declared;
|
|
@@ -4162,8 +4204,8 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
4162
4204
|
}
|
|
4163
4205
|
};
|
|
4164
4206
|
SkillDiscoveryService = _ts_decorate20([
|
|
4165
|
-
(0,
|
|
4166
|
-
_ts_param19(1, (0,
|
|
4207
|
+
(0, import_common21.Injectable)(),
|
|
4208
|
+
_ts_param19(1, (0, import_common21.Inject)(import_nestjs_agent_core22.AGENT_SKILL_SOURCES)),
|
|
4167
4209
|
_ts_metadata20("design:type", Function),
|
|
4168
4210
|
_ts_metadata20("design:paramtypes", [
|
|
4169
4211
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
@@ -4172,7 +4214,7 @@ SkillDiscoveryService = _ts_decorate20([
|
|
|
4172
4214
|
], SkillDiscoveryService);
|
|
4173
4215
|
|
|
4174
4216
|
// src/in-process-sink.ts
|
|
4175
|
-
var
|
|
4217
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
4176
4218
|
var InProcessTokenStreamSink = class {
|
|
4177
4219
|
static {
|
|
4178
4220
|
__name(this, "InProcessTokenStreamSink");
|
|
@@ -4227,7 +4269,7 @@ var InProcessTokenStreamSink = class {
|
|
|
4227
4269
|
}
|
|
4228
4270
|
if (buf.ended) {
|
|
4229
4271
|
if (buf.failure !== void 0) {
|
|
4230
|
-
throw new
|
|
4272
|
+
throw new import_nestjs_agent_core23.AgentStreamError(buf.failure);
|
|
4231
4273
|
}
|
|
4232
4274
|
return;
|
|
4233
4275
|
}
|
|
@@ -4240,7 +4282,7 @@ var InProcessTokenStreamSink = class {
|
|
|
4240
4282
|
};
|
|
4241
4283
|
|
|
4242
4284
|
// src/ledger-quota-provider.ts
|
|
4243
|
-
var
|
|
4285
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
4244
4286
|
var LedgerQuotaProvider = class {
|
|
4245
4287
|
static {
|
|
4246
4288
|
__name(this, "LedgerQuotaProvider");
|
|
@@ -4260,12 +4302,12 @@ var LedgerQuotaProvider = class {
|
|
|
4260
4302
|
await this.dayWindow(actorRef, now)
|
|
4261
4303
|
];
|
|
4262
4304
|
if (this.store.usageBetween !== void 0) {
|
|
4263
|
-
const range = (0,
|
|
4305
|
+
const range = (0, import_nestjs_agent_core24.quotaPeriodRange)("month", now);
|
|
4264
4306
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
4265
4307
|
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
4266
4308
|
}
|
|
4267
|
-
const blocked = (0,
|
|
4268
|
-
const warning = (0,
|
|
4309
|
+
const blocked = (0, import_nestjs_agent_core24.exhaustedWindow)(windows);
|
|
4310
|
+
const warning = (0, import_nestjs_agent_core24.quotaWarning)(windows);
|
|
4269
4311
|
return {
|
|
4270
4312
|
windows,
|
|
4271
4313
|
...blocked !== void 0 ? {
|
|
@@ -4277,7 +4319,7 @@ var LedgerQuotaProvider = class {
|
|
|
4277
4319
|
};
|
|
4278
4320
|
}
|
|
4279
4321
|
async dayWindow(actorRef, now) {
|
|
4280
|
-
const range = (0,
|
|
4322
|
+
const range = (0, import_nestjs_agent_core24.quotaPeriodRange)("day", now);
|
|
4281
4323
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
4282
4324
|
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
4283
4325
|
}
|
|
@@ -4302,8 +4344,8 @@ var LedgerQuotaProvider = class {
|
|
|
4302
4344
|
};
|
|
4303
4345
|
|
|
4304
4346
|
// src/runner/inline-agent-runner.ts
|
|
4305
|
-
var
|
|
4306
|
-
var
|
|
4347
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
4348
|
+
var import_common22 = require("@nestjs/common");
|
|
4307
4349
|
function _ts_decorate21(decorators, target, key, desc) {
|
|
4308
4350
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4309
4351
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -4337,7 +4379,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4337
4379
|
factory;
|
|
4338
4380
|
store;
|
|
4339
4381
|
queue;
|
|
4340
|
-
logger = new
|
|
4382
|
+
logger = new import_common22.Logger(_InlineAgentRunner.name);
|
|
4341
4383
|
pending = /* @__PURE__ */ new Map();
|
|
4342
4384
|
/**
|
|
4343
4385
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -4357,7 +4399,15 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4357
4399
|
* that was running it is gone (a restart), and a thread it still holds is a stale claim.
|
|
4358
4400
|
*/
|
|
4359
4401
|
async isRunActive(runId) {
|
|
4360
|
-
|
|
4402
|
+
if (this.live.has(runId)) {
|
|
4403
|
+
return true;
|
|
4404
|
+
}
|
|
4405
|
+
for (const key of this.pending.keys()) {
|
|
4406
|
+
if (key.startsWith(`${runId}:`)) {
|
|
4407
|
+
return true;
|
|
4408
|
+
}
|
|
4409
|
+
}
|
|
4410
|
+
return false;
|
|
4361
4411
|
}
|
|
4362
4412
|
async start(input, options = {}) {
|
|
4363
4413
|
const runId = options.runId ?? crypto.randomUUID();
|
|
@@ -4378,18 +4428,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4378
4428
|
],
|
|
4379
4429
|
input
|
|
4380
4430
|
});
|
|
4381
|
-
void (0,
|
|
4431
|
+
void (0, import_nestjs_agent_core25.runAgentLoop)({
|
|
4382
4432
|
...deps,
|
|
4383
4433
|
day
|
|
4384
|
-
}, input, hooks).then(() => (0,
|
|
4385
|
-
if (error instanceof
|
|
4434
|
+
}, input, hooks).then(() => (0, import_nestjs_agent_core25.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
|
|
4435
|
+
if (error instanceof import_nestjs_agent_core25.RunCancelledError) {
|
|
4386
4436
|
await this.settleCancelled(runId, input, deps);
|
|
4387
4437
|
return;
|
|
4388
4438
|
}
|
|
4389
4439
|
const message = error instanceof Error ? error.message : String(error);
|
|
4390
|
-
const code = (0,
|
|
4440
|
+
const code = (0, import_nestjs_agent_core25.agentFailureCode)(error);
|
|
4391
4441
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
4392
|
-
(0,
|
|
4442
|
+
(0, import_nestjs_agent_core25.publishAgentRunFailed)({
|
|
4393
4443
|
runId,
|
|
4394
4444
|
code,
|
|
4395
4445
|
message
|
|
@@ -4400,13 +4450,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4400
4450
|
errorCode: code,
|
|
4401
4451
|
errorMessage: message
|
|
4402
4452
|
});
|
|
4453
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core25.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
4403
4454
|
const writer = await deps.sink.open(runId);
|
|
4404
4455
|
await this.settleQueue(writer, input, runId, "failed", message);
|
|
4405
|
-
await (0,
|
|
4406
|
-
await writer.fail(
|
|
4407
|
-
code,
|
|
4408
|
-
message
|
|
4409
|
-
});
|
|
4456
|
+
await (0, import_nestjs_agent_core25.releaseThreadRun)(this.store, input.threadId, runId);
|
|
4457
|
+
await writer.fail((0, import_nestjs_agent_core25.streamFailure)(error));
|
|
4410
4458
|
}).finally(() => {
|
|
4411
4459
|
this.cancelled.delete(runId);
|
|
4412
4460
|
this.live.delete(runId);
|
|
@@ -4442,7 +4490,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4442
4490
|
for (const [key, waiter] of this.pending) {
|
|
4443
4491
|
if (key.startsWith(`${runId}:`)) {
|
|
4444
4492
|
this.pending.delete(key);
|
|
4445
|
-
waiter.reject(new
|
|
4493
|
+
waiter.reject(new import_nestjs_agent_core25.RunCancelledError());
|
|
4446
4494
|
}
|
|
4447
4495
|
}
|
|
4448
4496
|
await Promise.resolve();
|
|
@@ -4457,8 +4505,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4457
4505
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
4458
4506
|
const writer = await deps.sink.open(runId);
|
|
4459
4507
|
await this.settleQueue(writer, input, runId, "cancelled");
|
|
4460
|
-
await (0,
|
|
4461
|
-
await writer.write((0,
|
|
4508
|
+
await (0, import_nestjs_agent_core25.releaseThreadRun)(this.store, input.threadId, runId);
|
|
4509
|
+
await writer.write((0, import_nestjs_agent_core25.encodeStreamEvent)({
|
|
4462
4510
|
kind: "cancelled"
|
|
4463
4511
|
}));
|
|
4464
4512
|
await writer.end();
|
|
@@ -4493,7 +4541,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4493
4541
|
runId: nextRunId
|
|
4494
4542
|
}));
|
|
4495
4543
|
if (frame !== void 0) {
|
|
4496
|
-
await writer.write((0,
|
|
4544
|
+
await writer.write((0, import_nestjs_agent_core25.encodeStreamEvent)(frame));
|
|
4497
4545
|
}
|
|
4498
4546
|
} catch (failure) {
|
|
4499
4547
|
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
@@ -4564,7 +4612,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4564
4612
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
4565
4613
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
4566
4614
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
4567
|
-
parallel:
|
|
4615
|
+
parallel: import_nestjs_agent_core25.settleAll,
|
|
4568
4616
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
4569
4617
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
4570
4618
|
agentName,
|
|
@@ -4615,7 +4663,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4615
4663
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
4616
4664
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
4617
4665
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
4618
|
-
parallel:
|
|
4666
|
+
parallel: import_nestjs_agent_core25.settleAll,
|
|
4619
4667
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
4620
4668
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
4621
4669
|
agentName: childName,
|
|
@@ -4648,7 +4696,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4648
4696
|
}
|
|
4649
4697
|
}), "startAgent")
|
|
4650
4698
|
};
|
|
4651
|
-
void (0,
|
|
4699
|
+
void (0, import_nestjs_agent_core25.runAgentLoop)({
|
|
4652
4700
|
...deps,
|
|
4653
4701
|
day
|
|
4654
4702
|
}, {
|
|
@@ -4662,13 +4710,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4662
4710
|
parentRunId,
|
|
4663
4711
|
deliverTo
|
|
4664
4712
|
}, hooks).catch(async (error) => {
|
|
4665
|
-
const cancelled = error instanceof
|
|
4713
|
+
const cancelled = error instanceof import_nestjs_agent_core25.RunCancelledError;
|
|
4666
4714
|
const message = error instanceof Error ? error.message : String(error);
|
|
4667
4715
|
if (!cancelled) {
|
|
4668
4716
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
4669
|
-
(0,
|
|
4717
|
+
(0, import_nestjs_agent_core25.publishAgentRunFailed)({
|
|
4670
4718
|
runId,
|
|
4671
|
-
code: (0,
|
|
4719
|
+
code: (0, import_nestjs_agent_core25.agentFailureCode)(error),
|
|
4672
4720
|
message
|
|
4673
4721
|
});
|
|
4674
4722
|
}
|
|
@@ -4676,11 +4724,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4676
4724
|
runId,
|
|
4677
4725
|
status: cancelled ? "cancelled" : "failed",
|
|
4678
4726
|
...cancelled ? {} : {
|
|
4679
|
-
errorCode: (0,
|
|
4727
|
+
errorCode: (0, import_nestjs_agent_core25.agentFailureCode)(error),
|
|
4680
4728
|
errorMessage: message
|
|
4681
4729
|
}
|
|
4682
4730
|
});
|
|
4683
|
-
await (
|
|
4731
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core25.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
4732
|
+
await (0, import_nestjs_agent_core25.settleUnsettledDelegation)({
|
|
4684
4733
|
store: this.store,
|
|
4685
4734
|
delivery: deliverTo,
|
|
4686
4735
|
agent: agentName,
|
|
@@ -4719,7 +4768,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4719
4768
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
4720
4769
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
4721
4770
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
4722
|
-
parallel:
|
|
4771
|
+
parallel: import_nestjs_agent_core25.settleAll,
|
|
4723
4772
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
4724
4773
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
4725
4774
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -4754,7 +4803,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4754
4803
|
}), "startAgent")
|
|
4755
4804
|
};
|
|
4756
4805
|
try {
|
|
4757
|
-
return await (0,
|
|
4806
|
+
return await (0, import_nestjs_agent_core25.runAgentLoop)({
|
|
4758
4807
|
...deps,
|
|
4759
4808
|
day
|
|
4760
4809
|
}, {
|
|
@@ -4774,10 +4823,10 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4774
4823
|
}
|
|
4775
4824
|
};
|
|
4776
4825
|
InlineAgentRunner = _ts_decorate21([
|
|
4777
|
-
(0,
|
|
4778
|
-
_ts_param20(0, (0,
|
|
4779
|
-
_ts_param20(1, (0,
|
|
4780
|
-
_ts_param20(2, (0,
|
|
4826
|
+
(0, import_common22.Injectable)(),
|
|
4827
|
+
_ts_param20(0, (0, import_common22.Inject)(import_nestjs_agent_core25.AGENT_DEPS_FACTORY)),
|
|
4828
|
+
_ts_param20(1, (0, import_common22.Inject)(import_nestjs_agent_core25.AGENT_STORE)),
|
|
4829
|
+
_ts_param20(2, (0, import_common22.Optional)()),
|
|
4781
4830
|
_ts_metadata21("design:type", Function),
|
|
4782
4831
|
_ts_metadata21("design:paramtypes", [
|
|
4783
4832
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
@@ -4791,7 +4840,7 @@ function isThreadTurn(input) {
|
|
|
4791
4840
|
__name(isThreadTurn, "isThreadTurn");
|
|
4792
4841
|
|
|
4793
4842
|
// src/skills-config.ts
|
|
4794
|
-
var
|
|
4843
|
+
var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
|
|
4795
4844
|
function declaredSkillProvider(declared) {
|
|
4796
4845
|
return {
|
|
4797
4846
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -4817,7 +4866,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
4817
4866
|
declaredSkillProvider(declared)
|
|
4818
4867
|
];
|
|
4819
4868
|
return {
|
|
4820
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
4869
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core26.compositeSkillProvider)(providers),
|
|
4821
4870
|
...options.scopes !== void 0 ? {
|
|
4822
4871
|
scopes: options.scopes
|
|
4823
4872
|
} : {},
|
|
@@ -4844,11 +4893,11 @@ function _ts_decorate22(decorators, target, key, desc) {
|
|
|
4844
4893
|
}
|
|
4845
4894
|
__name(_ts_decorate22, "_ts_decorate");
|
|
4846
4895
|
var DEFAULT_PATH = "agent";
|
|
4847
|
-
var logger = new
|
|
4896
|
+
var logger = new import_common23.Logger("AgentModule");
|
|
4848
4897
|
function externalStoreWrapper(modules) {
|
|
4849
4898
|
for (const module2 of modules.values()) {
|
|
4850
4899
|
if (module2.metatype === AgentModule) continue;
|
|
4851
|
-
const wrapper = module2.providers.get(
|
|
4900
|
+
const wrapper = module2.providers.get(import_nestjs_agent_core27.AGENT_STORE);
|
|
4852
4901
|
if (wrapper !== void 0) return wrapper;
|
|
4853
4902
|
}
|
|
4854
4903
|
return void 0;
|
|
@@ -4879,7 +4928,7 @@ function resolveStore(options, modules) {
|
|
|
4879
4928
|
const external = externalStoreWrapper(modules);
|
|
4880
4929
|
if (external !== void 0) return forwardingStore(external);
|
|
4881
4930
|
logger.warn("No `store` configured and no store module imported \u2014 using the in-memory store. Threads are lost on restart and not shared between processes: not for production. Pass `store`, or import a store module (e.g. MikroOrmAgentStoreModule.forFeature()).");
|
|
4882
|
-
return new
|
|
4931
|
+
return new import_nestjs_agent_core27.InMemoryAgentStore();
|
|
4883
4932
|
}
|
|
4884
4933
|
__name(resolveStore, "resolveStore");
|
|
4885
4934
|
function isQuotaProvider(quota) {
|
|
@@ -4895,99 +4944,99 @@ __name(resolveCatalog, "resolveCatalog");
|
|
|
4895
4944
|
function sharedProviders(durable) {
|
|
4896
4945
|
const providers = [
|
|
4897
4946
|
{
|
|
4898
|
-
provide:
|
|
4899
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
4947
|
+
provide: import_nestjs_agent_core27.AGENT_TOOL_REGISTRY,
|
|
4948
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core27.ToolRegistry(), "useFactory")
|
|
4900
4949
|
},
|
|
4901
4950
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
4902
4951
|
{
|
|
4903
|
-
provide:
|
|
4904
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
4952
|
+
provide: import_nestjs_agent_core27.AGENT_REGISTRY,
|
|
4953
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core27.AgentRegistry(), "useFactory")
|
|
4905
4954
|
},
|
|
4906
4955
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
4907
4956
|
{
|
|
4908
|
-
provide:
|
|
4957
|
+
provide: import_nestjs_agent_core27.AGENT_PROMPT_CONTRIBUTORS,
|
|
4909
4958
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
4910
4959
|
},
|
|
4911
4960
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
4912
4961
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
4913
4962
|
{
|
|
4914
|
-
provide:
|
|
4963
|
+
provide: import_nestjs_agent_core27.AGENT_SKILL_SOURCES,
|
|
4915
4964
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
4916
4965
|
},
|
|
4917
4966
|
{
|
|
4918
4967
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
4919
4968
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
4920
4969
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
4921
|
-
provide:
|
|
4970
|
+
provide: import_nestjs_agent_core27.AGENT_SKILLS,
|
|
4922
4971
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
4923
4972
|
inject: [
|
|
4924
|
-
|
|
4925
|
-
|
|
4973
|
+
import_nestjs_agent_core27.AGENT_OPTIONS,
|
|
4974
|
+
import_nestjs_agent_core27.AGENT_SKILL_SOURCES
|
|
4926
4975
|
]
|
|
4927
4976
|
},
|
|
4928
4977
|
{
|
|
4929
4978
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
4930
4979
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
4931
|
-
provide:
|
|
4980
|
+
provide: import_nestjs_agent_core27.AGENT_MEMORY,
|
|
4932
4981
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
4933
4982
|
inject: [
|
|
4934
|
-
|
|
4983
|
+
import_nestjs_agent_core27.AGENT_OPTIONS
|
|
4935
4984
|
]
|
|
4936
4985
|
},
|
|
4937
4986
|
{
|
|
4938
|
-
provide:
|
|
4987
|
+
provide: import_nestjs_agent_core27.AGENT_SINK,
|
|
4939
4988
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
4940
4989
|
inject: [
|
|
4941
|
-
|
|
4990
|
+
import_nestjs_agent_core27.AGENT_OPTIONS
|
|
4942
4991
|
]
|
|
4943
4992
|
},
|
|
4944
4993
|
{
|
|
4945
|
-
provide:
|
|
4946
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
4994
|
+
provide: import_nestjs_agent_core27.AGENT_ROLES_POLICY,
|
|
4995
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core27.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
4947
4996
|
inject: [
|
|
4948
|
-
|
|
4997
|
+
import_nestjs_agent_core27.AGENT_OPTIONS
|
|
4949
4998
|
]
|
|
4950
4999
|
},
|
|
4951
5000
|
{
|
|
4952
|
-
provide:
|
|
5001
|
+
provide: import_nestjs_agent_core27.AGENT_ACTOR_RESOLVER,
|
|
4953
5002
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
4954
5003
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
4955
5004
|
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.");
|
|
4956
5005
|
return new AnonymousActorResolver();
|
|
4957
5006
|
}, "useFactory"),
|
|
4958
5007
|
inject: [
|
|
4959
|
-
|
|
5008
|
+
import_nestjs_agent_core27.AGENT_OPTIONS
|
|
4960
5009
|
]
|
|
4961
5010
|
},
|
|
4962
5011
|
{
|
|
4963
|
-
provide:
|
|
5012
|
+
provide: import_nestjs_agent_core27.AGENT_MODEL,
|
|
4964
5013
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
4965
5014
|
inject: [
|
|
4966
|
-
|
|
5015
|
+
import_nestjs_agent_core27.AGENT_OPTIONS
|
|
4967
5016
|
]
|
|
4968
5017
|
},
|
|
4969
5018
|
{
|
|
4970
5019
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
4971
5020
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
4972
|
-
provide:
|
|
5021
|
+
provide: import_nestjs_agent_core27.AGENT_QUOTA_PROVIDER,
|
|
4973
5022
|
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
|
|
4974
5023
|
warnAt: o.quota.warnAt
|
|
4975
5024
|
} : {}), "useFactory"),
|
|
4976
5025
|
inject: [
|
|
4977
|
-
|
|
4978
|
-
|
|
5026
|
+
import_nestjs_agent_core27.AGENT_OPTIONS,
|
|
5027
|
+
import_nestjs_agent_core27.AGENT_STORE
|
|
4979
5028
|
]
|
|
4980
5029
|
},
|
|
4981
5030
|
{
|
|
4982
|
-
provide:
|
|
5031
|
+
provide: import_nestjs_agent_core27.AGENT_MODEL_CATALOG,
|
|
4983
5032
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
4984
5033
|
inject: [
|
|
4985
|
-
|
|
5034
|
+
import_nestjs_agent_core27.AGENT_OPTIONS
|
|
4986
5035
|
]
|
|
4987
5036
|
},
|
|
4988
5037
|
AgentDepsFactory2,
|
|
4989
5038
|
{
|
|
4990
|
-
provide:
|
|
5039
|
+
provide: import_nestjs_agent_core27.AGENT_DEPS_FACTORY,
|
|
4991
5040
|
useExisting: AgentDepsFactory2
|
|
4992
5041
|
},
|
|
4993
5042
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -5004,21 +5053,21 @@ function sharedProviders(durable) {
|
|
|
5004
5053
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
5005
5054
|
AgentApprovalPortAdapter,
|
|
5006
5055
|
{
|
|
5007
|
-
provide:
|
|
5056
|
+
provide: import_nestjs_agent_core27.AGENT_APPROVAL_PORT,
|
|
5008
5057
|
useExisting: AgentApprovalPortAdapter
|
|
5009
5058
|
}
|
|
5010
5059
|
];
|
|
5011
5060
|
providers.push({
|
|
5012
|
-
provide:
|
|
5061
|
+
provide: import_nestjs_agent_core27.AGENT_STORE,
|
|
5013
5062
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
5014
5063
|
inject: [
|
|
5015
|
-
|
|
5064
|
+
import_nestjs_agent_core27.AGENT_OPTIONS,
|
|
5016
5065
|
import_core4.ModulesContainer
|
|
5017
5066
|
]
|
|
5018
5067
|
});
|
|
5019
5068
|
if (durable) {
|
|
5020
5069
|
providers.push({
|
|
5021
|
-
provide:
|
|
5070
|
+
provide: import_nestjs_agent_core27.AGENT_RUNNER,
|
|
5022
5071
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
5023
5072
|
if (durableRunner === void 0) {
|
|
5024
5073
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -5027,14 +5076,14 @@ function sharedProviders(durable) {
|
|
|
5027
5076
|
}, "useFactory"),
|
|
5028
5077
|
inject: [
|
|
5029
5078
|
{
|
|
5030
|
-
token:
|
|
5079
|
+
token: import_nestjs_agent_core27.AGENT_DURABLE_RUNNER,
|
|
5031
5080
|
optional: true
|
|
5032
5081
|
}
|
|
5033
5082
|
]
|
|
5034
5083
|
});
|
|
5035
5084
|
} else {
|
|
5036
5085
|
providers.push({
|
|
5037
|
-
provide:
|
|
5086
|
+
provide: import_nestjs_agent_core27.AGENT_RUNNER,
|
|
5038
5087
|
useExisting: InlineAgentRunner
|
|
5039
5088
|
});
|
|
5040
5089
|
}
|
|
@@ -5043,25 +5092,25 @@ function sharedProviders(durable) {
|
|
|
5043
5092
|
__name(sharedProviders, "sharedProviders");
|
|
5044
5093
|
function exportsFor() {
|
|
5045
5094
|
return [
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5095
|
+
import_nestjs_agent_core27.AGENT_OPTIONS,
|
|
5096
|
+
import_nestjs_agent_core27.AGENT_TOOL_REGISTRY,
|
|
5097
|
+
import_nestjs_agent_core27.AGENT_REGISTRY,
|
|
5098
|
+
import_nestjs_agent_core27.AGENT_SINK,
|
|
5099
|
+
import_nestjs_agent_core27.AGENT_ROLES_POLICY,
|
|
5100
|
+
import_nestjs_agent_core27.AGENT_ACTOR_RESOLVER,
|
|
5101
|
+
import_nestjs_agent_core27.AGENT_MODEL,
|
|
5102
|
+
import_nestjs_agent_core27.AGENT_STORE,
|
|
5103
|
+
import_nestjs_agent_core27.AGENT_MODEL_CATALOG,
|
|
5104
|
+
import_nestjs_agent_core27.AGENT_QUOTA_PROVIDER,
|
|
5105
|
+
import_nestjs_agent_core27.AGENT_PROMPT_CONTRIBUTORS,
|
|
5106
|
+
import_nestjs_agent_core27.AGENT_SKILLS,
|
|
5107
|
+
import_nestjs_agent_core27.AGENT_MEMORY,
|
|
5108
|
+
import_nestjs_agent_core27.AGENT_DEPS_FACTORY,
|
|
5060
5109
|
AgentDepsFactory2,
|
|
5061
5110
|
AgentService,
|
|
5062
5111
|
ChatQueueService,
|
|
5063
5112
|
InlineAgentRunner,
|
|
5064
|
-
|
|
5113
|
+
import_nestjs_agent_core27.AGENT_APPROVAL_PORT
|
|
5065
5114
|
];
|
|
5066
5115
|
}
|
|
5067
5116
|
__name(exportsFor, "exportsFor");
|
|
@@ -5125,7 +5174,7 @@ var AgentModule = class _AgentModule {
|
|
|
5125
5174
|
controllers: controllersForSurface(options.surface),
|
|
5126
5175
|
providers: [
|
|
5127
5176
|
{
|
|
5128
|
-
provide:
|
|
5177
|
+
provide: import_nestjs_agent_core27.AGENT_OPTIONS,
|
|
5129
5178
|
useValue: options
|
|
5130
5179
|
},
|
|
5131
5180
|
...sharedProviders(options.durable ?? false),
|
|
@@ -5148,7 +5197,7 @@ var AgentModule = class _AgentModule {
|
|
|
5148
5197
|
controllers: controllersForSurface(options.surface),
|
|
5149
5198
|
providers: [
|
|
5150
5199
|
{
|
|
5151
|
-
provide:
|
|
5200
|
+
provide: import_nestjs_agent_core27.AGENT_OPTIONS,
|
|
5152
5201
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
5153
5202
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
5154
5203
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -5170,12 +5219,12 @@ var AgentModule = class _AgentModule {
|
|
|
5170
5219
|
}
|
|
5171
5220
|
};
|
|
5172
5221
|
AgentModule = _ts_decorate22([
|
|
5173
|
-
(0,
|
|
5174
|
-
(0,
|
|
5222
|
+
(0, import_common23.Global)(),
|
|
5223
|
+
(0, import_common23.Module)({})
|
|
5175
5224
|
], AgentModule);
|
|
5176
5225
|
|
|
5177
5226
|
// src/resolver/header-actor-resolver.ts
|
|
5178
|
-
var
|
|
5227
|
+
var import_common24 = require("@nestjs/common");
|
|
5179
5228
|
function readHeader(req, name) {
|
|
5180
5229
|
if (typeof req !== "object" || req === null || !("headers" in req)) return void 0;
|
|
5181
5230
|
const { headers } = req;
|
|
@@ -5191,7 +5240,7 @@ var HeaderActorResolver = class {
|
|
|
5191
5240
|
resolve(req) {
|
|
5192
5241
|
const id = readHeader(req, "x-actor-id");
|
|
5193
5242
|
if (id === void 0 || id.length === 0) {
|
|
5194
|
-
throw new
|
|
5243
|
+
throw new import_common24.UnauthorizedException("HeaderActorResolver: missing x-actor-id header. No default actor is fabricated. Send x-actor-id from a trusted gateway, or configure AgentModule.forRoot({ actorResolver }) with a resolver that reads your authenticated principal.");
|
|
5195
5244
|
}
|
|
5196
5245
|
const roles = (readHeader(req, "x-actor-role") ?? "").split(",").map((role) => role.trim()).filter((role) => role.length > 0);
|
|
5197
5246
|
const tenantRef = readHeader(req, "x-tenant-ref");
|
|
@@ -5206,7 +5255,7 @@ var HeaderActorResolver = class {
|
|
|
5206
5255
|
};
|
|
5207
5256
|
|
|
5208
5257
|
// src/resolver/request-user-actor-resolver.ts
|
|
5209
|
-
var
|
|
5258
|
+
var import_common25 = require("@nestjs/common");
|
|
5210
5259
|
function field(user, ...names) {
|
|
5211
5260
|
for (const name of names) {
|
|
5212
5261
|
const value = user[name];
|
|
@@ -5218,7 +5267,7 @@ __name(field, "field");
|
|
|
5218
5267
|
function defaultRequestUserMapper(user) {
|
|
5219
5268
|
const id = field(user, "id", "sub", "_id", "userId");
|
|
5220
5269
|
if (id === void 0) {
|
|
5221
|
-
throw new
|
|
5270
|
+
throw new import_common25.UnauthorizedException("requestUserActorResolver: req.user has no id/sub/_id/userId \u2014 pass a mapper: requestUserActorResolver((user) => ({ id: \u2026, roles: \u2026 }))");
|
|
5222
5271
|
}
|
|
5223
5272
|
const rawRoles = field(user, "roles", "role");
|
|
5224
5273
|
const roles = Array.isArray(rawRoles) ? rawRoles.map(String) : typeof rawRoles === "string" ? [
|
|
@@ -5239,7 +5288,7 @@ function requestUserActorResolver(map) {
|
|
|
5239
5288
|
async resolve(req) {
|
|
5240
5289
|
const user = typeof req === "object" && req !== null ? req.user : void 0;
|
|
5241
5290
|
if (user === void 0 || user === null || user === false) {
|
|
5242
|
-
throw new
|
|
5291
|
+
throw new import_common25.UnauthorizedException("Sign in to use the agent.");
|
|
5243
5292
|
}
|
|
5244
5293
|
if (map !== void 0) return map(user, req);
|
|
5245
5294
|
return defaultRequestUserMapper(user);
|
|
@@ -5279,6 +5328,7 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
|
|
|
5279
5328
|
MessagesController,
|
|
5280
5329
|
ModelsController,
|
|
5281
5330
|
QueueController,
|
|
5331
|
+
RunNotActiveException,
|
|
5282
5332
|
SKILL_METADATA,
|
|
5283
5333
|
SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
|
|
5284
5334
|
SYSTEM_PROMPT_METADATA,
|