@xpert-ai/plugin-sdk 3.21.1 → 3.22.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/index.cjs.js CHANGED
@@ -35,6 +35,7 @@ var env = require('@langchain/core/utils/env');
35
35
  var modelProviderHttpClient = require('./model-provider-http-client.cjs.js');
36
36
  var jsTiktoken = require('js-tiktoken');
37
37
  var base$1 = require('@langchain/core/language_models/base');
38
+ var zod = require('zod');
38
39
  var v3 = require('zod/v3');
39
40
  var results = require('./results.cjs.js');
40
41
  var connector = require('./connector.cjs.js');
@@ -124,6 +125,9 @@ function assertPluginArtifactNamePart(value, label) {
124
125
  throw new Error(`${label} must contain only lowercase letters, numbers, and underscores`);
125
126
  }
126
127
  }
128
+ function isPluginArtifactNamespace(value) {
129
+ return typeof value === 'string' && ARTIFACT_NAMESPACE_PATTERN.test(value);
130
+ }
127
131
 
128
132
  /** Call after the business mutation commits. A display failure must not retry that mutation. */ async function emitResourceCard(card, config) {
129
133
  await dispatch.dispatchCustomEvent(contracts.ChatMessageEventTypeEnum.ON_CHAT_EVENT, contracts.createResourceCardContent(card), config);
@@ -347,10 +351,9 @@ class RequestContext {
347
351
  * server RequestContext. Authentication guards resolve JWTs, API keys and
348
352
  * ChatKit client secrets before this check; the bearer is not always a JWT.
349
353
  */ static hasPermissions(findPermissions, throwError) {
350
- const permissions = this.currentPermissions();
351
- if (permissions.length > 0) {
352
- const found = permissions.filter((value)=>findPermissions.indexOf(value) >= 0);
353
- if (found.length === findPermissions.length) return true;
354
+ const permissions = new Set(this.currentPermissions());
355
+ if (permissions.size > 0 && findPermissions.every((permission)=>permissions.has(permission))) {
356
+ return true;
354
357
  }
355
358
  if (throwError) {
356
359
  throw new common.HttpException('Unauthorized', common.HttpStatus.UNAUTHORIZED);
@@ -2738,6 +2741,46 @@ function normalizeCurrency(currency) {
2738
2741
  return currency.trim().toUpperCase();
2739
2742
  }
2740
2743
 
2744
+ /** Apply an explicit saved configuration without mutating a shared predefined schema. */ function applyModelConfiguration(model, configuration, schema) {
2745
+ var _schema_label, _schema_parameter_rules;
2746
+ const result = _extends._extends({}, schema, {
2747
+ model,
2748
+ label: (_schema_label = schema == null ? void 0 : schema.label) != null ? _schema_label : {
2749
+ en_US: model,
2750
+ zh_Hans: model
2751
+ },
2752
+ model_type: configuration.modelType,
2753
+ fetch_from: contracts.FetchFrom.CUSTOMIZABLE_MODEL,
2754
+ model_properties: _extends._extends({}, schema == null ? void 0 : schema.model_properties, {
2755
+ [contracts.ModelPropertyKey.CONTEXT_SIZE]: configuration.contextSize
2756
+ }),
2757
+ parameter_rules: [
2758
+ ...(_schema_parameter_rules = schema == null ? void 0 : schema.parameter_rules) != null ? _schema_parameter_rules : []
2759
+ ]
2760
+ });
2761
+ if (configuration.modelType === contracts.AiModelTypeEnum.LLM) {
2762
+ result.features = [
2763
+ ...configuration.features
2764
+ ];
2765
+ result.model_properties[contracts.ModelPropertyKey.MODE] = 'chat';
2766
+ result.parameter_rules = [
2767
+ ...result.parameter_rules.filter((rule)=>rule.name !== 'max_tokens'),
2768
+ {
2769
+ name: 'max_tokens',
2770
+ label: {
2771
+ en_US: 'Max output tokens',
2772
+ zh_Hans: '最大输出 Token'
2773
+ },
2774
+ type: contracts.ParameterType.INT,
2775
+ min: 1,
2776
+ max: configuration.maxOutputTokens,
2777
+ default: configuration.defaultMaxTokens
2778
+ }
2779
+ ];
2780
+ }
2781
+ return result;
2782
+ }
2783
+
2741
2784
  var AIModel_1;
2742
2785
  exports.AIModel = AIModel_1 = class AIModel {
2743
2786
  getRealtimeModel(_copilotModel) {
@@ -2799,6 +2842,13 @@ exports.AIModel = AIModel_1 = class AIModel {
2799
2842
  getModelSchema(model, credentials) {
2800
2843
  const models = this.predefinedModels();
2801
2844
  const schema = models.find((_)=>_.model === model);
2845
+ const configuration = contracts.readModelConfiguration(credentials);
2846
+ if (configuration) {
2847
+ if (configuration.modelType !== this.modelType) {
2848
+ throw new Error('Saved model configuration does not match its model type');
2849
+ }
2850
+ return applyModelConfiguration(model, configuration, schema != null ? schema : this.getCustomizableModelSchemaFromCredentials(model, credentials));
2851
+ }
2802
2852
  if (schema) {
2803
2853
  return schema;
2804
2854
  }
@@ -4011,6 +4061,62 @@ Reflect.defineMetadata(COMMAND_METADATA$1, {
4011
4061
  };
4012
4062
  }
4013
4063
 
4064
+ const modelListSchema = zod.z.object({
4065
+ data: zod.z.array(zod.z.object({
4066
+ id: zod.z.string().trim().min(1).max(512),
4067
+ active: zod.z.boolean().optional(),
4068
+ name: zod.z.string().optional(),
4069
+ model_type: zod.z.string().optional()
4070
+ }))
4071
+ });
4072
+ /** OpenAI-compatible discovery transport and import suggestions, never runtime routing. */ async function discoverOpenAIModels(options) {
4073
+ var _options_fetchImpl, _options_path;
4074
+ const response = await ((_options_fetchImpl = options.fetchImpl) != null ? _options_fetchImpl : fetch)(`${options.baseUrl.replace(/\/+$/, '')}/${((_options_path = options.path) != null ? _options_path : 'models').replace(/^\/+/, '')}`, {
4075
+ method: 'GET',
4076
+ headers: {
4077
+ Authorization: options.authorization,
4078
+ Accept: 'application/json'
4079
+ },
4080
+ signal: AbortSignal.timeout(15000)
4081
+ });
4082
+ if (!response.ok) throw new Error(`Model discovery returned HTTP ${response.status}`);
4083
+ const payload = modelListSchema.parse(await response.json());
4084
+ const models = new Map();
4085
+ for (const entry of payload.data){
4086
+ var _options_predefinedModels;
4087
+ if (entry.active === false || models.has(entry.id)) continue;
4088
+ const known = (_options_predefinedModels = options.predefinedModels) == null ? void 0 : _options_predefinedModels.find((model)=>model.model === entry.id);
4089
+ // Explicit unsupported types must not fall through to name-based guesses.
4090
+ if (entry.model_type && !contracts.isDiscoverableModelType(entry.model_type)) continue;
4091
+ if (known && !contracts.isDiscoverableModelType(known.model_type)) continue;
4092
+ var _entry_model_type, _ref;
4093
+ const modelType = (_ref = (_entry_model_type = entry.model_type) != null ? _entry_model_type : known == null ? void 0 : known.model_type) != null ? _ref : suggestModelType(entry.id);
4094
+ const typeSource = entry.model_type ? 'provider' : known ? 'catalog' : modelType ? 'name' : 'unknown';
4095
+ const supportedType = contracts.isDiscoverableModelType(modelType) ? modelType : null;
4096
+ models.set(entry.id, _extends._extends({
4097
+ model: entry.id,
4098
+ label: entry.name || entry.id,
4099
+ modelType: supportedType,
4100
+ typeSource
4101
+ }, supportedType ? {
4102
+ configuration: contracts.configurationFromModel(supportedType, known)
4103
+ } : {}));
4104
+ }
4105
+ return [
4106
+ ...models.values()
4107
+ ];
4108
+ }
4109
+ function suggestModelType(name) {
4110
+ if (/(?:rerank|reranker)/i.test(name)) return contracts.AiModelTypeEnum.RERANK;
4111
+ if (/(?:embedding|embed)/i.test(name)) return contracts.AiModelTypeEnum.TEXT_EMBEDDING;
4112
+ // Unknown and opaque IDs stay unclassified, including unsupported image/audio/video models.
4113
+ if (/(?:image|vision-exp|video|tts|whisper|speech|audio|wan\d|seedance|seedream)/i.test(name)) return null;
4114
+ if (/(?:^|[\/_-])(?:gpt|qwen|deepseek|glm|kimi|llama|mistral|claude|minimax|gemini|chat|doubao)(?:[\d._/-]|$)/i.test(name)) {
4115
+ return contracts.AiModelTypeEnum.LLM;
4116
+ }
4117
+ return null;
4118
+ }
4119
+
4014
4120
  const SKILL_SOURCE_PROVIDER = 'SKILL_SOURCE_PROVIDER';
4015
4121
  const SkillSourceProviderStrategy = (provider)=>common.applyDecorators(common.SetMetadata(SKILL_SOURCE_PROVIDER, provider), common.SetMetadata(STRATEGY_META_KEY, SKILL_SOURCE_PROVIDER));
4016
4122
 
@@ -6264,6 +6370,10 @@ function escapeInlineScript(value) {
6264
6370
 
6265
6371
  const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
6266
6372
 
6373
+ const ViewMiddlewareRuntimeCapability = modelProvider.createRuntimeCapability('platform.view.middleware-runtime', {
6374
+ description: 'Resolve a View capability through its authorized Assistant middleware and scoped runtime.'
6375
+ });
6376
+
6267
6377
  /** Platform-owned real-time collaboration capability available to scoped plugin runtimes. */ const CollaborationRuntimeCapability = modelProvider.createRuntimeCapability('platform.collaboration', {
6268
6378
  description: 'Create, synchronize, persist, authorize, and observe platform-managed real-time collaboration documents.'
6269
6379
  });
@@ -10179,6 +10289,10 @@ Object.defineProperty(exports, "agentResultPathSchema", {
10179
10289
  enumerable: true,
10180
10290
  get: function () { return contracts.agentResultPathSchema; }
10181
10291
  });
10292
+ Object.defineProperty(exports, "configurationFromModel", {
10293
+ enumerable: true,
10294
+ get: function () { return contracts.configurationFromModel; }
10295
+ });
10182
10296
  Object.defineProperty(exports, "createResourceCardContent", {
10183
10297
  enumerable: true,
10184
10298
  get: function () { return contracts.createResourceCardContent; }
@@ -10411,6 +10525,7 @@ exports.VIEW_EXTENSION_PROVIDER = VIEW_EXTENSION_PROVIDER;
10411
10525
  exports.VectorStoreStrategy = VectorStoreStrategy;
10412
10526
  exports.VideoGenerationModel = VideoGenerationModel;
10413
10527
  exports.ViewExtensionProvider = ViewExtensionProvider;
10528
+ exports.ViewMiddlewareRuntimeCapability = ViewMiddlewareRuntimeCapability;
10414
10529
  exports.WORKFLOW_NODE_STRATEGY = WORKFLOW_NODE_STRATEGY;
10415
10530
  exports.WORKFLOW_TRIGGER_STRATEGY = WORKFLOW_TRIGGER_STRATEGY;
10416
10531
  exports.WorkflowNodeStrategy = WorkflowNodeStrategy;
@@ -10438,6 +10553,7 @@ exports.agentRuntimeResultClaimSchema = agentRuntimeResultClaimSchema;
10438
10553
  exports.agentRuntimeResultConsumptionKey = agentRuntimeResultConsumptionKey;
10439
10554
  exports.als = als;
10440
10555
  exports.appendSandboxMessage = appendSandboxMessage;
10556
+ exports.applyModelConfiguration = applyModelConfiguration;
10441
10557
  exports.buildSandboxTimeoutMessage = buildSandboxTimeoutMessage;
10442
10558
  exports.calcTokenUsage = calcTokenUsage;
10443
10559
  exports.calculateLLMUsagePrice = calculateLLMUsagePrice;
@@ -10458,6 +10574,7 @@ exports.defineMcpResourceTemplate = defineMcpResourceTemplate;
10458
10574
  exports.defineXpertTool = defineXpertTool;
10459
10575
  exports.derivePluginArtifactNamespace = derivePluginArtifactNamespace;
10460
10576
  exports.describeXpertToolProvider = describeXpertToolProvider;
10577
+ exports.discoverOpenAIModels = discoverOpenAIModels;
10461
10578
  exports.downloadRemoteFile = downloadRemoteFile;
10462
10579
  exports.emitResourceCard = emitResourceCard;
10463
10580
  exports.formatSandboxTimeout = formatSandboxTimeout;
@@ -10475,6 +10592,7 @@ exports.isAgentInvocationTerminal = isAgentInvocationTerminal;
10475
10592
  exports.isDevelopmentSandboxRuntimeEnvironment = isDevelopmentSandboxRuntimeEnvironment;
10476
10593
  exports.isModelOutputValidationError = isModelOutputValidationError;
10477
10594
  exports.isModelUsagePricingConfig = isModelUsagePricingConfig;
10595
+ exports.isPluginArtifactNamespace = isPluginArtifactNamespace;
10478
10596
  exports.isRemoteFile = isRemoteFile;
10479
10597
  exports.isSandboxBackend = isSandboxBackend;
10480
10598
  exports.isSandboxManagedServiceAdapter = isSandboxManagedServiceAdapter;
package/index.esm.js CHANGED
@@ -2,8 +2,8 @@ import { Module, applyDecorators, SetMetadata, HttpException, HttpStatus, BadReq
2
2
  import { MODULE_METADATA } from '@nestjs/common/constants';
3
3
  import { pick } from 'lodash-es';
4
4
  import { dispatchCustomEvent } from '@langchain/core/callbacks/dispatch';
5
- import { ChatMessageEventTypeEnum, createResourceCardContent, LanguagesEnum, ParameterType, AiModelTypeEnum, PriceType, FetchFrom, ModelFeature, ModelPropertyKey, projectTaskExecutionContextSchema, projectTaskExecutionReferenceSchema, agentRuntimeProgressSchema, agentInvocationTerminalStatusSchema, MCP_REQUIRED_CONTEXTS, MCP_CAPABILITY_APPROVAL_MODES, MCP_TOOL_RISKS, MCP_TOOL_SIDE_EFFECTS, MCP_TOOL_IDEMPOTENCY, MCP_CAPABILITY_VISIBILITIES, PLUGIN_COMPONENT_TYPE } from '@xpert-ai/contracts';
6
- export { ASSISTANT_CHAT_SEND_MESSAGE_COMMAND, ASSISTANT_CONTEXT_SET_COMMAND, agentOutputDeliverySchema, agentResultPathSchema, createResourceCardContent, parseResourceCard, resourceCardId } from '@xpert-ai/contracts';
5
+ import { ChatMessageEventTypeEnum, createResourceCardContent, LanguagesEnum, ParameterType, AiModelTypeEnum, PriceType, FetchFrom, ModelPropertyKey, readModelConfiguration, ModelFeature, isDiscoverableModelType, configurationFromModel, projectTaskExecutionContextSchema, projectTaskExecutionReferenceSchema, agentRuntimeProgressSchema, agentInvocationTerminalStatusSchema, MCP_REQUIRED_CONTEXTS, MCP_CAPABILITY_APPROVAL_MODES, MCP_TOOL_RISKS, MCP_TOOL_SIDE_EFFECTS, MCP_TOOL_IDEMPOTENCY, MCP_CAPABILITY_VISIBILITIES, PLUGIN_COMPONENT_TYPE } from '@xpert-ai/contracts';
6
+ export { ASSISTANT_CHAT_SEND_MESSAGE_COMMAND, ASSISTANT_CONTEXT_SET_COMMAND, agentOutputDeliverySchema, agentResultPathSchema, configurationFromModel, createResourceCardContent, parseResourceCard, resourceCardId } from '@xpert-ai/contracts';
7
7
  import { DiscoveryService, Reflector } from '@nestjs/core';
8
8
  import { Subject, filter } from 'rxjs';
9
9
  import { _ as _extends } from './_extends.esm.js';
@@ -38,7 +38,8 @@ import { getEnvironmentVariable } from '@langchain/core/utils/env';
38
38
  export { ModelProviderHttpClient, ModelProviderHttpError } from './model-provider-http-client.esm.js';
39
39
  import { getEncodingNameForModel, encodingForModel, getEncoding } from 'js-tiktoken';
40
40
  import { getModelContextSize as getModelContextSize$1 } from '@langchain/core/language_models/base';
41
- import { z, ZodError, ZodFirstPartyTypeKind } from 'zod/v3';
41
+ import { z } from 'zod';
42
+ import { z as z$1, ZodError, ZodFirstPartyTypeKind } from 'zod/v3';
42
43
  export { A as AGENT_TASK_RESULTS_FEATURE, a as agentResultItemSchema, b as agentTaskResultSchema } from './results.esm.js';
43
44
  import { assertConnectorDefinition } from './connector.esm.js';
44
45
  export { CONNECTOR_AUTHORIZATION_MODES, CONNECTOR_SCOPE_TYPES, getConnectorAuthMethods, getConnectorAuthorizationModes } from './connector.esm.js';
@@ -106,6 +107,9 @@ function assertPluginArtifactNamePart(value, label) {
106
107
  throw new Error(`${label} must contain only lowercase letters, numbers, and underscores`);
107
108
  }
108
109
  }
110
+ function isPluginArtifactNamespace(value) {
111
+ return typeof value === 'string' && ARTIFACT_NAMESPACE_PATTERN.test(value);
112
+ }
109
113
 
110
114
  /** Call after the business mutation commits. A display failure must not retry that mutation. */ async function emitResourceCard(card, config) {
111
115
  await dispatchCustomEvent(ChatMessageEventTypeEnum.ON_CHAT_EVENT, createResourceCardContent(card), config);
@@ -329,10 +333,9 @@ class RequestContext {
329
333
  * server RequestContext. Authentication guards resolve JWTs, API keys and
330
334
  * ChatKit client secrets before this check; the bearer is not always a JWT.
331
335
  */ static hasPermissions(findPermissions, throwError) {
332
- const permissions = this.currentPermissions();
333
- if (permissions.length > 0) {
334
- const found = permissions.filter((value)=>findPermissions.indexOf(value) >= 0);
335
- if (found.length === findPermissions.length) return true;
336
+ const permissions = new Set(this.currentPermissions());
337
+ if (permissions.size > 0 && findPermissions.every((permission)=>permissions.has(permission))) {
338
+ return true;
336
339
  }
337
340
  if (throwError) {
338
341
  throw new HttpException('Unauthorized', HttpStatus.UNAUTHORIZED);
@@ -2720,6 +2723,46 @@ function normalizeCurrency(currency) {
2720
2723
  return currency.trim().toUpperCase();
2721
2724
  }
2722
2725
 
2726
+ /** Apply an explicit saved configuration without mutating a shared predefined schema. */ function applyModelConfiguration(model, configuration, schema) {
2727
+ var _schema_label, _schema_parameter_rules;
2728
+ const result = _extends({}, schema, {
2729
+ model,
2730
+ label: (_schema_label = schema == null ? void 0 : schema.label) != null ? _schema_label : {
2731
+ en_US: model,
2732
+ zh_Hans: model
2733
+ },
2734
+ model_type: configuration.modelType,
2735
+ fetch_from: FetchFrom.CUSTOMIZABLE_MODEL,
2736
+ model_properties: _extends({}, schema == null ? void 0 : schema.model_properties, {
2737
+ [ModelPropertyKey.CONTEXT_SIZE]: configuration.contextSize
2738
+ }),
2739
+ parameter_rules: [
2740
+ ...(_schema_parameter_rules = schema == null ? void 0 : schema.parameter_rules) != null ? _schema_parameter_rules : []
2741
+ ]
2742
+ });
2743
+ if (configuration.modelType === AiModelTypeEnum.LLM) {
2744
+ result.features = [
2745
+ ...configuration.features
2746
+ ];
2747
+ result.model_properties[ModelPropertyKey.MODE] = 'chat';
2748
+ result.parameter_rules = [
2749
+ ...result.parameter_rules.filter((rule)=>rule.name !== 'max_tokens'),
2750
+ {
2751
+ name: 'max_tokens',
2752
+ label: {
2753
+ en_US: 'Max output tokens',
2754
+ zh_Hans: '最大输出 Token'
2755
+ },
2756
+ type: ParameterType.INT,
2757
+ min: 1,
2758
+ max: configuration.maxOutputTokens,
2759
+ default: configuration.defaultMaxTokens
2760
+ }
2761
+ ];
2762
+ }
2763
+ return result;
2764
+ }
2765
+
2723
2766
  var AIModel_1;
2724
2767
  let AIModel = AIModel_1 = class AIModel {
2725
2768
  getRealtimeModel(_copilotModel) {
@@ -2781,6 +2824,13 @@ let AIModel = AIModel_1 = class AIModel {
2781
2824
  getModelSchema(model, credentials) {
2782
2825
  const models = this.predefinedModels();
2783
2826
  const schema = models.find((_)=>_.model === model);
2827
+ const configuration = readModelConfiguration(credentials);
2828
+ if (configuration) {
2829
+ if (configuration.modelType !== this.modelType) {
2830
+ throw new Error('Saved model configuration does not match its model type');
2831
+ }
2832
+ return applyModelConfiguration(model, configuration, schema != null ? schema : this.getCustomizableModelSchemaFromCredentials(model, credentials));
2833
+ }
2784
2834
  if (schema) {
2785
2835
  return schema;
2786
2836
  }
@@ -3993,6 +4043,62 @@ Reflect.defineMetadata(COMMAND_METADATA$1, {
3993
4043
  };
3994
4044
  }
3995
4045
 
4046
+ const modelListSchema = z.object({
4047
+ data: z.array(z.object({
4048
+ id: z.string().trim().min(1).max(512),
4049
+ active: z.boolean().optional(),
4050
+ name: z.string().optional(),
4051
+ model_type: z.string().optional()
4052
+ }))
4053
+ });
4054
+ /** OpenAI-compatible discovery transport and import suggestions, never runtime routing. */ async function discoverOpenAIModels(options) {
4055
+ var _options_fetchImpl, _options_path;
4056
+ const response = await ((_options_fetchImpl = options.fetchImpl) != null ? _options_fetchImpl : fetch)(`${options.baseUrl.replace(/\/+$/, '')}/${((_options_path = options.path) != null ? _options_path : 'models').replace(/^\/+/, '')}`, {
4057
+ method: 'GET',
4058
+ headers: {
4059
+ Authorization: options.authorization,
4060
+ Accept: 'application/json'
4061
+ },
4062
+ signal: AbortSignal.timeout(15000)
4063
+ });
4064
+ if (!response.ok) throw new Error(`Model discovery returned HTTP ${response.status}`);
4065
+ const payload = modelListSchema.parse(await response.json());
4066
+ const models = new Map();
4067
+ for (const entry of payload.data){
4068
+ var _options_predefinedModels;
4069
+ if (entry.active === false || models.has(entry.id)) continue;
4070
+ const known = (_options_predefinedModels = options.predefinedModels) == null ? void 0 : _options_predefinedModels.find((model)=>model.model === entry.id);
4071
+ // Explicit unsupported types must not fall through to name-based guesses.
4072
+ if (entry.model_type && !isDiscoverableModelType(entry.model_type)) continue;
4073
+ if (known && !isDiscoverableModelType(known.model_type)) continue;
4074
+ var _entry_model_type, _ref;
4075
+ const modelType = (_ref = (_entry_model_type = entry.model_type) != null ? _entry_model_type : known == null ? void 0 : known.model_type) != null ? _ref : suggestModelType(entry.id);
4076
+ const typeSource = entry.model_type ? 'provider' : known ? 'catalog' : modelType ? 'name' : 'unknown';
4077
+ const supportedType = isDiscoverableModelType(modelType) ? modelType : null;
4078
+ models.set(entry.id, _extends({
4079
+ model: entry.id,
4080
+ label: entry.name || entry.id,
4081
+ modelType: supportedType,
4082
+ typeSource
4083
+ }, supportedType ? {
4084
+ configuration: configurationFromModel(supportedType, known)
4085
+ } : {}));
4086
+ }
4087
+ return [
4088
+ ...models.values()
4089
+ ];
4090
+ }
4091
+ function suggestModelType(name) {
4092
+ if (/(?:rerank|reranker)/i.test(name)) return AiModelTypeEnum.RERANK;
4093
+ if (/(?:embedding|embed)/i.test(name)) return AiModelTypeEnum.TEXT_EMBEDDING;
4094
+ // Unknown and opaque IDs stay unclassified, including unsupported image/audio/video models.
4095
+ if (/(?:image|vision-exp|video|tts|whisper|speech|audio|wan\d|seedance|seedream)/i.test(name)) return null;
4096
+ if (/(?:^|[\/_-])(?:gpt|qwen|deepseek|glm|kimi|llama|mistral|claude|minimax|gemini|chat|doubao)(?:[\d._/-]|$)/i.test(name)) {
4097
+ return AiModelTypeEnum.LLM;
4098
+ }
4099
+ return null;
4100
+ }
4101
+
3996
4102
  const SKILL_SOURCE_PROVIDER = 'SKILL_SOURCE_PROVIDER';
3997
4103
  const SkillSourceProviderStrategy = (provider)=>applyDecorators(SetMetadata(SKILL_SOURCE_PROVIDER, provider), SetMetadata(STRATEGY_META_KEY, SKILL_SOURCE_PROVIDER));
3998
4104
 
@@ -4125,79 +4231,79 @@ const AGENT_CHAT_DISPATCH_MESSAGE_TYPE = defineAgentMessageType('chat_dispatch',
4125
4231
  const AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = 'steer_target_not_running';
4126
4232
 
4127
4233
  /** Captured by an authorized host command. Describing a recipient never authorizes delivery. */ const replyConversation = {
4128
- conversationId: z.string().uuid(),
4129
- threadId: z.string().trim().min(1).max(256)
4234
+ conversationId: z$1.string().uuid(),
4235
+ threadId: z$1.string().trim().min(1).max(256)
4130
4236
  };
4131
- const agentRuntimeReplyTargetSchema = z.discriminatedUnion('type', [
4132
- z.object(_extends({}, replyConversation, {
4133
- type: z.literal('xpert').optional(),
4134
- xpertId: z.string().uuid(),
4135
- agentKey: z.string().trim().min(1).max(256)
4237
+ const agentRuntimeReplyTargetSchema = z$1.discriminatedUnion('type', [
4238
+ z$1.object(_extends({}, replyConversation, {
4239
+ type: z$1.literal('xpert').optional(),
4240
+ xpertId: z$1.string().uuid(),
4241
+ agentKey: z$1.string().trim().min(1).max(256)
4136
4242
  })).strict(),
4137
- z.object(_extends({}, replyConversation, {
4138
- type: z.literal('project_agent'),
4139
- projectId: z.string().uuid(),
4140
- agentKey: z.literal('general_agent')
4243
+ z$1.object(_extends({}, replyConversation, {
4244
+ type: z$1.literal('project_agent'),
4245
+ projectId: z$1.string().uuid(),
4246
+ agentKey: z$1.literal('general_agent')
4141
4247
  })).strict()
4142
4248
  ]);
4143
- /** Persist with the immutable invocation request before launch. No credentials or arbitrary routing headers. */ const agentInvocationDispatchContextSchema = z.object({
4144
- version: z.literal(1),
4145
- requestId: z.string().uuid(),
4146
- sourceMessageId: z.string().trim().min(1).max(256),
4249
+ /** Persist with the immutable invocation request before launch. No credentials or arbitrary routing headers. */ const agentInvocationDispatchContextSchema = z$1.object({
4250
+ version: z$1.literal(1),
4251
+ requestId: z$1.string().uuid(),
4252
+ sourceMessageId: z$1.string().trim().min(1).max(256),
4147
4253
  replyTo: agentRuntimeReplyTargetSchema,
4148
4254
  projectTask: projectTaskExecutionContextSchema.optional()
4149
4255
  }).strict();
4150
4256
 
4151
4257
  const AGENT_RUNTIME_EVENT_MESSAGE_TYPE = defineAgentMessageType('runtime_event', 1);
4152
4258
  const reference = {
4153
- version: z.literal(1),
4154
- invocationId: z.string().uuid(),
4155
- /** Revision of the persisted observation, never a queue delivery attempt. */ revision: z.number().int().nonnegative(),
4259
+ version: z$1.literal(1),
4260
+ invocationId: z$1.string().uuid(),
4261
+ /** Revision of the persisted observation, never a queue delivery attempt. */ revision: z$1.number().int().nonnegative(),
4156
4262
  projectTask: projectTaskExecutionReferenceSchema.optional()
4157
4263
  };
4158
- /** Host-produced references. Consumers reload and authorize the invocation and its pinned observation. */ const agentRuntimeEventSchema = z.discriminatedUnion('kind', [
4159
- z.object(_extends({}, reference, {
4160
- kind: z.literal('progress'),
4264
+ /** Host-produced references. Consumers reload and authorize the invocation and its pinned observation. */ const agentRuntimeEventSchema = z$1.discriminatedUnion('kind', [
4265
+ z$1.object(_extends({}, reference, {
4266
+ kind: z$1.literal('progress'),
4161
4267
  progress: agentRuntimeProgressSchema
4162
4268
  })).strict(),
4163
- z.object(_extends({}, reference, {
4164
- kind: z.literal('result'),
4269
+ z$1.object(_extends({}, reference, {
4270
+ kind: z$1.literal('result'),
4165
4271
  status: agentInvocationTerminalStatusSchema
4166
4272
  })).strict(),
4167
- z.object(_extends({}, reference, {
4168
- kind: z.literal('input_request'),
4169
- interactionId: z.string().trim().min(1).max(256)
4273
+ z$1.object(_extends({}, reference, {
4274
+ kind: z$1.literal('input_request'),
4275
+ interactionId: z$1.string().trim().min(1).max(256)
4170
4276
  })).strict()
4171
4277
  ]);
4172
4278
  /** Same observation always has the same HandoffMessage.id across retries and process restarts. */ function agentRuntimeEventMessageId(event) {
4173
4279
  return `runtime-${event.invocationId}-${event.kind}-${event.revision}`;
4174
4280
  }
4175
- /** Transport states are deliberately separate from Task and Invocation status. */ const agentRuntimeDeliveryStateSchema = z.enum([
4281
+ /** Transport states are deliberately separate from Task and Invocation status. */ const agentRuntimeDeliveryStateSchema = z$1.enum([
4176
4282
  'pending',
4177
4283
  'received',
4178
4284
  'blocked',
4179
4285
  'failed'
4180
4286
  ]);
4181
- const agentRuntimeConsumptionStateSchema = z.enum([
4287
+ const agentRuntimeConsumptionStateSchema = z$1.enum([
4182
4288
  'pending',
4183
4289
  'processing',
4184
4290
  'processed',
4185
4291
  'blocked',
4186
4292
  'failed'
4187
4293
  ]);
4188
- /** Store under a unique scoped key in the same transaction as the continuation reservation. */ const agentRuntimeResultClaimSchema = z.object({
4189
- invocationId: z.string().uuid(),
4190
- resultRevision: z.number().int().nonnegative(),
4294
+ /** Store under a unique scoped key in the same transaction as the continuation reservation. */ const agentRuntimeResultClaimSchema = z$1.object({
4295
+ invocationId: z$1.string().uuid(),
4296
+ resultRevision: z$1.number().int().nonnegative(),
4191
4297
  recipient: agentRuntimeReplyTargetSchema,
4192
- consumer: z.discriminatedUnion('type', [
4193
- z.object({
4194
- type: z.literal('follow_up'),
4195
- executionId: z.string().uuid()
4298
+ consumer: z$1.discriminatedUnion('type', [
4299
+ z$1.object({
4300
+ type: z$1.literal('follow_up'),
4301
+ executionId: z$1.string().uuid()
4196
4302
  }).strict(),
4197
- z.object({
4198
- type: z.literal('wait'),
4199
- executionId: z.string().uuid(),
4200
- callId: z.string().trim().min(1).max(1024)
4303
+ z$1.object({
4304
+ type: z$1.literal('wait'),
4305
+ executionId: z$1.string().uuid(),
4306
+ callId: z$1.string().trim().min(1).max(1024)
4201
4307
  }).strict()
4202
4308
  ])
4203
4309
  }).strict();
@@ -6246,6 +6352,10 @@ function escapeInlineScript(value) {
6246
6352
 
6247
6353
  const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
6248
6354
 
6355
+ const ViewMiddlewareRuntimeCapability = createRuntimeCapability('platform.view.middleware-runtime', {
6356
+ description: 'Resolve a View capability through its authorized Assistant middleware and scoped runtime.'
6357
+ });
6358
+
6249
6359
  /** Platform-owned real-time collaboration capability available to scoped plugin runtimes. */ const CollaborationRuntimeCapability = createRuntimeCapability('platform.collaboration', {
6250
6360
  description: 'Create, synchronize, persist, authorize, and observe platform-managed real-time collaboration documents.'
6251
6361
  });
@@ -6789,38 +6899,38 @@ async function resolveToolResult(value, validate) {
6789
6899
  // Validate metadata with the declared output schema, preserve bounded media blocks,
6790
6900
  // and include the same DTO in text for clients that hide structuredContent.
6791
6901
  const XPERT_TOOL_RESULT_FORMAT_VERSION = 1;
6792
- const contentSchema = z.discriminatedUnion('type', [
6793
- z.object({
6794
- type: z.literal('text'),
6795
- text: z.string().max(2 * 1024 * 1024)
6902
+ const contentSchema = z$1.discriminatedUnion('type', [
6903
+ z$1.object({
6904
+ type: z$1.literal('text'),
6905
+ text: z$1.string().max(2 * 1024 * 1024)
6796
6906
  }).strict(),
6797
- z.object({
6798
- type: z.literal('image'),
6799
- data: z.string().min(1).max(8 * 1024 * 1024),
6800
- mimeType: z.enum([
6907
+ z$1.object({
6908
+ type: z$1.literal('image'),
6909
+ data: z$1.string().min(1).max(8 * 1024 * 1024),
6910
+ mimeType: z$1.enum([
6801
6911
  'image/png',
6802
6912
  'image/jpeg',
6803
6913
  'image/webp',
6804
6914
  'image/gif'
6805
6915
  ])
6806
6916
  }).strict(),
6807
- z.object({
6808
- type: z.literal('audio'),
6809
- data: z.string().min(1).max(8 * 1024 * 1024),
6810
- mimeType: z.string().min(1).max(100)
6917
+ z$1.object({
6918
+ type: z$1.literal('audio'),
6919
+ data: z$1.string().min(1).max(8 * 1024 * 1024),
6920
+ mimeType: z$1.string().min(1).max(100)
6811
6921
  }).strict(),
6812
- z.object({
6813
- type: z.literal('resource_link'),
6814
- uri: z.string().min(1).max(4096),
6815
- name: z.string().max(240).optional()
6922
+ z$1.object({
6923
+ type: z$1.literal('resource_link'),
6924
+ uri: z$1.string().min(1).max(4096),
6925
+ name: z$1.string().max(240).optional()
6816
6926
  }).strict()
6817
6927
  ]);
6818
6928
  /** Validate the envelope separately so binary content never enters the business DTO. */ async function parseDecoratedToolResult(value, outputSchema) {
6819
6929
  var _result_content;
6820
- const envelope = z.object({
6821
- content: z.array(contentSchema).max(32).optional(),
6822
- structuredContent: outputSchema != null ? outputSchema : z.unknown().optional(),
6823
- isError: z.boolean().optional()
6930
+ const envelope = z$1.object({
6931
+ content: z$1.array(contentSchema).max(32).optional(),
6932
+ structuredContent: outputSchema != null ? outputSchema : z$1.unknown().optional(),
6933
+ isError: z$1.boolean().optional()
6824
6934
  }).strict();
6825
6935
  const result = await envelope.parseAsync(value);
6826
6936
  var _result_content_map;
@@ -10145,4 +10255,4 @@ Reflect.defineMetadata('__command__', {
10145
10255
  id: ImportDefaultAgentPluginsCommand.type
10146
10256
  }, ImportDefaultAgentPluginsCommand);
10147
10257
 
10148
- export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AGENT_RUNTIME_EVENT_MESSAGE_TYPE, AGENT_RUNTIME_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ASSISTANT_CAPABILITY_PROVIDER, AdapterDataSourceStrategy, AgentExecutionRunnerCapability, AgentExecutionRunnerFactoryCapability, AgentInvocationRuntimeCapability, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AgentRuntimeFactoryCapability, AgentRuntimeRegistry, AgentRuntimeStrategy, AiModelNotFoundException, AssistantCapabilityProvider, AssistantCapabilityProviderRegistry, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, CLI_MODEL_TOKEN_REFERENCE, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CliModelProfilesCapability, 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, EvolutionBaselineRuntimeCapability, 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, ImportDefaultAgentPluginsCommand, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KEYWORD_ANALYZER_STRATEGY, KNOWLEDGE_STRATEGY, KeywordAnalyzerRegistry, KeywordAnalyzerStrategy, KnowledgeDocumentVisualAssetsRuntimeCapability, KnowledgeDocumentVisualAssetsRuntimeFactoryCapability, KnowledgeGraphRuntimeCapability, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseProvisioningRuntimeCapability, KnowledgebaseRuntimeCapability, 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, ModelExecutionEnvironmentCapability, 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, PROJECT_TASK_PROVIDER, PROJECT_TYPE_PROVIDER, 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, ProjectTaskProvider, ProjectTaskProviderRegistry, ProjectTasksRuntimeCapability, ProjectTypeProvider, ProjectTypeProviderRegistry, RESOURCE_CARD_EVENT, RESOURCE_CARD_PROVIDER, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, ResourceCardProvider, ResourceCardProviderRegistry, 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, ShellModelExecutionSourceCapability, 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, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XPERT_TOOL_RESULT_FORMAT_VERSION, XpFileSystem, XpertPrompt, XpertResource, XpertResourceTemplate, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, agentInvocationDispatchContextSchema, agentRuntimeConsumptionStateSchema, agentRuntimeDeliveryStateSchema, agentRuntimeEventMessageId, agentRuntimeEventSchema, agentRuntimeReplyTargetSchema, agentRuntimeResultClaimSchema, agentRuntimeResultConsumptionKey, 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, emitResourceCard, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, isAgentInvocationTerminal, isDevelopmentSandboxRuntimeEnvironment, isModelOutputValidationError, isModelUsagePricingConfig, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, knowledgebaseActions, loadYamlFile, mergeCredentials, mergeModelRequirements, mergeParentChildChunks, nativeModelTransport, normalizeContextSize, normalizeTokenUsage, pluginArtifactTableName, prepareToolResult, processAsyncAIGCManagedJob, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, resolveTokenUsageCandidates, resolveXpertMcpExtensions, runWithRequestContext, runtimeToolProviderComponent, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage, taskWaitReason, textTokenBoundaries };
10258
+ export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AGENT_RUNTIME_EVENT_MESSAGE_TYPE, AGENT_RUNTIME_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ASSISTANT_CAPABILITY_PROVIDER, AdapterDataSourceStrategy, AgentExecutionRunnerCapability, AgentExecutionRunnerFactoryCapability, AgentInvocationRuntimeCapability, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AgentRuntimeFactoryCapability, AgentRuntimeRegistry, AgentRuntimeStrategy, AiModelNotFoundException, AssistantCapabilityProvider, AssistantCapabilityProviderRegistry, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, CLI_MODEL_TOKEN_REFERENCE, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CliModelProfilesCapability, 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, EvolutionBaselineRuntimeCapability, 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, ImportDefaultAgentPluginsCommand, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KEYWORD_ANALYZER_STRATEGY, KNOWLEDGE_STRATEGY, KeywordAnalyzerRegistry, KeywordAnalyzerStrategy, KnowledgeDocumentVisualAssetsRuntimeCapability, KnowledgeDocumentVisualAssetsRuntimeFactoryCapability, KnowledgeGraphRuntimeCapability, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseProvisioningRuntimeCapability, KnowledgebaseRuntimeCapability, 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, ModelExecutionEnvironmentCapability, 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, PROJECT_TASK_PROVIDER, PROJECT_TYPE_PROVIDER, 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, ProjectTaskProvider, ProjectTaskProviderRegistry, ProjectTasksRuntimeCapability, ProjectTypeProvider, ProjectTypeProviderRegistry, RESOURCE_CARD_EVENT, RESOURCE_CARD_PROVIDER, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, ResourceCardProvider, ResourceCardProviderRegistry, 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, ShellModelExecutionSourceCapability, 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, ViewMiddlewareRuntimeCapability, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XPERT_TOOL_RESULT_FORMAT_VERSION, XpFileSystem, XpertPrompt, XpertResource, XpertResourceTemplate, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, agentInvocationDispatchContextSchema, agentRuntimeConsumptionStateSchema, agentRuntimeDeliveryStateSchema, agentRuntimeEventMessageId, agentRuntimeEventSchema, agentRuntimeReplyTargetSchema, agentRuntimeResultClaimSchema, agentRuntimeResultConsumptionKey, als, appendSandboxMessage, applyModelConfiguration, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, chunkText, countTextTokens, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, defineMcpApp, defineMcpCapabilities, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineXpertTool, derivePluginArtifactNamespace, describeXpertToolProvider, discoverOpenAIModels, downloadRemoteFile, emitResourceCard, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, isAgentInvocationTerminal, isDevelopmentSandboxRuntimeEnvironment, isModelOutputValidationError, isModelUsagePricingConfig, isPluginArtifactNamespace, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, knowledgebaseActions, loadYamlFile, mergeCredentials, mergeModelRequirements, mergeParentChildChunks, nativeModelTransport, normalizeContextSize, normalizeTokenUsage, pluginArtifactTableName, prepareToolResult, processAsyncAIGCManagedJob, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, resolveTokenUsageCandidates, resolveXpertMcpExtensions, runWithRequestContext, runtimeToolProviderComponent, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage, taskWaitReason, textTokenBoundaries };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.21.1",
3
+ "version": "3.22.1",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@langchain/openai": "0.6.9",
65
- "@xpert-ai/contracts": "3.21.0",
65
+ "@xpert-ai/contracts": "3.21.2",
66
66
  "express": "^4.22.1",
67
67
  "js-tiktoken": "^1.0.21"
68
68
  },
@@ -1,4 +1,4 @@
1
- import { AiModelTypeEnum, IAiProviderEntity, ICopilotModel, ProviderModel, AIModelEntity } from '@xpert-ai/contracts';
1
+ import { AiModelTypeEnum, IAiProviderEntity, ICopilotModel, ProviderModel, AIModelEntity, DiscoveredModel } from '@xpert-ai/contracts';
2
2
  import { BaseLanguageModel } from '@langchain/core/language_models/base';
3
3
  import { Embeddings } from '@langchain/core/embeddings';
4
4
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
@@ -6,6 +6,8 @@ import { AIGCModelClient, AsyncAIGCModelClient, IRerank } from './types';
6
6
  import { AIModel } from './ai-model';
7
7
  import type { NativeModelClientFactory } from './native-model';
8
8
  export interface IAIModelProviderStrategy {
9
+ /** Fetch account-visible models without persisting them or invoking model inference. */
10
+ discoverModels?(credentials: Record<string, unknown>): Promise<DiscoveredModel[]>;
9
11
  getNativeModelClient?: NativeModelClientFactory;
10
12
  /**
11
13
  * Provider metadata
@@ -15,3 +15,5 @@ export * from './commands/index';
15
15
  export * from './token-usage';
16
16
  export * from './native-model';
17
17
  export * from './realtime';
18
+ export * from './model-discovery';
19
+ export * from './model-configuration';
@@ -0,0 +1,3 @@
1
+ import { AIModelEntity, ModelConfiguration } from '@xpert-ai/contracts';
2
+ /** Apply an explicit saved configuration without mutating a shared predefined schema. */
3
+ export declare function applyModelConfiguration(model: string, configuration: ModelConfiguration, schema?: AIModelEntity | null): AIModelEntity;
@@ -0,0 +1,11 @@
1
+ import { AIModelEntity, DiscoveredModel } from '@xpert-ai/contracts';
2
+ export type OpenAIModelDiscoveryOptions = {
3
+ baseUrl: string;
4
+ authorization: string;
5
+ path?: string;
6
+ predefinedModels?: readonly AIModelEntity[];
7
+ fetchImpl?: typeof fetch;
8
+ };
9
+ /** OpenAI-compatible discovery transport and import suggestions, never runtime routing. */
10
+ export declare function discoverOpenAIModels(options: OpenAIModelDiscoveryOptions): Promise<DiscoveredModel[]>;
11
+ export { configurationFromModel } from '@xpert-ai/contracts';
@@ -8,3 +8,4 @@ export declare function derivePluginArtifactNamespace(packageName: string): stri
8
8
  * Keep table keys stable; the returned name is part of the plugin data contract.
9
9
  */
10
10
  export declare function pluginArtifactTableName(namespace: string, tableKey: string): string;
11
+ export declare function isPluginArtifactNamespace(value: unknown): value is string;
@@ -3,6 +3,11 @@ import type { ConnectorRuntimeApi } from './strategy.interface';
3
3
  export declare const ConnectorRuntimeCapability: import("../core").RuntimeCapabilityKey<ConnectorRuntimeApi>;
4
4
  /** No binding or provider grants means no connector access. */
5
5
  export type ConnectorRuntimeScope = RuntimeIdentityScope & {
6
+ /** Server-owned View host identity, set only after the host authorizes the Assistant and its graph. */
7
+ viewHost?: {
8
+ type: 'agent';
9
+ id: string;
10
+ };
6
11
  /** Host-validated Agent Plugin dependencies may use their workspace binding in an authorized project. */
7
12
  allowWorkspaceBindingsInProject?: boolean;
8
13
  /** Host-selected bindings, including IDs pinned by enabled graph Connector nodes. */
@@ -1,6 +1,7 @@
1
1
  export * from './actor-token';
2
2
  export * from './artifacts';
3
3
  export * from './workspace-files';
4
+ export * from './workspace-storage';
4
5
  export * from './sandbox-jobs';
5
6
  export * from './project-provisioning';
6
7
  export * from './project-access';
@@ -1,3 +1,4 @@
1
+ import type { WorkspaceAppDataOptions, WorkspaceStorage } from './workspace-storage';
1
2
  /** Logical workspace volume catalog supported by plugin-facing file APIs. */
2
3
  export type WorkspaceFileCatalog = 'projects' | 'users' | 'knowledges' | 'skills' | 'xperts' | 'user-xperts';
3
4
  /** Stable source identifier for portable workspace file references. */
@@ -232,6 +233,9 @@ export type WorkspaceSearchUnderstandingChunksInput = WorkspaceFileScope & {
232
233
  * understanding files in Xpert workspace Volumes.
233
234
  */
234
235
  export interface WorkspaceFilesApi {
236
+ /** Managed .apps data in the bound Assistant workspace. Each operation reauthorizes the actor.
237
+ * Ordinary Files/sandbox access cannot access this namespace. Requires a scoped runtime API. */
238
+ appData(options: WorkspaceAppDataOptions): WorkspaceStorage;
235
239
  /** Host-bound storage identity for restoring the same scope in durable jobs. */
236
240
  readonly scope?: Readonly<WorkspaceFileScope>;
237
241
  /** Upload raw bytes into an explicitly scoped workspace Volume. */
@@ -0,0 +1,22 @@
1
+ /** Durable application state inside an authorized Assistant workspace.
2
+ * Paths and lock keys are canonical relative paths: no empty, dot or .locks segments.
3
+ * Handles stay bound to their first authorized volume; recreate them after a workspace policy change. */
4
+ export interface WorkspaceStorage {
5
+ read(path: string): Promise<Buffer>;
6
+ write(path: string, content: string | Uint8Array): Promise<void>;
7
+ mkdir(path: string): Promise<void>;
8
+ list(path: string): Promise<string[]>;
9
+ remove(path: string): Promise<void>;
10
+ /** Shared-filesystem mutex renewed by confirmed heartbeats. Lock loss rejects subsequent
11
+ * app-data and ordinary Volume mutations in the callback, including detached work. */
12
+ withLock<T>(key: string, action: () => Promise<T>, options?: {
13
+ waitMs?: number;
14
+ }): Promise<T>;
15
+ }
16
+ /** Host resolves the namespace from this loaded plugin's metadata, never from a filesystem path.
17
+ * Native plugins are trusted server code; this handle is not a sandbox for malicious plugin code. */
18
+ export interface WorkspaceAppDataOptions {
19
+ pluginName: string;
20
+ /** Opt in for personal data; shared Assistant workspaces otherwise remain supported. */
21
+ requireUserIsolation?: boolean;
22
+ }
@@ -3,4 +3,5 @@ export * from './provider.interface';
3
3
  export * from './provider.registry';
4
4
  export * from './remote-component-html';
5
5
  export * from './tokens';
6
+ export * from './middleware-runtime';
6
7
  export { ASSISTANT_CHAT_SEND_MESSAGE_COMMAND, ASSISTANT_CONTEXT_SET_COMMAND } from '@xpert-ai/contracts';
@@ -0,0 +1,20 @@
1
+ import type { IWFNMiddleware, XpertResolvedViewHostContext } from '@xpert-ai/contracts';
2
+ import type { IAgentMiddlewareContext } from '../agent/middleware/strategy.interface';
3
+ /** Server-only input: use the authorized context received by a View provider, never iframe input. */
4
+ export interface ViewMiddlewareRuntimeInput {
5
+ context: XpertResolvedViewHostContext;
6
+ provider: string;
7
+ requiredFeature: string;
8
+ /** Authoring requires the same draft access policy as the Agent View host. Defaults to published. */
9
+ isDraft?: boolean;
10
+ }
11
+ /** Contains trusted configuration and callable capabilities. Never serialize this result to a Remote View. */
12
+ export interface ViewMiddlewareRuntimeResult {
13
+ options: IWFNMiddleware['options'];
14
+ context: IAgentMiddlewareContext;
15
+ }
16
+ export interface ViewMiddlewareRuntimeResolver {
17
+ /** Revalidates identity, host access, the exact connected middleware and its Feature on every call. */
18
+ resolve(input: ViewMiddlewareRuntimeInput): Promise<ViewMiddlewareRuntimeResult>;
19
+ }
20
+ export declare const ViewMiddlewareRuntimeCapability: import("../core/runtime-capability").RuntimeCapabilityKey<ViewMiddlewareRuntimeResolver>;