@xpert-ai/plugin-sdk 3.14.0 → 3.15.1

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,24 @@
1
1
  # @xpert-ai/plugin-sdk
2
2
 
3
+ ## 3.15.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8fded17: plugin scope for tenant
8
+ - Updated dependencies [8fded17]
9
+ - @xpert-ai/contracts@3.15.2
10
+
11
+ ## 3.15.0
12
+
13
+ ### Minor Changes
14
+
15
+ - c1e4da2: managed queue
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [c1e4da2]
20
+ - @xpert-ai/contracts@3.15.1
21
+
3
22
  ## 3.14.0
4
23
 
5
24
  ### Minor Changes
package/index.cjs.js CHANGED
@@ -91,6 +91,7 @@ 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 SYSTEM_GLOBAL_SCOPE = 'system:global';
94
95
  const BUILTIN_GLOBAL_SCOPE = 'builtin:global';
95
96
  const TENANT_GLOBAL_SCOPE_PREFIX = 'tenant:';
96
97
  const TENANT_GLOBAL_SCOPE_SUFFIX = ':global';
@@ -563,6 +564,9 @@ class BaseStrategyRegistry {
563
564
  if (orgKey !== globalKey) {
564
565
  scopeKeys.push(globalKey);
565
566
  }
567
+ if (!scopeKeys.includes(SYSTEM_GLOBAL_SCOPE)) {
568
+ scopeKeys.push(SYSTEM_GLOBAL_SCOPE);
569
+ }
566
570
  if (!scopeKeys.includes(BUILTIN_GLOBAL_SCOPE)) {
567
571
  scopeKeys.push(BUILTIN_GLOBAL_SCOPE);
568
572
  }
@@ -4115,6 +4119,46 @@ function resolveSandboxTerminalAdapter(sandbox) {
4115
4119
  const MANAGED_CONNECTION_REGISTRY_TOKEN = 'XPERT_MANAGED_CONNECTION_REGISTRY';
4116
4120
  const CONNECTION_COMMAND_ROUTER_TOKEN = 'XPERT_CONNECTION_COMMAND_ROUTER';
4117
4121
 
4122
+ const MANAGED_QUEUE_SERVICE_TOKEN = 'XPERT_MANAGED_QUEUE_SERVICE';
4123
+ const MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = 'XPERT_MANAGED_QUEUE_HANDLER_REGISTRY';
4124
+ const PLUGIN_JOB_PROCESSOR_METADATA = 'XPERT_PLUGIN_JOB_PROCESSOR_METADATA';
4125
+ function PluginJobProcessor(options) {
4126
+ return (target)=>{
4127
+ const metadata = normalizePluginJobProcessorMetadata(options);
4128
+ var _Reflect_getMetadata;
4129
+ const existing = (_Reflect_getMetadata = Reflect.getMetadata(PLUGIN_JOB_PROCESSOR_METADATA, target)) != null ? _Reflect_getMetadata : [];
4130
+ Reflect.defineMetadata(PLUGIN_JOB_PROCESSOR_METADATA, [
4131
+ metadata,
4132
+ ...existing
4133
+ ], target);
4134
+ };
4135
+ }
4136
+ function normalizePluginJobProcessorMetadata(options) {
4137
+ const pluginName = requireManagedQueueDecoratorValue(options.pluginName, 'pluginName');
4138
+ var _options_queueName;
4139
+ const queueName = requireManagedQueueDecoratorValue((_options_queueName = options.queueName) != null ? _options_queueName : options.queue, 'queueName');
4140
+ var _options_jobName;
4141
+ const jobName = requireManagedQueueDecoratorValue((_options_jobName = options.jobName) != null ? _options_jobName : options.jobType, 'jobName');
4142
+ const concurrency = options.concurrency;
4143
+ if (concurrency !== undefined && (!Number.isFinite(concurrency) || concurrency <= 0)) {
4144
+ throw new Error('PluginJobProcessor concurrency must be a positive number');
4145
+ }
4146
+ return _extends({
4147
+ pluginName,
4148
+ queueName,
4149
+ jobName
4150
+ }, concurrency === undefined ? {} : {
4151
+ concurrency: Math.trunc(concurrency)
4152
+ });
4153
+ }
4154
+ function requireManagedQueueDecoratorValue(value, field) {
4155
+ const normalized = `${value != null ? value : ''}`.trim();
4156
+ if (!normalized) {
4157
+ throw new Error(`PluginJobProcessor ${field} is required`);
4158
+ }
4159
+ return normalized;
4160
+ }
4161
+
4118
4162
  const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
4119
4163
  const ViewExtensionProvider = (providerKey)=>common.applyDecorators(common.SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), common.SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
4120
4164
 
@@ -4644,10 +4688,13 @@ exports.KnowledgebaseRuntimeCapability = KnowledgebaseRuntimeCapability;
4644
4688
  exports.LLMUsage = LLMUsage;
4645
4689
  exports.LargeLanguageModel = LargeLanguageModel;
4646
4690
  exports.MANAGED_CONNECTION_REGISTRY_TOKEN = MANAGED_CONNECTION_REGISTRY_TOKEN;
4691
+ exports.MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN;
4692
+ exports.MANAGED_QUEUE_SERVICE_TOKEN = MANAGED_QUEUE_SERVICE_TOKEN;
4647
4693
  exports.ORGANIZATION_METADATA_KEY = ORGANIZATION_METADATA_KEY;
4648
4694
  exports.OpenAICompatibleReranker = OpenAICompatibleReranker;
4649
4695
  exports.PERMISSION_OPERATION_METADATA_KEY = PERMISSION_OPERATION_METADATA_KEY;
4650
4696
  exports.PLUGIN_CONFIG_RESOLVER_TOKEN = PLUGIN_CONFIG_RESOLVER_TOKEN;
4697
+ exports.PLUGIN_JOB_PROCESSOR_METADATA = PLUGIN_JOB_PROCESSOR_METADATA;
4651
4698
  exports.PLUGIN_METADATA = PLUGIN_METADATA;
4652
4699
  exports.PLUGIN_METADATA_KEY = PLUGIN_METADATA_KEY;
4653
4700
  exports.PLUGIN_WEBHOOK_AUTH_METADATA_KEY = PLUGIN_WEBHOOK_AUTH_METADATA_KEY;
@@ -4658,6 +4705,7 @@ exports.PROVIDE_AI_MODEL_RERANK = PROVIDE_AI_MODEL_RERANK;
4658
4705
  exports.PROVIDE_AI_MODEL_SPEECH2TEXT = PROVIDE_AI_MODEL_SPEECH2TEXT;
4659
4706
  exports.PROVIDE_AI_MODEL_TEXT_EMBEDDING = PROVIDE_AI_MODEL_TEXT_EMBEDDING;
4660
4707
  exports.PROVIDE_AI_MODEL_TTS = PROVIDE_AI_MODEL_TTS;
4708
+ exports.PluginJobProcessor = PluginJobProcessor;
4661
4709
  exports.PluginWebhookAuth = PluginWebhookAuth;
4662
4710
  exports.RETRIEVER_STRATEGY = RETRIEVER_STRATEGY;
4663
4711
  exports.RequestContext = RequestContext;
@@ -4673,6 +4721,7 @@ exports.SSOProviderStrategyKey = SSOProviderStrategyKey;
4673
4721
  exports.SSO_BINDING_PERMISSION_SERVICE_TOKEN = SSO_BINDING_PERMISSION_SERVICE_TOKEN;
4674
4722
  exports.SSO_PROVIDER = SSO_PROVIDER;
4675
4723
  exports.STRATEGY_META_KEY = STRATEGY_META_KEY;
4724
+ exports.SYSTEM_GLOBAL_SCOPE = SYSTEM_GLOBAL_SCOPE;
4676
4725
  exports.SandboxProviderStrategy = SandboxProviderStrategy;
4677
4726
  exports.SkillSourceProviderStrategy = SkillSourceProviderStrategy;
4678
4727
  exports.Speech2TextChatModel = Speech2TextChatModel;
package/index.esm.js CHANGED
@@ -71,6 +71,7 @@ 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 SYSTEM_GLOBAL_SCOPE = 'system:global';
74
75
  const BUILTIN_GLOBAL_SCOPE = 'builtin:global';
75
76
  const TENANT_GLOBAL_SCOPE_PREFIX = 'tenant:';
76
77
  const TENANT_GLOBAL_SCOPE_SUFFIX = ':global';
@@ -543,6 +544,9 @@ class BaseStrategyRegistry {
543
544
  if (orgKey !== globalKey) {
544
545
  scopeKeys.push(globalKey);
545
546
  }
547
+ if (!scopeKeys.includes(SYSTEM_GLOBAL_SCOPE)) {
548
+ scopeKeys.push(SYSTEM_GLOBAL_SCOPE);
549
+ }
546
550
  if (!scopeKeys.includes(BUILTIN_GLOBAL_SCOPE)) {
547
551
  scopeKeys.push(BUILTIN_GLOBAL_SCOPE);
548
552
  }
@@ -4095,6 +4099,46 @@ function resolveSandboxTerminalAdapter(sandbox) {
4095
4099
  const MANAGED_CONNECTION_REGISTRY_TOKEN = 'XPERT_MANAGED_CONNECTION_REGISTRY';
4096
4100
  const CONNECTION_COMMAND_ROUTER_TOKEN = 'XPERT_CONNECTION_COMMAND_ROUTER';
4097
4101
 
4102
+ const MANAGED_QUEUE_SERVICE_TOKEN = 'XPERT_MANAGED_QUEUE_SERVICE';
4103
+ const MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = 'XPERT_MANAGED_QUEUE_HANDLER_REGISTRY';
4104
+ const PLUGIN_JOB_PROCESSOR_METADATA = 'XPERT_PLUGIN_JOB_PROCESSOR_METADATA';
4105
+ function PluginJobProcessor(options) {
4106
+ return (target)=>{
4107
+ const metadata = normalizePluginJobProcessorMetadata(options);
4108
+ var _Reflect_getMetadata;
4109
+ const existing = (_Reflect_getMetadata = Reflect.getMetadata(PLUGIN_JOB_PROCESSOR_METADATA, target)) != null ? _Reflect_getMetadata : [];
4110
+ Reflect.defineMetadata(PLUGIN_JOB_PROCESSOR_METADATA, [
4111
+ metadata,
4112
+ ...existing
4113
+ ], target);
4114
+ };
4115
+ }
4116
+ function normalizePluginJobProcessorMetadata(options) {
4117
+ const pluginName = requireManagedQueueDecoratorValue(options.pluginName, 'pluginName');
4118
+ var _options_queueName;
4119
+ const queueName = requireManagedQueueDecoratorValue((_options_queueName = options.queueName) != null ? _options_queueName : options.queue, 'queueName');
4120
+ var _options_jobName;
4121
+ const jobName = requireManagedQueueDecoratorValue((_options_jobName = options.jobName) != null ? _options_jobName : options.jobType, 'jobName');
4122
+ const concurrency = options.concurrency;
4123
+ if (concurrency !== undefined && (!Number.isFinite(concurrency) || concurrency <= 0)) {
4124
+ throw new Error('PluginJobProcessor concurrency must be a positive number');
4125
+ }
4126
+ return _extends({
4127
+ pluginName,
4128
+ queueName,
4129
+ jobName
4130
+ }, concurrency === undefined ? {} : {
4131
+ concurrency: Math.trunc(concurrency)
4132
+ });
4133
+ }
4134
+ function requireManagedQueueDecoratorValue(value, field) {
4135
+ const normalized = `${value != null ? value : ''}`.trim();
4136
+ if (!normalized) {
4137
+ throw new Error(`PluginJobProcessor ${field} is required`);
4138
+ }
4139
+ return normalized;
4140
+ }
4141
+
4098
4142
  const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
4099
4143
  const ViewExtensionProvider = (providerKey)=>applyDecorators(SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
4100
4144
 
@@ -4543,4 +4587,4 @@ function escapeHtmlAttribute(value) {
4543
4587
 
4544
4588
  const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
4545
4589
 
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, BUILTIN_GLOBAL_SCOPE, 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 };
4590
+ 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, BUILTIN_GLOBAL_SCOPE, 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, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, 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, PluginJobProcessor, 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, SYSTEM_GLOBAL_SCOPE, 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.14.0",
3
+ "version": "3.15.1",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
package/src/index.d.ts CHANGED
@@ -19,4 +19,5 @@ export * from './lib/strategy';
19
19
  export * from './lib/sso/index';
20
20
  export * from './lib/sandbox/index';
21
21
  export * from './lib/managed-connection/index';
22
+ export * from './lib/managed-queue/index';
22
23
  export * from './lib/view-extension/index';
@@ -0,0 +1,106 @@
1
+ export declare const MANAGED_QUEUE_SERVICE_TOKEN = "XPERT_MANAGED_QUEUE_SERVICE";
2
+ export declare const MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = "XPERT_MANAGED_QUEUE_HANDLER_REGISTRY";
3
+ export declare const PLUGIN_JOB_PROCESSOR_METADATA = "XPERT_PLUGIN_JOB_PROCESSOR_METADATA";
4
+ export type PluginJobProcessorOptions = {
5
+ pluginName: string;
6
+ queueName?: string;
7
+ queue?: string;
8
+ jobName?: string;
9
+ jobType?: string;
10
+ concurrency?: number;
11
+ };
12
+ export type PluginJobProcessorMetadata = {
13
+ pluginName: string;
14
+ queueName: string;
15
+ jobName: string;
16
+ concurrency?: number;
17
+ };
18
+ export type ManagedQueueRemoveOption = boolean | number | {
19
+ age?: number;
20
+ count?: number;
21
+ };
22
+ export type ManagedQueueBackoffInput = number | {
23
+ type?: 'fixed' | 'exponential';
24
+ delay: number;
25
+ };
26
+ export type ManagedQueueRedis = {
27
+ get(key: string): Promise<string | null>;
28
+ set(key: string, value: string, mode?: string, ttlMode?: string | number, ttlOrMode?: number | string): Promise<string | null>;
29
+ del(...keys: string[]): Promise<number>;
30
+ incr(key: string): Promise<number>;
31
+ expire(key: string, seconds: number): Promise<number>;
32
+ ttl(key: string): Promise<number>;
33
+ eval(script: string, numKeys: number, ...args: Array<string | number>): Promise<unknown>;
34
+ };
35
+ export type ManagedQueueEnqueueInput<TPayload = unknown> = {
36
+ pluginName: string;
37
+ queueName: string;
38
+ jobName: string;
39
+ payload: TPayload;
40
+ tenantId?: string | null;
41
+ organizationId?: string | null;
42
+ scopeKey?: string | null;
43
+ userId?: string | null;
44
+ jobId?: string;
45
+ delayMs?: number;
46
+ attempts?: number;
47
+ backoffMs?: ManagedQueueBackoffInput;
48
+ removeOnComplete?: ManagedQueueRemoveOption;
49
+ removeOnFail?: ManagedQueueRemoveOption;
50
+ };
51
+ export type ManagedQueueEnqueueResult = {
52
+ jobId: string;
53
+ };
54
+ export type ManagedQueueCancelInput = {
55
+ jobId: string;
56
+ };
57
+ export type ManagedQueueCancelResult = {
58
+ success: boolean;
59
+ jobId: string;
60
+ state?: string;
61
+ reason?: 'not_found' | 'active' | 'completed' | 'failed' | 'locked' | 'not_removable';
62
+ error?: string;
63
+ };
64
+ export type ManagedQueueJob<TPayload = unknown> = {
65
+ id?: string;
66
+ name: string;
67
+ data: TPayload;
68
+ attemptsMade: number;
69
+ opts?: Record<string, unknown>;
70
+ };
71
+ export type ManagedQueueJobContext = {
72
+ pluginName: string;
73
+ queueName: string;
74
+ jobName: string;
75
+ scopeKey?: string | null;
76
+ };
77
+ export type ManagedQueueJobSnapshot<TPayload = unknown> = ManagedQueueJob<TPayload> & {
78
+ state?: string;
79
+ timestamp?: number;
80
+ processedOn?: number;
81
+ finishedOn?: number;
82
+ };
83
+ export type ManagedQueueJobHandler<TPayload = unknown> = (job: ManagedQueueJob<TPayload>) => Promise<void> | void;
84
+ export interface ManagedQueueJobProcessor<TPayload = unknown> {
85
+ handle(job: ManagedQueueJob<TPayload>, context: ManagedQueueJobContext): Promise<void> | void;
86
+ }
87
+ export type ManagedQueueHandlerRegistration<TPayload = unknown> = {
88
+ pluginName: string;
89
+ queueName: string;
90
+ jobName: string;
91
+ scopeKey?: string | null;
92
+ concurrency?: number;
93
+ handler: ManagedQueueJobHandler<TPayload>;
94
+ };
95
+ export interface ManagedQueueHandlerRegistry {
96
+ register<TPayload = unknown>(registration: ManagedQueueHandlerRegistration<TPayload>): () => void;
97
+ }
98
+ export interface ManagedQueueService {
99
+ enqueue<TPayload = unknown>(input: ManagedQueueEnqueueInput<TPayload>): Promise<ManagedQueueEnqueueResult>;
100
+ cancel(input: ManagedQueueCancelInput): Promise<ManagedQueueCancelResult>;
101
+ getJob<TPayload = unknown>(input: {
102
+ jobId: string;
103
+ }): Promise<ManagedQueueJobSnapshot<TPayload> | null>;
104
+ getRedis(): Promise<ManagedQueueRedis>;
105
+ }
106
+ export declare function PluginJobProcessor(options: PluginJobProcessorOptions): ClassDecorator;
@@ -6,6 +6,7 @@ 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 SYSTEM_GLOBAL_SCOPE = "system:global";
9
10
  export declare const BUILTIN_GLOBAL_SCOPE = "builtin:global";
10
11
  export declare const TENANT_GLOBAL_SCOPE_PREFIX = "tenant:";
11
12
  export declare const TENANT_GLOBAL_SCOPE_SUFFIX = ":global";
@@ -87,6 +88,9 @@ export interface PluginContext<TConfig extends object = any> {
87
88
  app?: INestApplicationContext;
88
89
  logger: PluginLogger;
89
90
  config: TConfig;
91
+ tenantId?: string | null;
92
+ organizationId?: string | null;
93
+ scopeKey?: string | null;
90
94
  /** Helper method to access other Providers in the container */
91
95
  resolve<TInput = any, TResult = TInput>(token: any): TResult;
92
96
  }