@xpert-ai/plugin-sdk 3.9.8 → 4.0.0

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.esm.js CHANGED
@@ -338,22 +338,25 @@ class RequestContext {
338
338
  */ static hasRoles(roles, throwError) {
339
339
  const context = RequestContext.currentRequestContext();
340
340
  if (context) {
341
- try {
342
- // tslint:disable-next-line
343
- const token = this.currentToken();
344
- if (token) {
341
+ var _this_currentUser_role, _this_currentUser;
342
+ // tslint:disable-next-line
343
+ const token = this.currentToken();
344
+ if (token) {
345
+ try {
345
346
  const { role } = verify(token, process.env['JWT_SECRET']);
346
- return roles.includes(role != null ? role : null);
347
- } else if (this.currentUser().role) {
348
- return roles.includes(this.currentUser().role.name);
349
- }
350
- } catch (error) {
351
- if (error instanceof JsonWebTokenError) {
352
- return false;
353
- } else {
354
- throw error;
347
+ if (role) {
348
+ return roles.includes(role);
349
+ }
350
+ } catch (error) {
351
+ if (!(error instanceof JsonWebTokenError)) {
352
+ throw error;
353
+ }
355
354
  }
356
355
  }
356
+ const role = (_this_currentUser = this.currentUser()) == null ? void 0 : (_this_currentUser_role = _this_currentUser.role) == null ? void 0 : _this_currentUser_role.name;
357
+ if (role) {
358
+ return roles.includes(role);
359
+ }
357
360
  }
358
361
  if (throwError) {
359
362
  throw new HttpException('Unauthorized', HttpStatus.UNAUTHORIZED);
@@ -2616,6 +2619,52 @@ AgentMiddlewareRegistry = __decorate([
2616
2619
  "end"
2617
2620
  ];
2618
2621
 
2622
+ function createRuntimeCapability(id, options = {}) {
2623
+ return Object.freeze({
2624
+ id,
2625
+ description: options.description
2626
+ });
2627
+ }
2628
+ const XPERT_RUNTIME_CAPABILITIES_TOKEN = 'XPERT_RUNTIME_CAPABILITIES';
2629
+ class DefaultAgentMiddlewareRuntimeCapabilityRegistry {
2630
+ register(key, implementation) {
2631
+ this.capabilities.set(runtimeCapabilityId(key), implementation);
2632
+ return this;
2633
+ }
2634
+ has(key) {
2635
+ return this.capabilities.has(runtimeCapabilityId(key));
2636
+ }
2637
+ get(key) {
2638
+ return this.capabilities.get(runtimeCapabilityId(key));
2639
+ }
2640
+ require(key) {
2641
+ const implementation = this.get(key);
2642
+ if (!implementation) {
2643
+ throw new Error(`Runtime capability '${runtimeCapabilityId(key)}' is not available`);
2644
+ }
2645
+ return implementation;
2646
+ }
2647
+ constructor(entries = []){
2648
+ this.capabilities = new Map();
2649
+ entries.forEach(([key, implementation])=>this.register(key, implementation));
2650
+ }
2651
+ }
2652
+ function runtimeCapabilityId(key) {
2653
+ return typeof key === 'string' ? key : key.id;
2654
+ }
2655
+
2656
+ const KnowledgebaseRuntimeCapability = createRuntimeCapability('platform.knowledgebase', {
2657
+ description: 'List, search, and write chunks in platform knowledgebases.'
2658
+ });
2659
+
2660
+ const AssistantTaskRuntimeCapability = createRuntimeCapability('platform.assistant_task', {
2661
+ description: 'Start asynchronous tasks on the current platform assistant.'
2662
+ });
2663
+
2664
+ const FileRuntimeCapability = createRuntimeCapability('platform.file', {
2665
+ description: 'Resolve platform file handles into previewable file URLs.'
2666
+ });
2667
+
2619
2668
  const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
2620
2669
  const VERSION_PATTERN = /^v[1-9][0-9]*$/;
2621
2670
  function assertSegment(input, name) {
@@ -3951,6 +4000,420 @@ ViewExtensionProviderRegistry = __decorate([
3951
4000
  ])
3952
4001
  ], ViewExtensionProviderRegistry);
3953
4002
 
4003
+ const XPERT_REMOTE_UI_CSS = `
4004
+ :root {
4005
+ color-scheme: light;
4006
+ --xui-font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
4007
+ --xui-color-background: #fff;
4008
+ --xui-color-foreground: #18181b;
4009
+ --xui-color-card: #fff;
4010
+ --xui-color-card-foreground: #18181b;
4011
+ --xui-color-muted: #f4f4f5;
4012
+ --xui-color-muted-foreground: #71717a;
4013
+ --xui-color-border: #e4e4e7;
4014
+ --xui-color-input: #d4d4d8;
4015
+ --xui-color-primary: #18181b;
4016
+ --xui-color-primary-foreground: #fff;
4017
+ --xui-color-destructive: #dc2626;
4018
+ --xui-color-destructive-background: #fef2f2;
4019
+ --xui-color-success: #047857;
4020
+ --xui-color-success-background: #ecfdf5;
4021
+ --xui-radius-sm: 6px;
4022
+ --xui-radius-md: 8px;
4023
+ --xui-radius-lg: 10px;
4024
+ --xui-font-size-xs: 0.75rem;
4025
+ --xui-font-size-sm: 0.8125rem;
4026
+ --xui-font-size-md: 0.875rem;
4027
+ --xui-font-size-lg: 1rem;
4028
+ --xui-font-size-control: var(--xui-font-size-sm);
4029
+ --xui-font-size-button: var(--xui-font-size-sm);
4030
+ --xui-font-size-table: var(--xui-font-size-sm);
4031
+ --xui-control-height: 2rem;
4032
+ --xui-button-height: 2rem;
4033
+ --xui-button-height-sm: 1.75rem;
4034
+ --xui-shadow-dialog: 0 20px 50px rgba(24, 24, 27, 0.22);
4035
+ }
4036
+
4037
+ * {
4038
+ box-sizing: border-box;
4039
+ }
4040
+
4041
+ body {
4042
+ margin: 0;
4043
+ background: var(--xui-color-background);
4044
+ color: var(--xui-color-foreground);
4045
+ font-family: var(--xui-font-family);
4046
+ font-size: var(--xui-font-size-md);
4047
+ }
4048
+
4049
+ button,
4050
+ input,
4051
+ select,
4052
+ textarea {
4053
+ font: inherit;
4054
+ }
4055
+
4056
+ button {
4057
+ cursor: pointer;
4058
+ }
4059
+
4060
+ button:disabled,
4061
+ input:disabled,
4062
+ select:disabled,
4063
+ textarea:disabled {
4064
+ cursor: not-allowed;
4065
+ opacity: 0.56;
4066
+ }
4067
+
4068
+ .xui-app {
4069
+ min-height: 420px;
4070
+ padding: 2px;
4071
+ }
4072
+
4073
+ .xui-toolbar {
4074
+ display: grid;
4075
+ grid-template-columns: minmax(160px, 240px) minmax(160px, 240px) minmax(180px, 1fr) auto auto;
4076
+ gap: 8px;
4077
+ align-items: center;
4078
+ margin-bottom: 12px;
4079
+ }
4080
+
4081
+ .xui-control,
4082
+ .xui-input,
4083
+ .xui-textarea {
4084
+ width: 100%;
4085
+ min-width: 0;
4086
+ border: 1px solid var(--xui-color-input);
4087
+ border-radius: var(--xui-radius-md);
4088
+ background: var(--xui-color-card);
4089
+ color: var(--xui-color-card-foreground);
4090
+ outline: none;
4091
+ }
4092
+
4093
+ .xui-control,
4094
+ .xui-input {
4095
+ height: var(--xui-control-height);
4096
+ padding: 0 10px;
4097
+ font-size: var(--xui-font-size-control);
4098
+ }
4099
+
4100
+ .xui-textarea {
4101
+ min-height: 84px;
4102
+ padding: 8px 10px;
4103
+ resize: vertical;
4104
+ font-size: var(--xui-font-size-control);
4105
+ }
4106
+
4107
+ .xui-button {
4108
+ display: inline-flex;
4109
+ height: var(--xui-button-height);
4110
+ align-items: center;
4111
+ justify-content: center;
4112
+ gap: 6px;
4113
+ border: 1px solid var(--xui-color-input);
4114
+ border-radius: var(--xui-radius-md);
4115
+ background: var(--xui-color-card);
4116
+ color: var(--xui-color-card-foreground);
4117
+ padding: 0 12px;
4118
+ font-size: var(--xui-font-size-button);
4119
+ white-space: nowrap;
4120
+ }
4121
+
4122
+ .xui-button-primary {
4123
+ border-color: var(--xui-color-primary);
4124
+ background: var(--xui-color-primary);
4125
+ color: var(--xui-color-primary-foreground);
4126
+ }
4127
+
4128
+ .xui-button-danger {
4129
+ border-color: color-mix(in srgb, var(--xui-color-destructive) 32%, transparent);
4130
+ color: var(--xui-color-destructive);
4131
+ }
4132
+
4133
+ .xui-button-sm {
4134
+ height: var(--xui-button-height-sm);
4135
+ padding: 0 8px;
4136
+ font-size: var(--xui-font-size-xs);
4137
+ }
4138
+
4139
+ .xui-notice {
4140
+ display: flex;
4141
+ align-items: center;
4142
+ min-height: 36px;
4143
+ margin-bottom: 12px;
4144
+ border: 1px solid var(--xui-color-border);
4145
+ border-radius: var(--xui-radius-md);
4146
+ padding: 8px 10px;
4147
+ color: var(--xui-color-muted-foreground);
4148
+ background: var(--xui-color-muted);
4149
+ font-size: var(--xui-font-size-sm);
4150
+ }
4151
+
4152
+ .xui-notice-error {
4153
+ border-color: color-mix(in srgb, var(--xui-color-destructive) 32%, transparent);
4154
+ color: var(--xui-color-destructive);
4155
+ background: var(--xui-color-destructive-background);
4156
+ }
4157
+
4158
+ .xui-table-wrap {
4159
+ overflow: auto;
4160
+ border: 1px solid var(--xui-color-border);
4161
+ border-radius: var(--xui-radius-md);
4162
+ }
4163
+
4164
+ .xui-table {
4165
+ width: 100%;
4166
+ min-width: 880px;
4167
+ border-collapse: collapse;
4168
+ }
4169
+
4170
+ .xui-table th,
4171
+ .xui-table td {
4172
+ border-bottom: 1px solid var(--xui-color-border);
4173
+ padding: 10px;
4174
+ text-align: left;
4175
+ vertical-align: middle;
4176
+ font-size: var(--xui-font-size-table);
4177
+ }
4178
+
4179
+ .xui-table th {
4180
+ background: var(--xui-color-muted);
4181
+ color: var(--xui-color-muted-foreground);
4182
+ font-weight: 600;
4183
+ }
4184
+
4185
+ .xui-table tr:last-child td {
4186
+ border-bottom: 0;
4187
+ }
4188
+
4189
+ .xui-muted {
4190
+ color: var(--xui-color-muted-foreground);
4191
+ }
4192
+
4193
+ .xui-pill {
4194
+ display: inline-flex;
4195
+ align-items: center;
4196
+ border: 1px solid var(--xui-color-border);
4197
+ border-radius: 999px;
4198
+ padding: 2px 8px;
4199
+ font-size: var(--xui-font-size-xs);
4200
+ color: var(--xui-color-muted-foreground);
4201
+ background: var(--xui-color-muted);
4202
+ }
4203
+
4204
+ .xui-actions {
4205
+ display: flex;
4206
+ flex-wrap: wrap;
4207
+ gap: 6px;
4208
+ }
4209
+
4210
+ .xui-pager {
4211
+ display: flex;
4212
+ align-items: center;
4213
+ justify-content: space-between;
4214
+ gap: 12px;
4215
+ margin-top: 12px;
4216
+ color: var(--xui-color-muted-foreground);
4217
+ font-size: var(--xui-font-size-sm);
4218
+ }
4219
+
4220
+ .xui-empty {
4221
+ display: grid;
4222
+ min-height: 180px;
4223
+ place-items: center;
4224
+ color: var(--xui-color-muted-foreground);
4225
+ font-size: var(--xui-font-size-md);
4226
+ }
4227
+
4228
+ .xui-modal-backdrop {
4229
+ position: fixed;
4230
+ inset: 0;
4231
+ display: grid;
4232
+ place-items: center;
4233
+ background: rgba(24, 24, 27, 0.32);
4234
+ padding: 16px;
4235
+ }
4236
+
4237
+ .xui-modal {
4238
+ width: min(720px, 100%);
4239
+ max-height: calc(100vh - 32px);
4240
+ overflow: auto;
4241
+ border-radius: var(--xui-radius-lg);
4242
+ background: var(--xui-color-card);
4243
+ color: var(--xui-color-card-foreground);
4244
+ box-shadow: var(--xui-shadow-dialog);
4245
+ }
4246
+
4247
+ .xui-modal-header,
4248
+ .xui-modal-footer {
4249
+ display: flex;
4250
+ align-items: center;
4251
+ justify-content: space-between;
4252
+ gap: 12px;
4253
+ padding: 14px 16px;
4254
+ border-bottom: 1px solid var(--xui-color-border);
4255
+ }
4256
+
4257
+ .xui-modal-footer {
4258
+ border-top: 1px solid var(--xui-color-border);
4259
+ border-bottom: 0;
4260
+ }
4261
+
4262
+ .xui-modal-title {
4263
+ margin: 0;
4264
+ font-size: var(--xui-font-size-lg);
4265
+ font-weight: 700;
4266
+ }
4267
+
4268
+ .xui-form {
4269
+ display: grid;
4270
+ grid-template-columns: repeat(2, minmax(0, 1fr));
4271
+ gap: 12px;
4272
+ padding: 16px;
4273
+ }
4274
+
4275
+ .xui-field {
4276
+ display: grid;
4277
+ gap: 6px;
4278
+ }
4279
+
4280
+ .xui-field-full {
4281
+ grid-column: 1 / -1;
4282
+ }
4283
+
4284
+ .xui-field label {
4285
+ color: var(--xui-color-muted-foreground);
4286
+ font-size: var(--xui-font-size-xs);
4287
+ font-weight: 600;
4288
+ }
4289
+
4290
+ .xui-checkbox {
4291
+ display: inline-flex;
4292
+ align-items: center;
4293
+ gap: 8px;
4294
+ color: var(--xui-color-card-foreground);
4295
+ font-size: var(--xui-font-size-sm);
4296
+ }
4297
+
4298
+ @media (max-width: 760px) {
4299
+ .xui-toolbar,
4300
+ .xui-form {
4301
+ grid-template-columns: 1fr;
4302
+ }
4303
+ }
4304
+ `;
4305
+ const XPERT_REMOTE_UI_BOOTSTRAP = `
4306
+ (function () {
4307
+ var CHANNEL = 'xpertai.remote_component'
4308
+ var VERSION = 1
4309
+ var TOKEN_MAP = {
4310
+ fontFamily: '--xui-font-family',
4311
+ colorBackground: '--xui-color-background',
4312
+ colorForeground: '--xui-color-foreground',
4313
+ colorCard: '--xui-color-card',
4314
+ colorCardForeground: '--xui-color-card-foreground',
4315
+ colorMuted: '--xui-color-muted',
4316
+ colorMutedForeground: '--xui-color-muted-foreground',
4317
+ colorBorder: '--xui-color-border',
4318
+ colorInput: '--xui-color-input',
4319
+ colorPrimary: '--xui-color-primary',
4320
+ colorPrimaryForeground: '--xui-color-primary-foreground',
4321
+ colorDestructive: '--xui-color-destructive',
4322
+ colorDestructiveBackground: '--xui-color-destructive-background',
4323
+ colorSuccess: '--xui-color-success',
4324
+ colorSuccessBackground: '--xui-color-success-background',
4325
+ radiusSm: '--xui-radius-sm',
4326
+ radiusMd: '--xui-radius-md',
4327
+ radiusLg: '--xui-radius-lg',
4328
+ fontSizeXs: '--xui-font-size-xs',
4329
+ fontSizeSm: '--xui-font-size-sm',
4330
+ fontSizeMd: '--xui-font-size-md',
4331
+ fontSizeLg: '--xui-font-size-lg',
4332
+ fontSizeControl: '--xui-font-size-control',
4333
+ fontSizeButton: '--xui-font-size-button',
4334
+ fontSizeTable: '--xui-font-size-table',
4335
+ controlHeight: '--xui-control-height',
4336
+ buttonHeight: '--xui-button-height',
4337
+ buttonHeightSm: '--xui-button-height-sm'
4338
+ }
4339
+
4340
+ function isObject(value) {
4341
+ return value && typeof value === 'object' && !Array.isArray(value)
4342
+ }
4343
+
4344
+ function applyTheme(theme) {
4345
+ var mode = typeof theme === 'string' ? theme : isObject(theme) ? theme.mode : null
4346
+ var tokens = isObject(theme) && isObject(theme.tokens) ? theme.tokens : {}
4347
+ if (mode === 'dark') {
4348
+ document.documentElement.dataset.theme = 'dark'
4349
+ document.documentElement.style.colorScheme = 'dark'
4350
+ } else {
4351
+ document.documentElement.dataset.theme = 'light'
4352
+ document.documentElement.style.colorScheme = 'light'
4353
+ }
4354
+ Object.keys(TOKEN_MAP).forEach(function (key) {
4355
+ var value = tokens[key]
4356
+ if (typeof value === 'string' && value.trim()) {
4357
+ document.documentElement.style.setProperty(TOKEN_MAP[key], value.trim())
4358
+ }
4359
+ })
4360
+ }
4361
+
4362
+ window.XpertRemoteUI = {
4363
+ applyTheme: applyTheme
4364
+ }
4365
+
4366
+ window.addEventListener('message', function (event) {
4367
+ var message = event.data
4368
+ if (
4369
+ !isObject(message) ||
4370
+ message.channel !== CHANNEL ||
4371
+ message.protocolVersion !== VERSION ||
4372
+ message.type !== 'init'
4373
+ ) {
4374
+ return
4375
+ }
4376
+ applyTheme(message.theme)
4377
+ })
4378
+ })()
4379
+ `;
4380
+ function renderRemoteReactIframeHtml(options) {
4381
+ var _options_lang, _options_appCss;
4382
+ return `<!doctype html>
4383
+ <html lang="${escapeHtmlAttribute((_options_lang = options.lang) != null ? _options_lang : 'en')}">
4384
+ <head>
4385
+ <meta charset="utf-8" />
4386
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
4387
+ <title>${escapeHtml(options.title)}</title>
4388
+ <style>
4389
+ ${XPERT_REMOTE_UI_CSS}
4390
+ ${(_options_appCss = options.appCss) != null ? _options_appCss : ''}
4391
+ </style>
4392
+ <script>
4393
+ ${options.reactUmd}
4394
+ </script>
4395
+ <script>
4396
+ ${options.reactDomUmd}
4397
+ </script>
4398
+ <script>
4399
+ ${XPERT_REMOTE_UI_BOOTSTRAP}
4400
+ </script>
4401
+ </head>
4402
+ <body>
4403
+ <div id="root"></div>
4404
+ <script>
4405
+ ${options.appScript}
4406
+ </script>
4407
+ </body>
4408
+ </html>`;
4409
+ }
4410
+ function escapeHtml(value) {
4411
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
4412
+ }
4413
+ function escapeHtmlAttribute(value) {
4414
+ return escapeHtml(value).replace(/`/g, '&#96;');
4415
+ }
4416
+
3954
4417
  const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
3955
4418
 
3956
- 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 };
4419
+ export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PERMISSION_SERVICE_TOKEN, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, 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, DefaultAgentMiddlewareRuntimeCapabilityRegistry, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseRuntimeCapability, 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, XPERT_RUNTIME_CAPABILITIES_TOKEN, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, buildSandboxTimeoutMessage, calcTokenUsage, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, downloadRemoteFile, formatSandboxTimeout, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStructuredMessageType, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, renderRemoteReactIframeHtml, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, runWithRequestContext, secondsToMilliseconds, sumTokenUsage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.9.8",
3
+ "version": "4.0.0",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,45 @@
1
+ export type AgentMiddlewareAssistantTaskStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'interrupted' | 'unknown';
2
+ export type AgentMiddlewareAssistantTaskFile = {
3
+ id?: string;
4
+ fileId?: string;
5
+ fileAssetId?: string;
6
+ storageFileId?: string;
7
+ originalName?: string;
8
+ name?: string;
9
+ mimeType?: string;
10
+ mimetype?: string;
11
+ size?: number;
12
+ role?: string;
13
+ };
14
+ export type AgentMiddlewareAssistantTaskInput = {
15
+ xpertId: string;
16
+ agentKey?: string;
17
+ conversationId?: string | null;
18
+ projectId?: string | null;
19
+ taskId?: string;
20
+ clientMessageId?: string;
21
+ prompt: string;
22
+ files?: AgentMiddlewareAssistantTaskFile[];
23
+ context?: Record<string, unknown>;
24
+ };
25
+ export type AgentMiddlewareAssistantTaskResult = {
26
+ status: AgentMiddlewareAssistantTaskStatus;
27
+ taskId?: string;
28
+ executionId?: string;
29
+ conversationId?: string;
30
+ threadId?: string;
31
+ errorMessage?: string;
32
+ };
33
+ export type AgentMiddlewareAssistantTaskStatusInput = {
34
+ taskId?: string;
35
+ executionId?: string;
36
+ conversationId?: string;
37
+ threadId?: string;
38
+ clientMessageId?: string;
39
+ xpertId?: string;
40
+ };
41
+ export interface AgentMiddlewareAssistantTaskApi {
42
+ startTask(input: AgentMiddlewareAssistantTaskInput): Promise<AgentMiddlewareAssistantTaskResult>;
43
+ getTaskStatus?(input: AgentMiddlewareAssistantTaskStatusInput): Promise<AgentMiddlewareAssistantTaskResult | null>;
44
+ }
45
+ export declare const AssistantTaskRuntimeCapability: import("../runtime-capability").RuntimeCapabilityKey<AgentMiddlewareAssistantTaskApi>;
@@ -0,0 +1,29 @@
1
+ export type AgentMiddlewareFileReference = {
2
+ id?: string;
3
+ fileId?: string;
4
+ fileAssetId?: string;
5
+ storageFileId?: string;
6
+ name?: string;
7
+ originalName?: string;
8
+ mimeType?: string;
9
+ mimetype?: string;
10
+ size?: number;
11
+ url?: string;
12
+ fileUrl?: string;
13
+ previewUrl?: string;
14
+ };
15
+ export type AgentMiddlewareResolvedFile = {
16
+ id: string;
17
+ fileId?: string;
18
+ fileAssetId?: string;
19
+ storageFileId?: string;
20
+ name: string;
21
+ mimeType?: string;
22
+ size?: number;
23
+ url: string;
24
+ previewUrl?: string;
25
+ };
26
+ export interface AgentMiddlewareFileApi {
27
+ resolveFile(input: AgentMiddlewareFileReference): Promise<AgentMiddlewareResolvedFile | null>;
28
+ }
29
+ export declare const FileRuntimeCapability: import("../runtime-capability").RuntimeCapabilityKey<AgentMiddlewareFileApi>;
@@ -0,0 +1,3 @@
1
+ export * from './knowledgebase';
2
+ export * from './assistant-task';
3
+ export * from './file';
@@ -0,0 +1,70 @@
1
+ import { JSONValue } from '@xpert-ai/contracts';
2
+ export type AgentMiddlewareKnowledgebaseRetrievalMode = 'vector' | 'graph' | 'hybrid';
3
+ export type AgentMiddlewareKnowledgebaseMetadata = Record<string, JSONValue>;
4
+ export type AgentMiddlewareKnowledgebaseRetrievalSettings = {
5
+ mode?: AgentMiddlewareKnowledgebaseRetrievalMode;
6
+ neighborHops?: number;
7
+ entityTopK?: number;
8
+ communityTopK?: number;
9
+ graphWeight?: number;
10
+ };
11
+ export type AgentMiddlewareKnowledgebaseSearchInput = {
12
+ tenantId?: string;
13
+ organizationId?: string;
14
+ knowledgebaseIds: string[];
15
+ query: string;
16
+ k?: number;
17
+ score?: number;
18
+ filter?: AgentMiddlewareKnowledgebaseMetadata;
19
+ retrieval?: AgentMiddlewareKnowledgebaseRetrievalSettings;
20
+ source: string;
21
+ requestId?: string;
22
+ };
23
+ export type AgentMiddlewareKnowledgebaseDocument = {
24
+ pageContent: string;
25
+ metadata?: Record<string, unknown>;
26
+ };
27
+ export type AgentMiddlewareKnowledgebaseListInput = {
28
+ workspaceId?: string | null;
29
+ published?: boolean;
30
+ limit?: number;
31
+ };
32
+ export type AgentMiddlewareKnowledgebaseListItem = {
33
+ id: string;
34
+ name?: string;
35
+ description?: string | null;
36
+ type?: string | null;
37
+ status?: string | null;
38
+ permission?: string | null;
39
+ workspaceId?: string | null;
40
+ documentNum?: number | null;
41
+ chunkNum?: number | null;
42
+ graphRag?: {
43
+ enabled?: boolean;
44
+ [key: string]: JSONValue | undefined;
45
+ } | null;
46
+ graphStatus?: string | null;
47
+ };
48
+ export type AgentMiddlewareKnowledgebaseWriteChunkInput = {
49
+ xpertId: string;
50
+ agentKey: string;
51
+ knowledgebaseIds: string[];
52
+ knowledgebaseId: string;
53
+ text: string;
54
+ title?: string;
55
+ metadata?: AgentMiddlewareKnowledgebaseMetadata;
56
+ writeKey: string;
57
+ executionId?: string;
58
+ threadId?: string;
59
+ };
60
+ export type AgentMiddlewareKnowledgebaseWriteChunkResult = {
61
+ status?: 'created' | 'skipped';
62
+ chunkId?: string;
63
+ message?: string;
64
+ };
65
+ export interface AgentMiddlewareKnowledgebaseApi {
66
+ list(input: AgentMiddlewareKnowledgebaseListInput): Promise<AgentMiddlewareKnowledgebaseListItem[]>;
67
+ search(input: AgentMiddlewareKnowledgebaseSearchInput): Promise<AgentMiddlewareKnowledgebaseDocument[]>;
68
+ writeChunk(input: AgentMiddlewareKnowledgebaseWriteChunkInput): Promise<AgentMiddlewareKnowledgebaseWriteChunkResult>;
69
+ }
70
+ export declare const KnowledgebaseRuntimeCapability: import("../runtime-capability").RuntimeCapabilityKey<AgentMiddlewareKnowledgebaseApi>;