@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.
- package/README.md +82 -0
- package/dist/{chat-queue.service-BN6Ljswx.d.cts → chat-queue.service-Cu2nJpXz.d.cts} +38 -7
- package/dist/{chat-queue.service-DG44iDJA.d.ts → chat-queue.service-uD1vR8fs.d.ts} +38 -7
- package/dist/durable/index.cjs +18 -6
- 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 +18 -6
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +18 -6
- 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 +18 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -5190,7 +5190,7 @@ var LedgerQuotaProvider = class {
|
|
|
5190
5190
|
if (this.store.usageBetween !== void 0) {
|
|
5191
5191
|
const range = (0, import_nestjs_agent_core28.quotaPeriodRange)("month", now);
|
|
5192
5192
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
5193
|
-
windows.push(this.window("month", used.usedTokens, used
|
|
5193
|
+
windows.push(this.window("month", used.usedTokens, this.usd(used), range.resetsAt));
|
|
5194
5194
|
}
|
|
5195
5195
|
const blocked = (0, import_nestjs_agent_core28.exhaustedWindow)(windows);
|
|
5196
5196
|
const warning = (0, import_nestjs_agent_core28.quotaWarning)(windows);
|
|
@@ -5206,8 +5206,15 @@ var LedgerQuotaProvider = class {
|
|
|
5206
5206
|
}
|
|
5207
5207
|
async dayWindow(actorRef, now) {
|
|
5208
5208
|
const range = (0, import_nestjs_agent_core28.quotaPeriodRange)("day", now);
|
|
5209
|
-
const
|
|
5210
|
-
return this.window("day", usedTokens,
|
|
5209
|
+
const used = await this.store.quotaToday(actorRef, range.fromDay);
|
|
5210
|
+
return this.window("day", used.usedTokens, this.usd(used), range.resetsAt);
|
|
5211
|
+
}
|
|
5212
|
+
/** The window's USD: every priced row, or (with `countEstimatedCost: false`) reported cost only. */
|
|
5213
|
+
usd(used) {
|
|
5214
|
+
if (this.options.countEstimatedCost === false) {
|
|
5215
|
+
return Math.max(0, used.costUsd - (used.estimatedCostUsd ?? 0));
|
|
5216
|
+
}
|
|
5217
|
+
return used.costUsd;
|
|
5211
5218
|
}
|
|
5212
5219
|
window(period, usedTokens, usedUsd, resetsAt) {
|
|
5213
5220
|
const limits = this.limits[period] ?? {};
|
|
@@ -6312,9 +6319,14 @@ function sharedProviders(durable, engine) {
|
|
|
6312
6319
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
6313
6320
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
6314
6321
|
provide: import_nestjs_agent_core34.AGENT_QUOTA_PROVIDER,
|
|
6315
|
-
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits,
|
|
6316
|
-
|
|
6317
|
-
|
|
6322
|
+
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, {
|
|
6323
|
+
...o.quota?.warnAt !== void 0 ? {
|
|
6324
|
+
warnAt: o.quota.warnAt
|
|
6325
|
+
} : {},
|
|
6326
|
+
...o.quota?.countEstimatedCost !== void 0 ? {
|
|
6327
|
+
countEstimatedCost: o.quota.countEstimatedCost
|
|
6328
|
+
} : {}
|
|
6329
|
+
}), "useFactory"),
|
|
6318
6330
|
inject: [
|
|
6319
6331
|
import_nestjs_agent_core34.AGENT_OPTIONS,
|
|
6320
6332
|
import_nestjs_agent_core34.AGENT_STORE
|