@xpert-ai/plugin-sdk 3.12.2 → 3.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @xpert-ai/plugin-sdk
2
2
 
3
+ ## 3.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 54cff15: tenants and managed connections
8
+ - 6978bfd: release plugin tenant scope
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [54cff15]
13
+ - Updated dependencies [6978bfd]
14
+ - @xpert-ai/contracts@3.14.0
15
+
3
16
  ## 3.12.2
4
17
 
5
18
  ### Patch Changes
package/index.cjs.js CHANGED
@@ -91,7 +91,35 @@ var _axios__namespace = /*#__PURE__*/_interopNamespaceDefault(_axios);
91
91
  const ORGANIZATION_METADATA_KEY = 'xpert:organizationId';
92
92
  const PLUGIN_METADATA_KEY = 'xpert:pluginName';
93
93
  const GLOBAL_ORGANIZATION_SCOPE = 'global';
94
+ const TENANT_GLOBAL_SCOPE_PREFIX = 'tenant:';
95
+ const TENANT_GLOBAL_SCOPE_SUFFIX = ':global';
94
96
  const STRATEGY_META_KEY = 'XPERT_STRATEGY_META_KEY';
97
+ let defaultTenantId = null;
98
+ function normalizeOptionalString(value) {
99
+ return typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;
100
+ }
101
+ function getTenantGlobalScopeKey(tenantId) {
102
+ return `${TENANT_GLOBAL_SCOPE_PREFIX}${tenantId}${TENANT_GLOBAL_SCOPE_SUFFIX}`;
103
+ }
104
+ function isTenantGlobalScopeKey(value) {
105
+ return typeof value === 'string' && value.startsWith(TENANT_GLOBAL_SCOPE_PREFIX) && value.endsWith(TENANT_GLOBAL_SCOPE_SUFFIX);
106
+ }
107
+ function setDefaultTenantId(tenantId) {
108
+ defaultTenantId = normalizeOptionalString(tenantId);
109
+ }
110
+ function getDefaultTenantId() {
111
+ return defaultTenantId;
112
+ }
113
+ function resolveTenantGlobalScopeKey(tenantId) {
114
+ const normalizedTenantId = normalizeOptionalString(tenantId);
115
+ if (!normalizedTenantId) {
116
+ return GLOBAL_ORGANIZATION_SCOPE;
117
+ }
118
+ if (defaultTenantId && normalizedTenantId !== defaultTenantId) {
119
+ return getTenantGlobalScopeKey(normalizedTenantId);
120
+ }
121
+ return GLOBAL_ORGANIZATION_SCOPE;
122
+ }
95
123
 
96
124
  function _extends() {
97
125
  _extends = Object.assign || function assign(target) {
@@ -513,8 +541,17 @@ class BaseStrategyRegistry {
513
541
  /**
514
542
  * Resolve organization id, falling back to request context org or global scope.
515
543
  */ resolveOrganization(organizationId) {
516
- var _ref;
517
- return (_ref = organizationId != null ? organizationId : RequestContext.getOrganizationId()) != null ? _ref : GLOBAL_ORGANIZATION_SCOPE;
544
+ var _RequestContext_getScope;
545
+ var _RequestContext_getScope_tenantId;
546
+ const tenantId = (_RequestContext_getScope_tenantId = (_RequestContext_getScope = RequestContext.getScope()) == null ? void 0 : _RequestContext_getScope.tenantId) != null ? _RequestContext_getScope_tenantId : RequestContext.currentTenantId();
547
+ const requested = organizationId != null ? organizationId : RequestContext.getOrganizationId();
548
+ return !requested || requested === GLOBAL_ORGANIZATION_SCOPE ? resolveTenantGlobalScopeKey(tenantId) : requested;
549
+ }
550
+ resolveGlobalFallbackOrganization() {
551
+ var _RequestContext_getScope;
552
+ var _RequestContext_getScope_tenantId;
553
+ const tenantId = (_RequestContext_getScope_tenantId = (_RequestContext_getScope = RequestContext.getScope()) == null ? void 0 : _RequestContext_getScope.tenantId) != null ? _RequestContext_getScope_tenantId : RequestContext.currentTenantId();
554
+ return resolveTenantGlobalScopeKey(tenantId);
518
555
  }
519
556
  /**
520
557
  * Get strategy by type from the given organization including global strategies as fallback.
@@ -526,8 +563,9 @@ class BaseStrategyRegistry {
526
563
  var _this_strategies_get, _this_strategies_get1;
527
564
  organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
528
565
  const orgKey = this.resolveOrganization(organizationId);
566
+ const globalKey = this.resolveGlobalFallbackOrganization();
529
567
  var _this_strategies_get_get;
530
- const strategy = (_this_strategies_get_get = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.get(type)) != null ? _this_strategies_get_get : orgKey === GLOBAL_ORGANIZATION_SCOPE ? undefined : (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.get(type);
568
+ const strategy = (_this_strategies_get_get = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.get(type)) != null ? _this_strategies_get_get : orgKey === globalKey ? undefined : (_this_strategies_get1 = this.strategies.get(globalKey)) == null ? void 0 : _this_strategies_get1.get(type);
531
569
  if (!strategy) {
532
570
  throw new Error(`No strategy found for type '${type}' for strategy '${this.strategyKey}'`);
533
571
  }
@@ -542,15 +580,16 @@ class BaseStrategyRegistry {
542
580
  var _this_strategies_get;
543
581
  organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
544
582
  const orgKey = this.resolveOrganization(organizationId);
583
+ const globalKey = this.resolveGlobalFallbackOrganization();
545
584
  const effective = new Map();
546
585
  var _this_strategies_get_entries;
547
586
  for (const [type, strategy] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
548
587
  effective.set(type, strategy);
549
588
  }
550
- if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
589
+ if (orgKey !== globalKey) {
551
590
  var _this_strategies_get1;
552
591
  var _this_strategies_get_entries1;
553
- for (const [type, strategy] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
592
+ for (const [type, strategy] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(globalKey)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
554
593
  if (!effective.has(type)) {
555
594
  effective.set(type, strategy);
556
595
  }
@@ -2756,9 +2795,9 @@ exports.AgentMiddlewareRegistry = __decorate([
2756
2795
  /**
2757
2796
  * jump targets (user facing)
2758
2797
  */ const JUMP_TO_TARGETS = [
2759
- "model",
2760
- "tools",
2761
- "end"
2798
+ 'model',
2799
+ 'tools',
2800
+ 'end'
2762
2801
  ];
2763
2802
 
2764
2803
  const AssistantTaskRuntimeCapability = createRuntimeCapability('platform.assistant_task', {
@@ -4066,6 +4105,9 @@ function resolveSandboxTerminalAdapter(sandbox) {
4066
4105
  return isSandboxTerminalAdapter(candidate) ? candidate : null;
4067
4106
  }
4068
4107
 
4108
+ const MANAGED_CONNECTION_REGISTRY_TOKEN = 'XPERT_MANAGED_CONNECTION_REGISTRY';
4109
+ const CONNECTION_COMMAND_ROUTER_TOKEN = 'XPERT_CONNECTION_COMMAND_ROUTER';
4110
+
4069
4111
  const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
4070
4112
  const ViewExtensionProvider = (providerKey)=>common.applyDecorators(common.SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), common.SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
4071
4113
 
@@ -4073,15 +4115,16 @@ exports.ViewExtensionProviderRegistry = class ViewExtensionProviderRegistry exte
4073
4115
  listEntries(organizationId) {
4074
4116
  var _this_strategies_get;
4075
4117
  const orgKey = this.resolveOrganization(organizationId);
4118
+ const globalKey = this.resolveGlobalFallbackOrganization();
4076
4119
  const entries = new Map();
4077
4120
  var _this_strategies_get_entries;
4078
4121
  for (const [providerKey, provider] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
4079
4122
  entries.set(providerKey, provider);
4080
4123
  }
4081
- if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
4124
+ if (orgKey !== globalKey) {
4082
4125
  var _this_strategies_get1;
4083
4126
  var _this_strategies_get_entries1;
4084
- for (const [providerKey, provider] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
4127
+ for (const [providerKey, provider] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(globalKey)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
4085
4128
  if (!entries.has(providerKey)) {
4086
4129
  entries.set(providerKey, provider);
4087
4130
  }
@@ -4550,6 +4593,7 @@ exports.BaseToolset = BaseToolset;
4550
4593
  exports.BuiltinToolset = BuiltinToolset;
4551
4594
  exports.CHAT_CHANNEL = CHAT_CHANNEL;
4552
4595
  exports.CHAT_CHANNEL_TEXT_LIMITS = CHAT_CHANNEL_TEXT_LIMITS;
4596
+ exports.CONNECTION_COMMAND_ROUTER_TOKEN = CONNECTION_COMMAND_ROUTER_TOKEN;
4553
4597
  exports.CancelConversationCommand = CancelConversationCommand;
4554
4598
  exports.ChatChannel = ChatChannel;
4555
4599
  exports.ChatOAICompatReasoningModel = ChatOAICompatReasoningModel;
@@ -4598,6 +4642,7 @@ exports.KnowledgebaseDocumentsRuntimeCapability = KnowledgebaseDocumentsRuntimeC
4598
4642
  exports.KnowledgebaseRuntimeCapability = KnowledgebaseRuntimeCapability;
4599
4643
  exports.LLMUsage = LLMUsage;
4600
4644
  exports.LargeLanguageModel = LargeLanguageModel;
4645
+ exports.MANAGED_CONNECTION_REGISTRY_TOKEN = MANAGED_CONNECTION_REGISTRY_TOKEN;
4601
4646
  exports.ORGANIZATION_METADATA_KEY = ORGANIZATION_METADATA_KEY;
4602
4647
  exports.OpenAICompatibleReranker = OpenAICompatibleReranker;
4603
4648
  exports.PERMISSION_OPERATION_METADATA_KEY = PERMISSION_OPERATION_METADATA_KEY;
@@ -4631,6 +4676,8 @@ exports.SandboxProviderStrategy = SandboxProviderStrategy;
4631
4676
  exports.SkillSourceProviderStrategy = SkillSourceProviderStrategy;
4632
4677
  exports.Speech2TextChatModel = Speech2TextChatModel;
4633
4678
  exports.SpeechToTextModel = SpeechToTextModel;
4679
+ exports.TENANT_GLOBAL_SCOPE_PREFIX = TENANT_GLOBAL_SCOPE_PREFIX;
4680
+ exports.TENANT_GLOBAL_SCOPE_SUFFIX = TENANT_GLOBAL_SCOPE_SUFFIX;
4634
4681
  exports.TEXT_SPLITTER_STRATEGY = TEXT_SPLITTER_STRATEGY;
4635
4682
  exports.TOOLSET_STRATEGY = TOOLSET_STRATEGY;
4636
4683
  exports.TextEmbeddingModelManager = TextEmbeddingModelManager;
@@ -4665,6 +4712,7 @@ exports.defineAgentMessageType = defineAgentMessageType;
4665
4712
  exports.defineChannelMessageType = defineChannelMessageType;
4666
4713
  exports.downloadRemoteFile = downloadRemoteFile;
4667
4714
  exports.formatSandboxTimeout = formatSandboxTimeout;
4715
+ exports.getDefaultTenantId = getDefaultTenantId;
4668
4716
  exports.getErrorMessage = getErrorMessage;
4669
4717
  exports.getModelContextSize = getModelContextSize;
4670
4718
  exports.getPermissionOperationMetadata = getPermissionOperationMetadata;
@@ -4672,12 +4720,14 @@ exports.getPositionList = getPositionList;
4672
4720
  exports.getPositionMap = getPositionMap;
4673
4721
  exports.getRequestContext = getRequestContext;
4674
4722
  exports.getRequiredPermissionOperation = getRequiredPermissionOperation;
4723
+ exports.getTenantGlobalScopeKey = getTenantGlobalScopeKey;
4675
4724
  exports.isRemoteFile = isRemoteFile;
4676
4725
  exports.isSandboxBackend = isSandboxBackend;
4677
4726
  exports.isSandboxManagedServiceAdapter = isSandboxManagedServiceAdapter;
4678
4727
  exports.isSandboxServiceProxyAdapter = isSandboxServiceProxyAdapter;
4679
4728
  exports.isSandboxTerminalAdapter = isSandboxTerminalAdapter;
4680
4729
  exports.isStructuredMessageType = isStructuredMessageType;
4730
+ exports.isTenantGlobalScopeKey = isTenantGlobalScopeKey;
4681
4731
  exports.loadYamlFile = loadYamlFile;
4682
4732
  exports.mergeCredentials = mergeCredentials;
4683
4733
  exports.mergeParentChildChunks = mergeParentChildChunks;
@@ -4688,6 +4738,8 @@ exports.resolveSandboxExecutionOptions = resolveSandboxExecutionOptions;
4688
4738
  exports.resolveSandboxManagedServiceAdapter = resolveSandboxManagedServiceAdapter;
4689
4739
  exports.resolveSandboxServiceProxyAdapter = resolveSandboxServiceProxyAdapter;
4690
4740
  exports.resolveSandboxTerminalAdapter = resolveSandboxTerminalAdapter;
4741
+ exports.resolveTenantGlobalScopeKey = resolveTenantGlobalScopeKey;
4691
4742
  exports.runWithRequestContext = runWithRequestContext;
4692
4743
  exports.secondsToMilliseconds = secondsToMilliseconds;
4744
+ exports.setDefaultTenantId = setDefaultTenantId;
4693
4745
  exports.sumTokenUsage = sumTokenUsage;
package/index.esm.js CHANGED
@@ -71,7 +71,35 @@ import { getModelContextSize as getModelContextSize$1 } from '@langchain/core/la
71
71
  const ORGANIZATION_METADATA_KEY = 'xpert:organizationId';
72
72
  const PLUGIN_METADATA_KEY = 'xpert:pluginName';
73
73
  const GLOBAL_ORGANIZATION_SCOPE = 'global';
74
+ const TENANT_GLOBAL_SCOPE_PREFIX = 'tenant:';
75
+ const TENANT_GLOBAL_SCOPE_SUFFIX = ':global';
74
76
  const STRATEGY_META_KEY = 'XPERT_STRATEGY_META_KEY';
77
+ let defaultTenantId = null;
78
+ function normalizeOptionalString(value) {
79
+ return typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;
80
+ }
81
+ function getTenantGlobalScopeKey(tenantId) {
82
+ return `${TENANT_GLOBAL_SCOPE_PREFIX}${tenantId}${TENANT_GLOBAL_SCOPE_SUFFIX}`;
83
+ }
84
+ function isTenantGlobalScopeKey(value) {
85
+ return typeof value === 'string' && value.startsWith(TENANT_GLOBAL_SCOPE_PREFIX) && value.endsWith(TENANT_GLOBAL_SCOPE_SUFFIX);
86
+ }
87
+ function setDefaultTenantId(tenantId) {
88
+ defaultTenantId = normalizeOptionalString(tenantId);
89
+ }
90
+ function getDefaultTenantId() {
91
+ return defaultTenantId;
92
+ }
93
+ function resolveTenantGlobalScopeKey(tenantId) {
94
+ const normalizedTenantId = normalizeOptionalString(tenantId);
95
+ if (!normalizedTenantId) {
96
+ return GLOBAL_ORGANIZATION_SCOPE;
97
+ }
98
+ if (defaultTenantId && normalizedTenantId !== defaultTenantId) {
99
+ return getTenantGlobalScopeKey(normalizedTenantId);
100
+ }
101
+ return GLOBAL_ORGANIZATION_SCOPE;
102
+ }
75
103
 
76
104
  function _extends() {
77
105
  _extends = Object.assign || function assign(target) {
@@ -493,8 +521,17 @@ class BaseStrategyRegistry {
493
521
  /**
494
522
  * Resolve organization id, falling back to request context org or global scope.
495
523
  */ resolveOrganization(organizationId) {
496
- var _ref;
497
- return (_ref = organizationId != null ? organizationId : RequestContext.getOrganizationId()) != null ? _ref : GLOBAL_ORGANIZATION_SCOPE;
524
+ var _RequestContext_getScope;
525
+ var _RequestContext_getScope_tenantId;
526
+ const tenantId = (_RequestContext_getScope_tenantId = (_RequestContext_getScope = RequestContext.getScope()) == null ? void 0 : _RequestContext_getScope.tenantId) != null ? _RequestContext_getScope_tenantId : RequestContext.currentTenantId();
527
+ const requested = organizationId != null ? organizationId : RequestContext.getOrganizationId();
528
+ return !requested || requested === GLOBAL_ORGANIZATION_SCOPE ? resolveTenantGlobalScopeKey(tenantId) : requested;
529
+ }
530
+ resolveGlobalFallbackOrganization() {
531
+ var _RequestContext_getScope;
532
+ var _RequestContext_getScope_tenantId;
533
+ const tenantId = (_RequestContext_getScope_tenantId = (_RequestContext_getScope = RequestContext.getScope()) == null ? void 0 : _RequestContext_getScope.tenantId) != null ? _RequestContext_getScope_tenantId : RequestContext.currentTenantId();
534
+ return resolveTenantGlobalScopeKey(tenantId);
498
535
  }
499
536
  /**
500
537
  * Get strategy by type from the given organization including global strategies as fallback.
@@ -506,8 +543,9 @@ class BaseStrategyRegistry {
506
543
  var _this_strategies_get, _this_strategies_get1;
507
544
  organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
508
545
  const orgKey = this.resolveOrganization(organizationId);
546
+ const globalKey = this.resolveGlobalFallbackOrganization();
509
547
  var _this_strategies_get_get;
510
- const strategy = (_this_strategies_get_get = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.get(type)) != null ? _this_strategies_get_get : orgKey === GLOBAL_ORGANIZATION_SCOPE ? undefined : (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.get(type);
548
+ const strategy = (_this_strategies_get_get = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.get(type)) != null ? _this_strategies_get_get : orgKey === globalKey ? undefined : (_this_strategies_get1 = this.strategies.get(globalKey)) == null ? void 0 : _this_strategies_get1.get(type);
511
549
  if (!strategy) {
512
550
  throw new Error(`No strategy found for type '${type}' for strategy '${this.strategyKey}'`);
513
551
  }
@@ -522,15 +560,16 @@ class BaseStrategyRegistry {
522
560
  var _this_strategies_get;
523
561
  organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
524
562
  const orgKey = this.resolveOrganization(organizationId);
563
+ const globalKey = this.resolveGlobalFallbackOrganization();
525
564
  const effective = new Map();
526
565
  var _this_strategies_get_entries;
527
566
  for (const [type, strategy] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
528
567
  effective.set(type, strategy);
529
568
  }
530
- if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
569
+ if (orgKey !== globalKey) {
531
570
  var _this_strategies_get1;
532
571
  var _this_strategies_get_entries1;
533
- for (const [type, strategy] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
572
+ for (const [type, strategy] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(globalKey)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
534
573
  if (!effective.has(type)) {
535
574
  effective.set(type, strategy);
536
575
  }
@@ -2736,9 +2775,9 @@ AgentMiddlewareRegistry = __decorate([
2736
2775
  /**
2737
2776
  * jump targets (user facing)
2738
2777
  */ const JUMP_TO_TARGETS = [
2739
- "model",
2740
- "tools",
2741
- "end"
2778
+ 'model',
2779
+ 'tools',
2780
+ 'end'
2742
2781
  ];
2743
2782
 
2744
2783
  const AssistantTaskRuntimeCapability = createRuntimeCapability('platform.assistant_task', {
@@ -4046,6 +4085,9 @@ function resolveSandboxTerminalAdapter(sandbox) {
4046
4085
  return isSandboxTerminalAdapter(candidate) ? candidate : null;
4047
4086
  }
4048
4087
 
4088
+ const MANAGED_CONNECTION_REGISTRY_TOKEN = 'XPERT_MANAGED_CONNECTION_REGISTRY';
4089
+ const CONNECTION_COMMAND_ROUTER_TOKEN = 'XPERT_CONNECTION_COMMAND_ROUTER';
4090
+
4049
4091
  const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
4050
4092
  const ViewExtensionProvider = (providerKey)=>applyDecorators(SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
4051
4093
 
@@ -4053,15 +4095,16 @@ let ViewExtensionProviderRegistry = class ViewExtensionProviderRegistry extends
4053
4095
  listEntries(organizationId) {
4054
4096
  var _this_strategies_get;
4055
4097
  const orgKey = this.resolveOrganization(organizationId);
4098
+ const globalKey = this.resolveGlobalFallbackOrganization();
4056
4099
  const entries = new Map();
4057
4100
  var _this_strategies_get_entries;
4058
4101
  for (const [providerKey, provider] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
4059
4102
  entries.set(providerKey, provider);
4060
4103
  }
4061
- if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
4104
+ if (orgKey !== globalKey) {
4062
4105
  var _this_strategies_get1;
4063
4106
  var _this_strategies_get_entries1;
4064
- for (const [providerKey, provider] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
4107
+ for (const [providerKey, provider] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(globalKey)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
4065
4108
  if (!entries.has(providerKey)) {
4066
4109
  entries.set(providerKey, provider);
4067
4110
  }
@@ -4500,4 +4543,4 @@ function escapeHtmlAttribute(value) {
4500
4543
 
4501
4544
  const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
4502
4545
 
4503
- export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PERMISSION_SERVICE_TOKEN, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BaseTool, BaseToolset, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CommonParameterRules, CreateModelClientCommand, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DEFAULT_EXECUTION_CONFIG, DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC, DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS, DEFAULT_SANDBOX_SHELL_TIMEOUT_MS, DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DefaultRuntimeCapabilityRegistry as DefaultAgentMiddlewareRuntimeCapabilityRegistry, DefaultRuntimeCapabilityRegistry, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseRuntimeCapability, LLMUsage, LargeLanguageModel, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, PluginWebhookAuth, PluginWebhookAuthGuard, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SKILL_SOURCE_PROVIDER, SPEECH_TO_TEXT_PERMISSION_SERVICE_TOKEN, SPEECH_TO_TEXT_SERVICE_TOKEN, SSOProviderRegistry, SSOProviderStrategyKey, SSO_BINDING_PERMISSION_SERVICE_TOKEN, SSO_PROVIDER, STRATEGY_META_KEY, SandboxProviderRegistry, SandboxProviderStrategy, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_RUNTIME_CAPABILITIES_TOKEN, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, buildSandboxTimeoutMessage, calcTokenUsage, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, downloadRemoteFile, formatSandboxTimeout, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStructuredMessageType, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, renderRemoteReactIframeHtml, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, runWithRequestContext, secondsToMilliseconds, sumTokenUsage };
4546
+ export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PERMISSION_SERVICE_TOKEN, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BaseTool, BaseToolset, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, CONNECTION_COMMAND_ROUTER_TOKEN, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CommonParameterRules, CreateModelClientCommand, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DEFAULT_EXECUTION_CONFIG, DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC, DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS, DEFAULT_SANDBOX_SHELL_TIMEOUT_MS, DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DefaultRuntimeCapabilityRegistry as DefaultAgentMiddlewareRuntimeCapabilityRegistry, DefaultRuntimeCapabilityRegistry, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseRuntimeCapability, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, PluginWebhookAuth, PluginWebhookAuthGuard, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SKILL_SOURCE_PROVIDER, SPEECH_TO_TEXT_PERMISSION_SERVICE_TOKEN, SPEECH_TO_TEXT_SERVICE_TOKEN, SSOProviderRegistry, SSOProviderStrategyKey, SSO_BINDING_PERMISSION_SERVICE_TOKEN, SSO_PROVIDER, STRATEGY_META_KEY, SandboxProviderRegistry, SandboxProviderStrategy, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TENANT_GLOBAL_SCOPE_PREFIX, TENANT_GLOBAL_SCOPE_SUFFIX, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_RUNTIME_CAPABILITIES_TOKEN, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, buildSandboxTimeoutMessage, calcTokenUsage, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, renderRemoteReactIframeHtml, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveTenantGlobalScopeKey, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.12.2",
3
+ "version": "3.13.0",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,6 +16,7 @@
16
16
  "directory": "dist"
17
17
  },
18
18
  "dependencies": {
19
+ "@langchain/openai": "0.6.9",
19
20
  "@xpert-ai/contracts": "workspace:*",
20
21
  "js-tiktoken": "^1.0.21"
21
22
  },
package/src/index.d.ts CHANGED
@@ -18,4 +18,5 @@ export * from './lib/file/index';
18
18
  export * from './lib/strategy';
19
19
  export * from './lib/sso/index';
20
20
  export * from './lib/sandbox/index';
21
+ export * from './lib/managed-connection/index';
21
22
  export * from './lib/view-extension/index';
@@ -1,4 +1,4 @@
1
- import { TChatOptions, TChatRequest } from '@xpert-ai/contracts';
1
+ import { TChatOptions, TChatRequest, TChatRuntimePrincipal, TChatSourceAuditOptions } from '@xpert-ai/contracts';
2
2
  export declare const AGENT_CHAT_DISPATCH_MESSAGE_TYPE: import("./message-type").StructuredHandoffMessageType;
3
3
  export interface AgentChatHandoffMessageCallbackTarget {
4
4
  transport?: 'handoff-message';
@@ -11,13 +11,15 @@ export interface AgentChatRedisPubSubCallbackTarget {
11
11
  context?: Record<string, unknown>;
12
12
  }
13
13
  export type AgentChatCallbackTarget = AgentChatHandoffMessageCallbackTarget | AgentChatRedisPubSubCallbackTarget;
14
+ export type AgentChatRuntimePrincipal = TChatRuntimePrincipal;
14
15
  export interface AgentChatDispatchPayload extends Record<string, unknown> {
15
16
  request: TChatRequest;
16
- options: TChatOptions & {
17
+ options: TChatOptions & TChatSourceAuditOptions & {
17
18
  xpertId?: string;
18
19
  isDraft?: boolean;
19
20
  from?: string;
20
21
  fromEndUserId?: string;
22
+ runtimePrincipal?: AgentChatRuntimePrincipal;
21
23
  execution?: {
22
24
  id: string;
23
25
  };
@@ -1,15 +1,18 @@
1
1
  import { LanguageModelLike } from '@langchain/core/language_models/base';
2
2
  import { AIMessage, BaseMessage, SystemMessage } from '@langchain/core/messages';
3
3
  import { DynamicStructuredTool, DynamicTool, StructuredToolInterface } from '@langchain/core/tools';
4
- import type { ToolCall, ToolMessage } from "@langchain/core/messages/tool";
4
+ import type { ToolCall, ToolMessage } from '@langchain/core/messages/tool';
5
5
  import { InferInteropZodOutput, InteropZodObject } from '@langchain/core/utils/types';
6
6
  import { RunnableToolLike } from '@langchain/core/runnables';
7
7
  import { Command } from '@langchain/langgraph';
8
+ import type { JsonSchemaObjectType } from '@xpert-ai/contracts';
8
9
  import { AgentBuiltInState, Runtime } from './runtime';
9
10
  import { PromiseOrValue } from '../../types';
10
11
  export type ServerTool = Record<string, unknown>;
11
12
  export type ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;
12
- export type NormalizedSchemaInput<TSchema extends InteropZodObject | undefined | never = any> = [TSchema] extends [never] ? AgentBuiltInState : TSchema extends InteropZodObject ? InferInteropZodOutput<TSchema> & AgentBuiltInState : TSchema extends Record<string, unknown> ? TSchema & AgentBuiltInState : AgentBuiltInState;
13
+ export type NormalizedSchemaInput<TSchema extends InteropZodObject | undefined | never = any> = [TSchema] extends [
14
+ never
15
+ ] ? AgentBuiltInState : TSchema extends InteropZodObject ? InferInteropZodOutput<TSchema> & AgentBuiltInState : TSchema extends Record<string, unknown> ? TSchema & AgentBuiltInState : AgentBuiltInState;
13
16
  type NormalizeContextSchema<TContextSchema extends InteropZodObject | undefined = undefined> = TContextSchema extends InteropZodObject ? InferInteropZodOutput<TContextSchema> : never;
14
17
  /**
15
18
  * jump targets (user facing)
@@ -120,8 +123,8 @@ export interface ModelRequest<TState extends Record<string, unknown> = Record<st
120
123
  * - `"required"`: means the model must call one or more tools.
121
124
  * - `{ type: "function", function: { name: string } }`: The model will use the specified function.
122
125
  */
123
- toolChoice?: "auto" | "none" | "required" | {
124
- type: "function";
126
+ toolChoice?: 'auto' | 'none' | 'required' | {
127
+ type: 'function';
125
128
  function: {
126
129
  name: string;
127
130
  };
@@ -207,6 +210,12 @@ export interface AgentMiddleware<TSchema extends InteropZodObject | undefined =
207
210
  * - Undefined
208
211
  */
209
212
  stateSchema?: TSchema;
213
+ /**
214
+ * Optional JSON schema used by host form renderers for middleware state.
215
+ * Keep runtime validation and state typing in `stateSchema`; use this field
216
+ * only for form/UI metadata such as i18n labels and x-ui extensions.
217
+ */
218
+ stateFormSchema?: JsonSchemaObjectType;
210
219
  /**
211
220
  * The schema of the middleware context. Middleware context is read-only and not persisted between multiple invocations. It can be either:
212
221
  * - A Zod object
@@ -0,0 +1,98 @@
1
+ export declare const MANAGED_CONNECTION_REGISTRY_TOKEN = "XPERT_MANAGED_CONNECTION_REGISTRY";
2
+ export declare const CONNECTION_COMMAND_ROUTER_TOKEN = "XPERT_CONNECTION_COMMAND_ROUTER";
3
+ export type ManagedConnectionTransportType = 'websocket' | 'socket_io' | 'sse' | 'tcp_tunnel' | 'worker' | 'custom';
4
+ export type ManagedConnectionStatus = 'connected' | 'disconnected' | 'stale' | 'error';
5
+ export type ManagedConnectionDirection = 'inbound' | 'outbound' | 'internal';
6
+ export type ManagedConnectionRecord = {
7
+ id?: string;
8
+ pluginName: string;
9
+ connectionType: string;
10
+ connectionKey: string;
11
+ transportType: ManagedConnectionTransportType;
12
+ direction: ManagedConnectionDirection;
13
+ ownerInstanceId: string;
14
+ status: ManagedConnectionStatus;
15
+ connectedAt?: Date | string | null;
16
+ lastSeenAt?: Date | string | null;
17
+ leaseExpiresAt?: Date | string | null;
18
+ disconnectedAt?: Date | string | null;
19
+ remoteAddress?: string | null;
20
+ metadata?: Record<string, unknown> | null;
21
+ lastError?: string | null;
22
+ tenantId?: string | null;
23
+ organizationId?: string | null;
24
+ };
25
+ export type RegisterManagedConnectionInput = {
26
+ pluginName: string;
27
+ connectionType: string;
28
+ connectionKey: string;
29
+ transportType: ManagedConnectionTransportType;
30
+ direction?: ManagedConnectionDirection;
31
+ tenantId?: string | null;
32
+ organizationId?: string | null;
33
+ remoteAddress?: string | null;
34
+ metadata?: Record<string, unknown>;
35
+ leaseTtlMs?: number;
36
+ };
37
+ export type ManagedConnectionKeyInput = {
38
+ pluginName?: string;
39
+ connectionType: string;
40
+ connectionKey: string;
41
+ tenantId?: string | null;
42
+ organizationId?: string | null;
43
+ };
44
+ export type ManagedConnectionHeartbeatInput = ManagedConnectionKeyInput & {
45
+ remoteAddress?: string | null;
46
+ metadata?: Record<string, unknown>;
47
+ leaseTtlMs?: number;
48
+ };
49
+ export type ManagedConnectionMetadataInput = ManagedConnectionKeyInput & {
50
+ metadata?: Record<string, unknown>;
51
+ merge?: boolean;
52
+ leaseTtlMs?: number;
53
+ };
54
+ export type ManagedConnectionListQuery = {
55
+ pluginName?: string;
56
+ connectionType?: string;
57
+ connectionKey?: string;
58
+ transportType?: ManagedConnectionTransportType;
59
+ direction?: ManagedConnectionDirection;
60
+ ownerInstanceId?: string;
61
+ status?: ManagedConnectionStatus | ManagedConnectionStatus[];
62
+ activeOnly?: boolean;
63
+ tenantId?: string | null;
64
+ organizationId?: string | null;
65
+ limit?: number;
66
+ offset?: number;
67
+ };
68
+ export type ManagedConnectionCommandRequest<TPayload = unknown> = {
69
+ requestId: string;
70
+ connectionType: string;
71
+ connectionKey: string;
72
+ command: string;
73
+ payload?: TPayload;
74
+ };
75
+ export type ManagedConnectionCommandHandler<TPayload = unknown, TResult = unknown> = (request: ManagedConnectionCommandRequest<TPayload>) => Promise<TResult> | TResult;
76
+ export type ManagedConnectionCommandResult<TResult = unknown> = {
77
+ ok: boolean;
78
+ result?: TResult;
79
+ error?: string;
80
+ };
81
+ export type ConnectionCommandInvokeOptions = {
82
+ pluginName?: string;
83
+ tenantId?: string | null;
84
+ organizationId?: string | null;
85
+ timeoutMs?: number;
86
+ };
87
+ export interface ManagedConnectionRegistry {
88
+ register(input: RegisterManagedConnectionInput): Promise<ManagedConnectionRecord>;
89
+ heartbeat(input: ManagedConnectionHeartbeatInput): Promise<void>;
90
+ syncMetadata(input: ManagedConnectionMetadataInput): Promise<void>;
91
+ markDisconnected(input: ManagedConnectionKeyInput, reason?: string): Promise<void>;
92
+ list(query: ManagedConnectionListQuery): Promise<ManagedConnectionRecord[]>;
93
+ getOwner(input: ManagedConnectionKeyInput): Promise<string | null>;
94
+ }
95
+ export interface ConnectionCommandRouter {
96
+ registerHandler(connectionType: string, handler: ManagedConnectionCommandHandler): void;
97
+ invokeOwner(connectionType: string, connectionKey: string, command: string, payload?: unknown, options?: ConnectionCommandInvokeOptions): Promise<unknown>;
98
+ }
@@ -20,6 +20,7 @@ export declare class BaseStrategyRegistry<S> implements OnModuleInit {
20
20
  * Resolve organization id, falling back to request context org or global scope.
21
21
  */
22
22
  protected resolveOrganization(organizationId?: string): string;
23
+ protected resolveGlobalFallbackOrganization(): string;
23
24
  /**
24
25
  * Get strategy by type from the given organization including global strategies as fallback.
25
26
  *
@@ -1,7 +1,7 @@
1
1
  import { DynamicStructuredTool } from '@langchain/core/tools';
2
2
  import { I18nObject, IconDefinition } from '@xpert-ai/contracts';
3
3
  import { ZodSchema } from 'zod';
4
- import { BuiltinToolset } from './builtin';
4
+ import { BuiltinToolset, TBuiltinToolsetParams } from './builtin';
5
5
  export interface IToolsetStrategy<TConfig = any> {
6
6
  /**
7
7
  * Metadata about this toolset
@@ -19,6 +19,6 @@ export interface IToolsetStrategy<TConfig = any> {
19
19
  * Validate the configuration
20
20
  */
21
21
  validateConfig(config: TConfig): Promise<void>;
22
- create(config: TConfig): Promise<BuiltinToolset>;
22
+ create(config: TConfig, params?: TBuiltinToolsetParams): Promise<BuiltinToolset>;
23
23
  createTools(): DynamicStructuredTool<ZodSchema>[];
24
24
  }
@@ -6,7 +6,14 @@ import type { Permissions } from './core/permissions';
6
6
  export declare const ORGANIZATION_METADATA_KEY = "xpert:organizationId";
7
7
  export declare const PLUGIN_METADATA_KEY = "xpert:pluginName";
8
8
  export declare const GLOBAL_ORGANIZATION_SCOPE = "global";
9
+ export declare const TENANT_GLOBAL_SCOPE_PREFIX = "tenant:";
10
+ export declare const TENANT_GLOBAL_SCOPE_SUFFIX = ":global";
9
11
  export declare const STRATEGY_META_KEY = "XPERT_STRATEGY_META_KEY";
12
+ export declare function getTenantGlobalScopeKey(tenantId: string): string;
13
+ export declare function isTenantGlobalScopeKey(value?: string | null): boolean;
14
+ export declare function setDefaultTenantId(tenantId?: string | null): void;
15
+ export declare function getDefaultTenantId(): string;
16
+ export declare function resolveTenantGlobalScopeKey(tenantId?: string | null): string;
10
17
  export interface PluginLifecycle {
11
18
  /** Called after module registration but before application startup */
12
19
  onInit?(ctx: PluginContext): Promise<void> | void;
@@ -27,7 +27,7 @@ export interface IWorkflowTriggerStrategy<T> {
27
27
  * @param payload
28
28
  * @param callback
29
29
  */
30
- publish(payload: TWorkflowTriggerParams<T>, callback: (payload: any) => void): Promise<any> | void;
30
+ publish(payload: TWorkflowTriggerParams<T>, callback: (payload: any) => Promise<void> | void): Promise<any> | void;
31
31
  /**
32
32
  * Stop the trigger
33
33
  */