@dudousxd/nestjs-agent-core 0.29.0 → 0.30.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.
@@ -1,7 +1,7 @@
1
1
  import { a as Catalog, J as JsonSchema, G as GenuiValidation, b as GenuiIssue } from '../catalog-CrzetM3_.cjs';
2
2
  export { A as AjvLike, c as COMPONENT_NAME, d as CatalogOptions, C as ComponentDefinition, e as JsonSchemaValidator, P as PropsSchema, f as ajvValidator, g as builtinJsonSchemaValidator, h as defineCatalog, i as defineComponent, j as formatIssues, k as isStandardSchema, t as toJsonSchema, l as toSnakeCase, m as toolNameFor, v as validateProps, n as validatePropsSync } from '../catalog-CrzetM3_.cjs';
3
3
  import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
4
- import { A as Actor, T as ToolSpec, a as ToolHandler, b as ToolPresentation } from '../tool-CON4ZOrD.cjs';
4
+ import { A as Actor, T as ToolSpec, a as ToolHandler, b as ToolPresentation } from '../tool-CfnSyIQf.cjs';
5
5
 
6
6
  /**
7
7
  * One node of a composed UI: a catalog component, its props, and — for components declared with
@@ -1,7 +1,7 @@
1
1
  import { a as Catalog, J as JsonSchema, G as GenuiValidation, b as GenuiIssue } from '../catalog-CrzetM3_.js';
2
2
  export { A as AjvLike, c as COMPONENT_NAME, d as CatalogOptions, C as ComponentDefinition, e as JsonSchemaValidator, P as PropsSchema, f as ajvValidator, g as builtinJsonSchemaValidator, h as defineCatalog, i as defineComponent, j as formatIssues, k as isStandardSchema, t as toJsonSchema, l as toSnakeCase, m as toolNameFor, v as validateProps, n as validatePropsSync } from '../catalog-CrzetM3_.js';
3
3
  import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
4
- import { A as Actor, T as ToolSpec, a as ToolHandler, b as ToolPresentation } from '../tool-CON4ZOrD.js';
4
+ import { A as Actor, T as ToolSpec, a as ToolHandler, b as ToolPresentation } from '../tool-CfnSyIQf.js';
5
5
 
6
6
  /**
7
7
  * One node of a composed UI: a catalog component, its props, and — for components declared with
@@ -1,5 +1,5 @@
1
- import { I as InputProcessor, O as OutputProcessor } from '../processors-3FixaBnr.cjs';
2
- import { A as Actor, a as ToolHandler } from '../tool-CON4ZOrD.cjs';
1
+ import { I as InputProcessor, O as OutputProcessor } from '../processors-DdwZ0NFG.cjs';
2
+ import { A as Actor, a as ToolHandler } from '../tool-CfnSyIQf.cjs';
3
3
  import '@standard-schema/spec';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { I as InputProcessor, O as OutputProcessor } from '../processors-BrGKQgLf.js';
2
- import { A as Actor, a as ToolHandler } from '../tool-CON4ZOrD.js';
1
+ import { I as InputProcessor, O as OutputProcessor } from '../processors-8c9g9J6R.js';
2
+ import { A as Actor, a as ToolHandler } from '../tool-CfnSyIQf.js';
3
3
  import '@standard-schema/spec';
4
4
 
5
5
  /**
package/dist/index.cjs CHANGED
@@ -151,6 +151,8 @@ __export(src_exports, {
151
151
  publishAgentToolRetry: () => publishAgentToolRetry,
152
152
  questionOptions: () => questionOptions,
153
153
  quotaPeriodRange: () => quotaPeriodRange,
154
+ quotaUsedRatio: () => quotaUsedRatio,
155
+ quotaWarning: () => quotaWarning,
154
156
  readElicitationInput: () => readElicitationInput,
155
157
  readElicitationQuestions: () => readElicitationQuestions,
156
158
  releaseGatedFrames: () => releaseGatedFrames,
@@ -491,7 +493,7 @@ __name(mergeUi, "mergeUi");
491
493
  // src/spi/quota-provider.ts
492
494
  function exhaustedWindow(windows) {
493
495
  for (const window of windows) {
494
- const tokensOut = window.limitTokens !== void 0 && window.usedTokens >= window.limitTokens;
496
+ const tokensOut = window.limitTokens !== void 0 && (window.usedTokens ?? 0) >= window.limitTokens;
495
497
  const spendOut = window.limitUsd !== void 0 && window.usedUsd >= window.limitUsd;
496
498
  if (tokensOut || spendOut) {
497
499
  return {
@@ -503,6 +505,34 @@ function exhaustedWindow(windows) {
503
505
  return void 0;
504
506
  }
505
507
  __name(exhaustedWindow, "exhaustedWindow");
508
+ function quotaUsedRatio(window) {
509
+ const ratios = [];
510
+ if (window.limitUsd !== void 0 && window.limitUsd > 0) {
511
+ ratios.push(window.usedUsd / window.limitUsd);
512
+ }
513
+ if (window.limitTokens !== void 0 && window.limitTokens > 0 && window.usedTokens !== void 0) {
514
+ ratios.push(window.usedTokens / window.limitTokens);
515
+ }
516
+ return ratios.length === 0 ? null : Math.max(...ratios);
517
+ }
518
+ __name(quotaUsedRatio, "quotaUsedRatio");
519
+ function quotaWarning(windows) {
520
+ if (exhaustedWindow(windows) !== void 0) return void 0;
521
+ let fullest;
522
+ for (const window of windows) {
523
+ if (window.warnAt === void 0) continue;
524
+ const ratio = quotaUsedRatio(window);
525
+ if (ratio === null || ratio < window.warnAt) continue;
526
+ if (fullest === void 0 || ratio > fullest.ratio) {
527
+ fullest = {
528
+ period: window.period,
529
+ ratio
530
+ };
531
+ }
532
+ }
533
+ return fullest;
534
+ }
535
+ __name(quotaWarning, "quotaWarning");
506
536
  function quotaPeriodRange(period, now) {
507
537
  const year = now.getUTCFullYear();
508
538
  const month = now.getUTCMonth();
@@ -1439,6 +1469,7 @@ function normalizeElicitationReply(reply) {
1439
1469
  return reply;
1440
1470
  }
1441
1471
  const answeredByRef = candidate.answeredByRef ?? candidate.executedByRef;
1472
+ const answeredVia = candidate.answeredVia ?? candidate.decidedVia;
1442
1473
  return {
1443
1474
  answers: {},
1444
1475
  ...candidate.approved === false || candidate.skipped === true ? {
@@ -1446,6 +1477,9 @@ function normalizeElicitationReply(reply) {
1446
1477
  } : {},
1447
1478
  ...answeredByRef !== void 0 ? {
1448
1479
  answeredByRef
1480
+ } : {},
1481
+ ...answeredVia !== void 0 ? {
1482
+ answeredVia
1449
1483
  } : {}
1450
1484
  };
1451
1485
  }
@@ -1469,7 +1503,13 @@ function resolveElicitation(request, raw) {
1469
1503
  return {
1470
1504
  answers,
1471
1505
  skipped: reply.skipped === true,
1472
- defaulted
1506
+ defaulted,
1507
+ ...reply.answeredByRef !== void 0 ? {
1508
+ answeredBy: reply.answeredByRef
1509
+ } : {},
1510
+ ...reply.answeredVia !== void 0 ? {
1511
+ answeredVia: reply.answeredVia
1512
+ } : {}
1473
1513
  };
1474
1514
  }
1475
1515
  __name(resolveElicitation, "resolveElicitation");
@@ -5641,6 +5681,8 @@ var InMemoryAgentStore = class {
5641
5681
  publishAgentToolRetry,
5642
5682
  questionOptions,
5643
5683
  quotaPeriodRange,
5684
+ quotaUsedRatio,
5685
+ quotaWarning,
5644
5686
  readElicitationInput,
5645
5687
  readElicitationQuestions,
5646
5688
  releaseGatedFrames,