@xpert-ai/plugin-sdk 3.12.1 → 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 +22 -0
- package/index.cjs.js +70 -10
- package/index.esm.js +55 -11
- package/package.json +2 -1
- package/src/index.d.ts +1 -0
- package/src/lib/agent/handoff/agent-chat.contract.d.ts +4 -2
- package/src/lib/agent/middleware/types.d.ts +13 -4
- package/src/lib/managed-connection/index.d.ts +98 -0
- package/src/lib/strategy.d.ts +1 -0
- package/src/lib/toolset/strategy.interface.d.ts +2 -2
- package/src/lib/types.d.ts +7 -0
- package/src/lib/view-extension/index.d.ts +1 -0
- package/src/lib/workflow/trigger/strategy.interface.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
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
|
+
|
|
16
|
+
## 3.12.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- f23228b: client commands for extension view
|
|
21
|
+
- Updated dependencies [e6528c8]
|
|
22
|
+
- Updated dependencies [f23228b]
|
|
23
|
+
- @xpert-ai/contracts@3.13.0
|
|
24
|
+
|
|
3
25
|
## 3.12.1
|
|
4
26
|
|
|
5
27
|
### 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
|
|
517
|
-
|
|
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 ===
|
|
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 !==
|
|
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(
|
|
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
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
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 !==
|
|
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(
|
|
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
|
}
|
|
@@ -4520,6 +4563,14 @@ function escapeHtmlAttribute(value) {
|
|
|
4520
4563
|
|
|
4521
4564
|
const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
|
|
4522
4565
|
|
|
4566
|
+
Object.defineProperty(exports, "ASSISTANT_CHAT_SEND_MESSAGE_COMMAND", {
|
|
4567
|
+
enumerable: true,
|
|
4568
|
+
get: function () { return contracts.ASSISTANT_CHAT_SEND_MESSAGE_COMMAND; }
|
|
4569
|
+
});
|
|
4570
|
+
Object.defineProperty(exports, "ASSISTANT_CONTEXT_SET_COMMAND", {
|
|
4571
|
+
enumerable: true,
|
|
4572
|
+
get: function () { return contracts.ASSISTANT_CONTEXT_SET_COMMAND; }
|
|
4573
|
+
});
|
|
4523
4574
|
exports.ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN = ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN;
|
|
4524
4575
|
exports.AGENT_CHAT_DISPATCH_MESSAGE_TYPE = AGENT_CHAT_DISPATCH_MESSAGE_TYPE;
|
|
4525
4576
|
exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
|
|
@@ -4542,6 +4593,7 @@ exports.BaseToolset = BaseToolset;
|
|
|
4542
4593
|
exports.BuiltinToolset = BuiltinToolset;
|
|
4543
4594
|
exports.CHAT_CHANNEL = CHAT_CHANNEL;
|
|
4544
4595
|
exports.CHAT_CHANNEL_TEXT_LIMITS = CHAT_CHANNEL_TEXT_LIMITS;
|
|
4596
|
+
exports.CONNECTION_COMMAND_ROUTER_TOKEN = CONNECTION_COMMAND_ROUTER_TOKEN;
|
|
4545
4597
|
exports.CancelConversationCommand = CancelConversationCommand;
|
|
4546
4598
|
exports.ChatChannel = ChatChannel;
|
|
4547
4599
|
exports.ChatOAICompatReasoningModel = ChatOAICompatReasoningModel;
|
|
@@ -4590,6 +4642,7 @@ exports.KnowledgebaseDocumentsRuntimeCapability = KnowledgebaseDocumentsRuntimeC
|
|
|
4590
4642
|
exports.KnowledgebaseRuntimeCapability = KnowledgebaseRuntimeCapability;
|
|
4591
4643
|
exports.LLMUsage = LLMUsage;
|
|
4592
4644
|
exports.LargeLanguageModel = LargeLanguageModel;
|
|
4645
|
+
exports.MANAGED_CONNECTION_REGISTRY_TOKEN = MANAGED_CONNECTION_REGISTRY_TOKEN;
|
|
4593
4646
|
exports.ORGANIZATION_METADATA_KEY = ORGANIZATION_METADATA_KEY;
|
|
4594
4647
|
exports.OpenAICompatibleReranker = OpenAICompatibleReranker;
|
|
4595
4648
|
exports.PERMISSION_OPERATION_METADATA_KEY = PERMISSION_OPERATION_METADATA_KEY;
|
|
@@ -4623,6 +4676,8 @@ exports.SandboxProviderStrategy = SandboxProviderStrategy;
|
|
|
4623
4676
|
exports.SkillSourceProviderStrategy = SkillSourceProviderStrategy;
|
|
4624
4677
|
exports.Speech2TextChatModel = Speech2TextChatModel;
|
|
4625
4678
|
exports.SpeechToTextModel = SpeechToTextModel;
|
|
4679
|
+
exports.TENANT_GLOBAL_SCOPE_PREFIX = TENANT_GLOBAL_SCOPE_PREFIX;
|
|
4680
|
+
exports.TENANT_GLOBAL_SCOPE_SUFFIX = TENANT_GLOBAL_SCOPE_SUFFIX;
|
|
4626
4681
|
exports.TEXT_SPLITTER_STRATEGY = TEXT_SPLITTER_STRATEGY;
|
|
4627
4682
|
exports.TOOLSET_STRATEGY = TOOLSET_STRATEGY;
|
|
4628
4683
|
exports.TextEmbeddingModelManager = TextEmbeddingModelManager;
|
|
@@ -4657,6 +4712,7 @@ exports.defineAgentMessageType = defineAgentMessageType;
|
|
|
4657
4712
|
exports.defineChannelMessageType = defineChannelMessageType;
|
|
4658
4713
|
exports.downloadRemoteFile = downloadRemoteFile;
|
|
4659
4714
|
exports.formatSandboxTimeout = formatSandboxTimeout;
|
|
4715
|
+
exports.getDefaultTenantId = getDefaultTenantId;
|
|
4660
4716
|
exports.getErrorMessage = getErrorMessage;
|
|
4661
4717
|
exports.getModelContextSize = getModelContextSize;
|
|
4662
4718
|
exports.getPermissionOperationMetadata = getPermissionOperationMetadata;
|
|
@@ -4664,12 +4720,14 @@ exports.getPositionList = getPositionList;
|
|
|
4664
4720
|
exports.getPositionMap = getPositionMap;
|
|
4665
4721
|
exports.getRequestContext = getRequestContext;
|
|
4666
4722
|
exports.getRequiredPermissionOperation = getRequiredPermissionOperation;
|
|
4723
|
+
exports.getTenantGlobalScopeKey = getTenantGlobalScopeKey;
|
|
4667
4724
|
exports.isRemoteFile = isRemoteFile;
|
|
4668
4725
|
exports.isSandboxBackend = isSandboxBackend;
|
|
4669
4726
|
exports.isSandboxManagedServiceAdapter = isSandboxManagedServiceAdapter;
|
|
4670
4727
|
exports.isSandboxServiceProxyAdapter = isSandboxServiceProxyAdapter;
|
|
4671
4728
|
exports.isSandboxTerminalAdapter = isSandboxTerminalAdapter;
|
|
4672
4729
|
exports.isStructuredMessageType = isStructuredMessageType;
|
|
4730
|
+
exports.isTenantGlobalScopeKey = isTenantGlobalScopeKey;
|
|
4673
4731
|
exports.loadYamlFile = loadYamlFile;
|
|
4674
4732
|
exports.mergeCredentials = mergeCredentials;
|
|
4675
4733
|
exports.mergeParentChildChunks = mergeParentChildChunks;
|
|
@@ -4680,6 +4738,8 @@ exports.resolveSandboxExecutionOptions = resolveSandboxExecutionOptions;
|
|
|
4680
4738
|
exports.resolveSandboxManagedServiceAdapter = resolveSandboxManagedServiceAdapter;
|
|
4681
4739
|
exports.resolveSandboxServiceProxyAdapter = resolveSandboxServiceProxyAdapter;
|
|
4682
4740
|
exports.resolveSandboxTerminalAdapter = resolveSandboxTerminalAdapter;
|
|
4741
|
+
exports.resolveTenantGlobalScopeKey = resolveTenantGlobalScopeKey;
|
|
4683
4742
|
exports.runWithRequestContext = runWithRequestContext;
|
|
4684
4743
|
exports.secondsToMilliseconds = secondsToMilliseconds;
|
|
4744
|
+
exports.setDefaultTenantId = setDefaultTenantId;
|
|
4685
4745
|
exports.sumTokenUsage = sumTokenUsage;
|
package/index.esm.js
CHANGED
|
@@ -4,6 +4,7 @@ import { pick } from 'lodash-es';
|
|
|
4
4
|
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
5
5
|
import { Subject, filter } from 'rxjs';
|
|
6
6
|
import { LanguagesEnum, AiModelTypeEnum, ParameterType, PriceType, FetchFrom, ModelFeature, ModelPropertyKey } from '@xpert-ai/contracts';
|
|
7
|
+
export { ASSISTANT_CHAT_SEND_MESSAGE_COMMAND, ASSISTANT_CONTEXT_SET_COMMAND } from '@xpert-ai/contracts';
|
|
7
8
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
8
9
|
import { ExtractJwt } from 'passport-jwt';
|
|
9
10
|
import { verify, JsonWebTokenError } from 'jsonwebtoken';
|
|
@@ -70,7 +71,35 @@ import { getModelContextSize as getModelContextSize$1 } from '@langchain/core/la
|
|
|
70
71
|
const ORGANIZATION_METADATA_KEY = 'xpert:organizationId';
|
|
71
72
|
const PLUGIN_METADATA_KEY = 'xpert:pluginName';
|
|
72
73
|
const GLOBAL_ORGANIZATION_SCOPE = 'global';
|
|
74
|
+
const TENANT_GLOBAL_SCOPE_PREFIX = 'tenant:';
|
|
75
|
+
const TENANT_GLOBAL_SCOPE_SUFFIX = ':global';
|
|
73
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
|
+
}
|
|
74
103
|
|
|
75
104
|
function _extends() {
|
|
76
105
|
_extends = Object.assign || function assign(target) {
|
|
@@ -492,8 +521,17 @@ class BaseStrategyRegistry {
|
|
|
492
521
|
/**
|
|
493
522
|
* Resolve organization id, falling back to request context org or global scope.
|
|
494
523
|
*/ resolveOrganization(organizationId) {
|
|
495
|
-
var
|
|
496
|
-
|
|
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);
|
|
497
535
|
}
|
|
498
536
|
/**
|
|
499
537
|
* Get strategy by type from the given organization including global strategies as fallback.
|
|
@@ -505,8 +543,9 @@ class BaseStrategyRegistry {
|
|
|
505
543
|
var _this_strategies_get, _this_strategies_get1;
|
|
506
544
|
organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
|
|
507
545
|
const orgKey = this.resolveOrganization(organizationId);
|
|
546
|
+
const globalKey = this.resolveGlobalFallbackOrganization();
|
|
508
547
|
var _this_strategies_get_get;
|
|
509
|
-
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 ===
|
|
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);
|
|
510
549
|
if (!strategy) {
|
|
511
550
|
throw new Error(`No strategy found for type '${type}' for strategy '${this.strategyKey}'`);
|
|
512
551
|
}
|
|
@@ -521,15 +560,16 @@ class BaseStrategyRegistry {
|
|
|
521
560
|
var _this_strategies_get;
|
|
522
561
|
organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
|
|
523
562
|
const orgKey = this.resolveOrganization(organizationId);
|
|
563
|
+
const globalKey = this.resolveGlobalFallbackOrganization();
|
|
524
564
|
const effective = new Map();
|
|
525
565
|
var _this_strategies_get_entries;
|
|
526
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 : []){
|
|
527
567
|
effective.set(type, strategy);
|
|
528
568
|
}
|
|
529
|
-
if (orgKey !==
|
|
569
|
+
if (orgKey !== globalKey) {
|
|
530
570
|
var _this_strategies_get1;
|
|
531
571
|
var _this_strategies_get_entries1;
|
|
532
|
-
for (const [type, strategy] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(
|
|
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 : []){
|
|
533
573
|
if (!effective.has(type)) {
|
|
534
574
|
effective.set(type, strategy);
|
|
535
575
|
}
|
|
@@ -2735,9 +2775,9 @@ AgentMiddlewareRegistry = __decorate([
|
|
|
2735
2775
|
/**
|
|
2736
2776
|
* jump targets (user facing)
|
|
2737
2777
|
*/ const JUMP_TO_TARGETS = [
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2778
|
+
'model',
|
|
2779
|
+
'tools',
|
|
2780
|
+
'end'
|
|
2741
2781
|
];
|
|
2742
2782
|
|
|
2743
2783
|
const AssistantTaskRuntimeCapability = createRuntimeCapability('platform.assistant_task', {
|
|
@@ -4045,6 +4085,9 @@ function resolveSandboxTerminalAdapter(sandbox) {
|
|
|
4045
4085
|
return isSandboxTerminalAdapter(candidate) ? candidate : null;
|
|
4046
4086
|
}
|
|
4047
4087
|
|
|
4088
|
+
const MANAGED_CONNECTION_REGISTRY_TOKEN = 'XPERT_MANAGED_CONNECTION_REGISTRY';
|
|
4089
|
+
const CONNECTION_COMMAND_ROUTER_TOKEN = 'XPERT_CONNECTION_COMMAND_ROUTER';
|
|
4090
|
+
|
|
4048
4091
|
const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
|
|
4049
4092
|
const ViewExtensionProvider = (providerKey)=>applyDecorators(SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
|
|
4050
4093
|
|
|
@@ -4052,15 +4095,16 @@ let ViewExtensionProviderRegistry = class ViewExtensionProviderRegistry extends
|
|
|
4052
4095
|
listEntries(organizationId) {
|
|
4053
4096
|
var _this_strategies_get;
|
|
4054
4097
|
const orgKey = this.resolveOrganization(organizationId);
|
|
4098
|
+
const globalKey = this.resolveGlobalFallbackOrganization();
|
|
4055
4099
|
const entries = new Map();
|
|
4056
4100
|
var _this_strategies_get_entries;
|
|
4057
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 : []){
|
|
4058
4102
|
entries.set(providerKey, provider);
|
|
4059
4103
|
}
|
|
4060
|
-
if (orgKey !==
|
|
4104
|
+
if (orgKey !== globalKey) {
|
|
4061
4105
|
var _this_strategies_get1;
|
|
4062
4106
|
var _this_strategies_get_entries1;
|
|
4063
|
-
for (const [providerKey, provider] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(
|
|
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 : []){
|
|
4064
4108
|
if (!entries.has(providerKey)) {
|
|
4065
4109
|
entries.set(providerKey, provider);
|
|
4066
4110
|
}
|
|
@@ -4499,4 +4543,4 @@ function escapeHtmlAttribute(value) {
|
|
|
4499
4543
|
|
|
4500
4544
|
const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
|
|
4501
4545
|
|
|
4502
|
-
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.
|
|
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
|
@@ -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
|
|
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 [
|
|
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?:
|
|
124
|
-
type:
|
|
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
|
+
}
|
package/src/lib/strategy.d.ts
CHANGED
|
@@ -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
|
}
|
package/src/lib/types.d.ts
CHANGED
|
@@ -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
|
*/
|