@dudousxd/nestjs-agent 1.25.2 → 1.27.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 +80 -0
- package/dist/{chat-queue.service-Crf9uwum.d.cts → chat-queue.service-Cu2nJpXz.d.cts} +44 -1
- package/dist/{chat-queue.service-ZQkqb1Yw.d.ts → chat-queue.service-uD1vR8fs.d.ts} +44 -1
- package/dist/durable/index.cjs +273 -169
- 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 +195 -91
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +306 -202
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +218 -114
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/durable/index.cjs
CHANGED
|
@@ -1216,8 +1216,8 @@ AgentDurableModule = _ts_decorate4([
|
|
|
1216
1216
|
], AgentDurableModule);
|
|
1217
1217
|
|
|
1218
1218
|
// src/agent.module.ts
|
|
1219
|
-
var
|
|
1220
|
-
var
|
|
1219
|
+
var import_nestjs_agent_core40 = require("@dudousxd/nestjs-agent-core");
|
|
1220
|
+
var import_common32 = require("@nestjs/common");
|
|
1221
1221
|
var import_core4 = require("@nestjs/core");
|
|
1222
1222
|
|
|
1223
1223
|
// src/agent-deps.factory.ts
|
|
@@ -6170,7 +6170,7 @@ var LedgerQuotaProvider = class {
|
|
|
6170
6170
|
if (this.store.usageBetween !== void 0) {
|
|
6171
6171
|
const range = (0, import_nestjs_agent_core34.quotaPeriodRange)("month", now);
|
|
6172
6172
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
6173
|
-
windows.push(this.window("month", used.usedTokens, used
|
|
6173
|
+
windows.push(this.window("month", used.usedTokens, this.usd(used), range.resetsAt));
|
|
6174
6174
|
}
|
|
6175
6175
|
const blocked = (0, import_nestjs_agent_core34.exhaustedWindow)(windows);
|
|
6176
6176
|
const warning = (0, import_nestjs_agent_core34.quotaWarning)(windows);
|
|
@@ -6186,8 +6186,15 @@ var LedgerQuotaProvider = class {
|
|
|
6186
6186
|
}
|
|
6187
6187
|
async dayWindow(actorRef, now) {
|
|
6188
6188
|
const range = (0, import_nestjs_agent_core34.quotaPeriodRange)("day", now);
|
|
6189
|
-
const
|
|
6190
|
-
return this.window("day", usedTokens,
|
|
6189
|
+
const used = await this.store.quotaToday(actorRef, range.fromDay);
|
|
6190
|
+
return this.window("day", used.usedTokens, this.usd(used), range.resetsAt);
|
|
6191
|
+
}
|
|
6192
|
+
/** The window's USD: every priced row, or (with `countEstimatedCost: false`) reported cost only. */
|
|
6193
|
+
usd(used) {
|
|
6194
|
+
if (this.options.countEstimatedCost === false) {
|
|
6195
|
+
return Math.max(0, used.costUsd - (used.estimatedCostUsd ?? 0));
|
|
6196
|
+
}
|
|
6197
|
+
return used.costUsd;
|
|
6191
6198
|
}
|
|
6192
6199
|
window(period, usedTokens, usedUsd, resetsAt) {
|
|
6193
6200
|
const limits = this.limits[period] ?? {};
|
|
@@ -6209,8 +6216,7 @@ var LedgerQuotaProvider = class {
|
|
|
6209
6216
|
}
|
|
6210
6217
|
};
|
|
6211
6218
|
|
|
6212
|
-
// src/
|
|
6213
|
-
var import_node_crypto3 = require("crypto");
|
|
6219
|
+
// src/pricing-boot.service.ts
|
|
6214
6220
|
var import_nestjs_agent_core35 = require("@dudousxd/nestjs-agent-core");
|
|
6215
6221
|
var import_common28 = require("@nestjs/common");
|
|
6216
6222
|
function _ts_decorate27(decorators, target, key, desc) {
|
|
@@ -6239,6 +6245,96 @@ function _ts_param25(paramIndex, decorator) {
|
|
|
6239
6245
|
};
|
|
6240
6246
|
}
|
|
6241
6247
|
__name(_ts_param25, "_ts_param");
|
|
6248
|
+
var logger = new import_common28.Logger("AgentPricing");
|
|
6249
|
+
var PricingBootService = class {
|
|
6250
|
+
static {
|
|
6251
|
+
__name(this, "PricingBootService");
|
|
6252
|
+
}
|
|
6253
|
+
options;
|
|
6254
|
+
model;
|
|
6255
|
+
pricingStore;
|
|
6256
|
+
#run = null;
|
|
6257
|
+
constructor(options, model, pricingStore) {
|
|
6258
|
+
this.options = options;
|
|
6259
|
+
this.model = model;
|
|
6260
|
+
this.pricingStore = pricingStore;
|
|
6261
|
+
}
|
|
6262
|
+
onApplicationBootstrap() {
|
|
6263
|
+
this.#run = this.check();
|
|
6264
|
+
}
|
|
6265
|
+
/** Awaits a check still in flight, so a test (or a fast shutdown) never leaks it. */
|
|
6266
|
+
async onApplicationShutdown() {
|
|
6267
|
+
await this.#run;
|
|
6268
|
+
this.#run = null;
|
|
6269
|
+
}
|
|
6270
|
+
/** The check itself; resolves once it is done (exposed for tests). */
|
|
6271
|
+
async check() {
|
|
6272
|
+
let models;
|
|
6273
|
+
try {
|
|
6274
|
+
models = this.model?.describeModels?.() ?? [];
|
|
6275
|
+
} catch (error) {
|
|
6276
|
+
logger.warn(`describeModels() threw; boot pricing skipped: ${String(error)}`);
|
|
6277
|
+
return;
|
|
6278
|
+
}
|
|
6279
|
+
if (models.length === 0) return;
|
|
6280
|
+
const catalog = this.options.priceCatalog;
|
|
6281
|
+
if (catalog === void 0 && process.env.NODE_ENV === "test") return;
|
|
6282
|
+
await (0, import_nestjs_agent_core35.ensureModelPricing)({
|
|
6283
|
+
models,
|
|
6284
|
+
pricingStore: this.pricingStore,
|
|
6285
|
+
catalog: catalog ?? {},
|
|
6286
|
+
log: {
|
|
6287
|
+
info: /* @__PURE__ */ __name((message) => logger.log(message), "info"),
|
|
6288
|
+
warn: /* @__PURE__ */ __name((message) => logger.warn(message), "warn")
|
|
6289
|
+
}
|
|
6290
|
+
}).catch(() => void 0);
|
|
6291
|
+
}
|
|
6292
|
+
};
|
|
6293
|
+
PricingBootService = _ts_decorate27([
|
|
6294
|
+
(0, import_common28.Injectable)(),
|
|
6295
|
+
_ts_param25(0, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_OPTIONS)),
|
|
6296
|
+
_ts_param25(1, (0, import_common28.Optional)()),
|
|
6297
|
+
_ts_param25(1, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_MODEL)),
|
|
6298
|
+
_ts_param25(2, (0, import_common28.Optional)()),
|
|
6299
|
+
_ts_param25(2, (0, import_common28.Inject)(import_nestjs_agent_core35.AGENT_PRICING_STORE)),
|
|
6300
|
+
_ts_metadata25("design:type", Function),
|
|
6301
|
+
_ts_metadata25("design:paramtypes", [
|
|
6302
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
6303
|
+
Object,
|
|
6304
|
+
Object
|
|
6305
|
+
])
|
|
6306
|
+
], PricingBootService);
|
|
6307
|
+
|
|
6308
|
+
// src/proposals/action-proposal-worker.service.ts
|
|
6309
|
+
var import_node_crypto3 = require("crypto");
|
|
6310
|
+
var import_nestjs_agent_core36 = require("@dudousxd/nestjs-agent-core");
|
|
6311
|
+
var import_common29 = require("@nestjs/common");
|
|
6312
|
+
function _ts_decorate28(decorators, target, key, desc) {
|
|
6313
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6314
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6315
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6316
|
+
} else {
|
|
6317
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
6318
|
+
if (d = decorators[i]) {
|
|
6319
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6320
|
+
}
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6323
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6324
|
+
}
|
|
6325
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
6326
|
+
function _ts_metadata26(metadataKey, metadataValue) {
|
|
6327
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
6328
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
6329
|
+
}
|
|
6330
|
+
}
|
|
6331
|
+
__name(_ts_metadata26, "_ts_metadata");
|
|
6332
|
+
function _ts_param26(paramIndex, decorator) {
|
|
6333
|
+
return function(target, key) {
|
|
6334
|
+
decorator(target, key, paramIndex);
|
|
6335
|
+
};
|
|
6336
|
+
}
|
|
6337
|
+
__name(_ts_param26, "_ts_param");
|
|
6242
6338
|
var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
6243
6339
|
static {
|
|
6244
6340
|
__name(this, "ActionProposalWorkerService");
|
|
@@ -6247,7 +6343,7 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
|
6247
6343
|
options;
|
|
6248
6344
|
deps;
|
|
6249
6345
|
worker;
|
|
6250
|
-
logger = new
|
|
6346
|
+
logger = new import_common29.Logger(_ActionProposalWorkerService.name);
|
|
6251
6347
|
settledListeners = /* @__PURE__ */ new Set();
|
|
6252
6348
|
/**
|
|
6253
6349
|
* Run `listener` after every proposal this process's worker settles — how a module relays an
|
|
@@ -6283,16 +6379,16 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
|
6283
6379
|
}
|
|
6284
6380
|
onModuleInit() {
|
|
6285
6381
|
if (this.options.actionApprovalMode !== "independent") return;
|
|
6286
|
-
(0,
|
|
6382
|
+
(0, import_nestjs_agent_core36.assertIndependentActionCapabilities)(this.store, this.options.backgroundActorResolver);
|
|
6287
6383
|
if (this.options.surface === "http") return;
|
|
6288
6384
|
const resolver = this.options.backgroundActorResolver;
|
|
6289
6385
|
if (!resolver) throw new Error("BackgroundActorResolver is required");
|
|
6290
|
-
this.worker = new
|
|
6386
|
+
this.worker = new import_nestjs_agent_core36.ActionProposalWorker({
|
|
6291
6387
|
store: this.store,
|
|
6292
6388
|
workerId: (0, import_node_crypto3.randomUUID)(),
|
|
6293
6389
|
...this.options.actionProposalWorker,
|
|
6294
6390
|
onSettled: /* @__PURE__ */ __name((proposal) => this.settled(proposal), "onSettled"),
|
|
6295
|
-
executor: new
|
|
6391
|
+
executor: new import_nestjs_agent_core36.ActionProposalExecutor({
|
|
6296
6392
|
resolver,
|
|
6297
6393
|
resolveExecution: /* @__PURE__ */ __name(async (proposal, actor) => {
|
|
6298
6394
|
const deps = this.deps.forProposal(proposal, actor);
|
|
@@ -6316,13 +6412,13 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
|
6316
6412
|
await this.worker?.stop();
|
|
6317
6413
|
}
|
|
6318
6414
|
};
|
|
6319
|
-
ActionProposalWorkerService =
|
|
6320
|
-
(0,
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6415
|
+
ActionProposalWorkerService = _ts_decorate28([
|
|
6416
|
+
(0, import_common29.Injectable)(),
|
|
6417
|
+
_ts_param26(0, (0, import_common29.Inject)(import_nestjs_agent_core36.AGENT_STORE)),
|
|
6418
|
+
_ts_param26(1, (0, import_common29.Inject)(import_nestjs_agent_core36.AGENT_OPTIONS)),
|
|
6419
|
+
_ts_param26(2, (0, import_common29.Inject)(import_nestjs_agent_core36.AGENT_DEPS_FACTORY)),
|
|
6420
|
+
_ts_metadata26("design:type", Function),
|
|
6421
|
+
_ts_metadata26("design:paramtypes", [
|
|
6326
6422
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
6327
6423
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
6328
6424
|
typeof AgentDepsFactory2 === "undefined" ? Object : AgentDepsFactory2
|
|
@@ -6330,9 +6426,9 @@ ActionProposalWorkerService = _ts_decorate27([
|
|
|
6330
6426
|
], ActionProposalWorkerService);
|
|
6331
6427
|
|
|
6332
6428
|
// src/proposals/action-proposal.controller.ts
|
|
6333
|
-
var
|
|
6334
|
-
var
|
|
6335
|
-
function
|
|
6429
|
+
var import_nestjs_agent_core37 = require("@dudousxd/nestjs-agent-core");
|
|
6430
|
+
var import_common30 = require("@nestjs/common");
|
|
6431
|
+
function _ts_decorate29(decorators, target, key, desc) {
|
|
6336
6432
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6337
6433
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6338
6434
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6345,24 +6441,24 @@ function _ts_decorate28(decorators, target, key, desc) {
|
|
|
6345
6441
|
}
|
|
6346
6442
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6347
6443
|
}
|
|
6348
|
-
__name(
|
|
6349
|
-
function
|
|
6444
|
+
__name(_ts_decorate29, "_ts_decorate");
|
|
6445
|
+
function _ts_metadata27(metadataKey, metadataValue) {
|
|
6350
6446
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
6351
6447
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
6352
6448
|
}
|
|
6353
6449
|
}
|
|
6354
|
-
__name(
|
|
6355
|
-
function
|
|
6450
|
+
__name(_ts_metadata27, "_ts_metadata");
|
|
6451
|
+
function _ts_param27(paramIndex, decorator) {
|
|
6356
6452
|
return function(target, key) {
|
|
6357
6453
|
decorator(target, key, paramIndex);
|
|
6358
6454
|
};
|
|
6359
6455
|
}
|
|
6360
|
-
__name(
|
|
6456
|
+
__name(_ts_param27, "_ts_param");
|
|
6361
6457
|
function bodyFields(body, field) {
|
|
6362
6458
|
if (body === void 0) return {};
|
|
6363
|
-
if (typeof body !== "object" || body === null || Array.isArray(body) || Object.keys(body).some((key) => key !== field)) throw new
|
|
6459
|
+
if (typeof body !== "object" || body === null || Array.isArray(body) || Object.keys(body).some((key) => key !== field)) throw new import_common30.BadRequestException(`Only ${field} is accepted`);
|
|
6364
6460
|
const value = body;
|
|
6365
|
-
if (value[field] !== void 0 && (field === "remember" && typeof value[field] !== "boolean" || field === "reason" && typeof value[field] !== "string")) throw new
|
|
6461
|
+
if (value[field] !== void 0 && (field === "remember" && typeof value[field] !== "boolean" || field === "reason" && typeof value[field] !== "string")) throw new import_common30.BadRequestException(`Invalid ${field}`);
|
|
6366
6462
|
return value;
|
|
6367
6463
|
}
|
|
6368
6464
|
__name(bodyFields, "bodyFields");
|
|
@@ -6384,9 +6480,9 @@ var ActionProposalController = class {
|
|
|
6384
6480
|
query = {
|
|
6385
6481
|
after: JSON.parse(cursor)
|
|
6386
6482
|
};
|
|
6387
|
-
(0,
|
|
6483
|
+
(0, import_nestjs_agent_core37.validateActionProposalListQuery)(query);
|
|
6388
6484
|
} catch {
|
|
6389
|
-
throw new
|
|
6485
|
+
throw new import_common30.BadRequestException("Invalid action proposal cursor");
|
|
6390
6486
|
}
|
|
6391
6487
|
}
|
|
6392
6488
|
const page = await this.proposals.listPage(threadId, await this.actors.resolve(request), query);
|
|
@@ -6416,67 +6512,67 @@ var ActionProposalController = class {
|
|
|
6416
6512
|
});
|
|
6417
6513
|
}
|
|
6418
6514
|
};
|
|
6419
|
-
|
|
6420
|
-
(0,
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6515
|
+
_ts_decorate29([
|
|
6516
|
+
(0, import_common30.Get)(),
|
|
6517
|
+
_ts_param27(0, (0, import_common30.Param)("threadId")),
|
|
6518
|
+
_ts_param27(1, (0, import_common30.Req)()),
|
|
6519
|
+
_ts_param27(2, (0, import_common30.Query)("after")),
|
|
6520
|
+
_ts_param27(3, (0, import_common30.Res)({
|
|
6425
6521
|
passthrough: true
|
|
6426
6522
|
})),
|
|
6427
|
-
|
|
6428
|
-
|
|
6523
|
+
_ts_metadata27("design:type", Function),
|
|
6524
|
+
_ts_metadata27("design:paramtypes", [
|
|
6429
6525
|
String,
|
|
6430
6526
|
typeof Request === "undefined" ? Object : Request,
|
|
6431
6527
|
Object,
|
|
6432
6528
|
typeof Response === "undefined" ? Object : Response
|
|
6433
6529
|
]),
|
|
6434
|
-
|
|
6530
|
+
_ts_metadata27("design:returntype", Promise)
|
|
6435
6531
|
], ActionProposalController.prototype, "list", null);
|
|
6436
|
-
|
|
6437
|
-
(0,
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6532
|
+
_ts_decorate29([
|
|
6533
|
+
(0, import_common30.Post)(":proposalId/approve"),
|
|
6534
|
+
_ts_param27(0, (0, import_common30.Param)("threadId")),
|
|
6535
|
+
_ts_param27(1, (0, import_common30.Param)("proposalId")),
|
|
6536
|
+
_ts_param27(2, (0, import_common30.Req)()),
|
|
6537
|
+
_ts_param27(3, (0, import_common30.Body)()),
|
|
6538
|
+
_ts_metadata27("design:type", Function),
|
|
6539
|
+
_ts_metadata27("design:paramtypes", [
|
|
6444
6540
|
String,
|
|
6445
6541
|
String,
|
|
6446
6542
|
typeof Request === "undefined" ? Object : Request,
|
|
6447
6543
|
Object
|
|
6448
6544
|
]),
|
|
6449
|
-
|
|
6545
|
+
_ts_metadata27("design:returntype", Promise)
|
|
6450
6546
|
], ActionProposalController.prototype, "approve", null);
|
|
6451
|
-
|
|
6452
|
-
(0,
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6547
|
+
_ts_decorate29([
|
|
6548
|
+
(0, import_common30.Post)(":proposalId/reject"),
|
|
6549
|
+
_ts_param27(0, (0, import_common30.Param)("threadId")),
|
|
6550
|
+
_ts_param27(1, (0, import_common30.Param)("proposalId")),
|
|
6551
|
+
_ts_param27(2, (0, import_common30.Req)()),
|
|
6552
|
+
_ts_param27(3, (0, import_common30.Body)()),
|
|
6553
|
+
_ts_metadata27("design:type", Function),
|
|
6554
|
+
_ts_metadata27("design:paramtypes", [
|
|
6459
6555
|
String,
|
|
6460
6556
|
String,
|
|
6461
6557
|
typeof Request === "undefined" ? Object : Request,
|
|
6462
6558
|
Object
|
|
6463
6559
|
]),
|
|
6464
|
-
|
|
6560
|
+
_ts_metadata27("design:returntype", Promise)
|
|
6465
6561
|
], ActionProposalController.prototype, "reject", null);
|
|
6466
|
-
ActionProposalController =
|
|
6467
|
-
(0,
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6562
|
+
ActionProposalController = _ts_decorate29([
|
|
6563
|
+
(0, import_common30.Controller)("threads/:threadId/action-proposals"),
|
|
6564
|
+
_ts_param27(1, (0, import_common30.Inject)(import_nestjs_agent_core37.AGENT_ACTOR_RESOLVER)),
|
|
6565
|
+
_ts_metadata27("design:type", Function),
|
|
6566
|
+
_ts_metadata27("design:paramtypes", [
|
|
6471
6567
|
typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
|
|
6472
6568
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
6473
6569
|
])
|
|
6474
6570
|
], ActionProposalController);
|
|
6475
6571
|
|
|
6476
6572
|
// src/runner/inline-agent-runner.ts
|
|
6477
|
-
var
|
|
6478
|
-
var
|
|
6479
|
-
function
|
|
6573
|
+
var import_nestjs_agent_core38 = require("@dudousxd/nestjs-agent-core");
|
|
6574
|
+
var import_common31 = require("@nestjs/common");
|
|
6575
|
+
function _ts_decorate30(decorators, target, key, desc) {
|
|
6480
6576
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6481
6577
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6482
6578
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6489,19 +6585,19 @@ function _ts_decorate29(decorators, target, key, desc) {
|
|
|
6489
6585
|
}
|
|
6490
6586
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6491
6587
|
}
|
|
6492
|
-
__name(
|
|
6493
|
-
function
|
|
6588
|
+
__name(_ts_decorate30, "_ts_decorate");
|
|
6589
|
+
function _ts_metadata28(metadataKey, metadataValue) {
|
|
6494
6590
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
6495
6591
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
6496
6592
|
}
|
|
6497
6593
|
}
|
|
6498
|
-
__name(
|
|
6499
|
-
function
|
|
6594
|
+
__name(_ts_metadata28, "_ts_metadata");
|
|
6595
|
+
function _ts_param28(paramIndex, decorator) {
|
|
6500
6596
|
return function(target, key) {
|
|
6501
6597
|
decorator(target, key, paramIndex);
|
|
6502
6598
|
};
|
|
6503
6599
|
}
|
|
6504
|
-
__name(
|
|
6600
|
+
__name(_ts_param28, "_ts_param");
|
|
6505
6601
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
6506
6602
|
static {
|
|
6507
6603
|
__name(this, "InlineAgentRunner");
|
|
@@ -6509,7 +6605,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6509
6605
|
factory;
|
|
6510
6606
|
store;
|
|
6511
6607
|
queue;
|
|
6512
|
-
logger = new
|
|
6608
|
+
logger = new import_common31.Logger(_InlineAgentRunner.name);
|
|
6513
6609
|
pending = /* @__PURE__ */ new Map();
|
|
6514
6610
|
/**
|
|
6515
6611
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -6563,18 +6659,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6563
6659
|
],
|
|
6564
6660
|
input
|
|
6565
6661
|
});
|
|
6566
|
-
void (0,
|
|
6662
|
+
void (0, import_nestjs_agent_core38.runAgentLoop)({
|
|
6567
6663
|
...deps,
|
|
6568
6664
|
day
|
|
6569
|
-
}, input, hooks).then(() => (0,
|
|
6570
|
-
if (error instanceof
|
|
6665
|
+
}, input, hooks).then(() => (0, import_nestjs_agent_core38.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
|
|
6666
|
+
if (error instanceof import_nestjs_agent_core38.RunCancelledError) {
|
|
6571
6667
|
await this.settleCancelled(runId, input, deps);
|
|
6572
6668
|
return;
|
|
6573
6669
|
}
|
|
6574
6670
|
const message = error instanceof Error ? error.message : String(error);
|
|
6575
|
-
const code = (0,
|
|
6671
|
+
const code = (0, import_nestjs_agent_core38.agentFailureCode)(error);
|
|
6576
6672
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
6577
|
-
(0,
|
|
6673
|
+
(0, import_nestjs_agent_core38.publishAgentRunFailed)({
|
|
6578
6674
|
runId,
|
|
6579
6675
|
code,
|
|
6580
6676
|
message
|
|
@@ -6585,11 +6681,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6585
6681
|
errorCode: code,
|
|
6586
6682
|
errorMessage: message
|
|
6587
6683
|
});
|
|
6588
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
6684
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core38.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
6589
6685
|
const writer = await deps.sink.open(runId);
|
|
6590
6686
|
await this.settleQueue(writer, input, runId, "failed", message);
|
|
6591
|
-
await (0,
|
|
6592
|
-
await writer.fail((0,
|
|
6687
|
+
await (0, import_nestjs_agent_core38.releaseThreadRun)(this.store, input.threadId, runId);
|
|
6688
|
+
await writer.fail((0, import_nestjs_agent_core38.streamFailure)(error));
|
|
6593
6689
|
}).finally(() => {
|
|
6594
6690
|
this.forgetCancel(runId);
|
|
6595
6691
|
this.live.delete(runId);
|
|
@@ -6624,11 +6720,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6624
6720
|
*/
|
|
6625
6721
|
async cancel(runId) {
|
|
6626
6722
|
this.cancelled.add(runId);
|
|
6627
|
-
this.aborts.get(runId)?.abort(new
|
|
6723
|
+
this.aborts.get(runId)?.abort(new import_nestjs_agent_core38.RunCancelledError());
|
|
6628
6724
|
for (const [key, waiter] of this.pending) {
|
|
6629
6725
|
if (key.startsWith(`${runId}:`)) {
|
|
6630
6726
|
this.pending.delete(key);
|
|
6631
|
-
waiter.reject(new
|
|
6727
|
+
waiter.reject(new import_nestjs_agent_core38.RunCancelledError());
|
|
6632
6728
|
}
|
|
6633
6729
|
}
|
|
6634
6730
|
await Promise.resolve();
|
|
@@ -6657,8 +6753,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6657
6753
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
6658
6754
|
const writer = await deps.sink.open(runId);
|
|
6659
6755
|
await this.settleQueue(writer, input, runId, "cancelled");
|
|
6660
|
-
await (0,
|
|
6661
|
-
await writer.write((0,
|
|
6756
|
+
await (0, import_nestjs_agent_core38.releaseThreadRun)(this.store, input.threadId, runId);
|
|
6757
|
+
await writer.write((0, import_nestjs_agent_core38.encodeStreamEvent)({
|
|
6662
6758
|
kind: "cancelled"
|
|
6663
6759
|
}));
|
|
6664
6760
|
await writer.end();
|
|
@@ -6693,7 +6789,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6693
6789
|
runId: nextRunId
|
|
6694
6790
|
}));
|
|
6695
6791
|
if (frame !== void 0) {
|
|
6696
|
-
await writer.write((0,
|
|
6792
|
+
await writer.write((0, import_nestjs_agent_core38.encodeStreamEvent)(frame));
|
|
6697
6793
|
}
|
|
6698
6794
|
} catch (failure) {
|
|
6699
6795
|
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
@@ -6764,7 +6860,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6764
6860
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
6765
6861
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
6766
6862
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
6767
|
-
parallel:
|
|
6863
|
+
parallel: import_nestjs_agent_core38.settleAll,
|
|
6768
6864
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
6769
6865
|
abortSignal: this.abortSignalFor(runId),
|
|
6770
6866
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
@@ -6816,7 +6912,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6816
6912
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
6817
6913
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
6818
6914
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
6819
|
-
parallel:
|
|
6915
|
+
parallel: import_nestjs_agent_core38.settleAll,
|
|
6820
6916
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
6821
6917
|
abortSignal: this.abortSignalFor(runId),
|
|
6822
6918
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
@@ -6850,7 +6946,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6850
6946
|
}
|
|
6851
6947
|
}), "startAgent")
|
|
6852
6948
|
};
|
|
6853
|
-
void (0,
|
|
6949
|
+
void (0, import_nestjs_agent_core38.runAgentLoop)({
|
|
6854
6950
|
...deps,
|
|
6855
6951
|
day
|
|
6856
6952
|
}, {
|
|
@@ -6864,13 +6960,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6864
6960
|
parentRunId,
|
|
6865
6961
|
deliverTo
|
|
6866
6962
|
}, hooks).catch(async (error) => {
|
|
6867
|
-
const cancelled = error instanceof
|
|
6963
|
+
const cancelled = error instanceof import_nestjs_agent_core38.RunCancelledError;
|
|
6868
6964
|
const message = error instanceof Error ? error.message : String(error);
|
|
6869
6965
|
if (!cancelled) {
|
|
6870
6966
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
6871
|
-
(0,
|
|
6967
|
+
(0, import_nestjs_agent_core38.publishAgentRunFailed)({
|
|
6872
6968
|
runId,
|
|
6873
|
-
code: (0,
|
|
6969
|
+
code: (0, import_nestjs_agent_core38.agentFailureCode)(error),
|
|
6874
6970
|
message
|
|
6875
6971
|
});
|
|
6876
6972
|
}
|
|
@@ -6878,12 +6974,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6878
6974
|
runId,
|
|
6879
6975
|
status: cancelled ? "cancelled" : "failed",
|
|
6880
6976
|
...cancelled ? {} : {
|
|
6881
|
-
errorCode: (0,
|
|
6977
|
+
errorCode: (0, import_nestjs_agent_core38.agentFailureCode)(error),
|
|
6882
6978
|
errorMessage: message
|
|
6883
6979
|
}
|
|
6884
6980
|
});
|
|
6885
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
6886
|
-
await (0,
|
|
6981
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core38.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
6982
|
+
await (0, import_nestjs_agent_core38.settleUnsettledDelegation)({
|
|
6887
6983
|
store: this.store,
|
|
6888
6984
|
delivery: deliverTo,
|
|
6889
6985
|
agent: agentName,
|
|
@@ -6922,7 +7018,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6922
7018
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
6923
7019
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
6924
7020
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
6925
|
-
parallel:
|
|
7021
|
+
parallel: import_nestjs_agent_core38.settleAll,
|
|
6926
7022
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
6927
7023
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
6928
7024
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -6959,7 +7055,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6959
7055
|
}), "startAgent")
|
|
6960
7056
|
};
|
|
6961
7057
|
try {
|
|
6962
|
-
return await (0,
|
|
7058
|
+
return await (0, import_nestjs_agent_core38.runAgentLoop)({
|
|
6963
7059
|
...deps,
|
|
6964
7060
|
day
|
|
6965
7061
|
}, {
|
|
@@ -6978,13 +7074,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6978
7074
|
}
|
|
6979
7075
|
}
|
|
6980
7076
|
};
|
|
6981
|
-
InlineAgentRunner =
|
|
6982
|
-
(0,
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
7077
|
+
InlineAgentRunner = _ts_decorate30([
|
|
7078
|
+
(0, import_common31.Injectable)(),
|
|
7079
|
+
_ts_param28(0, (0, import_common31.Inject)(import_nestjs_agent_core38.AGENT_DEPS_FACTORY)),
|
|
7080
|
+
_ts_param28(1, (0, import_common31.Inject)(import_nestjs_agent_core38.AGENT_STORE)),
|
|
7081
|
+
_ts_param28(2, (0, import_common31.Optional)()),
|
|
7082
|
+
_ts_metadata28("design:type", Function),
|
|
7083
|
+
_ts_metadata28("design:paramtypes", [
|
|
6988
7084
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
6989
7085
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
6990
7086
|
typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2
|
|
@@ -6996,7 +7092,7 @@ function isThreadTurn2(input) {
|
|
|
6996
7092
|
__name(isThreadTurn2, "isThreadTurn");
|
|
6997
7093
|
|
|
6998
7094
|
// src/skills-config.ts
|
|
6999
|
-
var
|
|
7095
|
+
var import_nestjs_agent_core39 = require("@dudousxd/nestjs-agent-core");
|
|
7000
7096
|
function declaredSkillProvider(declared) {
|
|
7001
7097
|
return {
|
|
7002
7098
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -7022,7 +7118,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
7022
7118
|
declaredSkillProvider(declared)
|
|
7023
7119
|
];
|
|
7024
7120
|
return {
|
|
7025
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
7121
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core39.compositeSkillProvider)(providers),
|
|
7026
7122
|
...options.scopes !== void 0 ? {
|
|
7027
7123
|
scopes: options.scopes
|
|
7028
7124
|
} : {},
|
|
@@ -7034,7 +7130,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
7034
7130
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
7035
7131
|
|
|
7036
7132
|
// src/agent.module.ts
|
|
7037
|
-
function
|
|
7133
|
+
function _ts_decorate31(decorators, target, key, desc) {
|
|
7038
7134
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7039
7135
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
7040
7136
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -7047,9 +7143,9 @@ function _ts_decorate30(decorators, target, key, desc) {
|
|
|
7047
7143
|
}
|
|
7048
7144
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7049
7145
|
}
|
|
7050
|
-
__name(
|
|
7146
|
+
__name(_ts_decorate31, "_ts_decorate");
|
|
7051
7147
|
var DEFAULT_PATH = "agent";
|
|
7052
|
-
var
|
|
7148
|
+
var logger2 = new import_common32.Logger("AgentModule");
|
|
7053
7149
|
function externalWrapper(modules, token) {
|
|
7054
7150
|
for (const module2 of modules.values()) {
|
|
7055
7151
|
if (module2.metatype === AgentModule) continue;
|
|
@@ -7081,22 +7177,22 @@ function forwardingStore(wrapper) {
|
|
|
7081
7177
|
__name(forwardingStore, "forwardingStore");
|
|
7082
7178
|
function resolveStore(options, modules) {
|
|
7083
7179
|
if (options.store !== void 0) return options.store;
|
|
7084
|
-
const external = externalWrapper(modules,
|
|
7180
|
+
const external = externalWrapper(modules, import_nestjs_agent_core40.AGENT_STORE);
|
|
7085
7181
|
if (external !== void 0) return forwardingStore(external);
|
|
7086
|
-
|
|
7087
|
-
return new
|
|
7182
|
+
logger2.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()).");
|
|
7183
|
+
return new import_nestjs_agent_core40.InMemoryAgentStore();
|
|
7088
7184
|
}
|
|
7089
7185
|
__name(resolveStore, "resolveStore");
|
|
7090
7186
|
function resolveRolesPolicy(options, modules) {
|
|
7091
|
-
const external = externalWrapper(modules,
|
|
7187
|
+
const external = externalWrapper(modules, import_nestjs_agent_core40.AGENT_ROLES_POLICY);
|
|
7092
7188
|
if (options.rolesPolicy !== void 0) {
|
|
7093
7189
|
if (external !== void 0) {
|
|
7094
|
-
|
|
7190
|
+
logger2.warn("Both a `rolesPolicy` option and a module binding AGENT_ROLES_POLICY (e.g. AgentAuthzModule) are configured \u2014 the `rolesPolicy` option wins.");
|
|
7095
7191
|
}
|
|
7096
7192
|
return options.rolesPolicy;
|
|
7097
7193
|
}
|
|
7098
7194
|
if (external !== void 0) return forwardingPolicy(external);
|
|
7099
|
-
return options.emptyRoles === "deny" ? new
|
|
7195
|
+
return options.emptyRoles === "deny" ? new import_nestjs_agent_core40.ClosedRolesPolicy(options.defaultRoles) : new import_nestjs_agent_core40.DefaultRolesPolicy(options.defaultRoles);
|
|
7100
7196
|
}
|
|
7101
7197
|
__name(resolveRolesPolicy, "resolveRolesPolicy");
|
|
7102
7198
|
function forwardingPolicy(wrapper) {
|
|
@@ -7124,102 +7220,110 @@ __name(resolveCatalog, "resolveCatalog");
|
|
|
7124
7220
|
function sharedProviders(durable, engine) {
|
|
7125
7221
|
const providers = [
|
|
7126
7222
|
{
|
|
7127
|
-
provide:
|
|
7128
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
7223
|
+
provide: import_nestjs_agent_core40.AGENT_TOOL_REGISTRY,
|
|
7224
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core40.ToolRegistry(), "useFactory")
|
|
7129
7225
|
},
|
|
7130
7226
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
7131
7227
|
{
|
|
7132
|
-
provide:
|
|
7133
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
7228
|
+
provide: import_nestjs_agent_core40.AGENT_REGISTRY,
|
|
7229
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core40.AgentRegistry(), "useFactory")
|
|
7134
7230
|
},
|
|
7135
7231
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
7136
7232
|
{
|
|
7137
|
-
provide:
|
|
7233
|
+
provide: import_nestjs_agent_core40.AGENT_PROMPT_CONTRIBUTORS,
|
|
7138
7234
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
7139
7235
|
},
|
|
7140
7236
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
7141
7237
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
7142
7238
|
{
|
|
7143
|
-
provide:
|
|
7239
|
+
provide: import_nestjs_agent_core40.AGENT_SKILL_SOURCES,
|
|
7144
7240
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
7145
7241
|
},
|
|
7146
7242
|
{
|
|
7147
7243
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
7148
7244
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
7149
7245
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
7150
|
-
provide:
|
|
7246
|
+
provide: import_nestjs_agent_core40.AGENT_SKILLS,
|
|
7151
7247
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
7152
7248
|
inject: [
|
|
7153
|
-
|
|
7154
|
-
|
|
7249
|
+
import_nestjs_agent_core40.AGENT_OPTIONS,
|
|
7250
|
+
import_nestjs_agent_core40.AGENT_SKILL_SOURCES
|
|
7155
7251
|
]
|
|
7156
7252
|
},
|
|
7157
7253
|
{
|
|
7158
7254
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
7159
7255
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
7160
|
-
provide:
|
|
7256
|
+
provide: import_nestjs_agent_core40.AGENT_MEMORY,
|
|
7161
7257
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
7162
7258
|
inject: [
|
|
7163
|
-
|
|
7259
|
+
import_nestjs_agent_core40.AGENT_OPTIONS
|
|
7164
7260
|
]
|
|
7165
7261
|
},
|
|
7166
7262
|
{
|
|
7167
|
-
provide:
|
|
7263
|
+
provide: import_nestjs_agent_core40.AGENT_SINK,
|
|
7168
7264
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
7169
7265
|
inject: [
|
|
7170
|
-
|
|
7266
|
+
import_nestjs_agent_core40.AGENT_OPTIONS
|
|
7171
7267
|
]
|
|
7172
7268
|
},
|
|
7173
7269
|
{
|
|
7174
|
-
provide:
|
|
7270
|
+
provide: import_nestjs_agent_core40.AGENT_ROLES_POLICY,
|
|
7175
7271
|
useFactory: /* @__PURE__ */ __name((options, modules) => resolveRolesPolicy(options, modules), "useFactory"),
|
|
7176
7272
|
inject: [
|
|
7177
|
-
|
|
7273
|
+
import_nestjs_agent_core40.AGENT_OPTIONS,
|
|
7178
7274
|
import_core4.ModulesContainer
|
|
7179
7275
|
]
|
|
7180
7276
|
},
|
|
7181
7277
|
{
|
|
7182
|
-
provide:
|
|
7278
|
+
provide: import_nestjs_agent_core40.AGENT_ACTOR_RESOLVER,
|
|
7183
7279
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
7184
7280
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
7185
|
-
|
|
7281
|
+
logger2.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.");
|
|
7186
7282
|
return new AnonymousActorResolver();
|
|
7187
7283
|
}, "useFactory"),
|
|
7188
7284
|
inject: [
|
|
7189
|
-
|
|
7285
|
+
import_nestjs_agent_core40.AGENT_OPTIONS
|
|
7190
7286
|
]
|
|
7191
7287
|
},
|
|
7192
7288
|
{
|
|
7193
|
-
provide:
|
|
7289
|
+
provide: import_nestjs_agent_core40.AGENT_MODEL,
|
|
7194
7290
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
7195
7291
|
inject: [
|
|
7196
|
-
|
|
7292
|
+
import_nestjs_agent_core40.AGENT_OPTIONS
|
|
7197
7293
|
]
|
|
7198
7294
|
},
|
|
7199
7295
|
{
|
|
7200
7296
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
7201
7297
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
7202
|
-
provide:
|
|
7203
|
-
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits,
|
|
7204
|
-
|
|
7205
|
-
|
|
7298
|
+
provide: import_nestjs_agent_core40.AGENT_QUOTA_PROVIDER,
|
|
7299
|
+
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, {
|
|
7300
|
+
...o.quota?.warnAt !== void 0 ? {
|
|
7301
|
+
warnAt: o.quota.warnAt
|
|
7302
|
+
} : {},
|
|
7303
|
+
...o.quota?.countEstimatedCost !== void 0 ? {
|
|
7304
|
+
countEstimatedCost: o.quota.countEstimatedCost
|
|
7305
|
+
} : {}
|
|
7306
|
+
}), "useFactory"),
|
|
7206
7307
|
inject: [
|
|
7207
|
-
|
|
7208
|
-
|
|
7308
|
+
import_nestjs_agent_core40.AGENT_OPTIONS,
|
|
7309
|
+
import_nestjs_agent_core40.AGENT_STORE
|
|
7209
7310
|
]
|
|
7210
7311
|
},
|
|
7211
7312
|
{
|
|
7212
|
-
provide:
|
|
7313
|
+
provide: import_nestjs_agent_core40.AGENT_MODEL_CATALOG,
|
|
7213
7314
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
7214
7315
|
inject: [
|
|
7215
|
-
|
|
7316
|
+
import_nestjs_agent_core40.AGENT_OPTIONS
|
|
7216
7317
|
]
|
|
7217
7318
|
},
|
|
7218
7319
|
AgentDepsFactory2,
|
|
7219
7320
|
{
|
|
7220
|
-
provide:
|
|
7321
|
+
provide: import_nestjs_agent_core40.AGENT_DEPS_FACTORY,
|
|
7221
7322
|
useExisting: AgentDepsFactory2
|
|
7222
7323
|
},
|
|
7324
|
+
// Seeds a configured model's missing price row from models.dev and warns about one that would
|
|
7325
|
+
// record no cost (`priceCatalog`), once the app has bootstrapped.
|
|
7326
|
+
PricingBootService,
|
|
7223
7327
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
7224
7328
|
// handoff tools (onApplicationBootstrap) reads the registry.
|
|
7225
7329
|
AgentDiscoveryService,
|
|
@@ -7240,26 +7344,26 @@ function sharedProviders(durable, engine) {
|
|
|
7240
7344
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
7241
7345
|
AgentApprovalPortAdapter,
|
|
7242
7346
|
{
|
|
7243
|
-
provide:
|
|
7347
|
+
provide: import_nestjs_agent_core40.AGENT_APPROVAL_PORT,
|
|
7244
7348
|
useExisting: AgentApprovalPortAdapter
|
|
7245
7349
|
}
|
|
7246
7350
|
];
|
|
7247
7351
|
providers.push({
|
|
7248
|
-
provide:
|
|
7352
|
+
provide: import_nestjs_agent_core40.AGENT_STORE,
|
|
7249
7353
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
7250
7354
|
inject: [
|
|
7251
|
-
|
|
7355
|
+
import_nestjs_agent_core40.AGENT_OPTIONS,
|
|
7252
7356
|
import_core4.ModulesContainer
|
|
7253
7357
|
]
|
|
7254
7358
|
});
|
|
7255
7359
|
if (engine !== void 0) {
|
|
7256
7360
|
providers.push(...engine.providers, {
|
|
7257
|
-
provide:
|
|
7361
|
+
provide: import_nestjs_agent_core40.AGENT_RUNNER,
|
|
7258
7362
|
useExisting: engine.runner
|
|
7259
7363
|
});
|
|
7260
7364
|
} else if (durable) {
|
|
7261
7365
|
providers.push({
|
|
7262
|
-
provide:
|
|
7366
|
+
provide: import_nestjs_agent_core40.AGENT_RUNNER,
|
|
7263
7367
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
7264
7368
|
if (durableRunner === void 0) {
|
|
7265
7369
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -7268,14 +7372,14 @@ function sharedProviders(durable, engine) {
|
|
|
7268
7372
|
}, "useFactory"),
|
|
7269
7373
|
inject: [
|
|
7270
7374
|
{
|
|
7271
|
-
token:
|
|
7375
|
+
token: import_nestjs_agent_core40.AGENT_DURABLE_RUNNER,
|
|
7272
7376
|
optional: true
|
|
7273
7377
|
}
|
|
7274
7378
|
]
|
|
7275
7379
|
});
|
|
7276
7380
|
} else {
|
|
7277
7381
|
providers.push({
|
|
7278
|
-
provide:
|
|
7382
|
+
provide: import_nestjs_agent_core40.AGENT_RUNNER,
|
|
7279
7383
|
useExisting: InlineAgentRunner
|
|
7280
7384
|
});
|
|
7281
7385
|
}
|
|
@@ -7285,20 +7389,20 @@ __name(sharedProviders, "sharedProviders");
|
|
|
7285
7389
|
function exportsFor(engine) {
|
|
7286
7390
|
return [
|
|
7287
7391
|
...engine?.exports ?? [],
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7392
|
+
import_nestjs_agent_core40.AGENT_OPTIONS,
|
|
7393
|
+
import_nestjs_agent_core40.AGENT_TOOL_REGISTRY,
|
|
7394
|
+
import_nestjs_agent_core40.AGENT_REGISTRY,
|
|
7395
|
+
import_nestjs_agent_core40.AGENT_SINK,
|
|
7396
|
+
import_nestjs_agent_core40.AGENT_ROLES_POLICY,
|
|
7397
|
+
import_nestjs_agent_core40.AGENT_ACTOR_RESOLVER,
|
|
7398
|
+
import_nestjs_agent_core40.AGENT_MODEL,
|
|
7399
|
+
import_nestjs_agent_core40.AGENT_STORE,
|
|
7400
|
+
import_nestjs_agent_core40.AGENT_MODEL_CATALOG,
|
|
7401
|
+
import_nestjs_agent_core40.AGENT_QUOTA_PROVIDER,
|
|
7402
|
+
import_nestjs_agent_core40.AGENT_PROMPT_CONTRIBUTORS,
|
|
7403
|
+
import_nestjs_agent_core40.AGENT_SKILLS,
|
|
7404
|
+
import_nestjs_agent_core40.AGENT_MEMORY,
|
|
7405
|
+
import_nestjs_agent_core40.AGENT_DEPS_FACTORY,
|
|
7302
7406
|
AgentDepsFactory2,
|
|
7303
7407
|
AgentService,
|
|
7304
7408
|
ActionProposalService,
|
|
@@ -7306,7 +7410,7 @@ function exportsFor(engine) {
|
|
|
7306
7410
|
ChatQueueService2,
|
|
7307
7411
|
AGENT_CHAT_QUEUE,
|
|
7308
7412
|
InlineAgentRunner,
|
|
7309
|
-
|
|
7413
|
+
import_nestjs_agent_core40.AGENT_APPROVAL_PORT
|
|
7310
7414
|
];
|
|
7311
7415
|
}
|
|
7312
7416
|
__name(exportsFor, "exportsFor");
|
|
@@ -7395,7 +7499,7 @@ var AgentModule = class _AgentModule {
|
|
|
7395
7499
|
controllers: controllersForSurface(options.surface, options.adapters, options.engine),
|
|
7396
7500
|
providers: [
|
|
7397
7501
|
{
|
|
7398
|
-
provide:
|
|
7502
|
+
provide: import_nestjs_agent_core40.AGENT_OPTIONS,
|
|
7399
7503
|
useValue: options
|
|
7400
7504
|
},
|
|
7401
7505
|
...sharedProviders(options.durable ?? false, options.engine),
|
|
@@ -7425,7 +7529,7 @@ var AgentModule = class _AgentModule {
|
|
|
7425
7529
|
controllers: controllersForSurface(options.surface, options.adapters, options.engine),
|
|
7426
7530
|
providers: [
|
|
7427
7531
|
{
|
|
7428
|
-
provide:
|
|
7532
|
+
provide: import_nestjs_agent_core40.AGENT_OPTIONS,
|
|
7429
7533
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
7430
7534
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
7431
7535
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -7454,9 +7558,9 @@ var AgentModule = class _AgentModule {
|
|
|
7454
7558
|
};
|
|
7455
7559
|
}
|
|
7456
7560
|
};
|
|
7457
|
-
AgentModule =
|
|
7458
|
-
(0,
|
|
7459
|
-
(0,
|
|
7561
|
+
AgentModule = _ts_decorate31([
|
|
7562
|
+
(0, import_common32.Global)(),
|
|
7563
|
+
(0, import_common32.Module)({})
|
|
7460
7564
|
], AgentModule);
|
|
7461
7565
|
|
|
7462
7566
|
// src/durable/agent-durable.ts
|