@dudousxd/nestjs-agent 1.6.0 → 1.7.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 +35 -0
- package/dist/{agent-deps.factory-CUyVPsa1.d.cts → agent-deps.factory-CiC5Va9J.d.cts} +7 -1
- package/dist/{agent-deps.factory-CUyVPsa1.d.ts → agent-deps.factory-CiC5Va9J.d.ts} +7 -1
- package/dist/durable/index.cjs +466 -309
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +1 -1
- package/dist/durable/index.d.ts +1 -1
- package/dist/durable/index.js +366 -209
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +468 -312
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -5
- package/dist/index.d.ts +40 -5
- package/dist/index.js +363 -208
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/durable/index.cjs
CHANGED
|
@@ -120,7 +120,10 @@ var AgentRunSteps = class {
|
|
|
120
120
|
system: input.system,
|
|
121
121
|
messages: input.messages,
|
|
122
122
|
tools,
|
|
123
|
-
sink: frames.writer
|
|
123
|
+
sink: frames.writer,
|
|
124
|
+
...input.model !== void 0 ? {
|
|
125
|
+
model: input.model
|
|
126
|
+
} : {}
|
|
124
127
|
})), frames.summary());
|
|
125
128
|
const stamped = (0, import_nestjs_agent_core.stampToolKinds)(turn, deps);
|
|
126
129
|
return buffer === void 0 ? stamped : {
|
|
@@ -818,8 +821,8 @@ AgentDurableModule = _ts_decorate4([
|
|
|
818
821
|
], AgentDurableModule);
|
|
819
822
|
|
|
820
823
|
// src/agent.module.ts
|
|
821
|
-
var
|
|
822
|
-
var
|
|
824
|
+
var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
|
|
825
|
+
var import_common23 = require("@nestjs/common");
|
|
823
826
|
var import_core4 = require("@nestjs/core");
|
|
824
827
|
|
|
825
828
|
// src/agent-deps.factory.ts
|
|
@@ -1125,15 +1128,72 @@ var AgentService = class {
|
|
|
1125
1128
|
deps;
|
|
1126
1129
|
quota;
|
|
1127
1130
|
staging;
|
|
1128
|
-
|
|
1131
|
+
models;
|
|
1132
|
+
constructor(runner, store, deps, quota, staging, models) {
|
|
1129
1133
|
this.runner = runner;
|
|
1130
1134
|
this.store = store;
|
|
1131
1135
|
this.deps = deps;
|
|
1132
1136
|
this.quota = quota;
|
|
1133
1137
|
this.staging = staging;
|
|
1138
|
+
this.models = models;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* The models `actor` may pick for `agent` (`GET <base>/models`). An empty catalog when none is
|
|
1142
|
+
* bound, so a picker simply has nothing to offer.
|
|
1143
|
+
*/
|
|
1144
|
+
async listModels(actor, agent) {
|
|
1145
|
+
if (this.models === void 0) {
|
|
1146
|
+
return {
|
|
1147
|
+
providers: [],
|
|
1148
|
+
default: null
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
return this.models.list({
|
|
1152
|
+
actor,
|
|
1153
|
+
...agent !== void 0 ? {
|
|
1154
|
+
agent
|
|
1155
|
+
} : {}
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* `model` if the catalog offers it to this actor and agent right now, else a 400 naming why. The
|
|
1160
|
+
* one gate every model choice passes — a send's own, and a thread's pinned one at the moment it is
|
|
1161
|
+
* pinned and again at every turn that runs on it (availability can change in between).
|
|
1162
|
+
*/
|
|
1163
|
+
async assertModelAllowed(actor, agent, model) {
|
|
1164
|
+
if (this.models === void 0) {
|
|
1165
|
+
throw new import_common6.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
1166
|
+
}
|
|
1167
|
+
const entry = (0, import_nestjs_agent_core8.findCatalogModel)(await this.models.list({
|
|
1168
|
+
actor,
|
|
1169
|
+
agent
|
|
1170
|
+
}), model);
|
|
1171
|
+
if (entry === void 0) {
|
|
1172
|
+
throw new import_common6.BadRequestException(`model "${model}" is not offered`);
|
|
1173
|
+
}
|
|
1174
|
+
if (!entry.available) {
|
|
1175
|
+
throw new import_common6.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
1176
|
+
}
|
|
1177
|
+
return entry.id;
|
|
1178
|
+
}
|
|
1179
|
+
/** The model a turn runs on: the send's own, else the thread's pinned one, else none. */
|
|
1180
|
+
async resolveModel(actor, agent, requested, threadId) {
|
|
1181
|
+
const model = requested ?? (threadId !== void 0 ? await this.threadModel(threadId) : null);
|
|
1182
|
+
if (model === null || model === void 0) {
|
|
1183
|
+
return void 0;
|
|
1184
|
+
}
|
|
1185
|
+
return this.assertModelAllowed(actor, agent, model);
|
|
1186
|
+
}
|
|
1187
|
+
async threadModel(threadId) {
|
|
1188
|
+
const projecting = this.store;
|
|
1189
|
+
if (typeof projecting.modelForThread === "function") {
|
|
1190
|
+
return projecting.modelForThread(threadId);
|
|
1191
|
+
}
|
|
1192
|
+
return (await this.store.getThread(threadId))?.model ?? null;
|
|
1134
1193
|
}
|
|
1135
1194
|
async chat(params) {
|
|
1136
1195
|
const agentName = await this.resolveAgentName(params.agentName, params.threadId);
|
|
1196
|
+
const model = await this.resolveModel(params.actor, agentName, params.model, params.threadId);
|
|
1137
1197
|
const attachments = await this.resolveAttachments(params.actor, params.attachments ?? []);
|
|
1138
1198
|
let threadId = params.threadId;
|
|
1139
1199
|
if (threadId === void 0) {
|
|
@@ -1164,6 +1224,9 @@ var AgentService = class {
|
|
|
1164
1224
|
} : {},
|
|
1165
1225
|
...params.pageContext !== void 0 ? {
|
|
1166
1226
|
pageContext: params.pageContext
|
|
1227
|
+
} : {},
|
|
1228
|
+
...model !== void 0 ? {
|
|
1229
|
+
model
|
|
1167
1230
|
} : {}
|
|
1168
1231
|
};
|
|
1169
1232
|
const { runId } = await this.runner.start(input);
|
|
@@ -1334,20 +1397,26 @@ var AgentService = class {
|
|
|
1334
1397
|
async updateThread(actor, threadId, patch) {
|
|
1335
1398
|
const title = patch.title !== void 0 ? this.validateTitle(patch.title) : void 0;
|
|
1336
1399
|
await this.assertOwnsThread(actor, threadId);
|
|
1337
|
-
if (patch.defaultAgent === void 0) {
|
|
1400
|
+
if (patch.defaultAgent === void 0 && patch.model === void 0) {
|
|
1338
1401
|
if (title !== void 0) {
|
|
1339
1402
|
await this.store.setTitle(threadId, title);
|
|
1340
1403
|
}
|
|
1341
1404
|
return;
|
|
1342
1405
|
}
|
|
1343
1406
|
if (this.store.updateThread === void 0) {
|
|
1344
|
-
throw new import_common6.NotImplementedException("Setting a thread's defaultAgent requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
1407
|
+
throw new import_common6.NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
1345
1408
|
}
|
|
1409
|
+
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);
|
|
1346
1410
|
await this.store.updateThread(threadId, {
|
|
1347
1411
|
...title !== void 0 ? {
|
|
1348
1412
|
title
|
|
1349
1413
|
} : {},
|
|
1350
|
-
|
|
1414
|
+
...patch.defaultAgent !== void 0 ? {
|
|
1415
|
+
defaultAgent: patch.defaultAgent
|
|
1416
|
+
} : {},
|
|
1417
|
+
...model !== void 0 ? {
|
|
1418
|
+
model
|
|
1419
|
+
} : {}
|
|
1351
1420
|
});
|
|
1352
1421
|
}
|
|
1353
1422
|
validateTitle(title) {
|
|
@@ -1394,6 +1463,7 @@ var AgentService = class {
|
|
|
1394
1463
|
return {
|
|
1395
1464
|
...thread,
|
|
1396
1465
|
defaultAgent: thread.defaultAgent ?? null,
|
|
1466
|
+
model: thread.model ?? null,
|
|
1397
1467
|
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
|
|
1398
1468
|
};
|
|
1399
1469
|
}
|
|
@@ -1661,13 +1731,16 @@ AgentService = _ts_decorate6([
|
|
|
1661
1731
|
_ts_param5(3, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_QUOTA_STORE)),
|
|
1662
1732
|
_ts_param5(4, (0, import_common6.Optional)()),
|
|
1663
1733
|
_ts_param5(4, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_ATTACHMENT_STAGING)),
|
|
1734
|
+
_ts_param5(5, (0, import_common6.Optional)()),
|
|
1735
|
+
_ts_param5(5, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_MODEL_CATALOG)),
|
|
1664
1736
|
_ts_metadata5("design:type", Function),
|
|
1665
1737
|
_ts_metadata5("design:paramtypes", [
|
|
1666
1738
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
1667
1739
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1668
1740
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1669
1741
|
Object,
|
|
1670
|
-
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore
|
|
1742
|
+
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
1743
|
+
typeof ModelCatalog === "undefined" ? Object : ModelCatalog
|
|
1671
1744
|
])
|
|
1672
1745
|
], AgentService);
|
|
1673
1746
|
|
|
@@ -2039,6 +2112,9 @@ var ChatController = class {
|
|
|
2039
2112
|
} : {},
|
|
2040
2113
|
...body.transient === true ? {
|
|
2041
2114
|
transient: true
|
|
2115
|
+
} : {},
|
|
2116
|
+
...typeof body.model === "string" && body.model.length > 0 ? {
|
|
2117
|
+
model: body.model
|
|
2042
2118
|
} : {}
|
|
2043
2119
|
});
|
|
2044
2120
|
await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
|
|
@@ -2403,7 +2479,7 @@ MessagesController = _ts_decorate12([
|
|
|
2403
2479
|
])
|
|
2404
2480
|
], MessagesController);
|
|
2405
2481
|
|
|
2406
|
-
// src/controller/
|
|
2482
|
+
// src/controller/models.controller.ts
|
|
2407
2483
|
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
2408
2484
|
var import_common13 = require("@nestjs/common");
|
|
2409
2485
|
function _ts_decorate13(decorators, target, key, desc) {
|
|
@@ -2432,9 +2508,9 @@ function _ts_param11(paramIndex, decorator) {
|
|
|
2432
2508
|
};
|
|
2433
2509
|
}
|
|
2434
2510
|
__name(_ts_param11, "_ts_param");
|
|
2435
|
-
var
|
|
2511
|
+
var ModelsController = class {
|
|
2436
2512
|
static {
|
|
2437
|
-
__name(this, "
|
|
2513
|
+
__name(this, "ModelsController");
|
|
2438
2514
|
}
|
|
2439
2515
|
agent;
|
|
2440
2516
|
actorResolver;
|
|
@@ -2442,31 +2518,37 @@ var QuotaController = class {
|
|
|
2442
2518
|
this.agent = agent;
|
|
2443
2519
|
this.actorResolver = actorResolver;
|
|
2444
2520
|
}
|
|
2445
|
-
|
|
2521
|
+
/**
|
|
2522
|
+
* The models the caller may pick for `agent` (the default agent when omitted), grouped by
|
|
2523
|
+
* provider, with badges and availability — the bound `ModelCatalog`'s answer, or an empty one.
|
|
2524
|
+
*/
|
|
2525
|
+
async list(req, agent) {
|
|
2446
2526
|
const actor = await this.actorResolver.resolve(req);
|
|
2447
|
-
return this.agent.
|
|
2527
|
+
return this.agent.listModels(actor, agent);
|
|
2448
2528
|
}
|
|
2449
2529
|
};
|
|
2450
2530
|
_ts_decorate13([
|
|
2451
|
-
(0, import_common13.Get)(
|
|
2531
|
+
(0, import_common13.Get)(),
|
|
2452
2532
|
_ts_param11(0, (0, import_common13.Req)()),
|
|
2533
|
+
_ts_param11(1, (0, import_common13.Query)("agent")),
|
|
2453
2534
|
_ts_metadata12("design:type", Function),
|
|
2454
2535
|
_ts_metadata12("design:paramtypes", [
|
|
2455
|
-
typeof Request === "undefined" ? Object : Request
|
|
2536
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2537
|
+
String
|
|
2456
2538
|
]),
|
|
2457
2539
|
_ts_metadata12("design:returntype", Promise)
|
|
2458
|
-
],
|
|
2459
|
-
|
|
2460
|
-
(0, import_common13.Controller)("
|
|
2540
|
+
], ModelsController.prototype, "list", null);
|
|
2541
|
+
ModelsController = _ts_decorate13([
|
|
2542
|
+
(0, import_common13.Controller)("models"),
|
|
2461
2543
|
_ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
|
|
2462
2544
|
_ts_metadata12("design:type", Function),
|
|
2463
2545
|
_ts_metadata12("design:paramtypes", [
|
|
2464
2546
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2465
2547
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2466
2548
|
])
|
|
2467
|
-
],
|
|
2549
|
+
], ModelsController);
|
|
2468
2550
|
|
|
2469
|
-
// src/controller/
|
|
2551
|
+
// src/controller/quota.controller.ts
|
|
2470
2552
|
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
2471
2553
|
var import_common14 = require("@nestjs/common");
|
|
2472
2554
|
function _ts_decorate14(decorators, target, key, desc) {
|
|
@@ -2495,6 +2577,69 @@ function _ts_param12(paramIndex, decorator) {
|
|
|
2495
2577
|
};
|
|
2496
2578
|
}
|
|
2497
2579
|
__name(_ts_param12, "_ts_param");
|
|
2580
|
+
var QuotaController = class {
|
|
2581
|
+
static {
|
|
2582
|
+
__name(this, "QuotaController");
|
|
2583
|
+
}
|
|
2584
|
+
agent;
|
|
2585
|
+
actorResolver;
|
|
2586
|
+
constructor(agent, actorResolver) {
|
|
2587
|
+
this.agent = agent;
|
|
2588
|
+
this.actorResolver = actorResolver;
|
|
2589
|
+
}
|
|
2590
|
+
async today(req) {
|
|
2591
|
+
const actor = await this.actorResolver.resolve(req);
|
|
2592
|
+
return this.agent.quotaToday(actor.id);
|
|
2593
|
+
}
|
|
2594
|
+
};
|
|
2595
|
+
_ts_decorate14([
|
|
2596
|
+
(0, import_common14.Get)("today"),
|
|
2597
|
+
_ts_param12(0, (0, import_common14.Req)()),
|
|
2598
|
+
_ts_metadata13("design:type", Function),
|
|
2599
|
+
_ts_metadata13("design:paramtypes", [
|
|
2600
|
+
typeof Request === "undefined" ? Object : Request
|
|
2601
|
+
]),
|
|
2602
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2603
|
+
], QuotaController.prototype, "today", null);
|
|
2604
|
+
QuotaController = _ts_decorate14([
|
|
2605
|
+
(0, import_common14.Controller)("quota"),
|
|
2606
|
+
_ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
|
|
2607
|
+
_ts_metadata13("design:type", Function),
|
|
2608
|
+
_ts_metadata13("design:paramtypes", [
|
|
2609
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2610
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2611
|
+
])
|
|
2612
|
+
], QuotaController);
|
|
2613
|
+
|
|
2614
|
+
// src/controller/skills.controller.ts
|
|
2615
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
2616
|
+
var import_common15 = require("@nestjs/common");
|
|
2617
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2618
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2619
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2620
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2621
|
+
} else {
|
|
2622
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2623
|
+
if (d = decorators[i]) {
|
|
2624
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2629
|
+
}
|
|
2630
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2631
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2632
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2633
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2637
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2638
|
+
return function(target, key) {
|
|
2639
|
+
decorator(target, key, paramIndex);
|
|
2640
|
+
};
|
|
2641
|
+
}
|
|
2642
|
+
__name(_ts_param13, "_ts_param");
|
|
2498
2643
|
var SkillsController = class {
|
|
2499
2644
|
static {
|
|
2500
2645
|
__name(this, "SkillsController");
|
|
@@ -2510,40 +2655,40 @@ var SkillsController = class {
|
|
|
2510
2655
|
return [];
|
|
2511
2656
|
}
|
|
2512
2657
|
const actor = await this.actorResolver.resolve(req);
|
|
2513
|
-
const offer = await (0,
|
|
2658
|
+
const offer = await (0, import_nestjs_agent_core16.offerSkills)(this.skills, {
|
|
2514
2659
|
actor,
|
|
2515
2660
|
threadId: threadId ?? ""
|
|
2516
2661
|
});
|
|
2517
2662
|
return offer.entries;
|
|
2518
2663
|
}
|
|
2519
2664
|
};
|
|
2520
|
-
|
|
2521
|
-
(0,
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2665
|
+
_ts_decorate15([
|
|
2666
|
+
(0, import_common15.Get)(),
|
|
2667
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
2668
|
+
_ts_param13(1, (0, import_common15.Query)("threadId")),
|
|
2669
|
+
_ts_metadata14("design:type", Function),
|
|
2670
|
+
_ts_metadata14("design:paramtypes", [
|
|
2526
2671
|
typeof Request === "undefined" ? Object : Request,
|
|
2527
2672
|
String
|
|
2528
2673
|
]),
|
|
2529
|
-
|
|
2674
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2530
2675
|
], SkillsController.prototype, "list", null);
|
|
2531
|
-
SkillsController =
|
|
2532
|
-
(0,
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2676
|
+
SkillsController = _ts_decorate15([
|
|
2677
|
+
(0, import_common15.Controller)("skills"),
|
|
2678
|
+
_ts_param13(0, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
|
|
2679
|
+
_ts_param13(1, (0, import_common15.Optional)()),
|
|
2680
|
+
_ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_SKILLS)),
|
|
2681
|
+
_ts_metadata14("design:type", Function),
|
|
2682
|
+
_ts_metadata14("design:paramtypes", [
|
|
2538
2683
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2539
2684
|
Object
|
|
2540
2685
|
])
|
|
2541
2686
|
], SkillsController);
|
|
2542
2687
|
|
|
2543
2688
|
// src/controller/threads.controller.ts
|
|
2544
|
-
var
|
|
2545
|
-
var
|
|
2546
|
-
function
|
|
2689
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
2690
|
+
var import_common16 = require("@nestjs/common");
|
|
2691
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2547
2692
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2548
2693
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2549
2694
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2556,19 +2701,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2556
2701
|
}
|
|
2557
2702
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2558
2703
|
}
|
|
2559
|
-
__name(
|
|
2560
|
-
function
|
|
2704
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2705
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2561
2706
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2562
2707
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2563
2708
|
}
|
|
2564
2709
|
}
|
|
2565
|
-
__name(
|
|
2566
|
-
function
|
|
2710
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2711
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2567
2712
|
return function(target, key) {
|
|
2568
2713
|
decorator(target, key, paramIndex);
|
|
2569
2714
|
};
|
|
2570
2715
|
}
|
|
2571
|
-
__name(
|
|
2716
|
+
__name(_ts_param14, "_ts_param");
|
|
2572
2717
|
var ThreadsController = class {
|
|
2573
2718
|
static {
|
|
2574
2719
|
__name(this, "ThreadsController");
|
|
@@ -2611,6 +2756,9 @@ var ThreadsController = class {
|
|
|
2611
2756
|
} : {},
|
|
2612
2757
|
..."defaultAgent" in body ? {
|
|
2613
2758
|
defaultAgent: body.defaultAgent ?? null
|
|
2759
|
+
} : {},
|
|
2760
|
+
..."model" in body ? {
|
|
2761
|
+
model: body.model ?? null
|
|
2614
2762
|
} : {}
|
|
2615
2763
|
});
|
|
2616
2764
|
return {
|
|
@@ -2632,101 +2780,101 @@ var ThreadsController = class {
|
|
|
2632
2780
|
};
|
|
2633
2781
|
}
|
|
2634
2782
|
};
|
|
2635
|
-
|
|
2636
|
-
(0,
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2783
|
+
_ts_decorate16([
|
|
2784
|
+
(0, import_common16.Get)(),
|
|
2785
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2786
|
+
_ts_metadata15("design:type", Function),
|
|
2787
|
+
_ts_metadata15("design:paramtypes", [
|
|
2640
2788
|
typeof Request === "undefined" ? Object : Request
|
|
2641
2789
|
]),
|
|
2642
|
-
|
|
2790
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2643
2791
|
], ThreadsController.prototype, "list", null);
|
|
2644
|
-
|
|
2645
|
-
(0,
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2792
|
+
_ts_decorate16([
|
|
2793
|
+
(0, import_common16.Get)(":id"),
|
|
2794
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2795
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2796
|
+
_ts_metadata15("design:type", Function),
|
|
2797
|
+
_ts_metadata15("design:paramtypes", [
|
|
2650
2798
|
typeof Request === "undefined" ? Object : Request,
|
|
2651
2799
|
String
|
|
2652
2800
|
]),
|
|
2653
|
-
|
|
2801
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2654
2802
|
], ThreadsController.prototype, "detail", null);
|
|
2655
|
-
|
|
2656
|
-
(0,
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2803
|
+
_ts_decorate16([
|
|
2804
|
+
(0, import_common16.Delete)(":id"),
|
|
2805
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2806
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2807
|
+
_ts_metadata15("design:type", Function),
|
|
2808
|
+
_ts_metadata15("design:paramtypes", [
|
|
2661
2809
|
typeof Request === "undefined" ? Object : Request,
|
|
2662
2810
|
String
|
|
2663
2811
|
]),
|
|
2664
|
-
|
|
2812
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2665
2813
|
], ThreadsController.prototype, "remove", null);
|
|
2666
|
-
|
|
2667
|
-
(0,
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2814
|
+
_ts_decorate16([
|
|
2815
|
+
(0, import_common16.Post)(":id/fork-from/:messageId"),
|
|
2816
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2817
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2818
|
+
_ts_param14(2, (0, import_common16.Param)("messageId")),
|
|
2819
|
+
_ts_metadata15("design:type", Function),
|
|
2820
|
+
_ts_metadata15("design:paramtypes", [
|
|
2673
2821
|
typeof Request === "undefined" ? Object : Request,
|
|
2674
2822
|
String,
|
|
2675
2823
|
String
|
|
2676
2824
|
]),
|
|
2677
|
-
|
|
2825
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2678
2826
|
], ThreadsController.prototype, "fork", null);
|
|
2679
|
-
|
|
2680
|
-
(0,
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2827
|
+
_ts_decorate16([
|
|
2828
|
+
(0, import_common16.Patch)(":id"),
|
|
2829
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2830
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2831
|
+
_ts_param14(2, (0, import_common16.Body)()),
|
|
2832
|
+
_ts_metadata15("design:type", Function),
|
|
2833
|
+
_ts_metadata15("design:paramtypes", [
|
|
2686
2834
|
typeof Request === "undefined" ? Object : Request,
|
|
2687
2835
|
String,
|
|
2688
2836
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
2689
2837
|
]),
|
|
2690
|
-
|
|
2838
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2691
2839
|
], ThreadsController.prototype, "update", null);
|
|
2692
|
-
|
|
2693
|
-
(0,
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2840
|
+
_ts_decorate16([
|
|
2841
|
+
(0, import_common16.Post)(":id/promote"),
|
|
2842
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2843
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2844
|
+
_ts_metadata15("design:type", Function),
|
|
2845
|
+
_ts_metadata15("design:paramtypes", [
|
|
2698
2846
|
typeof Request === "undefined" ? Object : Request,
|
|
2699
2847
|
String
|
|
2700
2848
|
]),
|
|
2701
|
-
|
|
2849
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2702
2850
|
], ThreadsController.prototype, "promote", null);
|
|
2703
|
-
|
|
2704
|
-
(0,
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2851
|
+
_ts_decorate16([
|
|
2852
|
+
(0, import_common16.Delete)(":id/from/:messageId"),
|
|
2853
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2854
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2855
|
+
_ts_param14(2, (0, import_common16.Param)("messageId")),
|
|
2856
|
+
_ts_metadata15("design:type", Function),
|
|
2857
|
+
_ts_metadata15("design:paramtypes", [
|
|
2710
2858
|
typeof Request === "undefined" ? Object : Request,
|
|
2711
2859
|
String,
|
|
2712
2860
|
String
|
|
2713
2861
|
]),
|
|
2714
|
-
|
|
2862
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2715
2863
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
2716
|
-
ThreadsController =
|
|
2717
|
-
(0,
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2864
|
+
ThreadsController = _ts_decorate16([
|
|
2865
|
+
(0, import_common16.Controller)("threads"),
|
|
2866
|
+
_ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
|
|
2867
|
+
_ts_metadata15("design:type", Function),
|
|
2868
|
+
_ts_metadata15("design:paramtypes", [
|
|
2721
2869
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2722
2870
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2723
2871
|
])
|
|
2724
2872
|
], ThreadsController);
|
|
2725
2873
|
|
|
2726
2874
|
// src/controller/tool-call.controller.ts
|
|
2727
|
-
var
|
|
2728
|
-
var
|
|
2729
|
-
function
|
|
2875
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
2876
|
+
var import_common17 = require("@nestjs/common");
|
|
2877
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2730
2878
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2731
2879
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2732
2880
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2739,19 +2887,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2739
2887
|
}
|
|
2740
2888
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2741
2889
|
}
|
|
2742
|
-
__name(
|
|
2743
|
-
function
|
|
2890
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2891
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2744
2892
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2745
2893
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2746
2894
|
}
|
|
2747
2895
|
}
|
|
2748
|
-
__name(
|
|
2749
|
-
function
|
|
2896
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2897
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2750
2898
|
return function(target, key) {
|
|
2751
2899
|
decorator(target, key, paramIndex);
|
|
2752
2900
|
};
|
|
2753
2901
|
}
|
|
2754
|
-
__name(
|
|
2902
|
+
__name(_ts_param15, "_ts_param");
|
|
2755
2903
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
2756
2904
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
2757
2905
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -2760,7 +2908,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
2760
2908
|
var DEFAULT_VIA = "web";
|
|
2761
2909
|
function toolCallId(claimed) {
|
|
2762
2910
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
2763
|
-
throw new
|
|
2911
|
+
throw new import_common17.BadRequestException("toolCallId must be a non-empty string");
|
|
2764
2912
|
}
|
|
2765
2913
|
return claimed;
|
|
2766
2914
|
}
|
|
@@ -2770,10 +2918,10 @@ function rejectReason(claimed) {
|
|
|
2770
2918
|
return void 0;
|
|
2771
2919
|
}
|
|
2772
2920
|
if (typeof claimed !== "string") {
|
|
2773
|
-
throw new
|
|
2921
|
+
throw new import_common17.BadRequestException("reason must be a string");
|
|
2774
2922
|
}
|
|
2775
2923
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
2776
|
-
throw new
|
|
2924
|
+
throw new import_common17.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
2777
2925
|
}
|
|
2778
2926
|
return claimed;
|
|
2779
2927
|
}
|
|
@@ -2783,7 +2931,7 @@ function remember(claimed) {
|
|
|
2783
2931
|
return false;
|
|
2784
2932
|
}
|
|
2785
2933
|
if (typeof claimed !== "boolean") {
|
|
2786
|
-
throw new
|
|
2934
|
+
throw new import_common17.BadRequestException("remember must be a boolean");
|
|
2787
2935
|
}
|
|
2788
2936
|
return claimed;
|
|
2789
2937
|
}
|
|
@@ -2793,7 +2941,7 @@ function via(claimed) {
|
|
|
2793
2941
|
return DEFAULT_VIA;
|
|
2794
2942
|
}
|
|
2795
2943
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
2796
|
-
throw new
|
|
2944
|
+
throw new import_common17.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
2797
2945
|
}
|
|
2798
2946
|
return claimed;
|
|
2799
2947
|
}
|
|
@@ -2803,26 +2951,26 @@ function answers(claimed) {
|
|
|
2803
2951
|
return void 0;
|
|
2804
2952
|
}
|
|
2805
2953
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
2806
|
-
throw new
|
|
2954
|
+
throw new import_common17.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
2807
2955
|
}
|
|
2808
2956
|
const entries = Object.entries(claimed);
|
|
2809
2957
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
2810
|
-
throw new
|
|
2958
|
+
throw new import_common17.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
2811
2959
|
}
|
|
2812
2960
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
2813
2961
|
for (const [questionId, values] of entries) {
|
|
2814
2962
|
if (!Array.isArray(values)) {
|
|
2815
|
-
throw new
|
|
2963
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
2816
2964
|
}
|
|
2817
2965
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
2818
|
-
throw new
|
|
2966
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
2819
2967
|
}
|
|
2820
2968
|
for (const value of values) {
|
|
2821
2969
|
if (typeof value !== "string") {
|
|
2822
|
-
throw new
|
|
2970
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
2823
2971
|
}
|
|
2824
2972
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
2825
|
-
throw new
|
|
2973
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
2826
2974
|
}
|
|
2827
2975
|
}
|
|
2828
2976
|
validated[questionId] = values;
|
|
@@ -2880,64 +3028,64 @@ var ToolCallController = class {
|
|
|
2880
3028
|
};
|
|
2881
3029
|
}
|
|
2882
3030
|
};
|
|
2883
|
-
|
|
2884
|
-
(0,
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
3031
|
+
_ts_decorate17([
|
|
3032
|
+
(0, import_common17.Post)("approve"),
|
|
3033
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3034
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3035
|
+
_ts_metadata16("design:type", Function),
|
|
3036
|
+
_ts_metadata16("design:paramtypes", [
|
|
2889
3037
|
typeof Request === "undefined" ? Object : Request,
|
|
2890
3038
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
2891
3039
|
]),
|
|
2892
|
-
|
|
3040
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2893
3041
|
], ToolCallController.prototype, "approve", null);
|
|
2894
|
-
|
|
2895
|
-
(0,
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
3042
|
+
_ts_decorate17([
|
|
3043
|
+
(0, import_common17.Post)("reject"),
|
|
3044
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3045
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3046
|
+
_ts_metadata16("design:type", Function),
|
|
3047
|
+
_ts_metadata16("design:paramtypes", [
|
|
2900
3048
|
typeof Request === "undefined" ? Object : Request,
|
|
2901
3049
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
2902
3050
|
]),
|
|
2903
|
-
|
|
3051
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2904
3052
|
], ToolCallController.prototype, "reject", null);
|
|
2905
|
-
|
|
2906
|
-
(0,
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
3053
|
+
_ts_decorate17([
|
|
3054
|
+
(0, import_common17.Post)("answer"),
|
|
3055
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3056
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3057
|
+
_ts_metadata16("design:type", Function),
|
|
3058
|
+
_ts_metadata16("design:paramtypes", [
|
|
2911
3059
|
typeof Request === "undefined" ? Object : Request,
|
|
2912
3060
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
2913
3061
|
]),
|
|
2914
|
-
|
|
3062
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2915
3063
|
], ToolCallController.prototype, "answer", null);
|
|
2916
|
-
|
|
2917
|
-
(0,
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
3064
|
+
_ts_decorate17([
|
|
3065
|
+
(0, import_common17.Post)("skip"),
|
|
3066
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3067
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3068
|
+
_ts_metadata16("design:type", Function),
|
|
3069
|
+
_ts_metadata16("design:paramtypes", [
|
|
2922
3070
|
typeof Request === "undefined" ? Object : Request,
|
|
2923
3071
|
Object
|
|
2924
3072
|
]),
|
|
2925
|
-
|
|
3073
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2926
3074
|
], ToolCallController.prototype, "skip", null);
|
|
2927
|
-
ToolCallController =
|
|
2928
|
-
(0,
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
3075
|
+
ToolCallController = _ts_decorate17([
|
|
3076
|
+
(0, import_common17.Controller)("tool-call"),
|
|
3077
|
+
_ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
3078
|
+
_ts_metadata16("design:type", Function),
|
|
3079
|
+
_ts_metadata16("design:paramtypes", [
|
|
2932
3080
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2933
3081
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2934
3082
|
])
|
|
2935
3083
|
], ToolCallController);
|
|
2936
3084
|
|
|
2937
3085
|
// src/controller/tools.controller.ts
|
|
2938
|
-
var
|
|
2939
|
-
var
|
|
2940
|
-
function
|
|
3086
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
3087
|
+
var import_common18 = require("@nestjs/common");
|
|
3088
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2941
3089
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2942
3090
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2943
3091
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2950,19 +3098,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
2950
3098
|
}
|
|
2951
3099
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2952
3100
|
}
|
|
2953
|
-
__name(
|
|
2954
|
-
function
|
|
3101
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3102
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2955
3103
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2956
3104
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2957
3105
|
}
|
|
2958
3106
|
}
|
|
2959
|
-
__name(
|
|
2960
|
-
function
|
|
3107
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
3108
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2961
3109
|
return function(target, key) {
|
|
2962
3110
|
decorator(target, key, paramIndex);
|
|
2963
3111
|
};
|
|
2964
3112
|
}
|
|
2965
|
-
__name(
|
|
3113
|
+
__name(_ts_param16, "_ts_param");
|
|
2966
3114
|
var ToolsController = class {
|
|
2967
3115
|
static {
|
|
2968
3116
|
__name(this, "ToolsController");
|
|
@@ -2977,7 +3125,7 @@ var ToolsController = class {
|
|
|
2977
3125
|
}
|
|
2978
3126
|
async list(req, agent) {
|
|
2979
3127
|
if (agent !== void 0 && this.agents.get(agent) === void 0) {
|
|
2980
|
-
throw new
|
|
3128
|
+
throw new import_common18.NotFoundException(`No agent named "${agent}"`);
|
|
2981
3129
|
}
|
|
2982
3130
|
const actor = await this.actorResolver.resolve(req);
|
|
2983
3131
|
const deps = this.depsFactory.forAgent(agent);
|
|
@@ -2991,33 +3139,33 @@ var ToolsController = class {
|
|
|
2991
3139
|
}));
|
|
2992
3140
|
}
|
|
2993
3141
|
};
|
|
2994
|
-
|
|
2995
|
-
(0,
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3142
|
+
_ts_decorate18([
|
|
3143
|
+
(0, import_common18.Get)(),
|
|
3144
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
3145
|
+
_ts_param16(1, (0, import_common18.Query)("agent")),
|
|
3146
|
+
_ts_metadata17("design:type", Function),
|
|
3147
|
+
_ts_metadata17("design:paramtypes", [
|
|
3000
3148
|
typeof Request === "undefined" ? Object : Request,
|
|
3001
3149
|
String
|
|
3002
3150
|
]),
|
|
3003
|
-
|
|
3151
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3004
3152
|
], ToolsController.prototype, "list", null);
|
|
3005
|
-
ToolsController =
|
|
3006
|
-
(0,
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3153
|
+
ToolsController = _ts_decorate18([
|
|
3154
|
+
(0, import_common18.Controller)("tools"),
|
|
3155
|
+
_ts_param16(0, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
|
|
3156
|
+
_ts_param16(1, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_DEPS_FACTORY)),
|
|
3157
|
+
_ts_param16(2, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_REGISTRY)),
|
|
3158
|
+
_ts_metadata17("design:type", Function),
|
|
3159
|
+
_ts_metadata17("design:paramtypes", [
|
|
3012
3160
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3013
3161
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3014
|
-
typeof
|
|
3162
|
+
typeof import_nestjs_agent_core19.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core19.AgentRegistry
|
|
3015
3163
|
])
|
|
3016
3164
|
], ToolsController);
|
|
3017
3165
|
|
|
3018
3166
|
// src/discovery/agent-discovery.service.ts
|
|
3019
|
-
var
|
|
3020
|
-
var
|
|
3167
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
3168
|
+
var import_common19 = require("@nestjs/common");
|
|
3021
3169
|
var import_core = require("@nestjs/core");
|
|
3022
3170
|
|
|
3023
3171
|
// src/decorator/agent.decorator.ts
|
|
@@ -3034,7 +3182,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
|
|
|
3034
3182
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
3035
3183
|
|
|
3036
3184
|
// src/discovery/agent-discovery.service.ts
|
|
3037
|
-
function
|
|
3185
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3038
3186
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3039
3187
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3040
3188
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3047,19 +3195,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3047
3195
|
}
|
|
3048
3196
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3049
3197
|
}
|
|
3050
|
-
__name(
|
|
3051
|
-
function
|
|
3198
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3199
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
3052
3200
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3053
3201
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3054
3202
|
}
|
|
3055
3203
|
}
|
|
3056
|
-
__name(
|
|
3057
|
-
function
|
|
3204
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3205
|
+
function _ts_param17(paramIndex, decorator) {
|
|
3058
3206
|
return function(target, key) {
|
|
3059
3207
|
decorator(target, key, paramIndex);
|
|
3060
3208
|
};
|
|
3061
3209
|
}
|
|
3062
|
-
__name(
|
|
3210
|
+
__name(_ts_param17, "_ts_param");
|
|
3063
3211
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
3064
3212
|
static {
|
|
3065
3213
|
__name(this, "AgentDiscoveryService");
|
|
@@ -3068,7 +3216,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
3068
3216
|
scanner;
|
|
3069
3217
|
registry;
|
|
3070
3218
|
contributors;
|
|
3071
|
-
logger = new
|
|
3219
|
+
logger = new import_common19.Logger(_AgentDiscoveryService.name);
|
|
3072
3220
|
constructor(discovery, scanner, registry, contributors) {
|
|
3073
3221
|
this.discovery = discovery;
|
|
3074
3222
|
this.scanner = scanner;
|
|
@@ -3186,22 +3334,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
3186
3334
|
return (ctx) => candidate.call(instance, ctx);
|
|
3187
3335
|
}
|
|
3188
3336
|
};
|
|
3189
|
-
AgentDiscoveryService =
|
|
3190
|
-
(0,
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3337
|
+
AgentDiscoveryService = _ts_decorate19([
|
|
3338
|
+
(0, import_common19.Injectable)(),
|
|
3339
|
+
_ts_param17(2, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_REGISTRY)),
|
|
3340
|
+
_ts_param17(3, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_PROMPT_CONTRIBUTORS)),
|
|
3341
|
+
_ts_metadata18("design:type", Function),
|
|
3342
|
+
_ts_metadata18("design:paramtypes", [
|
|
3195
3343
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
3196
3344
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
3197
|
-
typeof
|
|
3345
|
+
typeof import_nestjs_agent_core20.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core20.AgentRegistry,
|
|
3198
3346
|
Array
|
|
3199
3347
|
])
|
|
3200
3348
|
], AgentDiscoveryService);
|
|
3201
3349
|
|
|
3202
3350
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3203
|
-
var
|
|
3204
|
-
var
|
|
3351
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
3352
|
+
var import_common20 = require("@nestjs/common");
|
|
3205
3353
|
var import_core2 = require("@nestjs/core");
|
|
3206
3354
|
var import_zod = require("zod");
|
|
3207
3355
|
|
|
@@ -3221,7 +3369,7 @@ function isBrandedFunctionalTool(value) {
|
|
|
3221
3369
|
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
3222
3370
|
|
|
3223
3371
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3224
|
-
function
|
|
3372
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3225
3373
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3226
3374
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3227
3375
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3234,19 +3382,19 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
3234
3382
|
}
|
|
3235
3383
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3236
3384
|
}
|
|
3237
|
-
__name(
|
|
3238
|
-
function
|
|
3385
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3386
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3239
3387
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3240
3388
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3241
3389
|
}
|
|
3242
3390
|
}
|
|
3243
|
-
__name(
|
|
3244
|
-
function
|
|
3391
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3392
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3245
3393
|
return function(target, key) {
|
|
3246
3394
|
decorator(target, key, paramIndex);
|
|
3247
3395
|
};
|
|
3248
3396
|
}
|
|
3249
|
-
__name(
|
|
3397
|
+
__name(_ts_param18, "_ts_param");
|
|
3250
3398
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
3251
3399
|
static {
|
|
3252
3400
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -3255,7 +3403,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3255
3403
|
registry;
|
|
3256
3404
|
agents;
|
|
3257
3405
|
options;
|
|
3258
|
-
logger = new
|
|
3406
|
+
logger = new import_common20.Logger(_AiToolDiscoveryService.name);
|
|
3259
3407
|
constructor(discovery, registry, agents, options) {
|
|
3260
3408
|
this.discovery = discovery;
|
|
3261
3409
|
this.registry = registry;
|
|
@@ -3329,7 +3477,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3329
3477
|
let delegates = 0;
|
|
3330
3478
|
for (const definition of this.agents.list()) {
|
|
3331
3479
|
for (const edge of definition.delegatesTo ?? []) {
|
|
3332
|
-
const { agent: target, detached } = (0,
|
|
3480
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core21.normalizeDelegation)(edge);
|
|
3333
3481
|
const targetDefinition = this.agents.get(target);
|
|
3334
3482
|
if (targetDefinition === void 0) {
|
|
3335
3483
|
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.`);
|
|
@@ -3379,13 +3527,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3379
3527
|
return true;
|
|
3380
3528
|
}
|
|
3381
3529
|
};
|
|
3382
|
-
AiToolDiscoveryService =
|
|
3383
|
-
(0,
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3530
|
+
AiToolDiscoveryService = _ts_decorate20([
|
|
3531
|
+
(0, import_common20.Injectable)(),
|
|
3532
|
+
_ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_TOOL_REGISTRY)),
|
|
3533
|
+
_ts_param18(2, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_REGISTRY)),
|
|
3534
|
+
_ts_param18(3, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_OPTIONS)),
|
|
3535
|
+
_ts_metadata19("design:type", Function),
|
|
3536
|
+
_ts_metadata19("design:paramtypes", [
|
|
3389
3537
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
3390
3538
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
3391
3539
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -3394,25 +3542,25 @@ AiToolDiscoveryService = _ts_decorate19([
|
|
|
3394
3542
|
], AiToolDiscoveryService);
|
|
3395
3543
|
|
|
3396
3544
|
// src/discovery/skill-discovery.service.ts
|
|
3397
|
-
var
|
|
3398
|
-
var
|
|
3545
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
3546
|
+
var import_common21 = require("@nestjs/common");
|
|
3399
3547
|
var import_core3 = require("@nestjs/core");
|
|
3400
3548
|
|
|
3401
3549
|
// src/decorator/skill.decorator.ts
|
|
3402
3550
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
3403
|
-
var
|
|
3551
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
3404
3552
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
3405
3553
|
function readSkillMetadata(target) {
|
|
3406
3554
|
return Reflect.getMetadata(SKILL_METADATA, target);
|
|
3407
3555
|
}
|
|
3408
3556
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
3409
3557
|
function skillScope(options) {
|
|
3410
|
-
return options.scope ??
|
|
3558
|
+
return options.scope ?? import_nestjs_agent_core22.GLOBAL_SCOPE;
|
|
3411
3559
|
}
|
|
3412
3560
|
__name(skillScope, "skillScope");
|
|
3413
3561
|
|
|
3414
3562
|
// src/discovery/skill-discovery.service.ts
|
|
3415
|
-
function
|
|
3563
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
3416
3564
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3417
3565
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3418
3566
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3425,26 +3573,26 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
3425
3573
|
}
|
|
3426
3574
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3427
3575
|
}
|
|
3428
|
-
__name(
|
|
3429
|
-
function
|
|
3576
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3577
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
3430
3578
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3431
3579
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3432
3580
|
}
|
|
3433
3581
|
}
|
|
3434
|
-
__name(
|
|
3435
|
-
function
|
|
3582
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
3583
|
+
function _ts_param19(paramIndex, decorator) {
|
|
3436
3584
|
return function(target, key) {
|
|
3437
3585
|
decorator(target, key, paramIndex);
|
|
3438
3586
|
};
|
|
3439
3587
|
}
|
|
3440
|
-
__name(
|
|
3588
|
+
__name(_ts_param19, "_ts_param");
|
|
3441
3589
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
3442
3590
|
static {
|
|
3443
3591
|
__name(this, "SkillDiscoveryService");
|
|
3444
3592
|
}
|
|
3445
3593
|
discovery;
|
|
3446
3594
|
declared;
|
|
3447
|
-
logger = new
|
|
3595
|
+
logger = new import_common21.Logger(_SkillDiscoveryService.name);
|
|
3448
3596
|
constructor(discovery, declared) {
|
|
3449
3597
|
this.discovery = discovery;
|
|
3450
3598
|
this.declared = declared;
|
|
@@ -3481,11 +3629,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
3481
3629
|
return flat === void 0 ? void 0 : () => flat;
|
|
3482
3630
|
}
|
|
3483
3631
|
};
|
|
3484
|
-
SkillDiscoveryService =
|
|
3485
|
-
(0,
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3632
|
+
SkillDiscoveryService = _ts_decorate21([
|
|
3633
|
+
(0, import_common21.Injectable)(),
|
|
3634
|
+
_ts_param19(1, (0, import_common21.Inject)(import_nestjs_agent_core23.AGENT_SKILL_SOURCES)),
|
|
3635
|
+
_ts_metadata20("design:type", Function),
|
|
3636
|
+
_ts_metadata20("design:paramtypes", [
|
|
3489
3637
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
3490
3638
|
Array
|
|
3491
3639
|
])
|
|
@@ -3515,9 +3663,9 @@ var LedgerQuotaStore = class {
|
|
|
3515
3663
|
};
|
|
3516
3664
|
|
|
3517
3665
|
// src/runner/inline-agent-runner.ts
|
|
3518
|
-
var
|
|
3519
|
-
var
|
|
3520
|
-
function
|
|
3666
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
3667
|
+
var import_common22 = require("@nestjs/common");
|
|
3668
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
3521
3669
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3522
3670
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3523
3671
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3530,26 +3678,26 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
3530
3678
|
}
|
|
3531
3679
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3532
3680
|
}
|
|
3533
|
-
__name(
|
|
3534
|
-
function
|
|
3681
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3682
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
3535
3683
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3536
3684
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3537
3685
|
}
|
|
3538
3686
|
}
|
|
3539
|
-
__name(
|
|
3540
|
-
function
|
|
3687
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
3688
|
+
function _ts_param20(paramIndex, decorator) {
|
|
3541
3689
|
return function(target, key) {
|
|
3542
3690
|
decorator(target, key, paramIndex);
|
|
3543
3691
|
};
|
|
3544
3692
|
}
|
|
3545
|
-
__name(
|
|
3693
|
+
__name(_ts_param20, "_ts_param");
|
|
3546
3694
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
3547
3695
|
static {
|
|
3548
3696
|
__name(this, "InlineAgentRunner");
|
|
3549
3697
|
}
|
|
3550
3698
|
factory;
|
|
3551
3699
|
store;
|
|
3552
|
-
logger = new
|
|
3700
|
+
logger = new import_common22.Logger(_InlineAgentRunner.name);
|
|
3553
3701
|
pending = /* @__PURE__ */ new Map();
|
|
3554
3702
|
/**
|
|
3555
3703
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -3578,18 +3726,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3578
3726
|
] : []
|
|
3579
3727
|
]
|
|
3580
3728
|
});
|
|
3581
|
-
void (0,
|
|
3729
|
+
void (0, import_nestjs_agent_core24.runAgentLoop)({
|
|
3582
3730
|
...deps,
|
|
3583
3731
|
day
|
|
3584
3732
|
}, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
|
|
3585
|
-
if (error instanceof
|
|
3733
|
+
if (error instanceof import_nestjs_agent_core24.RunCancelledError) {
|
|
3586
3734
|
await this.settleCancelled(runId, input.threadId, deps);
|
|
3587
3735
|
return;
|
|
3588
3736
|
}
|
|
3589
3737
|
const message = error instanceof Error ? error.message : String(error);
|
|
3590
|
-
const code = (0,
|
|
3738
|
+
const code = (0, import_nestjs_agent_core24.agentFailureCode)(error);
|
|
3591
3739
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
3592
|
-
(0,
|
|
3740
|
+
(0, import_nestjs_agent_core24.publishAgentRunFailed)({
|
|
3593
3741
|
runId,
|
|
3594
3742
|
code,
|
|
3595
3743
|
message
|
|
@@ -3638,7 +3786,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3638
3786
|
for (const [key, waiter] of this.pending) {
|
|
3639
3787
|
if (key.startsWith(`${runId}:`)) {
|
|
3640
3788
|
this.pending.delete(key);
|
|
3641
|
-
waiter.reject(new
|
|
3789
|
+
waiter.reject(new import_nestjs_agent_core24.RunCancelledError());
|
|
3642
3790
|
}
|
|
3643
3791
|
}
|
|
3644
3792
|
await Promise.resolve();
|
|
@@ -3653,7 +3801,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3653
3801
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
3654
3802
|
await this.store.setActiveStream(threadId, null);
|
|
3655
3803
|
const writer = await deps.sink.open(runId);
|
|
3656
|
-
await writer.write((0,
|
|
3804
|
+
await writer.write((0, import_nestjs_agent_core24.encodeStreamEvent)({
|
|
3657
3805
|
kind: "cancelled"
|
|
3658
3806
|
}));
|
|
3659
3807
|
await writer.end();
|
|
@@ -3714,7 +3862,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3714
3862
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3715
3863
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3716
3864
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3717
|
-
parallel:
|
|
3865
|
+
parallel: import_nestjs_agent_core24.settleAll,
|
|
3718
3866
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
3719
3867
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
3720
3868
|
agentName,
|
|
@@ -3765,7 +3913,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3765
3913
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3766
3914
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3767
3915
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3768
|
-
parallel:
|
|
3916
|
+
parallel: import_nestjs_agent_core24.settleAll,
|
|
3769
3917
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
3770
3918
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
3771
3919
|
agentName: childName,
|
|
@@ -3798,7 +3946,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3798
3946
|
}
|
|
3799
3947
|
}), "startAgent")
|
|
3800
3948
|
};
|
|
3801
|
-
void (0,
|
|
3949
|
+
void (0, import_nestjs_agent_core24.runAgentLoop)({
|
|
3802
3950
|
...deps,
|
|
3803
3951
|
day
|
|
3804
3952
|
}, {
|
|
@@ -3812,13 +3960,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3812
3960
|
parentRunId,
|
|
3813
3961
|
deliverTo
|
|
3814
3962
|
}, hooks).catch(async (error) => {
|
|
3815
|
-
const cancelled = error instanceof
|
|
3963
|
+
const cancelled = error instanceof import_nestjs_agent_core24.RunCancelledError;
|
|
3816
3964
|
const message = error instanceof Error ? error.message : String(error);
|
|
3817
3965
|
if (!cancelled) {
|
|
3818
3966
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
3819
|
-
(0,
|
|
3967
|
+
(0, import_nestjs_agent_core24.publishAgentRunFailed)({
|
|
3820
3968
|
runId,
|
|
3821
|
-
code: (0,
|
|
3969
|
+
code: (0, import_nestjs_agent_core24.agentFailureCode)(error),
|
|
3822
3970
|
message
|
|
3823
3971
|
});
|
|
3824
3972
|
}
|
|
@@ -3826,11 +3974,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3826
3974
|
runId,
|
|
3827
3975
|
status: cancelled ? "cancelled" : "failed",
|
|
3828
3976
|
...cancelled ? {} : {
|
|
3829
|
-
errorCode: (0,
|
|
3977
|
+
errorCode: (0, import_nestjs_agent_core24.agentFailureCode)(error),
|
|
3830
3978
|
errorMessage: message
|
|
3831
3979
|
}
|
|
3832
3980
|
});
|
|
3833
|
-
await (0,
|
|
3981
|
+
await (0, import_nestjs_agent_core24.settleUnsettledDelegation)({
|
|
3834
3982
|
store: this.store,
|
|
3835
3983
|
delivery: deliverTo,
|
|
3836
3984
|
agent: agentName,
|
|
@@ -3869,7 +4017,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3869
4017
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3870
4018
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3871
4019
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3872
|
-
parallel:
|
|
4020
|
+
parallel: import_nestjs_agent_core24.settleAll,
|
|
3873
4021
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
3874
4022
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
3875
4023
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -3904,7 +4052,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3904
4052
|
}), "startAgent")
|
|
3905
4053
|
};
|
|
3906
4054
|
try {
|
|
3907
|
-
return await (0,
|
|
4055
|
+
return await (0, import_nestjs_agent_core24.runAgentLoop)({
|
|
3908
4056
|
...deps,
|
|
3909
4057
|
day
|
|
3910
4058
|
}, {
|
|
@@ -3923,19 +4071,19 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3923
4071
|
}
|
|
3924
4072
|
}
|
|
3925
4073
|
};
|
|
3926
|
-
InlineAgentRunner =
|
|
3927
|
-
(0,
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
4074
|
+
InlineAgentRunner = _ts_decorate22([
|
|
4075
|
+
(0, import_common22.Injectable)(),
|
|
4076
|
+
_ts_param20(0, (0, import_common22.Inject)(import_nestjs_agent_core24.AGENT_DEPS_FACTORY)),
|
|
4077
|
+
_ts_param20(1, (0, import_common22.Inject)(import_nestjs_agent_core24.AGENT_STORE)),
|
|
4078
|
+
_ts_metadata21("design:type", Function),
|
|
4079
|
+
_ts_metadata21("design:paramtypes", [
|
|
3932
4080
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3933
4081
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
3934
4082
|
])
|
|
3935
4083
|
], InlineAgentRunner);
|
|
3936
4084
|
|
|
3937
4085
|
// src/skills-config.ts
|
|
3938
|
-
var
|
|
4086
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
3939
4087
|
function declaredSkillProvider(declared) {
|
|
3940
4088
|
return {
|
|
3941
4089
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -3961,7 +4109,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3961
4109
|
declaredSkillProvider(declared)
|
|
3962
4110
|
];
|
|
3963
4111
|
return {
|
|
3964
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
4112
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core25.compositeSkillProvider)(providers),
|
|
3965
4113
|
...options.scopes !== void 0 ? {
|
|
3966
4114
|
scopes: options.scopes
|
|
3967
4115
|
} : {},
|
|
@@ -3973,7 +4121,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3973
4121
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3974
4122
|
|
|
3975
4123
|
// src/agent.module.ts
|
|
3976
|
-
function
|
|
4124
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
3977
4125
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3978
4126
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3979
4127
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3986,92 +4134,99 @@ function _ts_decorate22(decorators, target, key, desc) {
|
|
|
3986
4134
|
}
|
|
3987
4135
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3988
4136
|
}
|
|
3989
|
-
__name(
|
|
4137
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
3990
4138
|
var DEFAULT_PATH = "agent";
|
|
3991
4139
|
function sharedProviders(durable, includeStore) {
|
|
3992
4140
|
const providers = [
|
|
3993
4141
|
{
|
|
3994
|
-
provide:
|
|
3995
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
4142
|
+
provide: import_nestjs_agent_core26.AGENT_TOOL_REGISTRY,
|
|
4143
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core26.ToolRegistry(), "useFactory")
|
|
3996
4144
|
},
|
|
3997
4145
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
3998
4146
|
{
|
|
3999
|
-
provide:
|
|
4000
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
4147
|
+
provide: import_nestjs_agent_core26.AGENT_REGISTRY,
|
|
4148
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core26.AgentRegistry(), "useFactory")
|
|
4001
4149
|
},
|
|
4002
4150
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
4003
4151
|
{
|
|
4004
|
-
provide:
|
|
4152
|
+
provide: import_nestjs_agent_core26.AGENT_PROMPT_CONTRIBUTORS,
|
|
4005
4153
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
4006
4154
|
},
|
|
4007
4155
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
4008
4156
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
4009
4157
|
{
|
|
4010
|
-
provide:
|
|
4158
|
+
provide: import_nestjs_agent_core26.AGENT_SKILL_SOURCES,
|
|
4011
4159
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
4012
4160
|
},
|
|
4013
4161
|
{
|
|
4014
4162
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
4015
4163
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
4016
4164
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
4017
|
-
provide:
|
|
4165
|
+
provide: import_nestjs_agent_core26.AGENT_SKILLS,
|
|
4018
4166
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
4019
4167
|
inject: [
|
|
4020
|
-
|
|
4021
|
-
|
|
4168
|
+
import_nestjs_agent_core26.AGENT_OPTIONS,
|
|
4169
|
+
import_nestjs_agent_core26.AGENT_SKILL_SOURCES
|
|
4022
4170
|
]
|
|
4023
4171
|
},
|
|
4024
4172
|
{
|
|
4025
4173
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
4026
4174
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
4027
|
-
provide:
|
|
4175
|
+
provide: import_nestjs_agent_core26.AGENT_MEMORY,
|
|
4028
4176
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
4029
4177
|
inject: [
|
|
4030
|
-
|
|
4178
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
4031
4179
|
]
|
|
4032
4180
|
},
|
|
4033
4181
|
{
|
|
4034
|
-
provide:
|
|
4182
|
+
provide: import_nestjs_agent_core26.AGENT_SINK,
|
|
4035
4183
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
4036
4184
|
inject: [
|
|
4037
|
-
|
|
4185
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
4038
4186
|
]
|
|
4039
4187
|
},
|
|
4040
4188
|
{
|
|
4041
|
-
provide:
|
|
4042
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
4189
|
+
provide: import_nestjs_agent_core26.AGENT_ROLES_POLICY,
|
|
4190
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core26.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
4043
4191
|
inject: [
|
|
4044
|
-
|
|
4192
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
4045
4193
|
]
|
|
4046
4194
|
},
|
|
4047
4195
|
{
|
|
4048
|
-
provide:
|
|
4196
|
+
provide: import_nestjs_agent_core26.AGENT_ACTOR_RESOLVER,
|
|
4049
4197
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
4050
4198
|
inject: [
|
|
4051
|
-
|
|
4199
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
4052
4200
|
]
|
|
4053
4201
|
},
|
|
4054
4202
|
{
|
|
4055
|
-
provide:
|
|
4203
|
+
provide: import_nestjs_agent_core26.AGENT_MODEL,
|
|
4056
4204
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
4057
4205
|
inject: [
|
|
4058
|
-
|
|
4206
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
4059
4207
|
]
|
|
4060
4208
|
},
|
|
4061
4209
|
{
|
|
4062
4210
|
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
4063
4211
|
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
4064
4212
|
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
4065
|
-
provide:
|
|
4213
|
+
provide: import_nestjs_agent_core26.AGENT_QUOTA_STORE,
|
|
4066
4214
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
4067
4215
|
inject: [
|
|
4068
|
-
|
|
4069
|
-
|
|
4216
|
+
import_nestjs_agent_core26.AGENT_OPTIONS,
|
|
4217
|
+
import_nestjs_agent_core26.AGENT_STORE
|
|
4218
|
+
]
|
|
4219
|
+
},
|
|
4220
|
+
{
|
|
4221
|
+
provide: import_nestjs_agent_core26.AGENT_MODEL_CATALOG,
|
|
4222
|
+
useFactory: /* @__PURE__ */ __name((o) => o.models, "useFactory"),
|
|
4223
|
+
inject: [
|
|
4224
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
4070
4225
|
]
|
|
4071
4226
|
},
|
|
4072
4227
|
AgentDepsFactory2,
|
|
4073
4228
|
{
|
|
4074
|
-
provide:
|
|
4229
|
+
provide: import_nestjs_agent_core26.AGENT_DEPS_FACTORY,
|
|
4075
4230
|
useExisting: AgentDepsFactory2
|
|
4076
4231
|
},
|
|
4077
4232
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -4085,22 +4240,22 @@ function sharedProviders(durable, includeStore) {
|
|
|
4085
4240
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
4086
4241
|
AgentApprovalPortAdapter,
|
|
4087
4242
|
{
|
|
4088
|
-
provide:
|
|
4243
|
+
provide: import_nestjs_agent_core26.AGENT_APPROVAL_PORT,
|
|
4089
4244
|
useExisting: AgentApprovalPortAdapter
|
|
4090
4245
|
}
|
|
4091
4246
|
];
|
|
4092
4247
|
if (includeStore) {
|
|
4093
4248
|
providers.push({
|
|
4094
|
-
provide:
|
|
4249
|
+
provide: import_nestjs_agent_core26.AGENT_STORE,
|
|
4095
4250
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
4096
4251
|
inject: [
|
|
4097
|
-
|
|
4252
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
4098
4253
|
]
|
|
4099
4254
|
});
|
|
4100
4255
|
}
|
|
4101
4256
|
if (durable) {
|
|
4102
4257
|
providers.push({
|
|
4103
|
-
provide:
|
|
4258
|
+
provide: import_nestjs_agent_core26.AGENT_RUNNER,
|
|
4104
4259
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
4105
4260
|
if (durableRunner === void 0) {
|
|
4106
4261
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -4109,14 +4264,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
4109
4264
|
}, "useFactory"),
|
|
4110
4265
|
inject: [
|
|
4111
4266
|
{
|
|
4112
|
-
token:
|
|
4267
|
+
token: import_nestjs_agent_core26.AGENT_DURABLE_RUNNER,
|
|
4113
4268
|
optional: true
|
|
4114
4269
|
}
|
|
4115
4270
|
]
|
|
4116
4271
|
});
|
|
4117
4272
|
} else {
|
|
4118
4273
|
providers.push({
|
|
4119
|
-
provide:
|
|
4274
|
+
provide: import_nestjs_agent_core26.AGENT_RUNNER,
|
|
4120
4275
|
useExisting: InlineAgentRunner
|
|
4121
4276
|
});
|
|
4122
4277
|
}
|
|
@@ -4125,25 +4280,26 @@ function sharedProviders(durable, includeStore) {
|
|
|
4125
4280
|
__name(sharedProviders, "sharedProviders");
|
|
4126
4281
|
function exportsFor(includeStore) {
|
|
4127
4282
|
return [
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4283
|
+
import_nestjs_agent_core26.AGENT_OPTIONS,
|
|
4284
|
+
import_nestjs_agent_core26.AGENT_TOOL_REGISTRY,
|
|
4285
|
+
import_nestjs_agent_core26.AGENT_REGISTRY,
|
|
4286
|
+
import_nestjs_agent_core26.AGENT_SINK,
|
|
4287
|
+
import_nestjs_agent_core26.AGENT_ROLES_POLICY,
|
|
4288
|
+
import_nestjs_agent_core26.AGENT_ACTOR_RESOLVER,
|
|
4289
|
+
import_nestjs_agent_core26.AGENT_MODEL,
|
|
4135
4290
|
...includeStore ? [
|
|
4136
|
-
|
|
4291
|
+
import_nestjs_agent_core26.AGENT_STORE
|
|
4137
4292
|
] : [],
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4293
|
+
import_nestjs_agent_core26.AGENT_QUOTA_STORE,
|
|
4294
|
+
import_nestjs_agent_core26.AGENT_MODEL_CATALOG,
|
|
4295
|
+
import_nestjs_agent_core26.AGENT_PROMPT_CONTRIBUTORS,
|
|
4296
|
+
import_nestjs_agent_core26.AGENT_SKILLS,
|
|
4297
|
+
import_nestjs_agent_core26.AGENT_MEMORY,
|
|
4298
|
+
import_nestjs_agent_core26.AGENT_DEPS_FACTORY,
|
|
4143
4299
|
AgentDepsFactory2,
|
|
4144
4300
|
AgentService,
|
|
4145
4301
|
InlineAgentRunner,
|
|
4146
|
-
|
|
4302
|
+
import_nestjs_agent_core26.AGENT_APPROVAL_PORT
|
|
4147
4303
|
];
|
|
4148
4304
|
}
|
|
4149
4305
|
__name(exportsFor, "exportsFor");
|
|
@@ -4156,7 +4312,8 @@ var BASE_CONTROLLERS = [
|
|
|
4156
4312
|
SkillsController,
|
|
4157
4313
|
MemoriesController,
|
|
4158
4314
|
ToolsController,
|
|
4159
|
-
MessagesController
|
|
4315
|
+
MessagesController,
|
|
4316
|
+
ModelsController
|
|
4160
4317
|
];
|
|
4161
4318
|
var GUARDABLE_CONTROLLERS = [
|
|
4162
4319
|
...BASE_CONTROLLERS,
|
|
@@ -4214,7 +4371,7 @@ var AgentModule = class _AgentModule {
|
|
|
4214
4371
|
controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
|
|
4215
4372
|
providers: [
|
|
4216
4373
|
{
|
|
4217
|
-
provide:
|
|
4374
|
+
provide: import_nestjs_agent_core26.AGENT_OPTIONS,
|
|
4218
4375
|
useValue: options
|
|
4219
4376
|
},
|
|
4220
4377
|
...sharedProviders(options.durable ?? false, includeStore),
|
|
@@ -4238,7 +4395,7 @@ var AgentModule = class _AgentModule {
|
|
|
4238
4395
|
controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
|
|
4239
4396
|
providers: [
|
|
4240
4397
|
{
|
|
4241
|
-
provide:
|
|
4398
|
+
provide: import_nestjs_agent_core26.AGENT_OPTIONS,
|
|
4242
4399
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
4243
4400
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
4244
4401
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -4259,9 +4416,9 @@ var AgentModule = class _AgentModule {
|
|
|
4259
4416
|
};
|
|
4260
4417
|
}
|
|
4261
4418
|
};
|
|
4262
|
-
AgentModule =
|
|
4263
|
-
(0,
|
|
4264
|
-
(0,
|
|
4419
|
+
AgentModule = _ts_decorate23([
|
|
4420
|
+
(0, import_common23.Global)(),
|
|
4421
|
+
(0, import_common23.Module)({})
|
|
4265
4422
|
], AgentModule);
|
|
4266
4423
|
|
|
4267
4424
|
// src/durable/agent-durable.ts
|