@dudousxd/nestjs-agent-core 0.24.0 → 0.25.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.cjs +44 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +63 -1
- package/dist/index.d.ts +63 -1
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(src_exports, {
|
|
|
36
36
|
AGENT_OPTIONS: () => AGENT_OPTIONS,
|
|
37
37
|
AGENT_PRICING_STORE: () => AGENT_PRICING_STORE,
|
|
38
38
|
AGENT_PROMPT_CONTRIBUTORS: () => AGENT_PROMPT_CONTRIBUTORS,
|
|
39
|
+
AGENT_QUOTA_PROVIDER: () => AGENT_QUOTA_PROVIDER,
|
|
39
40
|
AGENT_QUOTA_STORE: () => AGENT_QUOTA_STORE,
|
|
40
41
|
AGENT_REGISTRY: () => AGENT_REGISTRY,
|
|
41
42
|
AGENT_RETRIEVER: () => AGENT_RETRIEVER,
|
|
@@ -109,6 +110,7 @@ __export(src_exports, {
|
|
|
109
110
|
encodeStreamEvent: () => encodeStreamEvent,
|
|
110
111
|
estimateCost: () => estimateCost,
|
|
111
112
|
estimateMessageTokens: () => estimateMessageTokens,
|
|
113
|
+
exhaustedWindow: () => exhaustedWindow,
|
|
112
114
|
extractJson: () => extractJson,
|
|
113
115
|
filterToolsByAllowList: () => filterToolsByAllowList,
|
|
114
116
|
filterToolsByCanUse: () => filterToolsByCanUse,
|
|
@@ -146,6 +148,7 @@ __export(src_exports, {
|
|
|
146
148
|
publishAgentToolCall: () => publishAgentToolCall,
|
|
147
149
|
publishAgentToolRetry: () => publishAgentToolRetry,
|
|
148
150
|
questionOptions: () => questionOptions,
|
|
151
|
+
quotaPeriodRange: () => quotaPeriodRange,
|
|
149
152
|
readElicitationInput: () => readElicitationInput,
|
|
150
153
|
readElicitationQuestions: () => readElicitationQuestions,
|
|
151
154
|
releaseGatedFrames: () => releaseGatedFrames,
|
|
@@ -208,6 +211,7 @@ var AGENT_TOOL_REGISTRY = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:too
|
|
|
208
211
|
var AGENT_REGISTRY = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:agent-registry");
|
|
209
212
|
var AGENT_ACTOR_RESOLVER = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:actor-resolver");
|
|
210
213
|
var AGENT_GOVERNANCE_QUERIES = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:governance-queries");
|
|
214
|
+
var AGENT_QUOTA_PROVIDER = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:quota-provider");
|
|
211
215
|
var AGENT_MODEL_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:model-catalog");
|
|
212
216
|
var AGENT_PRICING_STORE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:pricing-store");
|
|
213
217
|
var AGENT_RETRIEVER = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:retriever");
|
|
@@ -466,6 +470,43 @@ function mergeUi(...lists) {
|
|
|
466
470
|
}
|
|
467
471
|
__name(mergeUi, "mergeUi");
|
|
468
472
|
|
|
473
|
+
// src/spi/quota-provider.ts
|
|
474
|
+
function exhaustedWindow(windows) {
|
|
475
|
+
for (const window of windows) {
|
|
476
|
+
const tokensOut = window.limitTokens !== void 0 && window.usedTokens >= window.limitTokens;
|
|
477
|
+
const spendOut = window.limitUsd !== void 0 && window.usedUsd >= window.limitUsd;
|
|
478
|
+
if (tokensOut || spendOut) {
|
|
479
|
+
return {
|
|
480
|
+
period: window.period,
|
|
481
|
+
reason: `${window.period === "day" ? "Daily" : "Monthly"} ${spendOut ? "spend" : "token"} limit reached`
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return void 0;
|
|
486
|
+
}
|
|
487
|
+
__name(exhaustedWindow, "exhaustedWindow");
|
|
488
|
+
function quotaPeriodRange(period, now) {
|
|
489
|
+
const year = now.getUTCFullYear();
|
|
490
|
+
const month = now.getUTCMonth();
|
|
491
|
+
const day = now.toISOString().slice(0, 10);
|
|
492
|
+
if (period === "day") {
|
|
493
|
+
const next = new Date(Date.UTC(year, month, now.getUTCDate() + 1));
|
|
494
|
+
return {
|
|
495
|
+
fromDay: day,
|
|
496
|
+
toDay: day,
|
|
497
|
+
resetsAt: next.toISOString()
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
const first = new Date(Date.UTC(year, month, 1));
|
|
501
|
+
const last = new Date(Date.UTC(year, month + 1, 0));
|
|
502
|
+
return {
|
|
503
|
+
fromDay: first.toISOString().slice(0, 10),
|
|
504
|
+
toDay: last.toISOString().slice(0, 10),
|
|
505
|
+
resetsAt: new Date(Date.UTC(year, month + 1, 1)).toISOString()
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
__name(quotaPeriodRange, "quotaPeriodRange");
|
|
509
|
+
|
|
469
510
|
// src/spi/pricing-store.ts
|
|
470
511
|
async function seedModelPrices(store, prices) {
|
|
471
512
|
for (const price of prices) {
|
|
@@ -4770,6 +4811,7 @@ __name(runAgentLoop, "runAgentLoop");
|
|
|
4770
4811
|
AGENT_OPTIONS,
|
|
4771
4812
|
AGENT_PRICING_STORE,
|
|
4772
4813
|
AGENT_PROMPT_CONTRIBUTORS,
|
|
4814
|
+
AGENT_QUOTA_PROVIDER,
|
|
4773
4815
|
AGENT_QUOTA_STORE,
|
|
4774
4816
|
AGENT_REGISTRY,
|
|
4775
4817
|
AGENT_RETRIEVER,
|
|
@@ -4843,6 +4885,7 @@ __name(runAgentLoop, "runAgentLoop");
|
|
|
4843
4885
|
encodeStreamEvent,
|
|
4844
4886
|
estimateCost,
|
|
4845
4887
|
estimateMessageTokens,
|
|
4888
|
+
exhaustedWindow,
|
|
4846
4889
|
extractJson,
|
|
4847
4890
|
filterToolsByAllowList,
|
|
4848
4891
|
filterToolsByCanUse,
|
|
@@ -4880,6 +4923,7 @@ __name(runAgentLoop, "runAgentLoop");
|
|
|
4880
4923
|
publishAgentToolCall,
|
|
4881
4924
|
publishAgentToolRetry,
|
|
4882
4925
|
questionOptions,
|
|
4926
|
+
quotaPeriodRange,
|
|
4883
4927
|
readElicitationInput,
|
|
4884
4928
|
readElicitationQuestions,
|
|
4885
4929
|
releaseGatedFrames,
|