@xpert-ai/plugin-sdk 3.9.0-beta.3 → 3.9.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,12 +1,28 @@
1
1
  # @xpert-ai/plugin-sdk
2
2
 
3
- ## 3.9.0-beta.3
3
+ ## 3.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - e040933: Tenant shared workspace to organization's users
8
+ - Updated dependencies [e040933]
9
+ - @xpert-ai/contracts@3.9.1
10
+ - @xpert-ai/ocap-core@3.9.1
11
+
12
+ ## 3.9.0
4
13
 
5
14
  ### Patch Changes
6
15
 
7
16
  - 4dcf5b5: add sso in plugin sdk
17
+ - 7fff870: beta 2
18
+ - c76facd: beta v
19
+ - 5b5c8ef: Updates
8
20
  - Updated dependencies [4dcf5b5]
9
- - @xpert-ai/contracts@3.9.0-beta.3
21
+ - Updated dependencies [7fff870]
22
+ - Updated dependencies [c76facd]
23
+ - Updated dependencies [5b5c8ef]
24
+ - @xpert-ai/contracts@3.9.0
25
+ - @xpert-ai/ocap-core@3.9.0
10
26
 
11
27
  ## 3.9.0-beta.2
12
28
 
package/index.cjs.js CHANGED
@@ -107,7 +107,7 @@ function _extends() {
107
107
  function createPluginLogger(scope, baseMeta = {}) {
108
108
  const nestLogger = new common.Logger(scope);
109
109
  const wrap = (level, msg, meta)=>{
110
- var // 保持与 Nest Logger 接口对齐
110
+ var // Maintain alignment with the Nest Logger interface
111
111
  _nestLogger_level;
112
112
  const payload = meta ? _extends({}, baseMeta, meta) : baseMeta;
113
113
  (_nestLogger_level = nestLogger[level]) == null ? void 0 : _nestLogger_level.call(nestLogger, msg + (Object.keys(payload).length ? ` ${JSON.stringify(payload)}` : ''));
@@ -617,6 +617,8 @@ exports.WorkflowNodeRegistry = __decorate([
617
617
  const COMMAND_METADATA$2 = '__command__';
618
618
  /**
619
619
  * Wrap Workflow Node Execution Command
620
+ *
621
+ * @deprecated Prefer `IAgentMiddlewareContext.runtime.wrapWorkflowNodeExecution(...)` in middleware and plugin code.
620
622
  */ class WrapWorkflowNodeExecutionCommand extends cqrs.Command {
621
623
  constructor(fuc, params){
622
624
  super();
@@ -2569,6 +2571,8 @@ function normalizeContextSize(value) {
2569
2571
  const COMMAND_METADATA$1 = '__command__';
2570
2572
  /**
2571
2573
  * Get a Chat Model of copilot model and check it's token limitation, record the token usage
2574
+ *
2575
+ * @deprecated Prefer `IAgentMiddlewareContext.runtime.createModelClient(...)` in middleware and plugin code.
2572
2576
  */ class CreateModelClientCommand extends cqrs.Command {
2573
2577
  constructor(copilotModel, options){
2574
2578
  super();
@@ -2939,19 +2943,43 @@ function resolveSandboxExecutionOptions(options, defaults = DEFAULT_SANDBOX_SHEL
2939
2943
  };
2940
2944
  }
2941
2945
 
2946
+ function isObjectLike$2(value) {
2947
+ return typeof value === 'object' && value !== null;
2948
+ }
2949
+ function isSandboxManagedServiceAdapter(value) {
2950
+ return isObjectLike$2(value) && typeof Reflect.get(value, 'startService') === 'function' && typeof Reflect.get(value, 'listServices') === 'function' && typeof Reflect.get(value, 'getServiceLogs') === 'function' && typeof Reflect.get(value, 'stopService') === 'function' && typeof Reflect.get(value, 'restartService') === 'function';
2951
+ }
2952
+ function resolveSandboxManagedServiceAdapter(sandbox) {
2953
+ if (!isObjectLike$2(sandbox)) {
2954
+ return null;
2955
+ }
2956
+ const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
2957
+ return isSandboxManagedServiceAdapter(candidate) ? candidate : null;
2958
+ }
2959
+ function isSandboxServiceProxyAdapter(value) {
2960
+ return isObjectLike$2(value) && typeof Reflect.get(value, 'proxyServiceRequest') === 'function';
2961
+ }
2962
+ function resolveSandboxServiceProxyAdapter(sandbox) {
2963
+ if (!isObjectLike$2(sandbox)) {
2964
+ return null;
2965
+ }
2966
+ const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
2967
+ return isSandboxServiceProxyAdapter(candidate) ? candidate : null;
2968
+ }
2969
+
2942
2970
  /**
2943
2971
  * Type guard to check if a backend supports execution.
2944
2972
  *
2945
2973
  * @param backend - Backend instance to check
2946
2974
  * @returns True if the backend implements SandboxBackendProtocol
2947
- */ function isObjectLike(value) {
2975
+ */ function isObjectLike$1(value) {
2948
2976
  return typeof value === 'object' && value !== null;
2949
2977
  }
2950
2978
  function isSandboxBackend(backend) {
2951
- return isObjectLike(backend) && typeof Reflect.get(backend, 'execute') === 'function' && typeof Reflect.get(backend, 'id') === 'string';
2979
+ return isObjectLike$1(backend) && typeof Reflect.get(backend, 'execute') === 'function' && typeof Reflect.get(backend, 'id') === 'string';
2952
2980
  }
2953
2981
  function resolveSandboxBackend(sandbox) {
2954
- if (!isObjectLike(sandbox)) {
2982
+ if (!isObjectLike$1(sandbox)) {
2955
2983
  return null;
2956
2984
  }
2957
2985
  const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
@@ -3880,6 +3908,20 @@ exports.SandboxProviderRegistry = __decorate([
3880
3908
  ])
3881
3909
  ], exports.SandboxProviderRegistry);
3882
3910
 
3911
+ function isObjectLike(value) {
3912
+ return typeof value === 'object' && value !== null;
3913
+ }
3914
+ function isSandboxTerminalAdapter(value) {
3915
+ return isObjectLike(value) && typeof Reflect.get(value, 'open') === 'function';
3916
+ }
3917
+ function resolveSandboxTerminalAdapter(sandbox) {
3918
+ if (!isObjectLike(sandbox)) {
3919
+ return null;
3920
+ }
3921
+ const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
3922
+ return isSandboxTerminalAdapter(candidate) ? candidate : null;
3923
+ }
3924
+
3883
3925
  const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
3884
3926
  const ViewExtensionProvider = (providerKey)=>common.applyDecorators(common.SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), common.SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
3885
3927
 
@@ -4052,6 +4094,9 @@ exports.getRequestContext = getRequestContext;
4052
4094
  exports.getRequiredPermissionOperation = getRequiredPermissionOperation;
4053
4095
  exports.isRemoteFile = isRemoteFile;
4054
4096
  exports.isSandboxBackend = isSandboxBackend;
4097
+ exports.isSandboxManagedServiceAdapter = isSandboxManagedServiceAdapter;
4098
+ exports.isSandboxServiceProxyAdapter = isSandboxServiceProxyAdapter;
4099
+ exports.isSandboxTerminalAdapter = isSandboxTerminalAdapter;
4055
4100
  exports.isStructuredMessageType = isStructuredMessageType;
4056
4101
  exports.loadYamlFile = loadYamlFile;
4057
4102
  exports.mergeCredentials = mergeCredentials;
@@ -4059,6 +4104,9 @@ exports.mergeParentChildChunks = mergeParentChildChunks;
4059
4104
  exports.normalizeContextSize = normalizeContextSize;
4060
4105
  exports.resolveSandboxBackend = resolveSandboxBackend;
4061
4106
  exports.resolveSandboxExecutionOptions = resolveSandboxExecutionOptions;
4107
+ exports.resolveSandboxManagedServiceAdapter = resolveSandboxManagedServiceAdapter;
4108
+ exports.resolveSandboxServiceProxyAdapter = resolveSandboxServiceProxyAdapter;
4109
+ exports.resolveSandboxTerminalAdapter = resolveSandboxTerminalAdapter;
4062
4110
  exports.runWithRequestContext = runWithRequestContext;
4063
4111
  exports.secondsToMilliseconds = secondsToMilliseconds;
4064
4112
  exports.sumTokenUsage = sumTokenUsage;
package/index.esm.js CHANGED
@@ -86,7 +86,7 @@ function _extends() {
86
86
  function createPluginLogger(scope, baseMeta = {}) {
87
87
  const nestLogger = new Logger(scope);
88
88
  const wrap = (level, msg, meta)=>{
89
- var // 保持与 Nest Logger 接口对齐
89
+ var // Maintain alignment with the Nest Logger interface
90
90
  _nestLogger_level;
91
91
  const payload = meta ? _extends({}, baseMeta, meta) : baseMeta;
92
92
  (_nestLogger_level = nestLogger[level]) == null ? void 0 : _nestLogger_level.call(nestLogger, msg + (Object.keys(payload).length ? ` ${JSON.stringify(payload)}` : ''));
@@ -596,6 +596,8 @@ WorkflowNodeRegistry = __decorate([
596
596
  const COMMAND_METADATA$2 = '__command__';
597
597
  /**
598
598
  * Wrap Workflow Node Execution Command
599
+ *
600
+ * @deprecated Prefer `IAgentMiddlewareContext.runtime.wrapWorkflowNodeExecution(...)` in middleware and plugin code.
599
601
  */ class WrapWorkflowNodeExecutionCommand extends Command {
600
602
  constructor(fuc, params){
601
603
  super();
@@ -2548,6 +2550,8 @@ function normalizeContextSize(value) {
2548
2550
  const COMMAND_METADATA$1 = '__command__';
2549
2551
  /**
2550
2552
  * Get a Chat Model of copilot model and check it's token limitation, record the token usage
2553
+ *
2554
+ * @deprecated Prefer `IAgentMiddlewareContext.runtime.createModelClient(...)` in middleware and plugin code.
2551
2555
  */ class CreateModelClientCommand extends Command {
2552
2556
  constructor(copilotModel, options){
2553
2557
  super();
@@ -2918,19 +2922,43 @@ function resolveSandboxExecutionOptions(options, defaults = DEFAULT_SANDBOX_SHEL
2918
2922
  };
2919
2923
  }
2920
2924
 
2925
+ function isObjectLike$2(value) {
2926
+ return typeof value === 'object' && value !== null;
2927
+ }
2928
+ function isSandboxManagedServiceAdapter(value) {
2929
+ return isObjectLike$2(value) && typeof Reflect.get(value, 'startService') === 'function' && typeof Reflect.get(value, 'listServices') === 'function' && typeof Reflect.get(value, 'getServiceLogs') === 'function' && typeof Reflect.get(value, 'stopService') === 'function' && typeof Reflect.get(value, 'restartService') === 'function';
2930
+ }
2931
+ function resolveSandboxManagedServiceAdapter(sandbox) {
2932
+ if (!isObjectLike$2(sandbox)) {
2933
+ return null;
2934
+ }
2935
+ const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
2936
+ return isSandboxManagedServiceAdapter(candidate) ? candidate : null;
2937
+ }
2938
+ function isSandboxServiceProxyAdapter(value) {
2939
+ return isObjectLike$2(value) && typeof Reflect.get(value, 'proxyServiceRequest') === 'function';
2940
+ }
2941
+ function resolveSandboxServiceProxyAdapter(sandbox) {
2942
+ if (!isObjectLike$2(sandbox)) {
2943
+ return null;
2944
+ }
2945
+ const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
2946
+ return isSandboxServiceProxyAdapter(candidate) ? candidate : null;
2947
+ }
2948
+
2921
2949
  /**
2922
2950
  * Type guard to check if a backend supports execution.
2923
2951
  *
2924
2952
  * @param backend - Backend instance to check
2925
2953
  * @returns True if the backend implements SandboxBackendProtocol
2926
- */ function isObjectLike(value) {
2954
+ */ function isObjectLike$1(value) {
2927
2955
  return typeof value === 'object' && value !== null;
2928
2956
  }
2929
2957
  function isSandboxBackend(backend) {
2930
- return isObjectLike(backend) && typeof Reflect.get(backend, 'execute') === 'function' && typeof Reflect.get(backend, 'id') === 'string';
2958
+ return isObjectLike$1(backend) && typeof Reflect.get(backend, 'execute') === 'function' && typeof Reflect.get(backend, 'id') === 'string';
2931
2959
  }
2932
2960
  function resolveSandboxBackend(sandbox) {
2933
- if (!isObjectLike(sandbox)) {
2961
+ if (!isObjectLike$1(sandbox)) {
2934
2962
  return null;
2935
2963
  }
2936
2964
  const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
@@ -3859,6 +3887,20 @@ SandboxProviderRegistry = __decorate([
3859
3887
  ])
3860
3888
  ], SandboxProviderRegistry);
3861
3889
 
3890
+ function isObjectLike(value) {
3891
+ return typeof value === 'object' && value !== null;
3892
+ }
3893
+ function isSandboxTerminalAdapter(value) {
3894
+ return isObjectLike(value) && typeof Reflect.get(value, 'open') === 'function';
3895
+ }
3896
+ function resolveSandboxTerminalAdapter(sandbox) {
3897
+ if (!isObjectLike(sandbox)) {
3898
+ return null;
3899
+ }
3900
+ const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
3901
+ return isSandboxTerminalAdapter(candidate) ? candidate : null;
3902
+ }
3903
+
3862
3904
  const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
3863
3905
  const ViewExtensionProvider = (providerKey)=>applyDecorators(SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
3864
3906
 
@@ -3899,4 +3941,4 @@ ViewExtensionProviderRegistry = __decorate([
3899
3941
 
3900
3942
  const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
3901
3943
 
3902
- 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, 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, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, 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, LLMUsage, LargeLanguageModel, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_METADATA, PLUGIN_METADATA_KEY, 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, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SKILL_SOURCE_PROVIDER, 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, WrapWorkflowNodeExecutionCommand, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, buildSandboxTimeoutMessage, calcTokenUsage, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, defineAgentMessageType, defineChannelMessageType, downloadRemoteFile, formatSandboxTimeout, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, isRemoteFile, isSandboxBackend, isStructuredMessageType, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, resolveSandboxBackend, resolveSandboxExecutionOptions, runWithRequestContext, secondsToMilliseconds, sumTokenUsage };
3944
+ 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, 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, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, 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, LLMUsage, LargeLanguageModel, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_METADATA, PLUGIN_METADATA_KEY, 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, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SKILL_SOURCE_PROVIDER, 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, WrapWorkflowNodeExecutionCommand, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, buildSandboxTimeoutMessage, calcTokenUsage, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, defineAgentMessageType, defineChannelMessageType, downloadRemoteFile, formatSandboxTimeout, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStructuredMessageType, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, runWithRequestContext, secondsToMilliseconds, sumTokenUsage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.9.0-beta.3",
3
+ "version": "3.9.1",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,6 +1,11 @@
1
+ import { Embeddings } from '@langchain/core/embeddings';
2
+ import { BaseLanguageModel } from '@langchain/core/language_models/base';
3
+ import { BaseChatModel } from '@langchain/core/language_models/chat_models';
1
4
  import type { Runtime as LangGraphRuntime } from "@langchain/langgraph";
2
5
  import type { BaseMessage } from "@langchain/core/messages";
3
- import { TSandboxConfigurable } from "@xpert-ai/contracts";
6
+ import { ICopilotModel, ILLMUsage, IXpertAgentExecution, JSONValue, TSandboxConfigurable } from "@xpert-ai/contracts";
7
+ import { Subscriber } from 'rxjs';
8
+ import { IRerank } from '../../ai-model/types';
4
9
  /**
5
10
  * Type for the agent's built-in state properties.
6
11
  */
@@ -56,4 +61,22 @@ export type Runtime<TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext
56
61
  [key: string]: unknown;
57
62
  };
58
63
  };
64
+ export type AgentMiddlewareModelClient = BaseLanguageModel | BaseChatModel | Embeddings | IRerank;
65
+ export type AgentMiddlewareCreateModelClientOptions = {
66
+ abortController?: AbortController;
67
+ usageCallback: (tokens: ILLMUsage) => void;
68
+ };
69
+ export type AgentMiddlewareWrapWorkflowNodeExecutionResult<T> = {
70
+ output?: string | JSONValue;
71
+ state: T;
72
+ };
73
+ export type AgentMiddlewareWrapWorkflowNodeExecutionParams = {
74
+ execution: Partial<IXpertAgentExecution>;
75
+ subscriber?: Subscriber<MessageEvent>;
76
+ catchError?: (error: Error) => Promise<void>;
77
+ };
78
+ export interface AgentMiddlewareRuntimeApi {
79
+ createModelClient<T = AgentMiddlewareModelClient>(copilotModel: ICopilotModel, options: AgentMiddlewareCreateModelClientOptions): Promise<T>;
80
+ wrapWorkflowNodeExecution<T>(run: (execution: Partial<IXpertAgentExecution>) => Promise<AgentMiddlewareWrapWorkflowNodeExecutionResult<T>>, params: AgentMiddlewareWrapWorkflowNodeExecutionParams): Promise<T>;
81
+ }
59
82
  export {};
@@ -3,6 +3,7 @@ import { StructuredToolInterface } from "@langchain/core/tools";
3
3
  import { RunnableToolLike } from '@langchain/core/runnables';
4
4
  import { AgentMiddleware } from './types';
5
5
  import { PromiseOrValue } from '../../types';
6
+ import { AgentMiddlewareRuntimeApi } from './runtime';
6
7
  export interface IAgentMiddlewareContext {
7
8
  tenantId: string;
8
9
  userId: string;
@@ -12,8 +13,10 @@ export interface IAgentMiddlewareContext {
12
13
  xpertId?: string;
13
14
  xpertFeatures?: TXpertFeatures | null;
14
15
  agentKey?: string;
16
+ knowledgebaseIds?: string[];
15
17
  node: IWFNMiddleware;
16
18
  tools: Map<string, StructuredToolInterface | RunnableToolLike>;
19
+ runtime: AgentMiddlewareRuntimeApi;
17
20
  }
18
21
  export interface IAgentMiddlewareStrategy<T = unknown> {
19
22
  meta: TAgentMiddlewareMeta;
@@ -1,21 +1,14 @@
1
- import { Embeddings } from '@langchain/core/embeddings';
2
- import { BaseLanguageModel } from '@langchain/core/language_models/base';
3
- import { BaseChatModel } from '@langchain/core/language_models/chat_models';
4
- import { ICopilotModel, ILLMUsage } from '@xpert-ai/contracts';
1
+ import { ICopilotModel } from '@xpert-ai/contracts';
5
2
  import { Command } from '@nestjs/cqrs';
6
- import { IRerank } from '../types';
3
+ import { AgentMiddlewareCreateModelClientOptions, AgentMiddlewareModelClient } from '../../agent/middleware/runtime';
7
4
  /**
8
5
  * Get a Chat Model of copilot model and check it's token limitation, record the token usage
6
+ *
7
+ * @deprecated Prefer `IAgentMiddlewareContext.runtime.createModelClient(...)` in middleware and plugin code.
9
8
  */
10
- export declare class CreateModelClientCommand<T = BaseLanguageModel | BaseChatModel | Embeddings | IRerank> extends Command<T> {
9
+ export declare class CreateModelClientCommand<T = AgentMiddlewareModelClient> extends Command<T> {
11
10
  readonly copilotModel: ICopilotModel;
12
- readonly options: {
13
- abortController?: AbortController;
14
- usageCallback: (tokens: ILLMUsage) => void;
15
- };
11
+ readonly options: AgentMiddlewareCreateModelClientOptions;
16
12
  static readonly type = "[AI Model] Create Model Client";
17
- constructor(copilotModel: ICopilotModel, options: {
18
- abortController?: AbortController;
19
- usageCallback: (tokens: ILLMUsage) => void;
20
- });
13
+ constructor(copilotModel: ICopilotModel, options: AgentMiddlewareCreateModelClientOptions);
21
14
  }
@@ -1,9 +1,11 @@
1
1
  export * from './execution';
2
+ export * from './managed-service';
2
3
  export * from './protocol';
3
4
  export * from './sandbox';
4
5
  export * from './sandbox.decorator';
5
6
  export * from './sandbox.interface';
6
7
  export * from './sandbox.registry';
8
+ export * from './terminal';
7
9
  export * from './sandbox.interface';
8
10
  export * from './sandbox.decorator';
9
11
  export * from './sandbox.registry';
@@ -0,0 +1,70 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import type { ISandboxManagedService, TSandboxConfigurable, TSandboxManagedServiceEnvEntry, TSandboxManagedServiceLogs, TSandboxManagedServiceStatus, TSandboxManagedServiceTransportMode } from '@xpert-ai/contracts';
3
+ import type { MaybePromise } from './protocol';
4
+ export type SandboxManagedServiceStateChange = {
5
+ actualPort?: number | null;
6
+ exitCode?: number | null;
7
+ runtimeRef?: ISandboxManagedService['runtimeRef'];
8
+ signal?: string | null;
9
+ startedAt?: Date;
10
+ status: TSandboxManagedServiceStatus;
11
+ stoppedAt?: Date | null;
12
+ transportMode?: TSandboxManagedServiceTransportMode | null;
13
+ };
14
+ export type SandboxManagedServiceStartOptions = {
15
+ command: string;
16
+ cwd: string;
17
+ env?: TSandboxManagedServiceEnvEntry[];
18
+ metadata?: ISandboxManagedService['metadata'];
19
+ port?: number | null;
20
+ previewPath?: string | null;
21
+ readyPattern?: string | null;
22
+ serviceId: string;
23
+ onStateChange?: (change: SandboxManagedServiceStateChange) => MaybePromise<void>;
24
+ };
25
+ export type SandboxManagedServiceListOptions = {
26
+ services: ISandboxManagedService[];
27
+ };
28
+ export type SandboxManagedServiceListResult = {
29
+ services: ISandboxManagedService[];
30
+ };
31
+ export type SandboxManagedServiceLogsOptions = {
32
+ service: ISandboxManagedService;
33
+ tail?: number;
34
+ };
35
+ export type SandboxManagedServiceStopOptions = {
36
+ service: ISandboxManagedService;
37
+ onStateChange?: (change: SandboxManagedServiceStateChange) => MaybePromise<void>;
38
+ };
39
+ export type SandboxManagedServiceRestartOptions = {
40
+ command: string;
41
+ cwd: string;
42
+ env?: TSandboxManagedServiceEnvEntry[];
43
+ metadata?: ISandboxManagedService['metadata'];
44
+ port?: number | null;
45
+ previewPath?: string | null;
46
+ readyPattern?: string | null;
47
+ service: ISandboxManagedService;
48
+ onStateChange?: (change: SandboxManagedServiceStateChange) => MaybePromise<void>;
49
+ };
50
+ export type SandboxManagedServiceStartResult = SandboxManagedServiceStateChange;
51
+ export interface SandboxManagedServiceAdapter {
52
+ getServiceLogs(options: SandboxManagedServiceLogsOptions): MaybePromise<TSandboxManagedServiceLogs>;
53
+ listServices(options: SandboxManagedServiceListOptions): MaybePromise<SandboxManagedServiceListResult>;
54
+ restartService(options: SandboxManagedServiceRestartOptions): MaybePromise<SandboxManagedServiceStartResult>;
55
+ startService(options: SandboxManagedServiceStartOptions): MaybePromise<SandboxManagedServiceStartResult>;
56
+ stopService(options: SandboxManagedServiceStopOptions): MaybePromise<SandboxManagedServiceStateChange>;
57
+ }
58
+ export type SandboxServiceProxyRequest = {
59
+ path: string;
60
+ request: IncomingMessage;
61
+ response: ServerResponse<IncomingMessage>;
62
+ service: ISandboxManagedService;
63
+ };
64
+ export interface SandboxServiceProxyAdapter {
65
+ proxyServiceRequest(request: SandboxServiceProxyRequest): MaybePromise<void>;
66
+ }
67
+ export declare function isSandboxManagedServiceAdapter(value: unknown): value is SandboxManagedServiceAdapter;
68
+ export declare function resolveSandboxManagedServiceAdapter(sandbox: TSandboxConfigurable | SandboxManagedServiceAdapter | null | undefined | unknown): SandboxManagedServiceAdapter | null;
69
+ export declare function isSandboxServiceProxyAdapter(value: unknown): value is SandboxServiceProxyAdapter;
70
+ export declare function resolveSandboxServiceProxyAdapter(sandbox: TSandboxConfigurable | SandboxServiceProxyAdapter | null | undefined | unknown): SandboxServiceProxyAdapter | null;
@@ -1,10 +1,36 @@
1
1
  import { TSandboxProviderMeta, TSandboxWorkForType } from '@xpert-ai/contracts';
2
2
  import { SandboxBackendProtocol } from './protocol';
3
+ export type SandboxWorkspaceBinding = {
4
+ /**
5
+ * Host-side bind source used by containerized sandboxes.
6
+ */
7
+ bindSource?: string;
8
+ /**
9
+ * Mount target inside the sandbox container, such as `/workspace`.
10
+ */
11
+ containerMountPath?: string;
12
+ /**
13
+ * Server-visible canonical volume root.
14
+ */
15
+ volumeRoot: string;
16
+ /**
17
+ * Concrete sandbox-visible working path derived from the mapped workspace root.
18
+ */
19
+ workspacePath: string;
20
+ /**
21
+ * Sandbox-visible workspace root that corresponds to `volumeRoot`.
22
+ */
23
+ workspaceRoot: string;
24
+ };
3
25
  export type SandboxProviderCreateOptions = {
4
26
  /**
5
27
  * Working space directory for the sandbox instance
6
28
  */
7
29
  workingDirectory?: string;
30
+ /**
31
+ * Explicit mapping between the server-visible volume root and the sandbox-visible workspace root.
32
+ */
33
+ workspaceBinding?: SandboxWorkspaceBinding;
8
34
  /**
9
35
  * Canonical sandbox environment identifier that owns the container lifecycle.
10
36
  */
@@ -0,0 +1,22 @@
1
+ import type { TSandboxConfigurable } from '@xpert-ai/contracts';
2
+ import type { MaybePromise } from './protocol';
3
+ export type SandboxTerminalExit = {
4
+ exitCode: number | null;
5
+ signal?: number | null;
6
+ };
7
+ export type SandboxTerminalOpenOptions = {
8
+ cols: number;
9
+ rows: number;
10
+ onExit: (event: SandboxTerminalExit) => void;
11
+ onOutput: (data: string) => void;
12
+ };
13
+ export interface SandboxTerminalSession {
14
+ close(): MaybePromise<void>;
15
+ resize(cols: number, rows: number): MaybePromise<void>;
16
+ write(data: string): MaybePromise<void>;
17
+ }
18
+ export interface SandboxTerminalAdapter {
19
+ open(options: SandboxTerminalOpenOptions): MaybePromise<SandboxTerminalSession>;
20
+ }
21
+ export declare function isSandboxTerminalAdapter(value: unknown): value is SandboxTerminalAdapter;
22
+ export declare function resolveSandboxTerminalAdapter(sandbox: TSandboxConfigurable | SandboxTerminalAdapter | null | undefined | unknown): SandboxTerminalAdapter | null;
@@ -1,26 +1,14 @@
1
- import { IXpertAgentExecution, JSONValue } from '@xpert-ai/contracts';
1
+ import { IXpertAgentExecution } from '@xpert-ai/contracts';
2
2
  import { Command } from '@nestjs/cqrs';
3
- import { Subscriber } from 'rxjs';
3
+ import { AgentMiddlewareWrapWorkflowNodeExecutionParams, AgentMiddlewareWrapWorkflowNodeExecutionResult } from '../../agent/middleware/runtime';
4
4
  /**
5
5
  * Wrap Workflow Node Execution Command
6
+ *
7
+ * @deprecated Prefer `IAgentMiddlewareContext.runtime.wrapWorkflowNodeExecution(...)` in middleware and plugin code.
6
8
  */
7
9
  export declare class WrapWorkflowNodeExecutionCommand<T = any> extends Command<T> {
8
- readonly fuc: (execution: Partial<IXpertAgentExecution>) => Promise<{
9
- output?: string | JSONValue;
10
- state: T;
11
- }>;
12
- readonly params: {
13
- execution: Partial<IXpertAgentExecution>;
14
- subscriber?: Subscriber<MessageEvent>;
15
- catchError?: (error: Error) => Promise<void>;
16
- };
10
+ readonly fuc: (execution: Partial<IXpertAgentExecution>) => Promise<AgentMiddlewareWrapWorkflowNodeExecutionResult<T>>;
11
+ readonly params: AgentMiddlewareWrapWorkflowNodeExecutionParams;
17
12
  static readonly type = "[Workflow] Wrap Workflow Node Execution";
18
- constructor(fuc: (execution: Partial<IXpertAgentExecution>) => Promise<{
19
- output?: string | JSONValue;
20
- state: T;
21
- }>, params: {
22
- execution: Partial<IXpertAgentExecution>;
23
- subscriber?: Subscriber<MessageEvent>;
24
- catchError?: (error: Error) => Promise<void>;
25
- });
13
+ constructor(fuc: (execution: Partial<IXpertAgentExecution>) => Promise<AgentMiddlewareWrapWorkflowNodeExecutionResult<T>>, params: AgentMiddlewareWrapWorkflowNodeExecutionParams);
26
14
  }