@xpert-ai/plugin-sdk 3.9.0 → 3.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/index.cjs.js +33 -1
- package/index.esm.js +30 -2
- package/package.json +1 -1
- package/src/lib/agent/middleware/runtime.d.ts +24 -1
- package/src/lib/agent/middleware/strategy.interface.d.ts +2 -0
- package/src/lib/ai-model/commands/create-model-client.command.d.ts +7 -14
- package/src/lib/sandbox/index.d.ts +1 -0
- package/src/lib/sandbox/managed-service.d.ts +70 -0
- package/src/lib/workflow/commands/wrap-workflow-node-execution.command.d.ts +7 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @xpert-ai/plugin-sdk
|
|
2
2
|
|
|
3
|
+
## 3.9.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8187f99: Update chatkit
|
|
8
|
+
- Updated dependencies [8187f99]
|
|
9
|
+
- @xpert-ai/contracts@3.9.2
|
|
10
|
+
|
|
11
|
+
## 3.9.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- e040933: Tenant shared workspace to organization's users
|
|
16
|
+
- Updated dependencies [e040933]
|
|
17
|
+
- @xpert-ai/contracts@3.9.1
|
|
18
|
+
- @xpert-ai/ocap-core@3.9.1
|
|
19
|
+
|
|
3
20
|
## 3.9.0
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
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 //
|
|
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,6 +2943,30 @@ 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
|
*
|
|
@@ -4066,6 +4094,8 @@ exports.getRequestContext = getRequestContext;
|
|
|
4066
4094
|
exports.getRequiredPermissionOperation = getRequiredPermissionOperation;
|
|
4067
4095
|
exports.isRemoteFile = isRemoteFile;
|
|
4068
4096
|
exports.isSandboxBackend = isSandboxBackend;
|
|
4097
|
+
exports.isSandboxManagedServiceAdapter = isSandboxManagedServiceAdapter;
|
|
4098
|
+
exports.isSandboxServiceProxyAdapter = isSandboxServiceProxyAdapter;
|
|
4069
4099
|
exports.isSandboxTerminalAdapter = isSandboxTerminalAdapter;
|
|
4070
4100
|
exports.isStructuredMessageType = isStructuredMessageType;
|
|
4071
4101
|
exports.loadYamlFile = loadYamlFile;
|
|
@@ -4074,6 +4104,8 @@ exports.mergeParentChildChunks = mergeParentChildChunks;
|
|
|
4074
4104
|
exports.normalizeContextSize = normalizeContextSize;
|
|
4075
4105
|
exports.resolveSandboxBackend = resolveSandboxBackend;
|
|
4076
4106
|
exports.resolveSandboxExecutionOptions = resolveSandboxExecutionOptions;
|
|
4107
|
+
exports.resolveSandboxManagedServiceAdapter = resolveSandboxManagedServiceAdapter;
|
|
4108
|
+
exports.resolveSandboxServiceProxyAdapter = resolveSandboxServiceProxyAdapter;
|
|
4077
4109
|
exports.resolveSandboxTerminalAdapter = resolveSandboxTerminalAdapter;
|
|
4078
4110
|
exports.runWithRequestContext = runWithRequestContext;
|
|
4079
4111
|
exports.secondsToMilliseconds = secondsToMilliseconds;
|
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 //
|
|
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,6 +2922,30 @@ 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
|
*
|
|
@@ -3913,4 +3941,4 @@ ViewExtensionProviderRegistry = __decorate([
|
|
|
3913
3941
|
|
|
3914
3942
|
const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
|
|
3915
3943
|
|
|
3916
|
-
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, isSandboxTerminalAdapter, isStructuredMessageType, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxTerminalAdapter, 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,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;
|
|
@@ -15,6 +16,7 @@ export interface IAgentMiddlewareContext {
|
|
|
15
16
|
knowledgebaseIds?: string[];
|
|
16
17
|
node: IWFNMiddleware;
|
|
17
18
|
tools: Map<string, StructuredToolInterface | RunnableToolLike>;
|
|
19
|
+
runtime: AgentMiddlewareRuntimeApi;
|
|
18
20
|
}
|
|
19
21
|
export interface IAgentMiddlewareStrategy<T = unknown> {
|
|
20
22
|
meta: TAgentMiddlewareMeta;
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
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 =
|
|
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
|
}
|
|
@@ -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,26 +1,14 @@
|
|
|
1
|
-
import { IXpertAgentExecution
|
|
1
|
+
import { IXpertAgentExecution } from '@xpert-ai/contracts';
|
|
2
2
|
import { Command } from '@nestjs/cqrs';
|
|
3
|
-
import {
|
|
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
|
-
|
|
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
|
}
|