@xpert-ai/plugin-sdk 3.18.0 → 3.18.2

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/index.cjs.js CHANGED
@@ -36,7 +36,7 @@ var jsTiktoken = require('js-tiktoken');
36
36
  var base$1 = require('@langchain/core/language_models/base');
37
37
  var connector = require('./connector.cjs.js');
38
38
  var collaborationClient = require('./collaboration-client.cjs.js');
39
- require('@langchain/core/tools');
39
+ var tools = require('@langchain/core/tools');
40
40
  require('zod/v3');
41
41
 
42
42
  function _interopNamespaceDefault(e) {
@@ -521,12 +521,14 @@ exports.StrategyBus = class StrategyBus {
521
521
  entry
522
522
  });
523
523
  }
524
- remove(orgId, pluginName) {
525
- this.subject.next({
524
+ remove(orgId, pluginName, cause) {
525
+ this.subject.next(_extends._extends({
526
526
  type: 'REMOVE',
527
527
  orgId,
528
528
  pluginName
529
- });
529
+ }, cause ? {
530
+ cause
531
+ } : {}));
530
532
  }
531
533
  constructor(){
532
534
  this.subject = new rxjs.Subject();
@@ -561,22 +563,39 @@ class BaseStrategyRegistry {
561
563
  const type = this.reflector.get(this.strategyKey, target);
562
564
  if (type) {
563
565
  const source = this.getSource(instance);
564
- const pluginName = source.kind === 'plugin' ? source.pluginName : undefined;
565
- const organizationId = source.scopeKey;
566
- var _this_strategies_get;
567
- const orgMap = (_this_strategies_get = this.strategies.get(organizationId)) != null ? _this_strategies_get : new Map();
568
- orgMap.set(type, instance);
569
- this.strategies.set(organizationId, orgMap);
570
- this.logger.debug(`Registered strategy of type ${type} for scope ${organizationId} from plugin ${pluginName}`);
571
- if (pluginName) {
572
- var _this_pluginStrategies_get;
573
- const pluginStrategies = (_this_pluginStrategies_get = this.pluginStrategies.get(pluginName)) != null ? _this_pluginStrategies_get : new Set();
574
- pluginStrategies.add(type);
575
- this.pluginStrategies.set(pluginName, pluginStrategies);
576
- }
566
+ this.store(type, instance, source, false);
577
567
  }
578
568
  }
569
+ /** Registers a host-generated adapter without mutating shared class metadata. */ register(type, instance, source) {
570
+ if ((typeof instance !== 'object' || instance === null) && typeof instance !== 'function') {
571
+ throw new Error(`Cannot register non-object strategy '${type}'.`);
572
+ }
573
+ this.assertCanRegister(type, instance, source);
574
+ this.explicitSources.set(instance, source);
575
+ return this.store(type, instance, source, false);
576
+ }
577
+ /** Preflights adapter batches so a provider is expanded atomically across registries. */ assertCanRegister(type, instance, source) {
578
+ var _this_strategies_get;
579
+ const existing = (_this_strategies_get = this.strategies.get(source.scopeKey)) == null ? void 0 : _this_strategies_get.get(type);
580
+ if (!existing || existing === instance) return;
581
+ const existingSource = this.getSource(existing);
582
+ const samePlugin = existingSource.kind === 'plugin' && source.kind === 'plugin' && existingSource.pluginName === source.pluginName;
583
+ if (!samePlugin) {
584
+ throw new Error(`Strategy '${type}' is already registered for scope '${source.scopeKey}'.`);
585
+ }
586
+ }
587
+ /** Removes one exact programmatic registration without affecting fallback scopes. */ unregister(type, source, expected) {
588
+ const orgMap = this.strategies.get(source.scopeKey);
589
+ const current = orgMap == null ? void 0 : orgMap.get(type);
590
+ if (expected !== undefined && current !== expected) return false;
591
+ var _orgMap_delete;
592
+ return (_orgMap_delete = orgMap == null ? void 0 : orgMap.delete(type)) != null ? _orgMap_delete : false;
593
+ }
579
594
  /** Returns the explicit registry provenance attached by the plugin loader. */ getSource(instance) {
595
+ if (typeof instance === 'object' && instance !== null || typeof instance === 'function') {
596
+ const explicit = this.explicitSources.get(instance);
597
+ if (explicit) return explicit;
598
+ }
580
599
  const target = resolveStrategyMetadataTarget(instance);
581
600
  if (!target) {
582
601
  return {
@@ -680,11 +699,68 @@ class BaseStrategyRegistry {
680
699
  }
681
700
  return Array.from(effective.values());
682
701
  }
702
+ listRegistrations(organizationId) {
703
+ organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
704
+ const effective = new Map();
705
+ for (const scopeKey of this.resolveStrategyScopeKeys(organizationId)){
706
+ var _this_strategies_get;
707
+ var _this_strategies_get_entries;
708
+ for (const [type, strategy] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(scopeKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
709
+ if (!effective.has(type)) effective.set(type, strategy);
710
+ }
711
+ }
712
+ return Array.from(effective, ([type, strategy])=>({
713
+ type,
714
+ strategy,
715
+ source: this.getSource(strategy)
716
+ }));
717
+ }
718
+ /** Returns every direct registration without applying request-scope fallback rules. */ listAllRegistrations() {
719
+ const registrations = [];
720
+ for (const [scopeKey, strategies] of this.strategies){
721
+ for (const [type, strategy] of strategies){
722
+ const source = this.getSource(strategy);
723
+ registrations.push({
724
+ type,
725
+ strategy,
726
+ source: source.scopeKey === scopeKey ? source : _extends._extends({}, source, {
727
+ scopeKey
728
+ })
729
+ });
730
+ }
731
+ }
732
+ return registrations;
733
+ }
734
+ store(type, instance, source, rejectCrossPluginConflict) {
735
+ const pluginName = source.kind === 'plugin' ? source.pluginName : undefined;
736
+ const organizationId = source.scopeKey;
737
+ var _this_strategies_get;
738
+ const orgMap = (_this_strategies_get = this.strategies.get(organizationId)) != null ? _this_strategies_get : new Map();
739
+ const existing = orgMap.get(type);
740
+ if (rejectCrossPluginConflict && existing && existing !== instance) {
741
+ const existingSource = this.getSource(existing);
742
+ const samePlugin = existingSource.kind === 'plugin' && source.kind === 'plugin' && existingSource.pluginName === source.pluginName;
743
+ if (!samePlugin) {
744
+ throw new Error(`Strategy '${type}' is already registered for scope '${organizationId}'.`);
745
+ }
746
+ }
747
+ orgMap.set(type, instance);
748
+ this.strategies.set(organizationId, orgMap);
749
+ this.logger.debug(`Registered strategy of type ${type} for scope ${organizationId} from plugin ${pluginName}`);
750
+ if (pluginName) {
751
+ var _this_pluginStrategies_get;
752
+ const pluginStrategies = (_this_pluginStrategies_get = this.pluginStrategies.get(pluginName)) != null ? _this_pluginStrategies_get : new Set();
753
+ pluginStrategies.add(type);
754
+ this.pluginStrategies.set(pluginName, pluginStrategies);
755
+ }
756
+ return existing;
757
+ }
683
758
  constructor(strategyKey, discoveryService, reflector){
684
759
  this.logger = new common.Logger(BaseStrategyRegistry.name);
685
760
  // Map<scopeKey, Map<type, strategy>>
686
761
  this.strategies = new Map();
687
762
  this.pluginStrategies = new Map();
763
+ this.explicitSources = new WeakMap();
688
764
  this.strategyKey = strategyKey;
689
765
  this.discoveryService = discoveryService;
690
766
  this.reflector = reflector;
@@ -1700,13 +1776,13 @@ var DefaultParameterName;
1700
1776
  const PARAMETER_RULE_TEMPLATE = {
1701
1777
  [DefaultParameterName.TEMPERATURE]: {
1702
1778
  label: {
1703
- en_US: "Temperature",
1704
- zh_Hans: "温度"
1779
+ en_US: 'Temperature',
1780
+ zh_Hans: '温度'
1705
1781
  },
1706
1782
  type: contracts.ParameterType.FLOAT,
1707
1783
  help: {
1708
- en_US: "Controls randomness. Lower temperature results in less random completions." + " As the temperature approaches zero, the model will become deterministic and repetitive." + " Higher temperature results in more random completions.",
1709
- zh_Hans: "温度控制随机性。较低的温度会导致较少的随机完成。随着温度接近零,模型将变得确定性和重复性。" + "较高的温度会导致更多的随机完成。"
1784
+ en_US: 'Controls randomness. Lower temperature results in less random completions.' + ' As the temperature approaches zero, the model will become deterministic and repetitive.' + ' Higher temperature results in more random completions.',
1785
+ zh_Hans: '温度控制随机性。较低的温度会导致较少的随机完成。随着温度接近零,模型将变得确定性和重复性。' + '较高的温度会导致更多的随机完成。'
1710
1786
  },
1711
1787
  required: false,
1712
1788
  default: 0.0,
@@ -1716,13 +1792,13 @@ const PARAMETER_RULE_TEMPLATE = {
1716
1792
  },
1717
1793
  [DefaultParameterName.TOP_P]: {
1718
1794
  label: {
1719
- en_US: "Top P",
1720
- zh_Hans: "Top P"
1795
+ en_US: 'Top P',
1796
+ zh_Hans: 'Top P'
1721
1797
  },
1722
1798
  type: contracts.ParameterType.FLOAT,
1723
1799
  help: {
1724
- en_US: "Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options" + " are considered.",
1725
- zh_Hans: "通过核心采样控制多样性:0.5表示考虑了一半的所有可能性加权选项。"
1800
+ en_US: 'Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options' + ' are considered.',
1801
+ zh_Hans: '通过核心采样控制多样性:0.5表示考虑了一半的所有可能性加权选项。'
1726
1802
  },
1727
1803
  required: false,
1728
1804
  default: 1.0,
@@ -1732,13 +1808,13 @@ const PARAMETER_RULE_TEMPLATE = {
1732
1808
  },
1733
1809
  [DefaultParameterName.TOP_K]: {
1734
1810
  label: {
1735
- en_US: "Top K",
1736
- zh_Hans: "Top K"
1811
+ en_US: 'Top K',
1812
+ zh_Hans: 'Top K'
1737
1813
  },
1738
1814
  type: contracts.ParameterType.INT,
1739
1815
  help: {
1740
- en_US: "Limits the number of tokens to consider for each step by keeping only the k most likely tokens.",
1741
- zh_Hans: "通过只保留每一步中最可能的 k 个标记来限制要考虑的标记数量。"
1816
+ en_US: 'Limits the number of tokens to consider for each step by keeping only the k most likely tokens.',
1817
+ zh_Hans: '通过只保留每一步中最可能的 k 个标记来限制要考虑的标记数量。'
1742
1818
  },
1743
1819
  required: false,
1744
1820
  default: 50,
@@ -1748,13 +1824,13 @@ const PARAMETER_RULE_TEMPLATE = {
1748
1824
  },
1749
1825
  [DefaultParameterName.PRESENCE_PENALTY]: {
1750
1826
  label: {
1751
- en_US: "Presence Penalty",
1752
- zh_Hans: "存在惩罚"
1827
+ en_US: 'Presence Penalty',
1828
+ zh_Hans: '存在惩罚'
1753
1829
  },
1754
1830
  type: contracts.ParameterType.FLOAT,
1755
1831
  help: {
1756
- en_US: "Applies a penalty to the log-probability of tokens already in the text.",
1757
- zh_Hans: "对文本中已有的标记的对数概率施加惩罚。"
1832
+ en_US: 'Applies a penalty to the log-probability of tokens already in the text.',
1833
+ zh_Hans: '对文本中已有的标记的对数概率施加惩罚。'
1758
1834
  },
1759
1835
  required: false,
1760
1836
  default: 0.0,
@@ -1764,13 +1840,13 @@ const PARAMETER_RULE_TEMPLATE = {
1764
1840
  },
1765
1841
  [DefaultParameterName.FREQUENCY_PENALTY]: {
1766
1842
  label: {
1767
- en_US: "Frequency Penalty",
1768
- zh_Hans: "频率惩罚"
1843
+ en_US: 'Frequency Penalty',
1844
+ zh_Hans: '频率惩罚'
1769
1845
  },
1770
1846
  type: contracts.ParameterType.FLOAT,
1771
1847
  help: {
1772
- en_US: "Applies a penalty to the log-probability of tokens that appear in the text.",
1773
- zh_Hans: "对文本中出现的标记的对数概率施加惩罚。"
1848
+ en_US: 'Applies a penalty to the log-probability of tokens that appear in the text.',
1849
+ zh_Hans: '对文本中出现的标记的对数概率施加惩罚。'
1774
1850
  },
1775
1851
  required: false,
1776
1852
  default: 0.0,
@@ -1780,44 +1856,44 @@ const PARAMETER_RULE_TEMPLATE = {
1780
1856
  },
1781
1857
  [DefaultParameterName.MAX_TOKENS]: {
1782
1858
  label: {
1783
- en_US: "Max Tokens",
1784
- zh_Hans: "最大标记"
1859
+ en_US: 'Max Tokens',
1860
+ zh_Hans: '最大标记'
1785
1861
  },
1786
1862
  type: contracts.ParameterType.INT,
1787
1863
  help: {
1788
- en_US: "Specifies the upper limit on the length of generated results." + " If the generated results are truncated, you can increase this parameter.",
1789
- zh_Hans: "指定生成结果长度的上限。如果生成结果截断,可以调大该参数。"
1864
+ en_US: 'Specifies the upper limit on the length of generated results.' + ' If the generated results are truncated, you can increase this parameter.',
1865
+ zh_Hans: '指定生成结果长度的上限。如果生成结果截断,可以调大该参数。'
1790
1866
  },
1791
1867
  required: false,
1792
- default: 64,
1868
+ default: 2048,
1793
1869
  min: 1,
1794
1870
  max: 2048,
1795
1871
  precision: 0
1796
1872
  },
1797
1873
  [DefaultParameterName.RESPONSE_FORMAT]: {
1798
1874
  label: {
1799
- en_US: "Response Format",
1800
- zh_Hans: "回复格式"
1875
+ en_US: 'Response Format',
1876
+ zh_Hans: '回复格式'
1801
1877
  },
1802
1878
  type: contracts.ParameterType.STRING,
1803
1879
  help: {
1804
- en_US: "Set a response format, ensure the output from llm is a valid code block as possible," + " such as JSON, XML, etc.",
1805
- zh_Hans: "设置一个返回格式,确保llm的输出尽可能是有效的代码块,如JSON、XML等"
1880
+ en_US: 'Set a response format, ensure the output from llm is a valid code block as possible,' + ' such as JSON, XML, etc.',
1881
+ zh_Hans: '设置一个返回格式,确保llm的输出尽可能是有效的代码块,如JSON、XML等'
1806
1882
  },
1807
1883
  required: false,
1808
1884
  options: [
1809
- "JSON",
1810
- "XML"
1885
+ 'JSON',
1886
+ 'XML'
1811
1887
  ]
1812
1888
  },
1813
1889
  [DefaultParameterName.JSON_SCHEMA]: {
1814
1890
  label: {
1815
- en_US: "JSON Schema"
1891
+ en_US: 'JSON Schema'
1816
1892
  },
1817
1893
  type: contracts.ParameterType.TEXT,
1818
1894
  help: {
1819
- en_US: "Set a response json schema will ensure LLM to adhere it.",
1820
- zh_Hans: "设置返回的json schema,llm将按照它返回"
1895
+ en_US: 'Set a response json schema will ensure LLM to adhere it.',
1896
+ zh_Hans: '设置返回的json schema,llm将按照它返回'
1821
1897
  },
1822
1898
  required: false
1823
1899
  }
@@ -5849,6 +5925,551 @@ function freezeItems(items) {
5849
5925
  ]) : undefined;
5850
5926
  }
5851
5927
 
5928
+ const XPERT_TOOL_PROVIDER = 'XPERT_TOOL_PROVIDER';
5929
+ const XPERT_TOOL_PROVIDER_METADATA = 'XPERT_TOOL_PROVIDER_METADATA';
5930
+ const XPERT_TOOL_METHOD_METADATA = 'XPERT_TOOL_METHOD_METADATA';
5931
+ /** Marks one injectable business service as a reusable Tool provider and one native MCP service. */ const XpertToolProvider = (options)=>common.applyDecorators(common.Injectable(), common.SetMetadata(XPERT_TOOL_PROVIDER, options.provider), common.SetMetadata(XPERT_TOOL_PROVIDER_METADATA, Object.freeze(_extends._extends({}, options))), common.SetMetadata(STRATEGY_META_KEY, XPERT_TOOL_PROVIDER));
5932
+ /** Exposes one business method through an Agent Middleware, native MCP, or both. */ const XpertTool = (options)=>common.SetMetadata(XPERT_TOOL_METHOD_METADATA, Object.freeze(_extends._extends({}, options)));
5933
+
5934
+ const PROVIDER_PATTERN = /^[a-z][a-z0-9_]*$/;
5935
+ const MIDDLEWARE_PROVIDER_PATTERN = /^[A-Za-z][A-Za-z0-9_]*$/;
5936
+ const COMPONENT_KEY_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
5937
+ const SLUG_PATTERN = COMPONENT_KEY_PATTERN;
5938
+ const TOOL_NAME_PATTERN = /^[A-Za-z0-9_-]+$/;
5939
+ function describeXpertToolProvider(instance) {
5940
+ const target = instance.constructor;
5941
+ const options = Reflect.getMetadata(XPERT_TOOL_PROVIDER_METADATA, target);
5942
+ if (!options) {
5943
+ throw new Error(`Provider '${target.name}' is missing @XpertToolProvider metadata.`);
5944
+ }
5945
+ validateProviderOptions(options);
5946
+ const methods = collectDecoratedMethods(instance);
5947
+ const names = new Set();
5948
+ var _options_middlewares;
5949
+ const middlewareProviders = new Set(((_options_middlewares = options.middlewares) != null ? _options_middlewares : []).map(({ provider })=>provider));
5950
+ var _options_apps;
5951
+ const appKeys = new Set(((_options_apps = options.apps) != null ? _options_apps : []).map(({ key })=>key));
5952
+ const tools = methods.map(({ methodName, options: toolOptions })=>{
5953
+ var _toolOptions_mcp_app;
5954
+ validateToolOptions(toolOptions, methodName);
5955
+ if (names.has(toolOptions.name)) {
5956
+ throw new Error(`Tool '${toolOptions.name}' is declared more than once by provider '${options.provider}'.`);
5957
+ }
5958
+ names.add(toolOptions.name);
5959
+ const middlewareProvider = resolveMiddlewareProvider(toolOptions, options);
5960
+ if (!middlewareProvider && !toolOptions.mcp) {
5961
+ throw new Error(`Tool '${toolOptions.name}' is not exposed through Middleware or MCP.`);
5962
+ }
5963
+ if (middlewareProvider && !middlewareProviders.has(middlewareProvider)) {
5964
+ throw new Error(`Tool '${toolOptions.name}' references undeclared Middleware provider '${middlewareProvider}'.`);
5965
+ }
5966
+ const appKey = toolOptions.mcp && ((_toolOptions_mcp_app = toolOptions.mcp.app) == null ? void 0 : _toolOptions_mcp_app.resourceKey);
5967
+ if (appKey && !appKeys.has(appKey)) {
5968
+ throw new Error(`MCP Tool '${toolOptions.name}' references undeclared App '${appKey}'.`);
5969
+ }
5970
+ return Object.freeze({
5971
+ methodName,
5972
+ middlewareProvider,
5973
+ options: toolOptions
5974
+ });
5975
+ });
5976
+ if (!tools.length) {
5977
+ throw new Error(`Provider '${options.provider}' does not declare any @XpertTool methods.`);
5978
+ }
5979
+ return Object.freeze({
5980
+ options: Object.freeze(_extends._extends({}, options)),
5981
+ tools: Object.freeze(tools)
5982
+ });
5983
+ }
5984
+ function collectDecoratedMethods(instance) {
5985
+ const result = [];
5986
+ const seen = new Set();
5987
+ let prototype = Object.getPrototypeOf(instance);
5988
+ while(prototype && prototype !== Object.prototype){
5989
+ for (const methodName of Object.getOwnPropertyNames(prototype)){
5990
+ if (methodName === 'constructor' || seen.has(methodName)) continue;
5991
+ seen.add(methodName);
5992
+ const method = Reflect.get(prototype, methodName);
5993
+ if (typeof method !== 'function') continue;
5994
+ const options = Reflect.getMetadata(XPERT_TOOL_METHOD_METADATA, method);
5995
+ if (options) result.push({
5996
+ methodName,
5997
+ options
5998
+ });
5999
+ }
6000
+ prototype = Object.getPrototypeOf(prototype);
6001
+ }
6002
+ return result;
6003
+ }
6004
+ function validateProviderOptions(options) {
6005
+ var _options_name;
6006
+ if (!PROVIDER_PATTERN.test(options.provider)) {
6007
+ throw new Error(`Xpert Tool provider '${options.provider}' must use lowercase snake_case.`);
6008
+ }
6009
+ if (!COMPONENT_KEY_PATTERN.test(options.componentKey)) {
6010
+ throw new Error(`Xpert Tool component key '${options.componentKey}' must use lowercase kebab-case.`);
6011
+ }
6012
+ if (!((_options_name = options.name) == null ? void 0 : _options_name.trim())) throw new Error(`Xpert Tool provider '${options.provider}' requires a name.`);
6013
+ if (options.slug && !SLUG_PATTERN.test(options.slug)) {
6014
+ throw new Error(`Xpert Tool provider slug '${options.slug}' must use lowercase kebab-case.`);
6015
+ }
6016
+ const middlewareProviders = new Set();
6017
+ var _options_middlewares;
6018
+ for (const definition of (_options_middlewares = options.middlewares) != null ? _options_middlewares : []){
6019
+ if (!MIDDLEWARE_PROVIDER_PATTERN.test(definition.provider)) {
6020
+ throw new Error(`Middleware provider '${definition.provider}' must be a stable identifier.`);
6021
+ }
6022
+ if (middlewareProviders.has(definition.provider)) {
6023
+ throw new Error(`Middleware provider '${definition.provider}' is declared more than once.`);
6024
+ }
6025
+ if (definition.meta.name !== definition.provider) {
6026
+ throw new Error(`Middleware metadata name must match provider '${definition.provider}'.`);
6027
+ }
6028
+ middlewareProviders.add(definition.provider);
6029
+ }
6030
+ if (options.defaultMiddleware && !middlewareProviders.has(options.defaultMiddleware)) {
6031
+ throw new Error(`Default Middleware provider '${options.defaultMiddleware}' is not declared.`);
6032
+ }
6033
+ const appKeys = new Set();
6034
+ var _options_apps;
6035
+ for (const app of (_options_apps = options.apps) != null ? _options_apps : []){
6036
+ if (!TOOL_NAME_PATTERN.test(app.key) || app.key.length > 191) {
6037
+ throw new Error(`MCP App key '${app.key}' is invalid.`);
6038
+ }
6039
+ if (appKeys.has(app.key)) {
6040
+ throw new Error(`MCP App '${app.key}' is declared more than once.`);
6041
+ }
6042
+ if (!isRelativeHtmlEntry(app.entry)) {
6043
+ throw new Error(`MCP App '${app.key}' entry must be a relative HTML path inside the plugin bundle.`);
6044
+ }
6045
+ appKeys.add(app.key);
6046
+ }
6047
+ }
6048
+ function validateToolOptions(options, methodName) {
6049
+ var _options_description;
6050
+ if (!TOOL_NAME_PATTERN.test(options.name) || options.name.length > 191) {
6051
+ throw new Error(`Method '${methodName}' declares invalid Tool name '${options.name}'.`);
6052
+ }
6053
+ if (!((_options_description = options.description) == null ? void 0 : _options_description.trim())) throw new Error(`Tool '${options.name}' requires a description.`);
6054
+ assertStrictObjectSchema(options.inputSchema, options.name, 'input');
6055
+ if (options.mcp && !options.outputSchema) {
6056
+ throw new Error(`MCP Tool '${options.name}' requires an outputSchema.`);
6057
+ }
6058
+ if (options.mcp && options.outputSchema) {
6059
+ assertStrictObjectSchema(options.outputSchema, options.name, 'output');
6060
+ }
6061
+ if (options.mcp && !options.mcp.requiredContext.length) {
6062
+ throw new Error(`MCP Tool '${options.name}' requires at least one execution context.`);
6063
+ }
6064
+ if (options.mcp) {
6065
+ const behavior = options.mcp.behavior;
6066
+ if (!includesValue(contracts.MCP_TOOL_RISKS, behavior == null ? void 0 : behavior.risk) || !includesValue(contracts.MCP_TOOL_SIDE_EFFECTS, behavior == null ? void 0 : behavior.sideEffect) || !includesValue(contracts.MCP_TOOL_IDEMPOTENCY, behavior == null ? void 0 : behavior.idempotency)) {
6067
+ throw new Error(`MCP Tool '${options.name}' requires valid behavior annotations.`);
6068
+ }
6069
+ const contexts = new Set(options.mcp.requiredContext);
6070
+ if (contexts.size !== options.mcp.requiredContext.length || [
6071
+ ...contexts
6072
+ ].some((context)=>!includesValue(contracts.MCP_REQUIRED_CONTEXTS, context))) {
6073
+ throw new Error(`MCP Tool '${options.name}' declares invalid or duplicate execution context requirements.`);
6074
+ }
6075
+ if (options.mcp.visibility && (!options.mcp.visibility.length || new Set(options.mcp.visibility).size !== options.mcp.visibility.length || options.mcp.visibility.some((visibility)=>!includesValue(contracts.MCP_CAPABILITY_VISIBILITIES, visibility)))) {
6076
+ throw new Error(`MCP Tool '${options.name}' declares invalid visibility.`);
6077
+ }
6078
+ if (options.mcp.app && options.mcp.visibility && !options.mcp.visibility.includes('app')) {
6079
+ throw new Error(`MCP Tool '${options.name}' with an App binding must include app visibility.`);
6080
+ }
6081
+ }
6082
+ }
6083
+ function isRelativeHtmlEntry(entry) {
6084
+ if (!entry || !entry.endsWith('.html') || entry.startsWith('/') || entry.includes('\\')) return false;
6085
+ return entry.split('/').every((segment)=>segment !== '.' && segment !== '..' && segment.length > 0);
6086
+ }
6087
+ function assertStrictObjectSchema(schema, toolName, role) {
6088
+ if (!schema || typeof Reflect.get(schema, 'parseAsync') !== 'function') {
6089
+ throw new Error(`Tool '${toolName}' requires a Zod ${role} schema.`);
6090
+ }
6091
+ const definition = Reflect.get(schema, '_def');
6092
+ if (!definition || Reflect.get(definition, 'unknownKeys') !== 'strict') {
6093
+ throw new Error(`Tool '${toolName}' ${role} schema must be a strict Zod object.`);
6094
+ }
6095
+ }
6096
+ function resolveMiddlewareProvider(tool, provider) {
6097
+ if (tool.middleware === false) return undefined;
6098
+ if (typeof tool.middleware === 'string') return tool.middleware;
6099
+ if (tool.middleware === true || tool.middleware === undefined) return provider.defaultMiddleware;
6100
+ return undefined;
6101
+ }
6102
+ function getXpertToolMethod(instance, descriptor) {
6103
+ const method = Reflect.get(instance, descriptor.methodName);
6104
+ if (typeof method !== 'function') {
6105
+ throw new Error(`Decorated Tool method '${descriptor.methodName}' is not callable.`);
6106
+ }
6107
+ return method.bind(instance);
6108
+ }
6109
+ function includesValue(values, value) {
6110
+ return values.some((candidate)=>candidate === value);
6111
+ }
6112
+
6113
+ exports.XpertToolProviderRegistry = class XpertToolProviderRegistry extends BaseStrategyRegistry {
6114
+ upsert(candidate) {
6115
+ const target = resolveStrategyMetadataTarget(candidate);
6116
+ if (!target || !Reflect.getMetadata(XPERT_TOOL_PROVIDER_METADATA, target)) return;
6117
+ const instance = candidate;
6118
+ const descriptor = describeXpertToolProvider(instance);
6119
+ const source = this.getSource(instance);
6120
+ this.assertUniqueClaims(instance, descriptor, source.scopeKey);
6121
+ const previous = this.register(descriptor.options.provider, instance, source);
6122
+ this.replacements.set(instance, previous != null ? previous : null);
6123
+ }
6124
+ rollback(instance) {
6125
+ const descriptor = describeXpertToolProvider(instance);
6126
+ const source = this.getSource(instance);
6127
+ const previous = this.replacements.get(instance);
6128
+ if (previous) {
6129
+ this.register(descriptor.options.provider, previous, this.getSource(previous));
6130
+ } else {
6131
+ this.unregister(descriptor.options.provider, source, instance);
6132
+ }
6133
+ this.replacements.delete(instance);
6134
+ }
6135
+ assertUniqueClaims(instance, descriptor, scopeKey) {
6136
+ var _this_strategies_get;
6137
+ const toolNames = new Set(descriptor.tools.map(({ options })=>options.name));
6138
+ var _this_strategies_get_entries;
6139
+ for (const [providerKey, existing] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(scopeKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
6140
+ if (existing === instance || providerKey === descriptor.options.provider) continue;
6141
+ const existingDescriptor = describeXpertToolProvider(existing);
6142
+ if (existingDescriptor.options.componentKey === descriptor.options.componentKey) {
6143
+ throw new Error(`Component key '${descriptor.options.componentKey}' is already registered for scope '${scopeKey}'.`);
6144
+ }
6145
+ const duplicateTool = existingDescriptor.tools.find(({ options })=>toolNames.has(options.name));
6146
+ if (duplicateTool) {
6147
+ throw new Error(`Tool '${duplicateTool.options.name}' is already registered for scope '${scopeKey}'.`);
6148
+ }
6149
+ }
6150
+ }
6151
+ constructor(discoveryService, reflector){
6152
+ super(XPERT_TOOL_PROVIDER, discoveryService, reflector);
6153
+ this.replacements = new WeakMap();
6154
+ }
6155
+ };
6156
+ exports.XpertToolProviderRegistry = __decorate([
6157
+ common.Injectable(),
6158
+ __metadata("design:paramtypes", [
6159
+ core.DiscoveryService,
6160
+ core.Reflector
6161
+ ])
6162
+ ], exports.XpertToolProviderRegistry);
6163
+
6164
+ class DecoratedToolsetStrategy {
6165
+ validateConfig() {
6166
+ return Promise.resolve();
6167
+ }
6168
+ async create(toolset, params) {
6169
+ return new DecoratedBuiltinToolset(this.instance, this.descriptor, toolset, params, this.pluginName, this.pluginVersion);
6170
+ }
6171
+ createTools() {
6172
+ return [];
6173
+ }
6174
+ constructor(instance, pluginName, pluginVersion){
6175
+ this.instance = instance;
6176
+ this.pluginName = pluginName;
6177
+ this.pluginVersion = pluginVersion;
6178
+ this.descriptor = describeXpertToolProvider(instance);
6179
+ const options = this.descriptor.options;
6180
+ var _options_author, _options_tags, _options_label, _options_configSchema;
6181
+ this.meta = _extends._extends({
6182
+ author: (_options_author = options.author) != null ? _options_author : 'Plugin',
6183
+ tags: [
6184
+ ...(_options_tags = options.tags) != null ? _options_tags : [
6185
+ 'mcp'
6186
+ ]
6187
+ ],
6188
+ name: options.provider,
6189
+ label: (_options_label = options.label) != null ? _options_label : asI18n(options.name)
6190
+ }, options.description ? {
6191
+ description: asI18n(options.description)
6192
+ } : {}, {
6193
+ configSchema: (_options_configSchema = options.configSchema) != null ? _options_configSchema : {
6194
+ type: 'object',
6195
+ properties: {},
6196
+ required: []
6197
+ }
6198
+ }, options.icon ? {
6199
+ icon: options.icon
6200
+ } : {});
6201
+ }
6202
+ }
6203
+ class DecoratedAgentMiddlewareStrategy {
6204
+ async createMiddleware(options, context) {
6205
+ const tools = this.descriptor.tools.filter((item)=>item.middlewareProvider === this.provider).map((item)=>createAgentTool(this.instance, item, context, options));
6206
+ const extensions = await (this.instance.getMiddlewareExtensions == null ? void 0 : this.instance.getMiddlewareExtensions.call(this.instance, this.provider, options, context));
6207
+ return _extends._extends({}, extensions != null ? extensions : {}, {
6208
+ name: this.provider,
6209
+ tools
6210
+ });
6211
+ }
6212
+ constructor(instance, descriptor, provider){
6213
+ var _descriptor_options_middlewares;
6214
+ this.instance = instance;
6215
+ this.descriptor = descriptor;
6216
+ this.provider = provider;
6217
+ const definition = (_descriptor_options_middlewares = descriptor.options.middlewares) == null ? void 0 : _descriptor_options_middlewares.find((item)=>item.provider === provider);
6218
+ if (!definition) throw new Error(`Middleware provider '${provider}' is not declared.`);
6219
+ this.meta = definition.meta;
6220
+ }
6221
+ }
6222
+ var _definitions = /*#__PURE__*/ _class_private_field_loose_key("_definitions");
6223
+ let DecoratedBuiltinToolset = class DecoratedBuiltinToolset extends modelProvider.BuiltinToolset {
6224
+ _validateCredentials() {
6225
+ return Promise.resolve();
6226
+ }
6227
+ async initTools() {
6228
+ return this.tools;
6229
+ }
6230
+ getMcpCapabilityDefinitions() {
6231
+ return _class_private_field_loose_base(this, _definitions)[_definitions];
6232
+ }
6233
+ getMcpCapabilitySource() {
6234
+ return _extends._extends({}, this.pluginName ? {
6235
+ pluginName: this.pluginName
6236
+ } : {}, this.pluginVersion ? {
6237
+ pluginVersion: this.pluginVersion
6238
+ } : {});
6239
+ }
6240
+ constructor(instance, descriptor, toolset, params, pluginName, pluginVersion){
6241
+ var _descriptor_options_apps;
6242
+ super(descriptor.options.provider, toolset, params);
6243
+ Object.defineProperty(this, _definitions, {
6244
+ writable: true,
6245
+ value: void 0
6246
+ });
6247
+ this.pluginName = pluginName;
6248
+ this.pluginVersion = pluginVersion;
6249
+ this.tools = [];
6250
+ _class_private_field_loose_base(this, _definitions)[_definitions] = _extends._extends({
6251
+ instructions: descriptor.options.instructions,
6252
+ tools: descriptor.tools.filter((item)=>!!item.options.mcp).map((item)=>createMcpTool(instance, item))
6253
+ }, ((_descriptor_options_apps = descriptor.options.apps) == null ? void 0 : _descriptor_options_apps.length) ? {
6254
+ apps: [
6255
+ ...descriptor.options.apps
6256
+ ]
6257
+ } : {});
6258
+ }
6259
+ };
6260
+ function createAgentTool(instance, descriptor, middlewareContext, middlewareOptions) {
6261
+ const invoke = getXpertToolMethod(instance, descriptor);
6262
+ return tools.tool(async (input, config)=>{
6263
+ const parsedInput = await descriptor.options.inputSchema.parseAsync(input);
6264
+ const output = await invoke(parsedInput, agentExecutionContext(middlewareContext, middlewareOptions, config));
6265
+ const parsedOutput = descriptor.options.outputSchema ? await descriptor.options.outputSchema.parseAsync(output) : output;
6266
+ return stringifyDto(parsedOutput, descriptor.options.name);
6267
+ }, _extends._extends({
6268
+ name: descriptor.options.name,
6269
+ description: descriptor.options.description,
6270
+ schema: descriptor.options.inputSchema,
6271
+ verboseParsingErrors: true
6272
+ }, descriptor.options.metadata ? {
6273
+ metadata: descriptor.options.metadata
6274
+ } : {}));
6275
+ }
6276
+ function createMcpTool(instance, descriptor) {
6277
+ const mcp = descriptor.options.mcp;
6278
+ const outputSchema = descriptor.options.outputSchema;
6279
+ if (!mcp || !outputSchema) throw new Error(`MCP Tool '${descriptor.options.name}' is incomplete.`);
6280
+ const invoke = getXpertToolMethod(instance, descriptor);
6281
+ var _mcp_visibility;
6282
+ return _extends._extends({
6283
+ name: descriptor.options.name
6284
+ }, descriptor.options.title ? {
6285
+ title: descriptor.options.title
6286
+ } : {}, {
6287
+ description: descriptor.options.description,
6288
+ inputSchema: descriptor.options.inputSchema,
6289
+ outputSchema,
6290
+ exposure: {
6291
+ mcp: {
6292
+ eligible: true
6293
+ }
6294
+ },
6295
+ behavior: mcp.behavior,
6296
+ requiredContext: [
6297
+ ...mcp.requiredContext
6298
+ ],
6299
+ visibility: [
6300
+ ...(_mcp_visibility = mcp.visibility) != null ? _mcp_visibility : mcp.app ? [
6301
+ 'model',
6302
+ 'app'
6303
+ ] : [
6304
+ 'model'
6305
+ ]
6306
+ ]
6307
+ }, mcp.app ? {
6308
+ app: {
6309
+ resourceKey: mcp.app.resourceKey
6310
+ }
6311
+ } : {}, {
6312
+ execute: async (input, context)=>{
6313
+ const parsedInput = await descriptor.options.inputSchema.parseAsync(input);
6314
+ const output = await invoke(parsedInput, mcpExecutionContext(context));
6315
+ const parsedOutput = await outputSchema.parseAsync(output);
6316
+ const dto = jsonDto(parsedOutput, descriptor.options.name);
6317
+ var _descriptor_options_title;
6318
+ return {
6319
+ content: [
6320
+ {
6321
+ type: 'text',
6322
+ text: `${(_descriptor_options_title = descriptor.options.title) != null ? _descriptor_options_title : descriptor.options.name} completed. See structuredContent for the result.`
6323
+ }
6324
+ ],
6325
+ structuredContent: dto
6326
+ };
6327
+ }
6328
+ });
6329
+ }
6330
+ function agentExecutionContext(context, middlewareOptions, config) {
6331
+ const configurable = config.configurable;
6332
+ const requestId = readString(configurable, 'tool_call_id');
6333
+ const executionId = readString(configurable, 'executionId');
6334
+ const traceId = readString(configurable, 'traceId');
6335
+ return _extends._extends({
6336
+ surface: 'middleware',
6337
+ tenantId: context.tenantId,
6338
+ organizationId: context.organizationId,
6339
+ principal: {
6340
+ type: 'user',
6341
+ id: context.userId,
6342
+ userId: context.userId
6343
+ },
6344
+ workspaceId: context.workspaceId,
6345
+ projectId: context.projectId,
6346
+ conversationId: context.conversationId,
6347
+ threadId: context.threadId,
6348
+ xpertId: context.xpertId,
6349
+ agentKey: context.agentKey
6350
+ }, executionId ? {
6351
+ executionId
6352
+ } : {}, requestId ? {
6353
+ requestId
6354
+ } : {}, traceId ? {
6355
+ traceId
6356
+ } : {}, {
6357
+ signal: config.signal,
6358
+ host: {
6359
+ models: {
6360
+ createModelClient: context.runtime.createModelClient,
6361
+ getModelProvider: context.runtime.getModelProvider
6362
+ }
6363
+ },
6364
+ middlewareOptions
6365
+ });
6366
+ }
6367
+ function mcpExecutionContext(context) {
6368
+ return {
6369
+ surface: 'mcp',
6370
+ tenantId: context.tenantId,
6371
+ organizationId: context.organizationId,
6372
+ principal: context.principal,
6373
+ workspaceId: context.workspaceId,
6374
+ projectId: context.projectId,
6375
+ conversationId: context.conversationId,
6376
+ threadId: readString(context, 'threadId'),
6377
+ xpertId: context.xpertId,
6378
+ agentKey: context.agentKey,
6379
+ executionId: context.executionId,
6380
+ requestId: context.requestId,
6381
+ traceId: context.traceId,
6382
+ signal: context.signal,
6383
+ host: context.host
6384
+ };
6385
+ }
6386
+ function stringifyDto(value, toolName) {
6387
+ const result = JSON.stringify(value);
6388
+ if (result === undefined) throw new Error(`Tool '${toolName}' returned a non-JSON value.`);
6389
+ return result;
6390
+ }
6391
+ function jsonDto(value, toolName) {
6392
+ return JSON.parse(stringifyDto(value, toolName));
6393
+ }
6394
+ function asI18n(value) {
6395
+ return {
6396
+ en_US: value,
6397
+ zh_Hans: value
6398
+ };
6399
+ }
6400
+ function readString(value, key) {
6401
+ if (!value || typeof value !== 'object') return undefined;
6402
+ const field = Reflect.get(value, key);
6403
+ return typeof field === 'string' && field ? field : undefined;
6404
+ }
6405
+
6406
+ /** Expands one decorated business provider into the existing Toolset and Middleware registries. */ exports.XpertToolProviderCoordinator = class XpertToolProviderCoordinator {
6407
+ onModuleInit() {
6408
+ this.subscription = this.bus.events$.subscribe((event)=>{
6409
+ if (event.type === 'UPSERT' && event.strategyType === XPERT_TOOL_PROVIDER) {
6410
+ this.expand(event.entry.instance);
6411
+ }
6412
+ });
6413
+ for (const wrapper of this.discovery.getProviders()){
6414
+ if (wrapper.instance) this.expand(wrapper.instance);
6415
+ }
6416
+ }
6417
+ onModuleDestroy() {
6418
+ var _this_subscription;
6419
+ (_this_subscription = this.subscription) == null ? void 0 : _this_subscription.unsubscribe();
6420
+ }
6421
+ expand(candidate) {
6422
+ if (!candidate || typeof candidate !== 'object' && typeof candidate !== 'function') return;
6423
+ const instance = candidate;
6424
+ if (this.processed.has(instance)) return;
6425
+ const target = resolveStrategyMetadataTarget(instance);
6426
+ if (!target || !Reflect.getMetadata(XPERT_TOOL_PROVIDER_METADATA, target)) return;
6427
+ const provider = instance;
6428
+ const descriptor = describeXpertToolProvider(provider);
6429
+ const source = this.providerRegistry.getSource(provider);
6430
+ const pluginName = source.kind === 'plugin' ? source.pluginName : undefined;
6431
+ const pluginVersion = source.kind === 'plugin' ? source.pluginVersion : undefined;
6432
+ const toolsetAdapter = new DecoratedToolsetStrategy(provider, pluginName, pluginVersion);
6433
+ var _descriptor_options_middlewares;
6434
+ const middlewareAdapters = ((_descriptor_options_middlewares = descriptor.options.middlewares) != null ? _descriptor_options_middlewares : []).filter((definition)=>descriptor.tools.some((item)=>item.middlewareProvider === definition.provider)).map((definition)=>({
6435
+ provider: definition.provider,
6436
+ strategy: new DecoratedAgentMiddlewareStrategy(provider, descriptor, definition.provider)
6437
+ }));
6438
+ try {
6439
+ this.toolsetRegistry.assertCanRegister(descriptor.options.provider, toolsetAdapter, source);
6440
+ for (const adapter of middlewareAdapters){
6441
+ this.middlewareRegistry.assertCanRegister(adapter.provider, adapter.strategy, source);
6442
+ }
6443
+ } catch (error) {
6444
+ this.providerRegistry.rollback(provider);
6445
+ throw error;
6446
+ }
6447
+ this.toolsetRegistry.register(descriptor.options.provider, toolsetAdapter, source);
6448
+ for (const adapter of middlewareAdapters){
6449
+ this.middlewareRegistry.register(adapter.provider, adapter.strategy, source);
6450
+ }
6451
+ this.processed.add(instance);
6452
+ }
6453
+ constructor(discovery, bus, providerRegistry, toolsetRegistry, middlewareRegistry){
6454
+ this.processed = new WeakSet();
6455
+ this.discovery = discovery;
6456
+ this.bus = bus;
6457
+ this.providerRegistry = providerRegistry;
6458
+ this.toolsetRegistry = toolsetRegistry;
6459
+ this.middlewareRegistry = middlewareRegistry;
6460
+ }
6461
+ };
6462
+ exports.XpertToolProviderCoordinator = __decorate([
6463
+ common.Injectable(),
6464
+ __metadata("design:paramtypes", [
6465
+ core.DiscoveryService,
6466
+ exports.StrategyBus,
6467
+ exports.XpertToolProviderRegistry,
6468
+ exports.ToolsetRegistry,
6469
+ exports.AgentMiddlewareRegistry
6470
+ ])
6471
+ ], exports.XpertToolProviderCoordinator);
6472
+
5852
6473
  Object.defineProperty(exports, "ASSISTANT_CHAT_SEND_MESSAGE_COMMAND", {
5853
6474
  enumerable: true,
5854
6475
  get: function () { return contracts.ASSISTANT_CHAT_SEND_MESSAGE_COMMAND; }
@@ -5940,6 +6561,8 @@ exports.DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC = DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC;
5940
6561
  exports.DOCUMENT_SOURCE_STRATEGY = DOCUMENT_SOURCE_STRATEGY;
5941
6562
  exports.DOCUMENT_TRANSFORMER_STRATEGY = DOCUMENT_TRANSFORMER_STRATEGY;
5942
6563
  exports.DataSourceStrategy = DataSourceStrategy;
6564
+ exports.DecoratedAgentMiddlewareStrategy = DecoratedAgentMiddlewareStrategy;
6565
+ exports.DecoratedToolsetStrategy = DecoratedToolsetStrategy;
5943
6566
  exports.DocumentSourceStrategy = DocumentSourceStrategy;
5944
6567
  exports.DocumentTransformerStrategy = DocumentTransformerStrategy;
5945
6568
  exports.EVOLUTION_RUNTIME_SERVICE_TOKEN = EVOLUTION_RUNTIME_SERVICE_TOKEN;
@@ -6039,8 +6662,13 @@ exports.WorkflowNodeStrategy = WorkflowNodeStrategy;
6039
6662
  exports.WorkflowTriggerStrategy = WorkflowTriggerStrategy;
6040
6663
  exports.WrapWorkflowNodeExecutionCommand = WrapWorkflowNodeExecutionCommand;
6041
6664
  exports.XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN = XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN;
6665
+ exports.XPERT_TOOL_METHOD_METADATA = XPERT_TOOL_METHOD_METADATA;
6666
+ exports.XPERT_TOOL_PROVIDER = XPERT_TOOL_PROVIDER;
6667
+ exports.XPERT_TOOL_PROVIDER_METADATA = XPERT_TOOL_PROVIDER_METADATA;
6042
6668
  exports.XpFileSystem = XpFileSystem;
6043
6669
  exports.XpertServerPlugin = XpertServerPlugin;
6670
+ exports.XpertTool = XpertTool;
6671
+ exports.XpertToolProvider = XpertToolProvider;
6044
6672
  exports.als = als;
6045
6673
  exports.appendSandboxMessage = appendSandboxMessage;
6046
6674
  exports.buildSandboxTimeoutMessage = buildSandboxTimeoutMessage;
@@ -6061,6 +6689,7 @@ exports.defineMcpResource = defineMcpResource;
6061
6689
  exports.defineMcpResourceTemplate = defineMcpResourceTemplate;
6062
6690
  exports.defineXpertTool = defineXpertTool;
6063
6691
  exports.derivePluginArtifactNamespace = derivePluginArtifactNamespace;
6692
+ exports.describeXpertToolProvider = describeXpertToolProvider;
6064
6693
  exports.downloadRemoteFile = downloadRemoteFile;
6065
6694
  exports.formatSandboxTimeout = formatSandboxTimeout;
6066
6695
  exports.getDefaultTenantId = getDefaultTenantId;
@@ -6072,6 +6701,7 @@ exports.getPositionMap = getPositionMap;
6072
6701
  exports.getRequestContext = getRequestContext;
6073
6702
  exports.getRequiredPermissionOperation = getRequiredPermissionOperation;
6074
6703
  exports.getTenantGlobalScopeKey = getTenantGlobalScopeKey;
6704
+ exports.getXpertToolMethod = getXpertToolMethod;
6075
6705
  exports.isDevelopmentSandboxRuntimeEnvironment = isDevelopmentSandboxRuntimeEnvironment;
6076
6706
  exports.isModelOutputValidationError = isModelOutputValidationError;
6077
6707
  exports.isModelUsagePricingConfig = isModelUsagePricingConfig;