@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.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AgentStore, AgentRunInput, AgentLoopResult, LlmStepEnvelope, BufferedModelTurnResult, ToolStepEnvelope, AgentRunner, TokenStreamSink, AgentRunStartOptions, HumanReply } from '@dudousxd/nestjs-agent-core';
|
|
2
2
|
import { WorkflowService } from '@dudousxd/nestjs-durable';
|
|
3
3
|
import { RunGateway, WorkflowCtx } from '@dudousxd/nestjs-durable-core';
|
|
4
|
-
import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-
|
|
4
|
+
import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-Cu2nJpXz.cjs';
|
|
5
5
|
import { DynamicModule } from '@nestjs/common';
|
|
6
6
|
import '@dudousxd/nestjs-agent-core/genui';
|
|
7
7
|
import '@standard-schema/spec';
|
package/dist/durable/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AgentStore, AgentRunInput, AgentLoopResult, LlmStepEnvelope, BufferedModelTurnResult, ToolStepEnvelope, AgentRunner, TokenStreamSink, AgentRunStartOptions, HumanReply } from '@dudousxd/nestjs-agent-core';
|
|
2
2
|
import { WorkflowService } from '@dudousxd/nestjs-durable';
|
|
3
3
|
import { RunGateway, WorkflowCtx } from '@dudousxd/nestjs-durable-core';
|
|
4
|
-
import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-
|
|
4
|
+
import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-uD1vR8fs.js';
|
|
5
5
|
import { DynamicModule } from '@nestjs/common';
|
|
6
6
|
import '@dudousxd/nestjs-agent-core/genui';
|
|
7
7
|
import '@standard-schema/spec';
|
package/dist/durable/index.js
CHANGED
|
@@ -1188,8 +1188,8 @@ AgentDurableModule = _ts_decorate4([
|
|
|
1188
1188
|
], AgentDurableModule);
|
|
1189
1189
|
|
|
1190
1190
|
// src/agent.module.ts
|
|
1191
|
-
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER14, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY9, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as
|
|
1192
|
-
import { Global as Global2, Logger as
|
|
1191
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER14, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY9, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL3, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS10, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER3, AGENT_REGISTRY as AGENT_REGISTRY6, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK4, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE9, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, ClosedRolesPolicy, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
1192
|
+
import { Global as Global2, Logger as Logger10, Module as Module3 } from "@nestjs/common";
|
|
1193
1193
|
import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
|
|
1194
1194
|
|
|
1195
1195
|
// src/agent-deps.factory.ts
|
|
@@ -6142,7 +6142,7 @@ var LedgerQuotaProvider = class {
|
|
|
6142
6142
|
if (this.store.usageBetween !== void 0) {
|
|
6143
6143
|
const range = quotaPeriodRange("month", now);
|
|
6144
6144
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
6145
|
-
windows.push(this.window("month", used.usedTokens, used
|
|
6145
|
+
windows.push(this.window("month", used.usedTokens, this.usd(used), range.resetsAt));
|
|
6146
6146
|
}
|
|
6147
6147
|
const blocked = exhaustedWindow(windows);
|
|
6148
6148
|
const warning = quotaWarning(windows);
|
|
@@ -6158,8 +6158,15 @@ var LedgerQuotaProvider = class {
|
|
|
6158
6158
|
}
|
|
6159
6159
|
async dayWindow(actorRef, now) {
|
|
6160
6160
|
const range = quotaPeriodRange("day", now);
|
|
6161
|
-
const
|
|
6162
|
-
return this.window("day", usedTokens,
|
|
6161
|
+
const used = await this.store.quotaToday(actorRef, range.fromDay);
|
|
6162
|
+
return this.window("day", used.usedTokens, this.usd(used), range.resetsAt);
|
|
6163
|
+
}
|
|
6164
|
+
/** The window's USD: every priced row, or (with `countEstimatedCost: false`) reported cost only. */
|
|
6165
|
+
usd(used) {
|
|
6166
|
+
if (this.options.countEstimatedCost === false) {
|
|
6167
|
+
return Math.max(0, used.costUsd - (used.estimatedCostUsd ?? 0));
|
|
6168
|
+
}
|
|
6169
|
+
return used.costUsd;
|
|
6163
6170
|
}
|
|
6164
6171
|
window(period, usedTokens, usedUsd, resetsAt) {
|
|
6165
6172
|
const limits = this.limits[period] ?? {};
|
|
@@ -6181,10 +6188,9 @@ var LedgerQuotaProvider = class {
|
|
|
6181
6188
|
}
|
|
6182
6189
|
};
|
|
6183
6190
|
|
|
6184
|
-
// src/
|
|
6185
|
-
import {
|
|
6186
|
-
import {
|
|
6187
|
-
import { Inject as Inject25, Injectable as Injectable12, Logger as Logger7 } from "@nestjs/common";
|
|
6191
|
+
// src/pricing-boot.service.ts
|
|
6192
|
+
import { AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS8, AGENT_PRICING_STORE as AGENT_PRICING_STORE2, ensureModelPricing } from "@dudousxd/nestjs-agent-core";
|
|
6193
|
+
import { Inject as Inject25, Injectable as Injectable12, Logger as Logger7, Optional as Optional11 } from "@nestjs/common";
|
|
6188
6194
|
function _ts_decorate27(decorators, target, key, desc) {
|
|
6189
6195
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6190
6196
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -6211,6 +6217,96 @@ function _ts_param25(paramIndex, decorator) {
|
|
|
6211
6217
|
};
|
|
6212
6218
|
}
|
|
6213
6219
|
__name(_ts_param25, "_ts_param");
|
|
6220
|
+
var logger = new Logger7("AgentPricing");
|
|
6221
|
+
var PricingBootService = class {
|
|
6222
|
+
static {
|
|
6223
|
+
__name(this, "PricingBootService");
|
|
6224
|
+
}
|
|
6225
|
+
options;
|
|
6226
|
+
model;
|
|
6227
|
+
pricingStore;
|
|
6228
|
+
#run = null;
|
|
6229
|
+
constructor(options, model, pricingStore) {
|
|
6230
|
+
this.options = options;
|
|
6231
|
+
this.model = model;
|
|
6232
|
+
this.pricingStore = pricingStore;
|
|
6233
|
+
}
|
|
6234
|
+
onApplicationBootstrap() {
|
|
6235
|
+
this.#run = this.check();
|
|
6236
|
+
}
|
|
6237
|
+
/** Awaits a check still in flight, so a test (or a fast shutdown) never leaks it. */
|
|
6238
|
+
async onApplicationShutdown() {
|
|
6239
|
+
await this.#run;
|
|
6240
|
+
this.#run = null;
|
|
6241
|
+
}
|
|
6242
|
+
/** The check itself; resolves once it is done (exposed for tests). */
|
|
6243
|
+
async check() {
|
|
6244
|
+
let models;
|
|
6245
|
+
try {
|
|
6246
|
+
models = this.model?.describeModels?.() ?? [];
|
|
6247
|
+
} catch (error) {
|
|
6248
|
+
logger.warn(`describeModels() threw; boot pricing skipped: ${String(error)}`);
|
|
6249
|
+
return;
|
|
6250
|
+
}
|
|
6251
|
+
if (models.length === 0) return;
|
|
6252
|
+
const catalog = this.options.priceCatalog;
|
|
6253
|
+
if (catalog === void 0 && process.env.NODE_ENV === "test") return;
|
|
6254
|
+
await ensureModelPricing({
|
|
6255
|
+
models,
|
|
6256
|
+
pricingStore: this.pricingStore,
|
|
6257
|
+
catalog: catalog ?? {},
|
|
6258
|
+
log: {
|
|
6259
|
+
info: /* @__PURE__ */ __name((message) => logger.log(message), "info"),
|
|
6260
|
+
warn: /* @__PURE__ */ __name((message) => logger.warn(message), "warn")
|
|
6261
|
+
}
|
|
6262
|
+
}).catch(() => void 0);
|
|
6263
|
+
}
|
|
6264
|
+
};
|
|
6265
|
+
PricingBootService = _ts_decorate27([
|
|
6266
|
+
Injectable12(),
|
|
6267
|
+
_ts_param25(0, Inject25(AGENT_OPTIONS8)),
|
|
6268
|
+
_ts_param25(1, Optional11()),
|
|
6269
|
+
_ts_param25(1, Inject25(AGENT_MODEL2)),
|
|
6270
|
+
_ts_param25(2, Optional11()),
|
|
6271
|
+
_ts_param25(2, Inject25(AGENT_PRICING_STORE2)),
|
|
6272
|
+
_ts_metadata25("design:type", Function),
|
|
6273
|
+
_ts_metadata25("design:paramtypes", [
|
|
6274
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
6275
|
+
Object,
|
|
6276
|
+
Object
|
|
6277
|
+
])
|
|
6278
|
+
], PricingBootService);
|
|
6279
|
+
|
|
6280
|
+
// src/proposals/action-proposal-worker.service.ts
|
|
6281
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
6282
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_OPTIONS as AGENT_OPTIONS9, AGENT_STORE as AGENT_STORE7, ActionProposalExecutor, ActionProposalWorker, assertIndependentActionCapabilities as assertIndependentActionCapabilities2 } from "@dudousxd/nestjs-agent-core";
|
|
6283
|
+
import { Inject as Inject26, Injectable as Injectable13, Logger as Logger8 } from "@nestjs/common";
|
|
6284
|
+
function _ts_decorate28(decorators, target, key, desc) {
|
|
6285
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6286
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6287
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
6288
|
+
} else {
|
|
6289
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
6290
|
+
if (d = decorators[i]) {
|
|
6291
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6292
|
+
}
|
|
6293
|
+
}
|
|
6294
|
+
}
|
|
6295
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6296
|
+
}
|
|
6297
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
6298
|
+
function _ts_metadata26(metadataKey, metadataValue) {
|
|
6299
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
6300
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
6301
|
+
}
|
|
6302
|
+
}
|
|
6303
|
+
__name(_ts_metadata26, "_ts_metadata");
|
|
6304
|
+
function _ts_param26(paramIndex, decorator) {
|
|
6305
|
+
return function(target, key) {
|
|
6306
|
+
decorator(target, key, paramIndex);
|
|
6307
|
+
};
|
|
6308
|
+
}
|
|
6309
|
+
__name(_ts_param26, "_ts_param");
|
|
6214
6310
|
var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
6215
6311
|
static {
|
|
6216
6312
|
__name(this, "ActionProposalWorkerService");
|
|
@@ -6219,7 +6315,7 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
|
6219
6315
|
options;
|
|
6220
6316
|
deps;
|
|
6221
6317
|
worker;
|
|
6222
|
-
logger = new
|
|
6318
|
+
logger = new Logger8(_ActionProposalWorkerService.name);
|
|
6223
6319
|
settledListeners = /* @__PURE__ */ new Set();
|
|
6224
6320
|
/**
|
|
6225
6321
|
* Run `listener` after every proposal this process's worker settles — how a module relays an
|
|
@@ -6288,13 +6384,13 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
|
6288
6384
|
await this.worker?.stop();
|
|
6289
6385
|
}
|
|
6290
6386
|
};
|
|
6291
|
-
ActionProposalWorkerService =
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6387
|
+
ActionProposalWorkerService = _ts_decorate28([
|
|
6388
|
+
Injectable13(),
|
|
6389
|
+
_ts_param26(0, Inject26(AGENT_STORE7)),
|
|
6390
|
+
_ts_param26(1, Inject26(AGENT_OPTIONS9)),
|
|
6391
|
+
_ts_param26(2, Inject26(AGENT_DEPS_FACTORY7)),
|
|
6392
|
+
_ts_metadata26("design:type", Function),
|
|
6393
|
+
_ts_metadata26("design:paramtypes", [
|
|
6298
6394
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
6299
6395
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
6300
6396
|
typeof AgentDepsFactory2 === "undefined" ? Object : AgentDepsFactory2
|
|
@@ -6303,8 +6399,8 @@ ActionProposalWorkerService = _ts_decorate27([
|
|
|
6303
6399
|
|
|
6304
6400
|
// src/proposals/action-proposal.controller.ts
|
|
6305
6401
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER13, validateActionProposalListQuery } from "@dudousxd/nestjs-agent-core";
|
|
6306
|
-
import { BadRequestException as BadRequestException7, Body as Body6, Controller as Controller14, Get as Get12, Inject as
|
|
6307
|
-
function
|
|
6402
|
+
import { BadRequestException as BadRequestException7, Body as Body6, Controller as Controller14, Get as Get12, Inject as Inject27, Param as Param6, Post as Post7, Query as Query6, Req as Req13, Res as Res2 } from "@nestjs/common";
|
|
6403
|
+
function _ts_decorate29(decorators, target, key, desc) {
|
|
6308
6404
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6309
6405
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6310
6406
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6317,19 +6413,19 @@ function _ts_decorate28(decorators, target, key, desc) {
|
|
|
6317
6413
|
}
|
|
6318
6414
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6319
6415
|
}
|
|
6320
|
-
__name(
|
|
6321
|
-
function
|
|
6416
|
+
__name(_ts_decorate29, "_ts_decorate");
|
|
6417
|
+
function _ts_metadata27(metadataKey, metadataValue) {
|
|
6322
6418
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
6323
6419
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
6324
6420
|
}
|
|
6325
6421
|
}
|
|
6326
|
-
__name(
|
|
6327
|
-
function
|
|
6422
|
+
__name(_ts_metadata27, "_ts_metadata");
|
|
6423
|
+
function _ts_param27(paramIndex, decorator) {
|
|
6328
6424
|
return function(target, key) {
|
|
6329
6425
|
decorator(target, key, paramIndex);
|
|
6330
6426
|
};
|
|
6331
6427
|
}
|
|
6332
|
-
__name(
|
|
6428
|
+
__name(_ts_param27, "_ts_param");
|
|
6333
6429
|
function bodyFields(body, field) {
|
|
6334
6430
|
if (body === void 0) return {};
|
|
6335
6431
|
if (typeof body !== "object" || body === null || Array.isArray(body) || Object.keys(body).some((key) => key !== field)) throw new BadRequestException7(`Only ${field} is accepted`);
|
|
@@ -6388,58 +6484,58 @@ var ActionProposalController = class {
|
|
|
6388
6484
|
});
|
|
6389
6485
|
}
|
|
6390
6486
|
};
|
|
6391
|
-
|
|
6487
|
+
_ts_decorate29([
|
|
6392
6488
|
Get12(),
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6489
|
+
_ts_param27(0, Param6("threadId")),
|
|
6490
|
+
_ts_param27(1, Req13()),
|
|
6491
|
+
_ts_param27(2, Query6("after")),
|
|
6492
|
+
_ts_param27(3, Res2({
|
|
6397
6493
|
passthrough: true
|
|
6398
6494
|
})),
|
|
6399
|
-
|
|
6400
|
-
|
|
6495
|
+
_ts_metadata27("design:type", Function),
|
|
6496
|
+
_ts_metadata27("design:paramtypes", [
|
|
6401
6497
|
String,
|
|
6402
6498
|
typeof Request === "undefined" ? Object : Request,
|
|
6403
6499
|
Object,
|
|
6404
6500
|
typeof Response === "undefined" ? Object : Response
|
|
6405
6501
|
]),
|
|
6406
|
-
|
|
6502
|
+
_ts_metadata27("design:returntype", Promise)
|
|
6407
6503
|
], ActionProposalController.prototype, "list", null);
|
|
6408
|
-
|
|
6504
|
+
_ts_decorate29([
|
|
6409
6505
|
Post7(":proposalId/approve"),
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6506
|
+
_ts_param27(0, Param6("threadId")),
|
|
6507
|
+
_ts_param27(1, Param6("proposalId")),
|
|
6508
|
+
_ts_param27(2, Req13()),
|
|
6509
|
+
_ts_param27(3, Body6()),
|
|
6510
|
+
_ts_metadata27("design:type", Function),
|
|
6511
|
+
_ts_metadata27("design:paramtypes", [
|
|
6416
6512
|
String,
|
|
6417
6513
|
String,
|
|
6418
6514
|
typeof Request === "undefined" ? Object : Request,
|
|
6419
6515
|
Object
|
|
6420
6516
|
]),
|
|
6421
|
-
|
|
6517
|
+
_ts_metadata27("design:returntype", Promise)
|
|
6422
6518
|
], ActionProposalController.prototype, "approve", null);
|
|
6423
|
-
|
|
6519
|
+
_ts_decorate29([
|
|
6424
6520
|
Post7(":proposalId/reject"),
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6521
|
+
_ts_param27(0, Param6("threadId")),
|
|
6522
|
+
_ts_param27(1, Param6("proposalId")),
|
|
6523
|
+
_ts_param27(2, Req13()),
|
|
6524
|
+
_ts_param27(3, Body6()),
|
|
6525
|
+
_ts_metadata27("design:type", Function),
|
|
6526
|
+
_ts_metadata27("design:paramtypes", [
|
|
6431
6527
|
String,
|
|
6432
6528
|
String,
|
|
6433
6529
|
typeof Request === "undefined" ? Object : Request,
|
|
6434
6530
|
Object
|
|
6435
6531
|
]),
|
|
6436
|
-
|
|
6532
|
+
_ts_metadata27("design:returntype", Promise)
|
|
6437
6533
|
], ActionProposalController.prototype, "reject", null);
|
|
6438
|
-
ActionProposalController =
|
|
6534
|
+
ActionProposalController = _ts_decorate29([
|
|
6439
6535
|
Controller14("threads/:threadId/action-proposals"),
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6536
|
+
_ts_param27(1, Inject27(AGENT_ACTOR_RESOLVER13)),
|
|
6537
|
+
_ts_metadata27("design:type", Function),
|
|
6538
|
+
_ts_metadata27("design:paramtypes", [
|
|
6443
6539
|
typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
|
|
6444
6540
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
6445
6541
|
])
|
|
@@ -6447,8 +6543,8 @@ ActionProposalController = _ts_decorate28([
|
|
|
6447
6543
|
|
|
6448
6544
|
// src/runner/inline-agent-runner.ts
|
|
6449
6545
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY8, AGENT_STORE as AGENT_STORE8, RUN_ENDED_BEFORE_TOOL_CALL as RUN_ENDED_BEFORE_TOOL_CALL2, RunCancelledError as RunCancelledError2, agentFailureCode as agentFailureCode2, encodeStreamEvent as encodeStreamEvent5, publishAgentRunFailed as publishAgentRunFailed2, releaseThreadRun as releaseThreadRun3, runAgentLoop as runAgentLoop2, settleAll as settleAll2, settleUnsettledDelegation as settleUnsettledDelegation3, streamFailure as streamFailure3 } from "@dudousxd/nestjs-agent-core";
|
|
6450
|
-
import { Inject as
|
|
6451
|
-
function
|
|
6546
|
+
import { Inject as Inject28, Injectable as Injectable14, Logger as Logger9, Optional as Optional12 } from "@nestjs/common";
|
|
6547
|
+
function _ts_decorate30(decorators, target, key, desc) {
|
|
6452
6548
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6453
6549
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
6454
6550
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6461,19 +6557,19 @@ function _ts_decorate29(decorators, target, key, desc) {
|
|
|
6461
6557
|
}
|
|
6462
6558
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6463
6559
|
}
|
|
6464
|
-
__name(
|
|
6465
|
-
function
|
|
6560
|
+
__name(_ts_decorate30, "_ts_decorate");
|
|
6561
|
+
function _ts_metadata28(metadataKey, metadataValue) {
|
|
6466
6562
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
6467
6563
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
6468
6564
|
}
|
|
6469
6565
|
}
|
|
6470
|
-
__name(
|
|
6471
|
-
function
|
|
6566
|
+
__name(_ts_metadata28, "_ts_metadata");
|
|
6567
|
+
function _ts_param28(paramIndex, decorator) {
|
|
6472
6568
|
return function(target, key) {
|
|
6473
6569
|
decorator(target, key, paramIndex);
|
|
6474
6570
|
};
|
|
6475
6571
|
}
|
|
6476
|
-
__name(
|
|
6572
|
+
__name(_ts_param28, "_ts_param");
|
|
6477
6573
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
6478
6574
|
static {
|
|
6479
6575
|
__name(this, "InlineAgentRunner");
|
|
@@ -6481,7 +6577,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6481
6577
|
factory;
|
|
6482
6578
|
store;
|
|
6483
6579
|
queue;
|
|
6484
|
-
logger = new
|
|
6580
|
+
logger = new Logger9(_InlineAgentRunner.name);
|
|
6485
6581
|
pending = /* @__PURE__ */ new Map();
|
|
6486
6582
|
/**
|
|
6487
6583
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -6950,13 +7046,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6950
7046
|
}
|
|
6951
7047
|
}
|
|
6952
7048
|
};
|
|
6953
|
-
InlineAgentRunner =
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
7049
|
+
InlineAgentRunner = _ts_decorate30([
|
|
7050
|
+
Injectable14(),
|
|
7051
|
+
_ts_param28(0, Inject28(AGENT_DEPS_FACTORY8)),
|
|
7052
|
+
_ts_param28(1, Inject28(AGENT_STORE8)),
|
|
7053
|
+
_ts_param28(2, Optional12()),
|
|
7054
|
+
_ts_metadata28("design:type", Function),
|
|
7055
|
+
_ts_metadata28("design:paramtypes", [
|
|
6960
7056
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
6961
7057
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
6962
7058
|
typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2
|
|
@@ -7006,7 +7102,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
7006
7102
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
7007
7103
|
|
|
7008
7104
|
// src/agent.module.ts
|
|
7009
|
-
function
|
|
7105
|
+
function _ts_decorate31(decorators, target, key, desc) {
|
|
7010
7106
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7011
7107
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
7012
7108
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -7019,9 +7115,9 @@ function _ts_decorate30(decorators, target, key, desc) {
|
|
|
7019
7115
|
}
|
|
7020
7116
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7021
7117
|
}
|
|
7022
|
-
__name(
|
|
7118
|
+
__name(_ts_decorate31, "_ts_decorate");
|
|
7023
7119
|
var DEFAULT_PATH = "agent";
|
|
7024
|
-
var
|
|
7120
|
+
var logger2 = new Logger10("AgentModule");
|
|
7025
7121
|
function externalWrapper(modules, token) {
|
|
7026
7122
|
for (const module of modules.values()) {
|
|
7027
7123
|
if (module.metatype === AgentModule) continue;
|
|
@@ -7055,7 +7151,7 @@ function resolveStore(options, modules) {
|
|
|
7055
7151
|
if (options.store !== void 0) return options.store;
|
|
7056
7152
|
const external = externalWrapper(modules, AGENT_STORE9);
|
|
7057
7153
|
if (external !== void 0) return forwardingStore(external);
|
|
7058
|
-
|
|
7154
|
+
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()).");
|
|
7059
7155
|
return new InMemoryAgentStore();
|
|
7060
7156
|
}
|
|
7061
7157
|
__name(resolveStore, "resolveStore");
|
|
@@ -7063,7 +7159,7 @@ function resolveRolesPolicy(options, modules) {
|
|
|
7063
7159
|
const external = externalWrapper(modules, AGENT_ROLES_POLICY2);
|
|
7064
7160
|
if (options.rolesPolicy !== void 0) {
|
|
7065
7161
|
if (external !== void 0) {
|
|
7066
|
-
|
|
7162
|
+
logger2.warn("Both a `rolesPolicy` option and a module binding AGENT_ROLES_POLICY (e.g. AgentAuthzModule) are configured \u2014 the `rolesPolicy` option wins.");
|
|
7067
7163
|
}
|
|
7068
7164
|
return options.rolesPolicy;
|
|
7069
7165
|
}
|
|
@@ -7122,7 +7218,7 @@ function sharedProviders(durable, engine) {
|
|
|
7122
7218
|
provide: AGENT_SKILLS3,
|
|
7123
7219
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
7124
7220
|
inject: [
|
|
7125
|
-
|
|
7221
|
+
AGENT_OPTIONS10,
|
|
7126
7222
|
AGENT_SKILL_SOURCES2
|
|
7127
7223
|
]
|
|
7128
7224
|
},
|
|
@@ -7132,21 +7228,21 @@ function sharedProviders(durable, engine) {
|
|
|
7132
7228
|
provide: AGENT_MEMORY3,
|
|
7133
7229
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
7134
7230
|
inject: [
|
|
7135
|
-
|
|
7231
|
+
AGENT_OPTIONS10
|
|
7136
7232
|
]
|
|
7137
7233
|
},
|
|
7138
7234
|
{
|
|
7139
7235
|
provide: AGENT_SINK4,
|
|
7140
7236
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
7141
7237
|
inject: [
|
|
7142
|
-
|
|
7238
|
+
AGENT_OPTIONS10
|
|
7143
7239
|
]
|
|
7144
7240
|
},
|
|
7145
7241
|
{
|
|
7146
7242
|
provide: AGENT_ROLES_POLICY2,
|
|
7147
7243
|
useFactory: /* @__PURE__ */ __name((options, modules) => resolveRolesPolicy(options, modules), "useFactory"),
|
|
7148
7244
|
inject: [
|
|
7149
|
-
|
|
7245
|
+
AGENT_OPTIONS10,
|
|
7150
7246
|
ModulesContainer
|
|
7151
7247
|
]
|
|
7152
7248
|
},
|
|
@@ -7154,29 +7250,34 @@ function sharedProviders(durable, engine) {
|
|
|
7154
7250
|
provide: AGENT_ACTOR_RESOLVER14,
|
|
7155
7251
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
7156
7252
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
7157
|
-
|
|
7253
|
+
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.");
|
|
7158
7254
|
return new AnonymousActorResolver();
|
|
7159
7255
|
}, "useFactory"),
|
|
7160
7256
|
inject: [
|
|
7161
|
-
|
|
7257
|
+
AGENT_OPTIONS10
|
|
7162
7258
|
]
|
|
7163
7259
|
},
|
|
7164
7260
|
{
|
|
7165
|
-
provide:
|
|
7261
|
+
provide: AGENT_MODEL3,
|
|
7166
7262
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
7167
7263
|
inject: [
|
|
7168
|
-
|
|
7264
|
+
AGENT_OPTIONS10
|
|
7169
7265
|
]
|
|
7170
7266
|
},
|
|
7171
7267
|
{
|
|
7172
7268
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
7173
7269
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
7174
7270
|
provide: AGENT_QUOTA_PROVIDER3,
|
|
7175
|
-
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits,
|
|
7176
|
-
|
|
7177
|
-
|
|
7271
|
+
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, {
|
|
7272
|
+
...o.quota?.warnAt !== void 0 ? {
|
|
7273
|
+
warnAt: o.quota.warnAt
|
|
7274
|
+
} : {},
|
|
7275
|
+
...o.quota?.countEstimatedCost !== void 0 ? {
|
|
7276
|
+
countEstimatedCost: o.quota.countEstimatedCost
|
|
7277
|
+
} : {}
|
|
7278
|
+
}), "useFactory"),
|
|
7178
7279
|
inject: [
|
|
7179
|
-
|
|
7280
|
+
AGENT_OPTIONS10,
|
|
7180
7281
|
AGENT_STORE9
|
|
7181
7282
|
]
|
|
7182
7283
|
},
|
|
@@ -7184,7 +7285,7 @@ function sharedProviders(durable, engine) {
|
|
|
7184
7285
|
provide: AGENT_MODEL_CATALOG3,
|
|
7185
7286
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
7186
7287
|
inject: [
|
|
7187
|
-
|
|
7288
|
+
AGENT_OPTIONS10
|
|
7188
7289
|
]
|
|
7189
7290
|
},
|
|
7190
7291
|
AgentDepsFactory2,
|
|
@@ -7192,6 +7293,9 @@ function sharedProviders(durable, engine) {
|
|
|
7192
7293
|
provide: AGENT_DEPS_FACTORY9,
|
|
7193
7294
|
useExisting: AgentDepsFactory2
|
|
7194
7295
|
},
|
|
7296
|
+
// Seeds a configured model's missing price row from models.dev and warns about one that would
|
|
7297
|
+
// record no cost (`priceCatalog`), once the app has bootstrapped.
|
|
7298
|
+
PricingBootService,
|
|
7195
7299
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
7196
7300
|
// handoff tools (onApplicationBootstrap) reads the registry.
|
|
7197
7301
|
AgentDiscoveryService,
|
|
@@ -7220,7 +7324,7 @@ function sharedProviders(durable, engine) {
|
|
|
7220
7324
|
provide: AGENT_STORE9,
|
|
7221
7325
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
7222
7326
|
inject: [
|
|
7223
|
-
|
|
7327
|
+
AGENT_OPTIONS10,
|
|
7224
7328
|
ModulesContainer
|
|
7225
7329
|
]
|
|
7226
7330
|
});
|
|
@@ -7257,13 +7361,13 @@ __name(sharedProviders, "sharedProviders");
|
|
|
7257
7361
|
function exportsFor(engine) {
|
|
7258
7362
|
return [
|
|
7259
7363
|
...engine?.exports ?? [],
|
|
7260
|
-
|
|
7364
|
+
AGENT_OPTIONS10,
|
|
7261
7365
|
AGENT_TOOL_REGISTRY3,
|
|
7262
7366
|
AGENT_REGISTRY6,
|
|
7263
7367
|
AGENT_SINK4,
|
|
7264
7368
|
AGENT_ROLES_POLICY2,
|
|
7265
7369
|
AGENT_ACTOR_RESOLVER14,
|
|
7266
|
-
|
|
7370
|
+
AGENT_MODEL3,
|
|
7267
7371
|
AGENT_STORE9,
|
|
7268
7372
|
AGENT_MODEL_CATALOG3,
|
|
7269
7373
|
AGENT_QUOTA_PROVIDER3,
|
|
@@ -7367,7 +7471,7 @@ var AgentModule = class _AgentModule {
|
|
|
7367
7471
|
controllers: controllersForSurface(options.surface, options.adapters, options.engine),
|
|
7368
7472
|
providers: [
|
|
7369
7473
|
{
|
|
7370
|
-
provide:
|
|
7474
|
+
provide: AGENT_OPTIONS10,
|
|
7371
7475
|
useValue: options
|
|
7372
7476
|
},
|
|
7373
7477
|
...sharedProviders(options.durable ?? false, options.engine),
|
|
@@ -7397,7 +7501,7 @@ var AgentModule = class _AgentModule {
|
|
|
7397
7501
|
controllers: controllersForSurface(options.surface, options.adapters, options.engine),
|
|
7398
7502
|
providers: [
|
|
7399
7503
|
{
|
|
7400
|
-
provide:
|
|
7504
|
+
provide: AGENT_OPTIONS10,
|
|
7401
7505
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
7402
7506
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
7403
7507
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -7426,7 +7530,7 @@ var AgentModule = class _AgentModule {
|
|
|
7426
7530
|
};
|
|
7427
7531
|
}
|
|
7428
7532
|
};
|
|
7429
|
-
AgentModule =
|
|
7533
|
+
AgentModule = _ts_decorate31([
|
|
7430
7534
|
Global2(),
|
|
7431
7535
|
Module3({})
|
|
7432
7536
|
], AgentModule);
|