@xpert-ai/plugin-sdk 3.18.4 → 3.18.5

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,29 @@
1
1
  # @xpert-ai/plugin-sdk
2
2
 
3
+ ## 3.18.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 6a51c17: Add a shared knowledge document language hint and bounded, model-free language detection for natural text chunk boundaries. Preserve Auto strategy routing, explicit separators, token limits, and parent-child behavior, and expose the requested and detected languages in chunk previews.
8
+ - 8402f72: Prepare the Xpert 3.18.5 patch release, including plugin-sdk.
9
+
10
+ Add knowledge document chunk token limits, question generation, automatic and
11
+ structure-aware chunking, spreadsheet table metadata, and format-specific scoped
12
+ parsers with diagnostics. Preserve OCR chunk limits and table context.
13
+
14
+ Extend MCP resource reads with scoped workspace files and the requested resource
15
+ URI, preserve confirmation sessions, and reauthorize queued execution. Add PPTX
16
+ preview and editing with binary workspace saves and edited downloads.
17
+
18
+ The target platform version is 3.18.5. Verify contracts, plugin-sdk, and xpert-ui
19
+ all resolve to this version in the release version PR, including changelogs,
20
+ internal dependency references, and lockfile entries.
21
+
22
+ - Updated dependencies [6a51c17]
23
+ - Updated dependencies [95ec638]
24
+ - Updated dependencies [8402f72]
25
+ - @xpert-ai/contracts@3.18.5
26
+
3
27
  ## 3.18.4
4
28
 
5
29
  ### Patch Changes
package/index.cjs.js CHANGED
@@ -3651,6 +3651,44 @@ class Speech2TextChatModel extends chat_models.BaseChatModel {
3651
3651
  }
3652
3652
 
3653
3653
  const encodingCache = new Map();
3654
+ /** Exact, model-independent text count for hard chunk limits. Treat special-token spellings as literal document text. */ function textEncoding() {
3655
+ const cacheKey = 'encoding:cl100k_base';
3656
+ let encoder = encodingCache.get(cacheKey);
3657
+ if (!encoder) {
3658
+ encoder = jsTiktoken.getEncoding('cl100k_base');
3659
+ encodingCache.set(cacheKey, encoder);
3660
+ }
3661
+ return encoder;
3662
+ }
3663
+ function countTextTokens(text) {
3664
+ if (!text) return 0;
3665
+ // A hard limit must fail if tokenization fails, never fall back to an estimate.
3666
+ return textEncoding().encode(text, [], []).length;
3667
+ }
3668
+ /** Token boundaries that also end on complete Unicode characters, in UTF-16 source offsets. */ function textTokenBoundaries(text) {
3669
+ const encoder = textEncoding();
3670
+ const tokens = encoder.encode(text, [], []);
3671
+ const boundaries = [
3672
+ {
3673
+ offset: 0,
3674
+ tokens: 0
3675
+ }
3676
+ ];
3677
+ let offset = 0;
3678
+ let start = 0;
3679
+ for(let end = 1; end <= tokens.length; end++){
3680
+ const decoded = encoder.decode(tokens.slice(start, end));
3681
+ if (!decoded || !text.startsWith(decoded, offset)) continue;
3682
+ offset += decoded.length;
3683
+ boundaries.push({
3684
+ offset,
3685
+ tokens: end
3686
+ });
3687
+ start = end;
3688
+ }
3689
+ if (offset !== text.length) throw new Error('Tokenization could not preserve the source text.');
3690
+ return boundaries;
3691
+ }
3654
3692
  /**
3655
3693
  * Fallback token estimation method.
3656
3694
  *
@@ -6862,6 +6900,7 @@ exports.calculateLLMUsagePrice = calculateLLMUsagePrice;
6862
6900
  exports.calculateModelPrice = calculateModelPrice;
6863
6901
  exports.calculateModelUsageCharge = calculateModelUsageCharge;
6864
6902
  exports.chunkText = chunkText;
6903
+ exports.countTextTokens = countTextTokens;
6865
6904
  exports.countTokensSafe = countTokensSafe;
6866
6905
  exports.createI18nInstance = createI18nInstance;
6867
6906
  exports.createPluginLogger = createPluginLogger;
@@ -6921,3 +6960,4 @@ exports.runWithRequestContext = runWithRequestContext;
6921
6960
  exports.secondsToMilliseconds = secondsToMilliseconds;
6922
6961
  exports.setDefaultTenantId = setDefaultTenantId;
6923
6962
  exports.sumTokenUsage = sumTokenUsage;
6963
+ exports.textTokenBoundaries = textTokenBoundaries;
package/index.esm.js CHANGED
@@ -3633,6 +3633,44 @@ class Speech2TextChatModel extends BaseChatModel {
3633
3633
  }
3634
3634
 
3635
3635
  const encodingCache = new Map();
3636
+ /** Exact, model-independent text count for hard chunk limits. Treat special-token spellings as literal document text. */ function textEncoding() {
3637
+ const cacheKey = 'encoding:cl100k_base';
3638
+ let encoder = encodingCache.get(cacheKey);
3639
+ if (!encoder) {
3640
+ encoder = getEncoding('cl100k_base');
3641
+ encodingCache.set(cacheKey, encoder);
3642
+ }
3643
+ return encoder;
3644
+ }
3645
+ function countTextTokens(text) {
3646
+ if (!text) return 0;
3647
+ // A hard limit must fail if tokenization fails, never fall back to an estimate.
3648
+ return textEncoding().encode(text, [], []).length;
3649
+ }
3650
+ /** Token boundaries that also end on complete Unicode characters, in UTF-16 source offsets. */ function textTokenBoundaries(text) {
3651
+ const encoder = textEncoding();
3652
+ const tokens = encoder.encode(text, [], []);
3653
+ const boundaries = [
3654
+ {
3655
+ offset: 0,
3656
+ tokens: 0
3657
+ }
3658
+ ];
3659
+ let offset = 0;
3660
+ let start = 0;
3661
+ for(let end = 1; end <= tokens.length; end++){
3662
+ const decoded = encoder.decode(tokens.slice(start, end));
3663
+ if (!decoded || !text.startsWith(decoded, offset)) continue;
3664
+ offset += decoded.length;
3665
+ boundaries.push({
3666
+ offset,
3667
+ tokens: end
3668
+ });
3669
+ start = end;
3670
+ }
3671
+ if (offset !== text.length) throw new Error('Tokenization could not preserve the source text.');
3672
+ return boundaries;
3673
+ }
3636
3674
  /**
3637
3675
  * Fallback token estimation method.
3638
3676
  *
@@ -6631,4 +6669,4 @@ XpertToolProviderCoordinator = __decorate([
6631
6669
  ])
6632
6670
  ], XpertToolProviderCoordinator);
6633
6671
 
6634
- export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorRuntimeCapability, ConnectorRuntimeFactoryCapability, ConnectorStrategyKey, ConnectorStrategyRegistry, 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, DecoratedAgentMiddlewareStrategy, DecoratedToolsetStrategy, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, EVOLUTION_RUNTIME_SERVICE_TOKEN, EVOLUTION_TARGET_PROVIDER, EvolutionChangeRuntimeCapability, EvolutionRuntimeCapability, EvolutionTargetProviderRegistry, EvolutionTargetProviderStrategy, 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, ImageGenerationModel, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, MCP_CAPABILITY_CHANGE_EVENT_TYPES, MODEL_OUTPUT_VALIDATION_ERROR_CODE, ModelOutputValidationError, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_VERSION_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_RUNTIME_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SANDBOX_WORKSPACE_MAPPER, 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, SandboxRuntimeProviderRegistry, SandboxRuntimeProviderStrategy, SandboxWorkspaceMapperRegistry, SandboxWorkspaceMapperStrategy, 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, VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN, VIDEO_GENERATION_SERVICE_TOKEN, VIDEO_GENERATOR_FAMILIES, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, VideoGenerationModel, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XPERT_TOOL_RESULT_FORMAT_VERSION, XpFileSystem, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, defineMcpApp, defineMcpCapabilities, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineXpertTool, derivePluginArtifactNamespace, describeXpertToolProvider, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, isDevelopmentSandboxRuntimeEnvironment, isModelOutputValidationError, isModelUsagePricingConfig, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, pluginArtifactTableName, prepareToolResult, processAsyncAIGCManagedJob, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage };
6672
+ export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorRuntimeCapability, ConnectorRuntimeFactoryCapability, ConnectorStrategyKey, ConnectorStrategyRegistry, 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, DecoratedAgentMiddlewareStrategy, DecoratedToolsetStrategy, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, EVOLUTION_RUNTIME_SERVICE_TOKEN, EVOLUTION_TARGET_PROVIDER, EvolutionChangeRuntimeCapability, EvolutionRuntimeCapability, EvolutionTargetProviderRegistry, EvolutionTargetProviderStrategy, 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, ImageGenerationModel, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, MCP_CAPABILITY_CHANGE_EVENT_TYPES, MODEL_OUTPUT_VALIDATION_ERROR_CODE, ModelOutputValidationError, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_VERSION_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_RUNTIME_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SANDBOX_WORKSPACE_MAPPER, 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, SandboxRuntimeProviderRegistry, SandboxRuntimeProviderStrategy, SandboxWorkspaceMapperRegistry, SandboxWorkspaceMapperStrategy, 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, VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN, VIDEO_GENERATION_SERVICE_TOKEN, VIDEO_GENERATOR_FAMILIES, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, VideoGenerationModel, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XPERT_TOOL_RESULT_FORMAT_VERSION, XpFileSystem, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, chunkText, countTextTokens, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, defineMcpApp, defineMcpCapabilities, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineXpertTool, derivePluginArtifactNamespace, describeXpertToolProvider, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, isDevelopmentSandboxRuntimeEnvironment, isModelOutputValidationError, isModelUsagePricingConfig, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, pluginArtifactTableName, prepareToolResult, processAsyncAIGCManagedJob, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage, textTokenBoundaries };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.18.4",
3
+ "version": "3.18.5",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@langchain/openai": "0.6.9",
20
- "@xpert-ai/contracts": "3.18.4",
20
+ "@xpert-ai/contracts": "3.18.5",
21
21
  "express": "^4.22.1",
22
22
  "js-tiktoken": "^1.0.21"
23
23
  },
@@ -1,4 +1,10 @@
1
1
  import type { TiktokenEncoding } from 'js-tiktoken';
2
+ export declare function countTextTokens(text: string): number;
3
+ /** Token boundaries that also end on complete Unicode characters, in UTF-16 source offsets. */
4
+ export declare function textTokenBoundaries(text: string): {
5
+ offset: number;
6
+ tokens: number;
7
+ }[];
2
8
  /**
3
9
  * Count tokens in text
4
10
  * 1) Preferred: js-tiktoken precise encoding
@@ -1,7 +1,6 @@
1
1
  import type { McpRequiredContext } from '@xpert-ai/contracts';
2
- import type { ToolExecutionContext } from '../toolset/tool-execution-context';
3
2
  import type { McpCompletionHandler } from './completion';
4
- import type { McpResourceReadResult } from './resource';
3
+ import type { McpResourceReadResult, ResourceReadContext } from './resource';
5
4
  export interface McpResourceTemplateArgument {
6
5
  required: boolean;
7
6
  description?: string;
@@ -15,7 +14,7 @@ export interface McpResourceTemplateDefinition {
15
14
  arguments: Record<string, McpResourceTemplateArgument>;
16
15
  requiredContext?: McpRequiredContext[];
17
16
  cacheTtlMs?: number;
18
- read(arguments_: Record<string, string>, context: ToolExecutionContext): McpResourceReadResult | Promise<McpResourceReadResult>;
17
+ read(arguments_: Record<string, string>, context: ResourceReadContext): McpResourceReadResult | Promise<McpResourceReadResult>;
19
18
  complete?: McpCompletionHandler;
20
19
  }
21
20
  export declare function defineMcpResourceTemplate(definition: McpResourceTemplateDefinition): Readonly<McpResourceTemplateDefinition>;
@@ -1,5 +1,9 @@
1
1
  import type { JSONValue, McpRequiredContext } from '@xpert-ai/contracts';
2
2
  import type { ToolExecutionContext } from '../toolset/tool-execution-context';
3
+ export interface ResourceReadContext extends ToolExecutionContext {
4
+ /** Exact URI requested by resources/read, including query parameters. */
5
+ resourceUri: string;
6
+ }
3
7
  export interface McpResourceContent {
4
8
  uri: string;
5
9
  mimeType?: string;
@@ -18,6 +22,6 @@ export interface McpResourceDefinition {
18
22
  mimeType?: string;
19
23
  requiredContext?: McpRequiredContext[];
20
24
  cacheTtlMs?: number;
21
- read(context: ToolExecutionContext): McpResourceReadResult | Promise<McpResourceReadResult>;
25
+ read(context: ResourceReadContext): McpResourceReadResult | Promise<McpResourceReadResult>;
22
26
  }
23
27
  export declare function defineMcpResource(definition: McpResourceDefinition): Readonly<McpResourceDefinition>;
@@ -1,6 +1,19 @@
1
- import { IDocumentChunkerProvider, KnowledgeStructureEnum } from '@xpert-ai/contracts';
1
+ import { IDocumentChunkerProvider, KnowledgeChunkingDecision, KnowledgeChunkLanguage, KnowledgeChunkLanguageHint, KnowledgeChunkLanguageDecision, KnowledgeStructureEnum } from '@xpert-ai/contracts';
2
2
  import { DocumentInterface } from '@langchain/core/documents';
3
3
  import { ChunkMetadata } from '../types';
4
+ export interface TextSplitterExecutionContext {
5
+ /** Public parser-level token cap. Providers must not persist a second copy in their own options. */
6
+ maxChunkTokens?: number;
7
+ languageHint?: KnowledgeChunkLanguageHint;
8
+ /** Resolved once at the execution boundary, shared by all fragments of a document. */
9
+ resolvedLanguage?: KnowledgeChunkLanguage;
10
+ resolvedLanguages?: ReadonlyMap<DocumentInterface, KnowledgeChunkLanguage>;
11
+ }
12
+ export interface TextSplitterResult {
13
+ chunks: DocumentInterface<ChunkMetadata>[];
14
+ decisions?: KnowledgeChunkingDecision[];
15
+ languages?: KnowledgeChunkLanguageDecision[];
16
+ }
4
17
  /**
5
18
  * Split text content into chunks for embedding and retrieval
6
19
  */
@@ -17,7 +30,5 @@ export interface ITextSplitterStrategy<TConfig = any> {
17
30
  /**
18
31
  * Split a text into chunks and pages (if applicable)
19
32
  */
20
- splitDocuments(documents: DocumentInterface[], options?: TConfig): Promise<{
21
- chunks: DocumentInterface<ChunkMetadata>[];
22
- }>;
33
+ splitDocuments(documents: DocumentInterface[], options?: TConfig, context?: TextSplitterExecutionContext): Promise<TextSplitterResult>;
23
34
  }
@@ -1,9 +1,12 @@
1
1
  import { IDocumentProcessorProvider, IIntegration, IKnowledgeDocument } from '@xpert-ai/contracts';
2
2
  import { Permissions, XpFileSystem } from '../../core/index';
3
+ import type { WorkspaceFileScope } from '../../runtime/capabilities/workspace-files';
3
4
  import { ChunkMetadata } from '../types';
4
5
  export type TDocumentTransformerConfig = {
5
6
  stage: 'test' | 'prod';
6
7
  tempDir?: string;
8
+ /** Trusted host scope for background transforms using Workspace Files and Sandbox Jobs. */
9
+ fileScope?: WorkspaceFileScope;
7
10
  permissions?: {
8
11
  fileSystem?: XpFileSystem;
9
12
  integration?: IIntegration;
@@ -232,6 +232,8 @@ export type WorkspaceSearchUnderstandingChunksInput = WorkspaceFileScope & {
232
232
  * understanding files in Xpert workspace Volumes.
233
233
  */
234
234
  export interface WorkspaceFilesApi {
235
+ /** Host-bound storage identity for restoring the same scope in durable jobs. */
236
+ readonly scope?: Readonly<WorkspaceFileScope>;
235
237
  /** Upload raw bytes into an explicitly scoped workspace Volume. */
236
238
  uploadBuffer(input: WorkspaceUploadBufferInput): Promise<WorkspaceFile>;
237
239
  /** Register an existing workspace file with the platform understanding pipeline. */