@dudousxd/nestjs-agent 1.26.0 → 1.27.1

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.
@@ -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-BN6Ljswx.cjs';
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';
@@ -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-DG44iDJA.js';
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';
@@ -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.costUsd, range.resetsAt));
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 { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
6162
- return this.window("day", usedTokens, costUsd, range.resetsAt);
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] ?? {};
@@ -7261,9 +7268,14 @@ function sharedProviders(durable, engine) {
7261
7268
  // `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
7262
7269
  // omitted, the ledger provider still reports usage, with no ceiling to block on.
7263
7270
  provide: AGENT_QUOTA_PROVIDER3,
7264
- useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
7265
- warnAt: o.quota.warnAt
7266
- } : {}), "useFactory"),
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"),
7267
7279
  inject: [
7268
7280
  AGENT_OPTIONS10,
7269
7281
  AGENT_STORE9