@dudousxd/nestjs-agent-core 0.29.0 → 0.31.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-B0J4Fjyd.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-B0J4Fjyd.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-DdnRmmlq.cjs';
2
+ import { A as Actor, a as ToolHandler } from '../tool-B0J4Fjyd.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-C3Qx3ZdF.js';
2
+ import { A as Actor, a as ToolHandler } from '../tool-B0J4Fjyd.js';
3
3
  import '@standard-schema/spec';
4
4
 
5
5
  /**
package/dist/index.cjs CHANGED
@@ -48,6 +48,7 @@ __export(src_exports, {
48
48
  AGENT_SPAN_EVENTS: () => AGENT_SPAN_EVENTS,
49
49
  AGENT_STORE: () => AGENT_STORE,
50
50
  AGENT_TOOL_REGISTRY: () => AGENT_TOOL_REGISTRY,
51
+ ALL_AGENTS: () => ALL_AGENTS,
51
52
  APPROVAL_EXPIRED_REASON: () => APPROVAL_EXPIRED_REASON,
52
53
  ASK_TOOL_DESCRIPTION: () => ASK_TOOL_DESCRIPTION,
53
54
  ASK_TOOL_NAME: () => ASK_TOOL_NAME,
@@ -151,6 +152,8 @@ __export(src_exports, {
151
152
  publishAgentToolRetry: () => publishAgentToolRetry,
152
153
  questionOptions: () => questionOptions,
153
154
  quotaPeriodRange: () => quotaPeriodRange,
155
+ quotaUsedRatio: () => quotaUsedRatio,
156
+ quotaWarning: () => quotaWarning,
154
157
  readElicitationInput: () => readElicitationInput,
155
158
  readElicitationQuestions: () => readElicitationQuestions,
156
159
  releaseGatedFrames: () => releaseGatedFrames,
@@ -488,10 +491,13 @@ function mergeUi(...lists) {
488
491
  }
489
492
  __name(mergeUi, "mergeUi");
490
493
 
494
+ // src/tool-presentation.ts
495
+ var ALL_AGENTS = "*";
496
+
491
497
  // src/spi/quota-provider.ts
492
498
  function exhaustedWindow(windows) {
493
499
  for (const window of windows) {
494
- const tokensOut = window.limitTokens !== void 0 && window.usedTokens >= window.limitTokens;
500
+ const tokensOut = window.limitTokens !== void 0 && (window.usedTokens ?? 0) >= window.limitTokens;
495
501
  const spendOut = window.limitUsd !== void 0 && window.usedUsd >= window.limitUsd;
496
502
  if (tokensOut || spendOut) {
497
503
  return {
@@ -503,6 +509,34 @@ function exhaustedWindow(windows) {
503
509
  return void 0;
504
510
  }
505
511
  __name(exhaustedWindow, "exhaustedWindow");
512
+ function quotaUsedRatio(window) {
513
+ const ratios = [];
514
+ if (window.limitUsd !== void 0 && window.limitUsd > 0) {
515
+ ratios.push(window.usedUsd / window.limitUsd);
516
+ }
517
+ if (window.limitTokens !== void 0 && window.limitTokens > 0 && window.usedTokens !== void 0) {
518
+ ratios.push(window.usedTokens / window.limitTokens);
519
+ }
520
+ return ratios.length === 0 ? null : Math.max(...ratios);
521
+ }
522
+ __name(quotaUsedRatio, "quotaUsedRatio");
523
+ function quotaWarning(windows) {
524
+ if (exhaustedWindow(windows) !== void 0) return void 0;
525
+ let fullest;
526
+ for (const window of windows) {
527
+ if (window.warnAt === void 0) continue;
528
+ const ratio = quotaUsedRatio(window);
529
+ if (ratio === null || ratio < window.warnAt) continue;
530
+ if (fullest === void 0 || ratio > fullest.ratio) {
531
+ fullest = {
532
+ period: window.period,
533
+ ratio
534
+ };
535
+ }
536
+ }
537
+ return fullest;
538
+ }
539
+ __name(quotaWarning, "quotaWarning");
506
540
  function quotaPeriodRange(period, now) {
507
541
  const year = now.getUTCFullYear();
508
542
  const month = now.getUTCMonth();
@@ -1439,6 +1473,7 @@ function normalizeElicitationReply(reply) {
1439
1473
  return reply;
1440
1474
  }
1441
1475
  const answeredByRef = candidate.answeredByRef ?? candidate.executedByRef;
1476
+ const answeredVia = candidate.answeredVia ?? candidate.decidedVia;
1442
1477
  return {
1443
1478
  answers: {},
1444
1479
  ...candidate.approved === false || candidate.skipped === true ? {
@@ -1446,6 +1481,9 @@ function normalizeElicitationReply(reply) {
1446
1481
  } : {},
1447
1482
  ...answeredByRef !== void 0 ? {
1448
1483
  answeredByRef
1484
+ } : {},
1485
+ ...answeredVia !== void 0 ? {
1486
+ answeredVia
1449
1487
  } : {}
1450
1488
  };
1451
1489
  }
@@ -1469,7 +1507,13 @@ function resolveElicitation(request, raw) {
1469
1507
  return {
1470
1508
  answers,
1471
1509
  skipped: reply.skipped === true,
1472
- defaulted
1510
+ defaulted,
1511
+ ...reply.answeredByRef !== void 0 ? {
1512
+ answeredBy: reply.answeredByRef
1513
+ } : {},
1514
+ ...reply.answeredVia !== void 0 ? {
1515
+ answeredVia: reply.answeredVia
1516
+ } : {}
1473
1517
  };
1474
1518
  }
1475
1519
  __name(resolveElicitation, "resolveElicitation");
@@ -5538,6 +5582,7 @@ var InMemoryAgentStore = class {
5538
5582
  AGENT_SPAN_EVENTS,
5539
5583
  AGENT_STORE,
5540
5584
  AGENT_TOOL_REGISTRY,
5585
+ ALL_AGENTS,
5541
5586
  APPROVAL_EXPIRED_REASON,
5542
5587
  ASK_TOOL_DESCRIPTION,
5543
5588
  ASK_TOOL_NAME,
@@ -5641,6 +5686,8 @@ var InMemoryAgentStore = class {
5641
5686
  publishAgentToolRetry,
5642
5687
  questionOptions,
5643
5688
  quotaPeriodRange,
5689
+ quotaUsedRatio,
5690
+ quotaWarning,
5644
5691
  readElicitationInput,
5645
5692
  readElicitationQuestions,
5646
5693
  releaseGatedFrames,