@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/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DynamicModule, Type, OnApplicationBootstrap, OnModuleInit, ConflictException, OnModuleDestroy } from '@nestjs/common';
2
- import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-Crf9uwum.cjs';
3
- export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-Crf9uwum.cjs';
2
+ import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-Cu2nJpXz.cjs';
3
+ export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-Cu2nJpXz.cjs';
4
4
  import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
5
5
  import { AgentAttachmentConfig, AttachmentStagingStore, AgentStore, Actor, ListActionProposals, ActionProposalView, ActionProposalMutationView, TextActionProposalVocabulary, AgentRunner, ModelCatalog, QuotaProvider, ActionApprovalMode, MessageAttachment, QuotaReport, ModelCatalogView, AgentHostContext, AttachmentRef, PageContext, ChatQueueState, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, ActorResolver, AgentApprovalPort, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, AgentRunStartOptions, TokenStreamSink, SinkWriter, ActionProposal } from '@dudousxd/nestjs-agent-core';
6
6
  export * from '@dudousxd/nestjs-agent-core';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DynamicModule, Type, OnApplicationBootstrap, OnModuleInit, ConflictException, OnModuleDestroy } from '@nestjs/common';
2
- import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-ZQkqb1Yw.js';
3
- export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-ZQkqb1Yw.js';
2
+ import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-uD1vR8fs.js';
3
+ export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-uD1vR8fs.js';
4
4
  import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
5
5
  import { AgentAttachmentConfig, AttachmentStagingStore, AgentStore, Actor, ListActionProposals, ActionProposalView, ActionProposalMutationView, TextActionProposalVocabulary, AgentRunner, ModelCatalog, QuotaProvider, ActionApprovalMode, MessageAttachment, QuotaReport, ModelCatalogView, AgentHostContext, AttachmentRef, PageContext, ChatQueueState, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, ActorResolver, AgentApprovalPort, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, AgentRunStartOptions, TokenStreamSink, SinkWriter, ActionProposal } from '@dudousxd/nestjs-agent-core';
6
6
  export * from '@dudousxd/nestjs-agent-core';
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/agent.module.ts
5
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER14, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_DURABLE_RUNNER, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS9, 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_SINK3, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE7, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, ClosedRolesPolicy, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
6
- import { Global, Logger as Logger7, Module as Module2 } from "@nestjs/common";
5
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER14, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_DURABLE_RUNNER, 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_SINK3, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE7, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, ClosedRolesPolicy, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
6
+ import { Global, Logger as Logger8, Module as Module2 } from "@nestjs/common";
7
7
  import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
8
8
 
9
9
  // src/agent-deps.factory.ts
@@ -5106,7 +5106,7 @@ var LedgerQuotaProvider = class {
5106
5106
  if (this.store.usageBetween !== void 0) {
5107
5107
  const range = quotaPeriodRange("month", now);
5108
5108
  const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
5109
- windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
5109
+ windows.push(this.window("month", used.usedTokens, this.usd(used), range.resetsAt));
5110
5110
  }
5111
5111
  const blocked = exhaustedWindow(windows);
5112
5112
  const warning = quotaWarning(windows);
@@ -5122,8 +5122,15 @@ var LedgerQuotaProvider = class {
5122
5122
  }
5123
5123
  async dayWindow(actorRef, now) {
5124
5124
  const range = quotaPeriodRange("day", now);
5125
- const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
5126
- return this.window("day", usedTokens, costUsd, range.resetsAt);
5125
+ const used = await this.store.quotaToday(actorRef, range.fromDay);
5126
+ return this.window("day", used.usedTokens, this.usd(used), range.resetsAt);
5127
+ }
5128
+ /** The window's USD: every priced row, or (with `countEstimatedCost: false`) reported cost only. */
5129
+ usd(used) {
5130
+ if (this.options.countEstimatedCost === false) {
5131
+ return Math.max(0, used.costUsd - (used.estimatedCostUsd ?? 0));
5132
+ }
5133
+ return used.costUsd;
5127
5134
  }
5128
5135
  window(period, usedTokens, usedUsd, resetsAt) {
5129
5136
  const limits = this.limits[period] ?? {};
@@ -5145,10 +5152,9 @@ var LedgerQuotaProvider = class {
5145
5152
  }
5146
5153
  };
5147
5154
 
5148
- // src/proposals/action-proposal-worker.service.ts
5149
- import { randomUUID } from "crypto";
5150
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_OPTIONS as AGENT_OPTIONS8, AGENT_STORE as AGENT_STORE5, ActionProposalExecutor, ActionProposalWorker, assertIndependentActionCapabilities as assertIndependentActionCapabilities2 } from "@dudousxd/nestjs-agent-core";
5151
- import { Inject as Inject22, Injectable as Injectable9, Logger as Logger5 } from "@nestjs/common";
5155
+ // src/pricing-boot.service.ts
5156
+ import { AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS8, AGENT_PRICING_STORE as AGENT_PRICING_STORE2, ensureModelPricing } from "@dudousxd/nestjs-agent-core";
5157
+ import { Inject as Inject22, Injectable as Injectable9, Logger as Logger5, Optional as Optional9 } from "@nestjs/common";
5152
5158
  function _ts_decorate23(decorators, target, key, desc) {
5153
5159
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5154
5160
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -5175,6 +5181,96 @@ function _ts_param22(paramIndex, decorator) {
5175
5181
  };
5176
5182
  }
5177
5183
  __name(_ts_param22, "_ts_param");
5184
+ var logger = new Logger5("AgentPricing");
5185
+ var PricingBootService = class {
5186
+ static {
5187
+ __name(this, "PricingBootService");
5188
+ }
5189
+ options;
5190
+ model;
5191
+ pricingStore;
5192
+ #run = null;
5193
+ constructor(options, model, pricingStore) {
5194
+ this.options = options;
5195
+ this.model = model;
5196
+ this.pricingStore = pricingStore;
5197
+ }
5198
+ onApplicationBootstrap() {
5199
+ this.#run = this.check();
5200
+ }
5201
+ /** Awaits a check still in flight, so a test (or a fast shutdown) never leaks it. */
5202
+ async onApplicationShutdown() {
5203
+ await this.#run;
5204
+ this.#run = null;
5205
+ }
5206
+ /** The check itself; resolves once it is done (exposed for tests). */
5207
+ async check() {
5208
+ let models;
5209
+ try {
5210
+ models = this.model?.describeModels?.() ?? [];
5211
+ } catch (error) {
5212
+ logger.warn(`describeModels() threw; boot pricing skipped: ${String(error)}`);
5213
+ return;
5214
+ }
5215
+ if (models.length === 0) return;
5216
+ const catalog = this.options.priceCatalog;
5217
+ if (catalog === void 0 && process.env.NODE_ENV === "test") return;
5218
+ await ensureModelPricing({
5219
+ models,
5220
+ pricingStore: this.pricingStore,
5221
+ catalog: catalog ?? {},
5222
+ log: {
5223
+ info: /* @__PURE__ */ __name((message) => logger.log(message), "info"),
5224
+ warn: /* @__PURE__ */ __name((message) => logger.warn(message), "warn")
5225
+ }
5226
+ }).catch(() => void 0);
5227
+ }
5228
+ };
5229
+ PricingBootService = _ts_decorate23([
5230
+ Injectable9(),
5231
+ _ts_param22(0, Inject22(AGENT_OPTIONS8)),
5232
+ _ts_param22(1, Optional9()),
5233
+ _ts_param22(1, Inject22(AGENT_MODEL2)),
5234
+ _ts_param22(2, Optional9()),
5235
+ _ts_param22(2, Inject22(AGENT_PRICING_STORE2)),
5236
+ _ts_metadata22("design:type", Function),
5237
+ _ts_metadata22("design:paramtypes", [
5238
+ typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
5239
+ Object,
5240
+ Object
5241
+ ])
5242
+ ], PricingBootService);
5243
+
5244
+ // src/proposals/action-proposal-worker.service.ts
5245
+ import { randomUUID } from "crypto";
5246
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_OPTIONS as AGENT_OPTIONS9, AGENT_STORE as AGENT_STORE5, ActionProposalExecutor, ActionProposalWorker, assertIndependentActionCapabilities as assertIndependentActionCapabilities2 } from "@dudousxd/nestjs-agent-core";
5247
+ import { Inject as Inject23, Injectable as Injectable10, Logger as Logger6 } from "@nestjs/common";
5248
+ function _ts_decorate24(decorators, target, key, desc) {
5249
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5250
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5251
+ r = Reflect.decorate(decorators, target, key, desc);
5252
+ } else {
5253
+ for (var i = decorators.length - 1; i >= 0; i--) {
5254
+ if (d = decorators[i]) {
5255
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5256
+ }
5257
+ }
5258
+ }
5259
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5260
+ }
5261
+ __name(_ts_decorate24, "_ts_decorate");
5262
+ function _ts_metadata23(metadataKey, metadataValue) {
5263
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
5264
+ return Reflect.metadata(metadataKey, metadataValue);
5265
+ }
5266
+ }
5267
+ __name(_ts_metadata23, "_ts_metadata");
5268
+ function _ts_param23(paramIndex, decorator) {
5269
+ return function(target, key) {
5270
+ decorator(target, key, paramIndex);
5271
+ };
5272
+ }
5273
+ __name(_ts_param23, "_ts_param");
5178
5274
  var ActionProposalWorkerService = class _ActionProposalWorkerService {
5179
5275
  static {
5180
5276
  __name(this, "ActionProposalWorkerService");
@@ -5183,7 +5279,7 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
5183
5279
  options;
5184
5280
  deps;
5185
5281
  worker;
5186
- logger = new Logger5(_ActionProposalWorkerService.name);
5282
+ logger = new Logger6(_ActionProposalWorkerService.name);
5187
5283
  settledListeners = /* @__PURE__ */ new Set();
5188
5284
  /**
5189
5285
  * Run `listener` after every proposal this process's worker settles — how a module relays an
@@ -5252,13 +5348,13 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
5252
5348
  await this.worker?.stop();
5253
5349
  }
5254
5350
  };
5255
- ActionProposalWorkerService = _ts_decorate23([
5256
- Injectable9(),
5257
- _ts_param22(0, Inject22(AGENT_STORE5)),
5258
- _ts_param22(1, Inject22(AGENT_OPTIONS8)),
5259
- _ts_param22(2, Inject22(AGENT_DEPS_FACTORY5)),
5260
- _ts_metadata22("design:type", Function),
5261
- _ts_metadata22("design:paramtypes", [
5351
+ ActionProposalWorkerService = _ts_decorate24([
5352
+ Injectable10(),
5353
+ _ts_param23(0, Inject23(AGENT_STORE5)),
5354
+ _ts_param23(1, Inject23(AGENT_OPTIONS9)),
5355
+ _ts_param23(2, Inject23(AGENT_DEPS_FACTORY5)),
5356
+ _ts_metadata23("design:type", Function),
5357
+ _ts_metadata23("design:paramtypes", [
5262
5358
  typeof AgentStore === "undefined" ? Object : AgentStore,
5263
5359
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
5264
5360
  typeof AgentDepsFactory2 === "undefined" ? Object : AgentDepsFactory2
@@ -5267,8 +5363,8 @@ ActionProposalWorkerService = _ts_decorate23([
5267
5363
 
5268
5364
  // src/proposals/action-proposal.controller.ts
5269
5365
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER13, validateActionProposalListQuery } from "@dudousxd/nestjs-agent-core";
5270
- import { BadRequestException as BadRequestException7, Body as Body6, Controller as Controller14, Get as Get12, Inject as Inject23, Param as Param6, Post as Post7, Query as Query6, Req as Req13, Res as Res2 } from "@nestjs/common";
5271
- function _ts_decorate24(decorators, target, key, desc) {
5366
+ import { BadRequestException as BadRequestException7, Body as Body6, Controller as Controller14, Get as Get12, Inject as Inject24, Param as Param6, Post as Post7, Query as Query6, Req as Req13, Res as Res2 } from "@nestjs/common";
5367
+ function _ts_decorate25(decorators, target, key, desc) {
5272
5368
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5273
5369
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5274
5370
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5281,19 +5377,19 @@ function _ts_decorate24(decorators, target, key, desc) {
5281
5377
  }
5282
5378
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5283
5379
  }
5284
- __name(_ts_decorate24, "_ts_decorate");
5285
- function _ts_metadata23(metadataKey, metadataValue) {
5380
+ __name(_ts_decorate25, "_ts_decorate");
5381
+ function _ts_metadata24(metadataKey, metadataValue) {
5286
5382
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
5287
5383
  return Reflect.metadata(metadataKey, metadataValue);
5288
5384
  }
5289
5385
  }
5290
- __name(_ts_metadata23, "_ts_metadata");
5291
- function _ts_param23(paramIndex, decorator) {
5386
+ __name(_ts_metadata24, "_ts_metadata");
5387
+ function _ts_param24(paramIndex, decorator) {
5292
5388
  return function(target, key) {
5293
5389
  decorator(target, key, paramIndex);
5294
5390
  };
5295
5391
  }
5296
- __name(_ts_param23, "_ts_param");
5392
+ __name(_ts_param24, "_ts_param");
5297
5393
  function bodyFields(body, field2) {
5298
5394
  if (body === void 0) return {};
5299
5395
  if (typeof body !== "object" || body === null || Array.isArray(body) || Object.keys(body).some((key) => key !== field2)) throw new BadRequestException7(`Only ${field2} is accepted`);
@@ -5352,58 +5448,58 @@ var ActionProposalController = class {
5352
5448
  });
5353
5449
  }
5354
5450
  };
5355
- _ts_decorate24([
5451
+ _ts_decorate25([
5356
5452
  Get12(),
5357
- _ts_param23(0, Param6("threadId")),
5358
- _ts_param23(1, Req13()),
5359
- _ts_param23(2, Query6("after")),
5360
- _ts_param23(3, Res2({
5453
+ _ts_param24(0, Param6("threadId")),
5454
+ _ts_param24(1, Req13()),
5455
+ _ts_param24(2, Query6("after")),
5456
+ _ts_param24(3, Res2({
5361
5457
  passthrough: true
5362
5458
  })),
5363
- _ts_metadata23("design:type", Function),
5364
- _ts_metadata23("design:paramtypes", [
5459
+ _ts_metadata24("design:type", Function),
5460
+ _ts_metadata24("design:paramtypes", [
5365
5461
  String,
5366
5462
  typeof Request === "undefined" ? Object : Request,
5367
5463
  Object,
5368
5464
  typeof Response === "undefined" ? Object : Response
5369
5465
  ]),
5370
- _ts_metadata23("design:returntype", Promise)
5466
+ _ts_metadata24("design:returntype", Promise)
5371
5467
  ], ActionProposalController.prototype, "list", null);
5372
- _ts_decorate24([
5468
+ _ts_decorate25([
5373
5469
  Post7(":proposalId/approve"),
5374
- _ts_param23(0, Param6("threadId")),
5375
- _ts_param23(1, Param6("proposalId")),
5376
- _ts_param23(2, Req13()),
5377
- _ts_param23(3, Body6()),
5378
- _ts_metadata23("design:type", Function),
5379
- _ts_metadata23("design:paramtypes", [
5470
+ _ts_param24(0, Param6("threadId")),
5471
+ _ts_param24(1, Param6("proposalId")),
5472
+ _ts_param24(2, Req13()),
5473
+ _ts_param24(3, Body6()),
5474
+ _ts_metadata24("design:type", Function),
5475
+ _ts_metadata24("design:paramtypes", [
5380
5476
  String,
5381
5477
  String,
5382
5478
  typeof Request === "undefined" ? Object : Request,
5383
5479
  Object
5384
5480
  ]),
5385
- _ts_metadata23("design:returntype", Promise)
5481
+ _ts_metadata24("design:returntype", Promise)
5386
5482
  ], ActionProposalController.prototype, "approve", null);
5387
- _ts_decorate24([
5483
+ _ts_decorate25([
5388
5484
  Post7(":proposalId/reject"),
5389
- _ts_param23(0, Param6("threadId")),
5390
- _ts_param23(1, Param6("proposalId")),
5391
- _ts_param23(2, Req13()),
5392
- _ts_param23(3, Body6()),
5393
- _ts_metadata23("design:type", Function),
5394
- _ts_metadata23("design:paramtypes", [
5485
+ _ts_param24(0, Param6("threadId")),
5486
+ _ts_param24(1, Param6("proposalId")),
5487
+ _ts_param24(2, Req13()),
5488
+ _ts_param24(3, Body6()),
5489
+ _ts_metadata24("design:type", Function),
5490
+ _ts_metadata24("design:paramtypes", [
5395
5491
  String,
5396
5492
  String,
5397
5493
  typeof Request === "undefined" ? Object : Request,
5398
5494
  Object
5399
5495
  ]),
5400
- _ts_metadata23("design:returntype", Promise)
5496
+ _ts_metadata24("design:returntype", Promise)
5401
5497
  ], ActionProposalController.prototype, "reject", null);
5402
- ActionProposalController = _ts_decorate24([
5498
+ ActionProposalController = _ts_decorate25([
5403
5499
  Controller14("threads/:threadId/action-proposals"),
5404
- _ts_param23(1, Inject23(AGENT_ACTOR_RESOLVER13)),
5405
- _ts_metadata23("design:type", Function),
5406
- _ts_metadata23("design:paramtypes", [
5500
+ _ts_param24(1, Inject24(AGENT_ACTOR_RESOLVER13)),
5501
+ _ts_metadata24("design:type", Function),
5502
+ _ts_metadata24("design:paramtypes", [
5407
5503
  typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
5408
5504
  typeof ActorResolver === "undefined" ? Object : ActorResolver
5409
5505
  ])
@@ -5414,8 +5510,8 @@ var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-q
5414
5510
 
5415
5511
  // src/runner/inline-agent-runner.ts
5416
5512
  import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_STORE as AGENT_STORE6, RUN_ENDED_BEFORE_TOOL_CALL, RunCancelledError, agentFailureCode, encodeStreamEvent as encodeStreamEvent2, publishAgentRunFailed, releaseThreadRun, runAgentLoop, settleAll, settleUnsettledDelegation, streamFailure as streamFailure2 } from "@dudousxd/nestjs-agent-core";
5417
- import { Inject as Inject24, Injectable as Injectable10, Logger as Logger6, Optional as Optional9 } from "@nestjs/common";
5418
- function _ts_decorate25(decorators, target, key, desc) {
5513
+ import { Inject as Inject25, Injectable as Injectable11, Logger as Logger7, Optional as Optional10 } from "@nestjs/common";
5514
+ function _ts_decorate26(decorators, target, key, desc) {
5419
5515
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5420
5516
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5421
5517
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5428,19 +5524,19 @@ function _ts_decorate25(decorators, target, key, desc) {
5428
5524
  }
5429
5525
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5430
5526
  }
5431
- __name(_ts_decorate25, "_ts_decorate");
5432
- function _ts_metadata24(metadataKey, metadataValue) {
5527
+ __name(_ts_decorate26, "_ts_decorate");
5528
+ function _ts_metadata25(metadataKey, metadataValue) {
5433
5529
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
5434
5530
  return Reflect.metadata(metadataKey, metadataValue);
5435
5531
  }
5436
5532
  }
5437
- __name(_ts_metadata24, "_ts_metadata");
5438
- function _ts_param24(paramIndex, decorator) {
5533
+ __name(_ts_metadata25, "_ts_metadata");
5534
+ function _ts_param25(paramIndex, decorator) {
5439
5535
  return function(target, key) {
5440
5536
  decorator(target, key, paramIndex);
5441
5537
  };
5442
5538
  }
5443
- __name(_ts_param24, "_ts_param");
5539
+ __name(_ts_param25, "_ts_param");
5444
5540
  var InlineAgentRunner = class _InlineAgentRunner {
5445
5541
  static {
5446
5542
  __name(this, "InlineAgentRunner");
@@ -5448,7 +5544,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5448
5544
  factory;
5449
5545
  store;
5450
5546
  queue;
5451
- logger = new Logger6(_InlineAgentRunner.name);
5547
+ logger = new Logger7(_InlineAgentRunner.name);
5452
5548
  pending = /* @__PURE__ */ new Map();
5453
5549
  /**
5454
5550
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -5917,13 +6013,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
5917
6013
  }
5918
6014
  }
5919
6015
  };
5920
- InlineAgentRunner = _ts_decorate25([
5921
- Injectable10(),
5922
- _ts_param24(0, Inject24(AGENT_DEPS_FACTORY6)),
5923
- _ts_param24(1, Inject24(AGENT_STORE6)),
5924
- _ts_param24(2, Optional9()),
5925
- _ts_metadata24("design:type", Function),
5926
- _ts_metadata24("design:paramtypes", [
6016
+ InlineAgentRunner = _ts_decorate26([
6017
+ Injectable11(),
6018
+ _ts_param25(0, Inject25(AGENT_DEPS_FACTORY6)),
6019
+ _ts_param25(1, Inject25(AGENT_STORE6)),
6020
+ _ts_param25(2, Optional10()),
6021
+ _ts_metadata25("design:type", Function),
6022
+ _ts_metadata25("design:paramtypes", [
5927
6023
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
5928
6024
  typeof AgentStore === "undefined" ? Object : AgentStore,
5929
6025
  typeof ChatQueueService === "undefined" ? Object : ChatQueueService
@@ -5973,7 +6069,7 @@ function resolveSkillsConfig(options, declared) {
5973
6069
  __name(resolveSkillsConfig, "resolveSkillsConfig");
5974
6070
 
5975
6071
  // src/agent.module.ts
5976
- function _ts_decorate26(decorators, target, key, desc) {
6072
+ function _ts_decorate27(decorators, target, key, desc) {
5977
6073
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5978
6074
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5979
6075
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5986,9 +6082,9 @@ function _ts_decorate26(decorators, target, key, desc) {
5986
6082
  }
5987
6083
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5988
6084
  }
5989
- __name(_ts_decorate26, "_ts_decorate");
6085
+ __name(_ts_decorate27, "_ts_decorate");
5990
6086
  var DEFAULT_PATH = "agent";
5991
- var logger = new Logger7("AgentModule");
6087
+ var logger2 = new Logger8("AgentModule");
5992
6088
  function externalWrapper(modules, token) {
5993
6089
  for (const module of modules.values()) {
5994
6090
  if (module.metatype === AgentModule) continue;
@@ -6022,7 +6118,7 @@ function resolveStore(options, modules) {
6022
6118
  if (options.store !== void 0) return options.store;
6023
6119
  const external = externalWrapper(modules, AGENT_STORE7);
6024
6120
  if (external !== void 0) return forwardingStore(external);
6025
- logger.warn("No `store` configured and no store module imported \u2014 using the in-memory store. Threads are lost on restart and not shared between processes: not for production. Pass `store`, or import a store module (e.g. MikroOrmAgentStoreModule.forFeature()).");
6121
+ 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()).");
6026
6122
  return new InMemoryAgentStore();
6027
6123
  }
6028
6124
  __name(resolveStore, "resolveStore");
@@ -6030,7 +6126,7 @@ function resolveRolesPolicy(options, modules) {
6030
6126
  const external = externalWrapper(modules, AGENT_ROLES_POLICY2);
6031
6127
  if (options.rolesPolicy !== void 0) {
6032
6128
  if (external !== void 0) {
6033
- logger.warn("Both a `rolesPolicy` option and a module binding AGENT_ROLES_POLICY (e.g. AgentAuthzModule) are configured \u2014 the `rolesPolicy` option wins.");
6129
+ logger2.warn("Both a `rolesPolicy` option and a module binding AGENT_ROLES_POLICY (e.g. AgentAuthzModule) are configured \u2014 the `rolesPolicy` option wins.");
6034
6130
  }
6035
6131
  return options.rolesPolicy;
6036
6132
  }
@@ -6089,7 +6185,7 @@ function sharedProviders(durable, engine) {
6089
6185
  provide: AGENT_SKILLS3,
6090
6186
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
6091
6187
  inject: [
6092
- AGENT_OPTIONS9,
6188
+ AGENT_OPTIONS10,
6093
6189
  AGENT_SKILL_SOURCES2
6094
6190
  ]
6095
6191
  },
@@ -6099,21 +6195,21 @@ function sharedProviders(durable, engine) {
6099
6195
  provide: AGENT_MEMORY3,
6100
6196
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
6101
6197
  inject: [
6102
- AGENT_OPTIONS9
6198
+ AGENT_OPTIONS10
6103
6199
  ]
6104
6200
  },
6105
6201
  {
6106
6202
  provide: AGENT_SINK3,
6107
6203
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
6108
6204
  inject: [
6109
- AGENT_OPTIONS9
6205
+ AGENT_OPTIONS10
6110
6206
  ]
6111
6207
  },
6112
6208
  {
6113
6209
  provide: AGENT_ROLES_POLICY2,
6114
6210
  useFactory: /* @__PURE__ */ __name((options, modules) => resolveRolesPolicy(options, modules), "useFactory"),
6115
6211
  inject: [
6116
- AGENT_OPTIONS9,
6212
+ AGENT_OPTIONS10,
6117
6213
  ModulesContainer
6118
6214
  ]
6119
6215
  },
@@ -6121,29 +6217,34 @@ function sharedProviders(durable, engine) {
6121
6217
  provide: AGENT_ACTOR_RESOLVER14,
6122
6218
  useFactory: /* @__PURE__ */ __name((options) => {
6123
6219
  if (options.actorResolver !== void 0) return options.actorResolver;
6124
- logger.warn("No `actorResolver` configured \u2014 the agent endpoints are PUBLIC: every browser gets its own anonymous identity (an HttpOnly cookie). Set `actorResolver: requestUserActorResolver()` (or your own) to require login.");
6220
+ 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.");
6125
6221
  return new AnonymousActorResolver();
6126
6222
  }, "useFactory"),
6127
6223
  inject: [
6128
- AGENT_OPTIONS9
6224
+ AGENT_OPTIONS10
6129
6225
  ]
6130
6226
  },
6131
6227
  {
6132
- provide: AGENT_MODEL2,
6228
+ provide: AGENT_MODEL3,
6133
6229
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
6134
6230
  inject: [
6135
- AGENT_OPTIONS9
6231
+ AGENT_OPTIONS10
6136
6232
  ]
6137
6233
  },
6138
6234
  {
6139
6235
  // `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
6140
6236
  // omitted, the ledger provider still reports usage, with no ceiling to block on.
6141
6237
  provide: AGENT_QUOTA_PROVIDER3,
6142
- useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
6143
- warnAt: o.quota.warnAt
6144
- } : {}), "useFactory"),
6238
+ useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, {
6239
+ ...o.quota?.warnAt !== void 0 ? {
6240
+ warnAt: o.quota.warnAt
6241
+ } : {},
6242
+ ...o.quota?.countEstimatedCost !== void 0 ? {
6243
+ countEstimatedCost: o.quota.countEstimatedCost
6244
+ } : {}
6245
+ }), "useFactory"),
6145
6246
  inject: [
6146
- AGENT_OPTIONS9,
6247
+ AGENT_OPTIONS10,
6147
6248
  AGENT_STORE7
6148
6249
  ]
6149
6250
  },
@@ -6151,7 +6252,7 @@ function sharedProviders(durable, engine) {
6151
6252
  provide: AGENT_MODEL_CATALOG3,
6152
6253
  useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
6153
6254
  inject: [
6154
- AGENT_OPTIONS9
6255
+ AGENT_OPTIONS10
6155
6256
  ]
6156
6257
  },
6157
6258
  AgentDepsFactory2,
@@ -6159,6 +6260,9 @@ function sharedProviders(durable, engine) {
6159
6260
  provide: AGENT_DEPS_FACTORY7,
6160
6261
  useExisting: AgentDepsFactory2
6161
6262
  },
6263
+ // Seeds a configured model's missing price row from models.dev and warns about one that would
6264
+ // record no cost (`priceCatalog`), once the app has bootstrapped.
6265
+ PricingBootService,
6162
6266
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
6163
6267
  // handoff tools (onApplicationBootstrap) reads the registry.
6164
6268
  AgentDiscoveryService,
@@ -6187,7 +6291,7 @@ function sharedProviders(durable, engine) {
6187
6291
  provide: AGENT_STORE7,
6188
6292
  useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
6189
6293
  inject: [
6190
- AGENT_OPTIONS9,
6294
+ AGENT_OPTIONS10,
6191
6295
  ModulesContainer
6192
6296
  ]
6193
6297
  });
@@ -6224,13 +6328,13 @@ __name(sharedProviders, "sharedProviders");
6224
6328
  function exportsFor(engine) {
6225
6329
  return [
6226
6330
  ...engine?.exports ?? [],
6227
- AGENT_OPTIONS9,
6331
+ AGENT_OPTIONS10,
6228
6332
  AGENT_TOOL_REGISTRY3,
6229
6333
  AGENT_REGISTRY6,
6230
6334
  AGENT_SINK3,
6231
6335
  AGENT_ROLES_POLICY2,
6232
6336
  AGENT_ACTOR_RESOLVER14,
6233
- AGENT_MODEL2,
6337
+ AGENT_MODEL3,
6234
6338
  AGENT_STORE7,
6235
6339
  AGENT_MODEL_CATALOG3,
6236
6340
  AGENT_QUOTA_PROVIDER3,
@@ -6334,7 +6438,7 @@ var AgentModule = class _AgentModule {
6334
6438
  controllers: controllersForSurface(options.surface, options.adapters, options.engine),
6335
6439
  providers: [
6336
6440
  {
6337
- provide: AGENT_OPTIONS9,
6441
+ provide: AGENT_OPTIONS10,
6338
6442
  useValue: options
6339
6443
  },
6340
6444
  ...sharedProviders(options.durable ?? false, options.engine),
@@ -6364,7 +6468,7 @@ var AgentModule = class _AgentModule {
6364
6468
  controllers: controllersForSurface(options.surface, options.adapters, options.engine),
6365
6469
  providers: [
6366
6470
  {
6367
- provide: AGENT_OPTIONS9,
6471
+ provide: AGENT_OPTIONS10,
6368
6472
  // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
6369
6473
  // authoritative on the async config object (they decided the actual wiring above), and
6370
6474
  // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
@@ -6393,16 +6497,16 @@ var AgentModule = class _AgentModule {
6393
6497
  };
6394
6498
  }
6395
6499
  };
6396
- AgentModule = _ts_decorate26([
6500
+ AgentModule = _ts_decorate27([
6397
6501
  Global(),
6398
6502
  Module2({})
6399
6503
  ], AgentModule);
6400
6504
 
6401
6505
  // src/ag-ui/ag-ui.adapter.ts
6402
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER15, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING5, AGENT_OPTIONS as AGENT_OPTIONS10 } from "@dudousxd/nestjs-agent-core";
6506
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER15, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING5, AGENT_OPTIONS as AGENT_OPTIONS11 } from "@dudousxd/nestjs-agent-core";
6403
6507
  import { AG_UI_CUSTOM, actionProposalDecisionEvents, agUiEvents, agUiFramesFromNdjson, agUiSse, parseRunInput, planResume, readAnswersPayload, readApprovalPayload, readContext, readForwardedProps, readUserTurn } from "@dudousxd/nestjs-agent-core/ag-ui";
6404
- import { BadRequestException as BadRequestException8, Body as Body7, Controller as Controller15, ForbiddenException as ForbiddenException4, HttpCode as HttpCode2, Inject as Inject25, Optional as Optional10, Post as Post8, Req as Req14, Res as Res3 } from "@nestjs/common";
6405
- function _ts_decorate27(decorators, target, key, desc) {
6508
+ import { BadRequestException as BadRequestException8, Body as Body7, Controller as Controller15, ForbiddenException as ForbiddenException4, HttpCode as HttpCode2, Inject as Inject26, Optional as Optional11, Post as Post8, Req as Req14, Res as Res3 } from "@nestjs/common";
6509
+ function _ts_decorate28(decorators, target, key, desc) {
6406
6510
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6407
6511
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
6408
6512
  r = Reflect.decorate(decorators, target, key, desc);
@@ -6415,19 +6519,19 @@ function _ts_decorate27(decorators, target, key, desc) {
6415
6519
  }
6416
6520
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6417
6521
  }
6418
- __name(_ts_decorate27, "_ts_decorate");
6419
- function _ts_metadata25(metadataKey, metadataValue) {
6522
+ __name(_ts_decorate28, "_ts_decorate");
6523
+ function _ts_metadata26(metadataKey, metadataValue) {
6420
6524
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
6421
6525
  return Reflect.metadata(metadataKey, metadataValue);
6422
6526
  }
6423
6527
  }
6424
- __name(_ts_metadata25, "_ts_metadata");
6425
- function _ts_param25(paramIndex, decorator) {
6528
+ __name(_ts_metadata26, "_ts_metadata");
6529
+ function _ts_param26(paramIndex, decorator) {
6426
6530
  return function(target, key) {
6427
6531
  decorator(target, key, paramIndex);
6428
6532
  };
6429
6533
  }
6430
- __name(_ts_param25, "_ts_param");
6534
+ __name(_ts_param26, "_ts_param");
6431
6535
  var AG_UI_VIA = "ag-ui";
6432
6536
  function invalid(code, message) {
6433
6537
  return new BadRequestException8({
@@ -6787,29 +6891,29 @@ function agUiAdapter(options = {}) {
6787
6891
  return this.handle(req, res, body);
6788
6892
  }
6789
6893
  };
6790
- _ts_decorate27([
6894
+ _ts_decorate28([
6791
6895
  Post8(path),
6792
6896
  HttpCode2(200),
6793
- _ts_param25(0, Req14()),
6794
- _ts_param25(1, Res3()),
6795
- _ts_param25(2, Body7()),
6796
- _ts_metadata25("design:type", Function),
6797
- _ts_metadata25("design:paramtypes", [
6897
+ _ts_param26(0, Req14()),
6898
+ _ts_param26(1, Res3()),
6899
+ _ts_param26(2, Body7()),
6900
+ _ts_metadata26("design:type", Function),
6901
+ _ts_metadata26("design:paramtypes", [
6798
6902
  typeof Request === "undefined" ? Object : Request,
6799
6903
  typeof Response === "undefined" ? Object : Response,
6800
6904
  Object
6801
6905
  ]),
6802
- _ts_metadata25("design:returntype", typeof Promise === "undefined" ? Object : Promise)
6906
+ _ts_metadata26("design:returntype", typeof Promise === "undefined" ? Object : Promise)
6803
6907
  ], AgUiController.prototype, "run", null);
6804
- AgUiController = _ts_decorate27([
6908
+ AgUiController = _ts_decorate28([
6805
6909
  Controller15(),
6806
- _ts_param25(0, Inject25(AgentService)),
6807
- _ts_param25(1, Inject25(AGENT_ACTOR_RESOLVER15)),
6808
- _ts_param25(2, Inject25(AGENT_OPTIONS10)),
6809
- _ts_param25(3, Optional10()),
6810
- _ts_param25(3, Inject25(AGENT_ATTACHMENT_STAGING5)),
6811
- _ts_metadata25("design:type", Function),
6812
- _ts_metadata25("design:paramtypes", [
6910
+ _ts_param26(0, Inject26(AgentService)),
6911
+ _ts_param26(1, Inject26(AGENT_ACTOR_RESOLVER15)),
6912
+ _ts_param26(2, Inject26(AGENT_OPTIONS11)),
6913
+ _ts_param26(3, Optional11()),
6914
+ _ts_param26(3, Inject26(AGENT_ATTACHMENT_STAGING5)),
6915
+ _ts_metadata26("design:type", Function),
6916
+ _ts_metadata26("design:paramtypes", [
6813
6917
  typeof AgentService === "undefined" ? Object : AgentService,
6814
6918
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
6815
6919
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,