@xpert-ai/plugin-sdk 3.8.4 → 3.9.0-beta.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/index.cjs.js +486 -325
  3. package/index.esm.js +468 -298
  4. package/package.json +8 -9
  5. package/src/index.d.ts +1 -0
  6. package/src/lib/agent/handoff/agent-chat.contract.d.ts +1 -1
  7. package/src/lib/agent/handoff/handoff-processor.decorator.d.ts +1 -1
  8. package/src/lib/agent/index.d.ts +1 -0
  9. package/src/lib/agent/middleware/runtime.d.ts +1 -1
  10. package/src/lib/agent/middleware/strategy.decorator.d.ts +1 -1
  11. package/src/lib/agent/middleware/strategy.interface.d.ts +2 -1
  12. package/src/lib/agent/skill/skill-source-provider.decorator.d.ts +1 -1
  13. package/src/lib/agent/skill/skill-source-provider.interface.d.ts +1 -1
  14. package/src/lib/ai-model/abstract-provider.d.ts +1 -1
  15. package/src/lib/ai-model/ai-model-provider.interface.d.ts +1 -1
  16. package/src/lib/ai-model/ai-model.d.ts +1 -1
  17. package/src/lib/ai-model/commands/create-model-client.command.d.ts +1 -1
  18. package/src/lib/ai-model/entities/defaults.d.ts +1 -1
  19. package/src/lib/ai-model/llm.d.ts +1 -1
  20. package/src/lib/ai-model/types/model.d.ts +1 -1
  21. package/src/lib/ai-model/types/rerank.d.ts +1 -1
  22. package/src/lib/ai-model/types/text-embedding-model.d.ts +1 -1
  23. package/src/lib/ai-model/types/tts.d.ts +1 -1
  24. package/src/lib/ai-model/utils/limits.d.ts +1 -1
  25. package/src/lib/channel/strategy.interface.d.ts +1 -3
  26. package/src/lib/core/context/request-context.d.ts +9 -4
  27. package/src/lib/core/context/request-context.middleware.d.ts +1 -2
  28. package/src/lib/core/file-system.d.ts +3 -3
  29. package/src/lib/core/permissions/analytics.d.ts +2 -3
  30. package/src/lib/core/permissions/general.d.ts +1 -1
  31. package/src/lib/core/permissions/user.d.ts +1 -1
  32. package/src/lib/data/datasource/strategy.decorator.d.ts +1 -1
  33. package/src/lib/data/datasource/types.d.ts +2 -5
  34. package/src/lib/file/file-storage/provider.decorator.d.ts +1 -1
  35. package/src/lib/file/file-storage/provider.interface.d.ts +1 -3
  36. package/src/lib/file/file-upload/strategy.decorator.d.ts +1 -1
  37. package/src/lib/file/file-upload/strategy.interface.d.ts +1 -3
  38. package/src/lib/integration/strategy.decorator.d.ts +1 -1
  39. package/src/lib/integration/strategy.interface.d.ts +1 -1
  40. package/src/lib/rag/image/strategy.decorator.d.ts +1 -1
  41. package/src/lib/rag/image/strategy.interface.d.ts +1 -1
  42. package/src/lib/rag/knowledge/knowledge-strategy.decorator.d.ts +1 -1
  43. package/src/lib/rag/knowledge/knowledge-strategy.interface.d.ts +1 -1
  44. package/src/lib/rag/retriever/strategy.decorator.d.ts +1 -1
  45. package/src/lib/rag/retriever/strategy.interface.d.ts +1 -1
  46. package/src/lib/rag/source/strategy.decorator.d.ts +1 -1
  47. package/src/lib/rag/source/strategy.interface.d.ts +1 -1
  48. package/src/lib/rag/textsplitter/strategy.decorator.d.ts +1 -1
  49. package/src/lib/rag/textsplitter/strategy.interface.d.ts +1 -1
  50. package/src/lib/rag/transformer/strategy.decorator.d.ts +1 -1
  51. package/src/lib/rag/transformer/strategy.interface.d.ts +1 -1
  52. package/src/lib/rag/types.d.ts +2 -2
  53. package/src/lib/sandbox/protocol.d.ts +4 -8
  54. package/src/lib/sandbox/sandbox.decorator.d.ts +1 -1
  55. package/src/lib/sandbox/sandbox.interface.d.ts +1 -1
  56. package/src/lib/strategy.d.ts +3 -3
  57. package/src/lib/toolset/builtin.d.ts +1 -1
  58. package/src/lib/toolset/strategy.decorator.d.ts +1 -1
  59. package/src/lib/toolset/strategy.interface.d.ts +1 -1
  60. package/src/lib/toolset/toolset.d.ts +1 -1
  61. package/src/lib/types.d.ts +1 -1
  62. package/src/lib/vectorstore/strategy.decorator.d.ts +1 -1
  63. package/src/lib/view-extension/index.d.ts +4 -0
  64. package/src/lib/view-extension/provider.decorator.d.ts +2 -0
  65. package/src/lib/view-extension/provider.interface.d.ts +7 -0
  66. package/src/lib/view-extension/provider.registry.d.ts +10 -0
  67. package/src/lib/view-extension/tokens.d.ts +1 -0
  68. package/src/lib/workflow/commands/wrap-workflow-node-execution.command.d.ts +1 -1
  69. package/src/lib/workflow/node/strategy.decorator.d.ts +1 -1
  70. package/src/lib/workflow/node/strategy.interface.d.ts +1 -1
  71. package/src/lib/workflow/trigger/strategy.decorator.d.ts +1 -1
  72. package/src/lib/workflow/trigger/strategy.interface.d.ts +1 -1
  73. package/index.esm.d.ts +0 -1
  74. /package/{index.cjs.d.ts → index.d.ts} +0 -0
package/index.esm.js CHANGED
@@ -1,10 +1,9 @@
1
- import { Module, Logger, applyDecorators, SetMetadata, HttpException, HttpStatus, Injectable, Inject, NotFoundException, ForbiddenException } from '@nestjs/common';
1
+ import { Module, Logger, applyDecorators, SetMetadata, HttpException, HttpStatus, BadRequestException, Injectable, Inject, NotFoundException, ForbiddenException } from '@nestjs/common';
2
2
  import { MODULE_METADATA } from '@nestjs/common/constants';
3
3
  import { pick } from 'lodash-es';
4
4
  import { DiscoveryService, Reflector } from '@nestjs/core';
5
5
  import { Subject, filter } from 'rxjs';
6
- import { LanguagesEnum, AiModelTypeEnum, ParameterType, PriceType, FetchFrom, ModelFeature, ModelPropertyKey } from '@metad/contracts';
7
- export { IColumnDef, IDSSchema, IDSTable, TDocumentAsset } from '@metad/contracts';
6
+ import { LanguagesEnum, AiModelTypeEnum, ParameterType, PriceType, FetchFrom, ModelFeature, ModelPropertyKey } from '@xpert-ai/contracts';
8
7
  import { AsyncLocalStorage } from 'node:async_hooks';
9
8
  import { ExtractJwt } from 'passport-jwt';
10
9
  import { verify, JsonWebTokenError } from 'jsonwebtoken';
@@ -38,11 +37,11 @@ import { getModelContextSize as getModelContextSize$1 } from '@langchain/core/la
38
37
  * Metadata keys used in plugins for defining various aspects like entities, subscribers, and configurations.
39
38
  */ const PLUGIN_METADATA = {
40
39
  /**
41
- * Key representing the entities registered within the plugin.
42
- */ ENTITIES: 'entities',
40
+ * Key representing the entities registered within the plugin.
41
+ */ ENTITIES: 'entities',
43
42
  /**
44
- * Key representing event subscribers within the plugin.
45
- */ SUBSCRIBERS: 'subscribers'
43
+ * Key representing event subscribers within the plugin.
44
+ */ SUBSCRIBERS: 'subscribers'
46
45
  };
47
46
 
48
47
  /**
@@ -87,10 +86,10 @@ function _extends() {
87
86
  function createPluginLogger(scope, baseMeta = {}) {
88
87
  const nestLogger = new Logger(scope);
89
88
  const wrap = (level, msg, meta)=>{
90
- var _nestLogger_level;
89
+ var // 保持与 Nest Logger 接口对齐
90
+ _nestLogger_level;
91
91
  const payload = meta ? _extends({}, baseMeta, meta) : baseMeta;
92
- (_nestLogger_level = // 保持与 Nest Logger 接口对齐
93
- nestLogger[level]) == null ? void 0 : _nestLogger_level.call(nestLogger, msg + (Object.keys(payload).length ? ` ${JSON.stringify(payload)}` : ''));
92
+ (_nestLogger_level = nestLogger[level]) == null ? void 0 : _nestLogger_level.call(nestLogger, msg + (Object.keys(payload).length ? ` ${JSON.stringify(payload)}` : ''));
94
93
  };
95
94
  return {
96
95
  child (meta) {
@@ -121,11 +120,22 @@ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedEr
121
120
  };
122
121
 
123
122
  // request-context.ts
123
+ const TENANT_SCOPE = 'tenant';
124
+ const ORGANIZATION_SCOPE = 'organization';
124
125
  class RequestContext {
125
126
  static currentRequestContext() {
126
127
  const session = getRequestContext();
127
128
  return session;
128
129
  }
130
+ static currentApiKey() {
131
+ var _RequestContext_currentApiPrincipal;
132
+ var _RequestContext_currentApiPrincipal_apiKey;
133
+ return (_RequestContext_currentApiPrincipal_apiKey = (_RequestContext_currentApiPrincipal = RequestContext.currentApiPrincipal()) == null ? void 0 : _RequestContext_currentApiPrincipal.apiKey) != null ? _RequestContext_currentApiPrincipal_apiKey : null;
134
+ }
135
+ static currentApiPrincipal() {
136
+ const user = RequestContext.currentUser();
137
+ return (user == null ? void 0 : user.apiKey) ? user : null;
138
+ }
129
139
  static currentRequest() {
130
140
  const requestContext = RequestContext.currentRequestContext();
131
141
  if (requestContext) {
@@ -174,9 +184,9 @@ class RequestContext {
174
184
  ], throwError);
175
185
  }
176
186
  /**
177
- * Retrieves the language code from the headers of the current request.
178
- * @returns The language code (LanguagesEnum) extracted from the headers, or the default language (ENGLISH) if not found.
179
- */ static getLanguageCode() {
187
+ * Retrieves the language code from the headers of the current request.
188
+ * @returns The language code (LanguagesEnum) extracted from the headers, or the default language (ENGLISH) if not found.
189
+ */ static getLanguageCode() {
180
190
  // Retrieve the current request
181
191
  const req = RequestContext.currentRequest();
182
192
  // Variable to store the extracted language code
@@ -192,21 +202,71 @@ class RequestContext {
192
202
  // Return the extracted language code or the default language (ENGLISH) if not found
193
203
  return lang || LanguagesEnum.English;
194
204
  }
195
- static getOrganizationId() {
196
- const req = this.currentRequest();
197
- let organizationId;
198
- const keys = [
205
+ static getScope() {
206
+ const request = this.currentRequest();
207
+ const user = this.currentUser();
208
+ var _user_tenantId, _ref;
209
+ const tenantId = (_ref = (_user_tenantId = user == null ? void 0 : user.tenantId) != null ? _user_tenantId : getHeaderValue(request, [
210
+ 'tenant-id'
211
+ ])) != null ? _ref : null;
212
+ var _getHeaderValue;
213
+ const organizationId = (_getHeaderValue = getHeaderValue(request, [
199
214
  'organization-id'
200
- ];
201
- if (req) {
202
- for (const key of keys){
203
- if (req.headers && req.headers[key]) {
204
- organizationId = req.headers[key];
205
- break;
215
+ ])) != null ? _getHeaderValue : null;
216
+ const scopeLevelHeader = getHeaderValue(request, [
217
+ 'x-scope-level'
218
+ ]);
219
+ if (scopeLevelHeader) {
220
+ if (scopeLevelHeader !== TENANT_SCOPE && scopeLevelHeader !== ORGANIZATION_SCOPE) {
221
+ throw new BadRequestException(`Unsupported scope level: ${scopeLevelHeader}`);
222
+ }
223
+ if (scopeLevelHeader === TENANT_SCOPE) {
224
+ if (organizationId) {
225
+ throw new BadRequestException('Tenant scope requests must not include Organization-Id.');
206
226
  }
227
+ return {
228
+ tenantId,
229
+ level: TENANT_SCOPE,
230
+ organizationId: null
231
+ };
207
232
  }
233
+ if (!organizationId) {
234
+ throw new BadRequestException('Organization scope requests require Organization-Id.');
235
+ }
236
+ return {
237
+ tenantId,
238
+ level: ORGANIZATION_SCOPE,
239
+ organizationId
240
+ };
241
+ }
242
+ if (organizationId) {
243
+ return {
244
+ tenantId,
245
+ level: ORGANIZATION_SCOPE,
246
+ organizationId
247
+ };
208
248
  }
209
- return organizationId;
249
+ return {
250
+ tenantId,
251
+ level: TENANT_SCOPE,
252
+ organizationId: null
253
+ };
254
+ }
255
+ static getOrganizationId() {
256
+ return this.getScope().organizationId;
257
+ }
258
+ static isTenantScope() {
259
+ return this.getScope().level === TENANT_SCOPE;
260
+ }
261
+ static isOrganizationScope() {
262
+ return this.getScope().level === ORGANIZATION_SCOPE;
263
+ }
264
+ static requireOrganizationScope() {
265
+ const scope = this.getScope();
266
+ if (scope.level !== ORGANIZATION_SCOPE || !scope.organizationId) {
267
+ throw new BadRequestException('Organization scope is required for this operation.');
268
+ }
269
+ return scope.organizationId;
210
270
  }
211
271
  static hasPermissions(findPermissions, throwError) {
212
272
  const requestContext = RequestContext.currentRequestContext();
@@ -260,22 +320,22 @@ class RequestContext {
260
320
  return null;
261
321
  }
262
322
  /**
263
- * Checks if the current user has a specific role.
264
- * @param {RolesEnum} role - The role to check.
265
- * @param {boolean} throwError - Flag indicating whether to throw an error if the role is not granted.
266
- * @returns {boolean} - True if the user has the role, otherwise false.
267
- */ static hasRole(role, throwError) {
323
+ * Checks if the current user has a specific role.
324
+ * @param {RolesEnum} role - The role to check.
325
+ * @param {boolean} throwError - Flag indicating whether to throw an error if the role is not granted.
326
+ * @returns {boolean} - True if the user has the role, otherwise false.
327
+ */ static hasRole(role, throwError) {
268
328
  return this.hasRoles([
269
329
  role
270
330
  ], throwError);
271
331
  }
272
332
  /**
273
- * Checks if the current request context has any of the specified roles.
274
- *
275
- * @param roles - An array of roles to check.
276
- * @param throwError - Whether to throw an error if no roles are found.
277
- * @returns True if any of the required roles are found, otherwise false.
278
- */ static hasRoles(roles, throwError) {
333
+ * Checks if the current request context has any of the specified roles.
334
+ *
335
+ * @param roles - An array of roles to check.
336
+ * @param throwError - Whether to throw an error if no roles are found.
337
+ * @returns True if any of the required roles are found, otherwise false.
338
+ */ static hasRoles(roles, throwError) {
279
339
  const context = RequestContext.currentRequestContext();
280
340
  if (context) {
281
341
  try {
@@ -312,8 +372,23 @@ const als = new AsyncLocalStorage();
312
372
  function getRequestContext() {
313
373
  return als.getStore();
314
374
  }
375
+ function getHeaderValue(req, keys) {
376
+ if (!(req == null ? void 0 : req.headers)) {
377
+ return null;
378
+ }
379
+ for (const key of keys){
380
+ const value = req.headers[key];
381
+ if (Array.isArray(value)) {
382
+ var _value_;
383
+ return (_value_ = value[0]) != null ? _value_ : null;
384
+ }
385
+ if (typeof value === 'string' && value) {
386
+ return value;
387
+ }
388
+ }
389
+ return null;
390
+ }
315
391
 
316
- // request-context.middleware.ts
317
392
  let RequestContextMiddleware = class RequestContextMiddleware {
318
393
  use(req, _res, next) {
319
394
  var _req_user;
@@ -414,10 +489,10 @@ class BaseStrategyRegistry {
414
489
  }
415
490
  /**
416
491
  * Get strategy by type from the given organization including global strategies as fallback.
417
- *
418
- * @param type
419
- * @param organizationId
420
- * @returns
492
+ *
493
+ * @param type
494
+ * @param organizationId
495
+ * @returns
421
496
  */ get(type, organizationId) {
422
497
  var _this_strategies_get, _this_strategies_get1;
423
498
  organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
@@ -431,34 +506,42 @@ class BaseStrategyRegistry {
431
506
  }
432
507
  /**
433
508
  * List all strategies for the given organization including global strategies, or only global strategies if global org is specified.
434
- *
435
- * @param organizationId
436
- * @returns
509
+ *
510
+ * @param organizationId
511
+ * @returns
437
512
  */ list(organizationId) {
438
- var _this_strategies_get, _this_strategies_get1;
513
+ var _this_strategies_get;
439
514
  organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
440
515
  const orgKey = this.resolveOrganization(organizationId);
441
- var _this_strategies_get_values;
442
- const scoped = (_this_strategies_get_values = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.values()) != null ? _this_strategies_get_values : [];
443
- var _this_strategies_get_values1;
444
- const global = orgKey === GLOBAL_ORGANIZATION_SCOPE ? [] : (_this_strategies_get_values1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.values()) != null ? _this_strategies_get_values1 : [];
445
- return Array.from(new Set([
446
- ...scoped,
447
- ...global
448
- ]));
516
+ const effective = new Map();
517
+ var _this_strategies_get_entries;
518
+ for (const [type, strategy] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
519
+ effective.set(type, strategy);
520
+ }
521
+ if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
522
+ var _this_strategies_get1;
523
+ var _this_strategies_get_entries1;
524
+ for (const [type, strategy] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
525
+ if (!effective.has(type)) {
526
+ effective.set(type, strategy);
527
+ }
528
+ }
529
+ }
530
+ return Array.from(effective.values());
449
531
  }
450
532
  constructor(strategyKey, discoveryService, reflector){
451
- this.strategyKey = strategyKey;
452
- this.discoveryService = discoveryService;
453
- this.reflector = reflector;
454
533
  this.logger = new Logger(BaseStrategyRegistry.name);
534
+ // Map<organizationId, Map<type, strategy>>
455
535
  this.strategies = new Map();
456
536
  this.pluginStrategies = new Map();
537
+ this.strategyKey = strategyKey;
538
+ this.discoveryService = discoveryService;
539
+ this.reflector = reflector;
457
540
  }
458
541
  }
459
542
  __decorate([
460
543
  Inject(StrategyBus),
461
- __metadata("design:type", typeof StrategyBus === "undefined" ? Object : StrategyBus)
544
+ __metadata("design:type", StrategyBus)
462
545
  ], BaseStrategyRegistry.prototype, "bus", void 0);
463
546
 
464
547
  let IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends BaseStrategyRegistry {
@@ -468,10 +551,9 @@ let IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends Base
468
551
  };
469
552
  IntegrationStrategyRegistry = __decorate([
470
553
  Injectable(),
471
- __metadata("design:type", Function),
472
554
  __metadata("design:paramtypes", [
473
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
474
- typeof Reflector === "undefined" ? Object : Reflector
555
+ DiscoveryService,
556
+ Reflector
475
557
  ])
476
558
  ], IntegrationStrategyRegistry);
477
559
 
@@ -485,10 +567,9 @@ let WorkflowTriggerRegistry = class WorkflowTriggerRegistry extends BaseStrategy
485
567
  };
486
568
  WorkflowTriggerRegistry = __decorate([
487
569
  Injectable(),
488
- __metadata("design:type", Function),
489
570
  __metadata("design:paramtypes", [
490
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
491
- typeof Reflector === "undefined" ? Object : Reflector
571
+ DiscoveryService,
572
+ Reflector
492
573
  ])
493
574
  ], WorkflowTriggerRegistry);
494
575
 
@@ -497,21 +578,22 @@ const WORKFLOW_NODE_STRATEGY = 'WORKFLOW_NODE_STRATEGY';
497
578
  * Decorator to mark a provider as a Workflow Node Strategy
498
579
  */ const WorkflowNodeStrategy = (provider)=>applyDecorators(SetMetadata(WORKFLOW_NODE_STRATEGY, provider), SetMetadata(STRATEGY_META_KEY, WORKFLOW_NODE_STRATEGY));
499
580
 
500
- let WorkflowNodeRegistry = class WorkflowNodeRegistry extends BaseStrategyRegistry {
581
+ /**
582
+ * Registry for Workflow Node Strategies
583
+ */ let WorkflowNodeRegistry = class WorkflowNodeRegistry extends BaseStrategyRegistry {
501
584
  constructor(discoveryService, reflector){
502
585
  super(WORKFLOW_NODE_STRATEGY, discoveryService, reflector);
503
586
  }
504
587
  };
505
588
  WorkflowNodeRegistry = __decorate([
506
589
  Injectable(),
507
- __metadata("design:type", Function),
508
590
  __metadata("design:paramtypes", [
509
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
510
- typeof Reflector === "undefined" ? Object : Reflector
591
+ DiscoveryService,
592
+ Reflector
511
593
  ])
512
594
  ], WorkflowNodeRegistry);
513
595
 
514
- const COMMAND_METADATA$1 = '__command__';
596
+ const COMMAND_METADATA$2 = '__command__';
515
597
  /**
516
598
  * Wrap Workflow Node Execution Command
517
599
  */ class WrapWorkflowNodeExecutionCommand extends Command {
@@ -522,7 +604,7 @@ const COMMAND_METADATA$1 = '__command__';
522
604
  }
523
605
  }
524
606
  WrapWorkflowNodeExecutionCommand.type = '[Workflow] Wrap Workflow Node Execution';
525
- Reflect.defineMetadata(COMMAND_METADATA$1, {
607
+ Reflect.defineMetadata(COMMAND_METADATA$2, {
526
608
  id: WrapWorkflowNodeExecutionCommand.type
527
609
  }, WrapWorkflowNodeExecutionCommand);
528
610
 
@@ -536,10 +618,9 @@ let VectorStoreRegistry = class VectorStoreRegistry extends BaseStrategyRegistry
536
618
  };
537
619
  VectorStoreRegistry = __decorate([
538
620
  Injectable(),
539
- __metadata("design:type", Function),
540
621
  __metadata("design:paramtypes", [
541
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
542
- typeof Reflector === "undefined" ? Object : Reflector
622
+ DiscoveryService,
623
+ Reflector
543
624
  ])
544
625
  ], VectorStoreRegistry);
545
626
 
@@ -553,10 +634,9 @@ let TextSplitterRegistry = class TextSplitterRegistry extends BaseStrategyRegist
553
634
  };
554
635
  TextSplitterRegistry = __decorate([
555
636
  Injectable(),
556
- __metadata("design:type", Function),
557
637
  __metadata("design:paramtypes", [
558
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
559
- typeof Reflector === "undefined" ? Object : Reflector
638
+ DiscoveryService,
639
+ Reflector
560
640
  ])
561
641
  ], TextSplitterRegistry);
562
642
 
@@ -572,10 +652,9 @@ let DocumentSourceRegistry = class DocumentSourceRegistry extends BaseStrategyRe
572
652
  };
573
653
  DocumentSourceRegistry = __decorate([
574
654
  Injectable(),
575
- __metadata("design:type", Function),
576
655
  __metadata("design:paramtypes", [
577
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
578
- typeof Reflector === "undefined" ? Object : Reflector
656
+ DiscoveryService,
657
+ Reflector
579
658
  ])
580
659
  ], DocumentSourceRegistry);
581
660
 
@@ -591,10 +670,9 @@ let DocumentTransformerRegistry = class DocumentTransformerRegistry extends Base
591
670
  };
592
671
  DocumentTransformerRegistry = __decorate([
593
672
  Injectable(),
594
- __metadata("design:type", Function),
595
673
  __metadata("design:paramtypes", [
596
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
597
- typeof Reflector === "undefined" ? Object : Reflector
674
+ DiscoveryService,
675
+ Reflector
598
676
  ])
599
677
  ], DocumentTransformerRegistry);
600
678
 
@@ -610,16 +688,15 @@ let RetrieverRegistry = class RetrieverRegistry extends BaseStrategyRegistry {
610
688
  };
611
689
  RetrieverRegistry = __decorate([
612
690
  Injectable(),
613
- __metadata("design:type", Function),
614
691
  __metadata("design:paramtypes", [
615
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
616
- typeof Reflector === "undefined" ? Object : Reflector
692
+ DiscoveryService,
693
+ Reflector
617
694
  ])
618
695
  ], RetrieverRegistry);
619
696
 
620
697
  /**
621
698
  * Merge parent chunks with their child chunks based on metadata (parentId and chunkId)
622
- *
699
+ *
623
700
  * @deprecated use buildChunkTreeAndFindLeaves instead
624
701
  */ function mergeParentChildChunks(chunks, children // Child chunks
625
702
  ) {
@@ -685,10 +762,9 @@ let ImageUnderstandingRegistry = class ImageUnderstandingRegistry extends BaseSt
685
762
  };
686
763
  ImageUnderstandingRegistry = __decorate([
687
764
  Injectable(),
688
- __metadata("design:type", Function),
689
765
  __metadata("design:paramtypes", [
690
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
691
- typeof Reflector === "undefined" ? Object : Reflector
766
+ DiscoveryService,
767
+ Reflector
692
768
  ])
693
769
  ], ImageUnderstandingRegistry);
694
770
 
@@ -702,10 +778,9 @@ let KnowledgeStrategyRegistry = class KnowledgeStrategyRegistry extends BaseStra
702
778
  };
703
779
  KnowledgeStrategyRegistry = __decorate([
704
780
  Injectable(),
705
- __metadata("design:type", Function),
706
781
  __metadata("design:paramtypes", [
707
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
708
- typeof Reflector === "undefined" ? Object : Reflector
782
+ DiscoveryService,
783
+ Reflector
709
784
  ])
710
785
  ], KnowledgeStrategyRegistry);
711
786
 
@@ -721,10 +796,9 @@ let ToolsetRegistry = class ToolsetRegistry extends BaseStrategyRegistry {
721
796
  };
722
797
  ToolsetRegistry = __decorate([
723
798
  Injectable(),
724
- __metadata("design:type", Function),
725
799
  __metadata("design:paramtypes", [
726
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
727
- typeof Reflector === "undefined" ? Object : Reflector
800
+ DiscoveryService,
801
+ Reflector
728
802
  ])
729
803
  ], ToolsetRegistry);
730
804
 
@@ -732,26 +806,26 @@ ToolsetRegistry = __decorate([
732
806
  * Base ability for all toolsets
733
807
  */ class BaseToolset extends BaseToolkit {
734
808
  /**
735
- * Async init tools
736
- *
737
- * @returns
738
- */ async initTools() {
809
+ * Async init tools
810
+ *
811
+ * @returns
812
+ */ async initTools() {
739
813
  return this.tools;
740
814
  }
741
815
  /**
742
- * Get one tool
743
- *
744
- * @param toolName
745
- * @returns
746
- */ getTool(toolName) {
816
+ * Get one tool
817
+ *
818
+ * @param toolName
819
+ * @returns
820
+ */ getTool(toolName) {
747
821
  var _this_getTools;
748
822
  return (_this_getTools = this.getTools()) == null ? void 0 : _this_getTools.find((tool)=>tool.name === toolName);
749
823
  }
750
824
  /**
751
- * Get state variables config
752
- *
753
- * @returns State variables
754
- */ async getVariables() {
825
+ * Get state variables config
826
+ *
827
+ * @returns State variables
828
+ */ async getVariables() {
755
829
  return null;
756
830
  }
757
831
  /**
@@ -809,26 +883,26 @@ class BuiltinToolset extends BaseToolset {
809
883
  return (_this_toolset = this.toolset) == null ? void 0 : _this_toolset.credentials;
810
884
  }
811
885
  getToolTitle(name) {
812
- var _this_toolset_tools, _this_toolset, _this;
886
+ var _this_toolset_tools, _this_toolset, _tool_schema;
813
887
  const tool = (_this_toolset = this.toolset) == null ? void 0 : (_this_toolset_tools = _this_toolset.tools) == null ? void 0 : _this_toolset_tools.find((tool)=>tool.name === name);
814
- const identity = (_this = tool == null ? void 0 : tool.schema) == null ? void 0 : _this.identity;
888
+ const identity = tool == null ? void 0 : (_tool_schema = tool.schema) == null ? void 0 : _tool_schema.identity;
815
889
  if (identity) {
816
890
  return identity.label;
817
891
  }
818
892
  return null;
819
893
  }
820
894
  /**
821
- * Get credentials schema
822
- *
823
- * @returns Credentials schema
824
- */ getCredentialsSchema() {
895
+ * Get credentials schema
896
+ *
897
+ * @returns Credentials schema
898
+ */ getCredentialsSchema() {
825
899
  return _extends({}, this.credentialsSchema);
826
900
  }
827
901
  /**
828
- * Get toolset entity
829
- *
830
- * @returns XpertToolset
831
- */ getToolset() {
902
+ * Get toolset entity
903
+ *
904
+ * @returns XpertToolset
905
+ */ getToolset() {
832
906
  return this.toolset;
833
907
  }
834
908
  getName() {
@@ -837,27 +911,27 @@ class BuiltinToolset extends BaseToolset {
837
911
  }
838
912
  constructor(providerName, toolset, params){
839
913
  super(params);
914
+ this.logger = new Logger(this.constructor.name);
840
915
  this.providerName = providerName;
841
916
  this.toolset = toolset;
842
917
  this.params = params;
843
- this.logger = new Logger(this.constructor.name);
844
918
  }
845
- }
919
+ }
846
920
  BuiltinToolset.provider = '';
847
921
 
848
922
  /**
849
923
  * Restricted FileSystem based on granted permissions
850
924
  */ class XpFileSystem {
851
925
  /**
852
- * Check if operation is allowed
853
- */ ensureAllowed(op) {
926
+ * Check if operation is allowed
927
+ */ ensureAllowed(op) {
854
928
  if (!this.allowedOps.has(op)) {
855
929
  throw new Error(`Permission denied: ${op} operation not allowed`);
856
930
  }
857
931
  }
858
932
  /**
859
- * Check if path is within scope
860
- */ ensureInScope(targetPath) {
933
+ * Check if path is within scope
934
+ */ ensureInScope(targetPath) {
861
935
  if (!this.scope || this.scope.length === 0) return;
862
936
  const resolved = path__default.resolve(targetPath);
863
937
  for (const s of this.scope){
@@ -867,33 +941,32 @@ BuiltinToolset.provider = '';
867
941
  throw new Error(`Permission denied: path "${targetPath}" is out of scope`);
868
942
  }
869
943
  /**
870
- * Get the absolute path of file in the file system.
871
- *
872
- * @param filePath Relative file path
873
- * @returns Absolute file path
874
- */ fullPath(filePath) {
944
+ * Get the absolute path of file in the file system.
945
+ *
946
+ * @param filePath Relative file path
947
+ * @returns Absolute file path
948
+ */ fullPath(filePath) {
875
949
  return path__default.join(this.basePath, filePath);
876
950
  }
877
951
  /**
878
- * Get web url for a given file path in the file system.
879
- *
880
- * @param filePath Relative file path
881
- * @returns Web URL of file
882
- */ fullUrl(filePath) {
883
- const url = new URL(filePath, this.baseUrl);
884
- return url.href;
952
+ * Get web url for a given file path in the file system.
953
+ *
954
+ * @param filePath Relative file path
955
+ * @returns Web URL of file
956
+ */ fullUrl(filePath) {
957
+ return this.buildUrl(filePath);
885
958
  }
886
959
  /**
887
- * Read file contents
888
- */ async readFile(filePath, encoding = 'utf-8') {
960
+ * Read file contents
961
+ */ async readFile(filePath, encoding = 'utf-8') {
889
962
  this.ensureAllowed('read');
890
963
  const fullPath = this.fullPath(filePath);
891
964
  this.ensureInScope(fullPath);
892
965
  return await fsPromises.readFile(fullPath);
893
966
  }
894
967
  /**
895
- * Write file contents
896
- */ async writeFile(filePath, content) {
968
+ * Write file contents
969
+ */ async writeFile(filePath, content) {
897
970
  this.ensureAllowed('write');
898
971
  const fullPath = this.fullPath(filePath);
899
972
  this.ensureInScope(fullPath);
@@ -901,26 +974,25 @@ BuiltinToolset.provider = '';
901
974
  recursive: true
902
975
  });
903
976
  await fsPromises.writeFile(fullPath, content);
904
- const url = new URL(filePath, this.baseUrl);
905
- return url.href;
977
+ return this.buildUrl(filePath);
906
978
  }
907
979
  /**
908
- * Delete a file
909
- */ async deleteFile(filePath) {
980
+ * Delete a file
981
+ */ async deleteFile(filePath) {
910
982
  this.ensureAllowed('delete');
911
983
  this.ensureInScope(filePath);
912
984
  await fsPromises.unlink(filePath);
913
985
  }
914
986
  /**
915
- * List directory contents
916
- */ async listDir(dirPath) {
987
+ * List directory contents
988
+ */ async listDir(dirPath) {
917
989
  this.ensureAllowed('list');
918
990
  this.ensureInScope(dirPath);
919
991
  return fsPromises.readdir(dirPath);
920
992
  }
921
993
  /**
922
- * Utility: check if a file or directory exists
923
- */ async exists(targetPath) {
994
+ * Utility: check if a file or directory exists
995
+ */ async exists(targetPath) {
924
996
  try {
925
997
  await fsPromises.access(targetPath);
926
998
  return true;
@@ -928,6 +1000,23 @@ BuiltinToolset.provider = '';
928
1000
  return false;
929
1001
  }
930
1002
  }
1003
+ // Keep URL generation tolerant of protocol-relative base URLs like "//localhost:3000",
1004
+ // which are used by the current dev config and would otherwise make `new URL()` throw.
1005
+ buildUrl(filePath) {
1006
+ if (/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(filePath) || filePath.startsWith('//')) {
1007
+ return filePath;
1008
+ }
1009
+ const normalizedPath = this.encodePath(`${filePath}`.replace(/^\/+/, ''));
1010
+ const normalizedBaseUrl = `${this.baseUrl}`.replace(/\/+$/, '');
1011
+ if (normalizedBaseUrl.startsWith('//')) {
1012
+ return `${normalizedBaseUrl}/${normalizedPath}`;
1013
+ }
1014
+ const url = new URL(normalizedPath, `${normalizedBaseUrl}/`);
1015
+ return url.href;
1016
+ }
1017
+ encodePath(filePath) {
1018
+ return filePath.split('/').map((segment)=>encodeURIComponent(segment)).join('/');
1019
+ }
931
1020
  constructor(permission, basePath, baseUrl){
932
1021
  this.basePath = basePath;
933
1022
  this.baseUrl = baseUrl;
@@ -1027,7 +1116,7 @@ function loadYamlFile(filePath, logger, ignoreError = true, defaultValue = {}) {
1027
1116
  }
1028
1117
  /**
1029
1118
  * Get the mapping from name to index from a YAML file
1030
- *
1119
+ *
1031
1120
  * @param folderPath
1032
1121
  * @param fileName the YAML file name, default to '_position.yaml'
1033
1122
  * @return a dict with name as key and index as value
@@ -1096,10 +1185,9 @@ let DataSourceStrategyRegistry = class DataSourceStrategyRegistry extends BaseSt
1096
1185
  };
1097
1186
  DataSourceStrategyRegistry = __decorate([
1098
1187
  Injectable(),
1099
- __metadata("design:type", Function),
1100
1188
  __metadata("design:paramtypes", [
1101
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
1102
- typeof Reflector === "undefined" ? Object : Reflector
1189
+ DiscoveryService,
1190
+ Reflector
1103
1191
  ])
1104
1192
  ], DataSourceStrategyRegistry);
1105
1193
 
@@ -1108,12 +1196,12 @@ DataSourceStrategyRegistry = __decorate([
1108
1196
  * into datasource strategies consumable by the plugin SDK.
1109
1197
  */ class AdapterDataSourceStrategy {
1110
1198
  /**
1111
- * Get from cache or create new instance of DB adapter.
1112
- *
1113
- * @param options
1114
- * @param id
1115
- * @returns
1116
- */ async create(options, id) {
1199
+ * Get from cache or create new instance of DB adapter.
1200
+ *
1201
+ * @param options
1202
+ * @param id
1203
+ * @returns
1204
+ */ async create(options, id) {
1117
1205
  if (id) {
1118
1206
  if (this.runners.has(id)) {
1119
1207
  return this.runners.get(id);
@@ -1149,9 +1237,10 @@ DataSourceStrategyRegistry = __decorate([
1149
1237
  return this.runnerClass;
1150
1238
  }
1151
1239
  constructor(runnerClass, extraArgs = []){
1240
+ this.runners = new Map() // dataSourceId -> runner instance
1241
+ ;
1152
1242
  this.runnerClass = runnerClass;
1153
1243
  this.extraArgs = extraArgs;
1154
- this.runners = new Map();
1155
1244
  }
1156
1245
  }
1157
1246
 
@@ -1251,13 +1340,13 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1251
1340
  await this.runQuery(`SELECT 1`);
1252
1341
  }
1253
1342
  /**
1254
- * Default implementation for table operations
1255
- */ async tableOp(action, params, options) {
1343
+ * Default implementation for table operations
1344
+ */ async tableOp(action, params, options) {
1256
1345
  switch(action){
1257
- case "createTable":
1346
+ case DBTableAction.CREATE_TABLE:
1258
1347
  {
1259
1348
  // Default implementation for creating table (generic SQL syntax)
1260
- const { schema, table, columns, createMode = "error" } = params;
1349
+ const { schema, table, columns, createMode = DBCreateTableMode.ERROR } = params;
1261
1350
  const tableName = schema ? `${schema}.${table}` : table;
1262
1351
  // Check if table exists (try to query table info)
1263
1352
  let exists = false;
@@ -1269,17 +1358,17 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1269
1358
  exists = false;
1270
1359
  }
1271
1360
  // --- MODE: ERROR → throw error if table exists ---
1272
- if (exists && createMode === "error") {
1361
+ if (exists && createMode === DBCreateTableMode.ERROR) {
1273
1362
  throw new Error(`Table "${tableName}" already exists`);
1274
1363
  }
1275
1364
  // --- MODE: IGNORE → do nothing if exists ---
1276
- if (exists && createMode === "ignore") {
1365
+ if (exists && createMode === DBCreateTableMode.IGNORE) {
1277
1366
  return;
1278
1367
  }
1279
1368
  // --- MODE: UPGRADE → auto upgrade (simple implementation: only add new columns) ---
1280
1369
  // Note: This default implementation does not support modifying column types,
1281
1370
  // recommend each database to implement its own version
1282
- if (exists && createMode === "upgrade") {
1371
+ if (exists && createMode === DBCreateTableMode.UPGRADE) {
1283
1372
  console.warn(`[BaseSQLQueryRunner] UPGRADE mode uses basic implementation. Consider implementing tableOp for better support.`);
1284
1373
  // Try to add new columns (will fail if column already exists, but doesn't affect)
1285
1374
  for (const col of columns){
@@ -1304,7 +1393,7 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1304
1393
  await this.runQuery(createTableStatement, options);
1305
1394
  return;
1306
1395
  }
1307
- case "dropTable":
1396
+ case DBTableAction.DROP_TABLE:
1308
1397
  {
1309
1398
  // Default implementation for dropping table
1310
1399
  const { schema, table } = params;
@@ -1318,8 +1407,8 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1318
1407
  }
1319
1408
  }
1320
1409
  /**
1321
- * Generic type mapping (subclasses can override)
1322
- */ mapColumnType(type, isKey, length) {
1410
+ * Generic type mapping (subclasses can override)
1411
+ */ mapColumnType(type, isKey, length) {
1323
1412
  switch(type == null ? void 0 : type.toLowerCase()){
1324
1413
  case 'string':
1325
1414
  return length ? `VARCHAR(${length})` : isKey ? 'VARCHAR(255)' : 'VARCHAR(1000)';
@@ -1339,8 +1428,8 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1339
1428
  }
1340
1429
  constructor(...args){
1341
1430
  super(...args);
1342
- this.syntax = "sql";
1343
- this.protocol = "sql";
1431
+ this.syntax = DBSyntaxEnum.SQL;
1432
+ this.protocol = DBProtocolEnum.SQL;
1344
1433
  }
1345
1434
  }
1346
1435
  var DBTableAction;
@@ -1361,7 +1450,9 @@ var DBTableAction;
1361
1450
  DBTableAction["CLONE_TABLE"] = "cloneTable";
1362
1451
  DBTableAction["OPTIMIZE_TABLE"] = "optimizeTable";
1363
1452
  })(DBTableAction || (DBTableAction = {}));
1364
- var DBCreateTableMode;
1453
+ /**
1454
+ * Modes for creating a table, if the table already exists
1455
+ */ var DBCreateTableMode;
1365
1456
  (function(DBCreateTableMode) {
1366
1457
  DBCreateTableMode["ERROR"] = "error";
1367
1458
  DBCreateTableMode["IGNORE"] = "ignore";
@@ -1391,8 +1482,7 @@ function AIModelProviderStrategy(provider) {
1391
1482
  const match = (callerLine == null ? void 0 : callerLine.match(/\((file:\/\/\/[^\s)]+)\)/)) || (// case 1: file:///path...
1392
1483
  callerLine == null ? void 0 : callerLine.match(/\((\/[^\s)]+)\)/)) || (// case 2: (/Users/xxx)
1393
1484
  callerLine == null ? void 0 : callerLine.match(/at (file:\/\/\/[^\s]+)/)) || (// case 3: at file:///...
1394
- callerLine == null ? void 0 : callerLine.match(/at (\/[^\s]+)/) // case 4: at /Users/xxx
1395
- );
1485
+ callerLine == null ? void 0 : callerLine.match(/at (\/[^\s]+)/)); // case 4: at /Users/xxx
1396
1486
  let file = match == null ? void 0 : match[1];
1397
1487
  // remove the file:/// prefix
1398
1488
  if (file == null ? void 0 : file.startsWith('file:///')) {
@@ -1427,10 +1517,9 @@ let AIModelProviderRegistry = class AIModelProviderRegistry extends BaseStrategy
1427
1517
  };
1428
1518
  AIModelProviderRegistry = __decorate([
1429
1519
  Injectable(),
1430
- __metadata("design:type", Function),
1431
1520
  __metadata("design:paramtypes", [
1432
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
1433
- typeof Reflector === "undefined" ? Object : Reflector
1521
+ DiscoveryService,
1522
+ Reflector
1434
1523
  ])
1435
1524
  ], AIModelProviderRegistry);
1436
1525
 
@@ -1441,7 +1530,8 @@ class CredentialsValidateFailedError extends ForbiddenException {
1441
1530
  class AIModelProviderNotFoundException extends NotFoundException {
1442
1531
  }
1443
1532
 
1444
- let ModelProvider = class ModelProvider {
1533
+ var ModelProvider_1;
1534
+ let ModelProvider = ModelProvider_1 = class ModelProvider {
1445
1535
  get name() {
1446
1536
  return this.getProviderSchema().provider;
1447
1537
  }
@@ -1449,10 +1539,10 @@ let ModelProvider = class ModelProvider {
1449
1539
  await this.validateProviderCredentials(credentials);
1450
1540
  }
1451
1541
  /**
1452
- * Get provider lib root path.
1453
- *
1454
- * @returns Root of library
1455
- */ getProviderServerPath() {
1542
+ * Get provider lib root path.
1543
+ *
1544
+ * @returns Root of library
1545
+ */ getProviderServerPath() {
1456
1546
  return this.dir;
1457
1547
  }
1458
1548
  getProviderSchema() {
@@ -1487,11 +1577,11 @@ let ModelProvider = class ModelProvider {
1487
1577
  return modelInstance;
1488
1578
  }
1489
1579
  /**
1490
- * Get provider models.
1491
- * @param modelType - model type
1492
- * @param onlyActive - only active models
1493
- * @return provider models
1494
- */ getProviderModels(modelType, onlyActive = false) {
1580
+ * Get provider models.
1581
+ * @param modelType - model type
1582
+ * @param onlyActive - only active models
1583
+ * @return provider models
1584
+ */ getProviderModels(modelType, onlyActive = false) {
1495
1585
  let modelTypes = [];
1496
1586
  if (modelType) {
1497
1587
  modelTypes.push(modelType);
@@ -1543,7 +1633,7 @@ let ModelProvider = class ModelProvider {
1543
1633
  return null;
1544
1634
  }
1545
1635
  constructor(){
1546
- this.logger = new Logger(ModelProvider.name);
1636
+ this.logger = new Logger(ModelProvider_1.name);
1547
1637
  // protected providerSchema: IAiProviderEntity | null = null
1548
1638
  this.modelManagers = new Map();
1549
1639
  const provider = Reflect.getMetadata(AI_MODEL_PROVIDER, this.constructor);
@@ -1553,9 +1643,8 @@ let ModelProvider = class ModelProvider {
1553
1643
  this.dir = dir;
1554
1644
  }
1555
1645
  };
1556
- ModelProvider = __decorate([
1646
+ ModelProvider = ModelProvider_1 = __decorate([
1557
1647
  Injectable(),
1558
- __metadata("design:type", Function),
1559
1648
  __metadata("design:paramtypes", [])
1560
1649
  ], ModelProvider);
1561
1650
 
@@ -1744,7 +1833,8 @@ function mergeCredentials(credentials, modelProperties) {
1744
1833
  return _extends({}, credentials != null ? credentials : {}, modelProperties != null ? modelProperties : {});
1745
1834
  }
1746
1835
 
1747
- let AIModel = class AIModel {
1836
+ var AIModel_1;
1837
+ let AIModel = AIModel_1 = class AIModel {
1748
1838
  getChatModel(copilotModel, options) {
1749
1839
  throw new Error(`Unsupport chat model!`);
1750
1840
  }
@@ -1819,13 +1909,13 @@ let AIModel = class AIModel {
1819
1909
  return null;
1820
1910
  }
1821
1911
  /**
1822
- * Get customizable model schema.
1823
- * Implement this method in ai model sub class that can customize model
1824
- *
1825
- * @param model model name
1826
- * @param credentials model credentials
1827
- * @returns model schema
1828
- */ getCustomizableModelSchemaFromCredentials(model, credentials) {
1912
+ * Get customizable model schema.
1913
+ * Implement this method in ai model sub class that can customize model
1914
+ *
1915
+ * @param model model name
1916
+ * @param credentials model credentials
1917
+ * @returns model schema
1918
+ */ getCustomizableModelSchemaFromCredentials(model, credentials) {
1829
1919
  return null;
1830
1920
  }
1831
1921
  processParameterRules(yamlData) {
@@ -1897,29 +1987,28 @@ let AIModel = class AIModel {
1897
1987
  };
1898
1988
  }
1899
1989
  constructor(modelProvider, modelType){
1900
- this.modelProvider = modelProvider;
1901
- this.modelType = modelType;
1902
- this.logger = new Logger(AIModel.name);
1990
+ this.logger = new Logger(AIModel_1.name);
1903
1991
  this.modelSchemas = null;
1904
1992
  this.positions = null;
1993
+ this.modelProvider = modelProvider;
1994
+ this.modelType = modelType;
1905
1995
  this.modelProvider.registerAIModelInstance(this.modelType, this);
1906
1996
  }
1907
1997
  };
1908
- AIModel = __decorate([
1998
+ AIModel = AIModel_1 = __decorate([
1909
1999
  Injectable(),
1910
- __metadata("design:type", Function),
1911
2000
  __metadata("design:paramtypes", [
1912
- typeof ModelProvider === "undefined" ? Object : ModelProvider,
1913
- typeof AiModelTypeEnum === "undefined" ? Object : AiModelTypeEnum
2001
+ ModelProvider,
2002
+ String
1914
2003
  ])
1915
2004
  ], AIModel);
1916
2005
  function getDefaultParameterRuleVariableMap(name) {
1917
2006
  /**
1918
- * Get default parameter rule for given name
1919
- *
1920
- * @param name - parameter name
1921
- * @return parameter rule
1922
- */ const defaultParameterRule = PARAMETER_RULE_TEMPLATE[name];
2007
+ * Get default parameter rule for given name
2008
+ *
2009
+ * @param name - parameter name
2010
+ * @return parameter rule
2011
+ */ const defaultParameterRule = PARAMETER_RULE_TEMPLATE[name];
1923
2012
  if (!defaultParameterRule) {
1924
2013
  throw new Error(`Invalid model parameter rule name ${name}`);
1925
2014
  }
@@ -1985,17 +2074,18 @@ function _class_private_field_loose_key(name) {
1985
2074
  return "__private_" + id++ + "_" + name;
1986
2075
  }
1987
2076
 
2077
+ var _a;
1988
2078
  class LLMUsage {
1989
2079
  static emptyUsage() {
1990
2080
  return new LLMUsage(0, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0, 0.0, 'USD', 0.0);
1991
2081
  }
1992
2082
  plus(other) {
1993
2083
  /**
1994
- * Add two LLMUsage instances together.
1995
- *
1996
- * @param other: Another LLMUsage instance to add
1997
- * @return: A new LLMUsage instance with summed values
1998
- */ if (this.totalTokens === 0) {
2084
+ * Add two LLMUsage instances together.
2085
+ *
2086
+ * @param other: Another LLMUsage instance to add
2087
+ * @return: A new LLMUsage instance with summed values
2088
+ */ if (this.totalTokens === 0) {
1999
2089
  return other;
2000
2090
  } else {
2001
2091
  return new LLMUsage(this.promptTokens + other.promptTokens, other.promptUnitPrice, other.promptPriceUnit, this.promptPrice + other.promptPrice, this.completionTokens + other.completionTokens, other.completionUnitPrice, other.completionPriceUnit, this.completionPrice + other.completionPrice, this.totalTokens + other.totalTokens, this.totalPrice + other.totalPrice, other.currency, this.latency + other.latency);
@@ -2003,11 +2093,11 @@ class LLMUsage {
2003
2093
  }
2004
2094
  add(other) {
2005
2095
  /**
2006
- * Overload the + operator to add two LLMUsage instances.
2007
- *
2008
- * @param other: Another LLMUsage instance to add
2009
- * @return: A new LLMUsage instance with summed values
2010
- */ return this.plus(other);
2096
+ * Overload the + operator to add two LLMUsage instances.
2097
+ *
2098
+ * @param other: Another LLMUsage instance to add
2099
+ * @return: A new LLMUsage instance with summed values
2100
+ */ return this.plus(other);
2011
2101
  }
2012
2102
  constructor(promptTokens, promptUnitPrice, promptPriceUnit, promptPrice, completionTokens, completionUnitPrice, completionPriceUnit, completionPrice, totalTokens, totalPrice, currency, latency){
2013
2103
  this.promptTokens = promptTokens;
@@ -2205,9 +2295,10 @@ class LargeLanguageModel extends AIModel {
2205
2295
  writable: true,
2206
2296
  value: void 0
2207
2297
  });
2208
- _class_private_field_loose_base(this, _logger)[_logger] = new Logger(LargeLanguageModel.name);
2298
+ _class_private_field_loose_base(this, _logger)[_logger] = new Logger(_a.name);
2209
2299
  }
2210
2300
  }
2301
+ _a = LargeLanguageModel;
2211
2302
  function calcTokenUsage(output) {
2212
2303
  var _output_generations;
2213
2304
  const tokenUsage = {
@@ -2255,8 +2346,8 @@ function calcTokenUsage(output) {
2255
2346
  * In this way, the reasoning process in the model output can be separated from the main content, making it easier for subsequent structured processing and display.
2256
2347
  */ class ChatOAICompatReasoningModel extends ChatOpenAICompletions {
2257
2348
  /**
2258
- *
2259
- */ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
2349
+ *
2350
+ */ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
2260
2351
  delta, rawResponse, defaultRole) {
2261
2352
  const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole);
2262
2353
  if (delta['content'] === '<think>') {
@@ -2442,7 +2533,7 @@ function normalizeContextSize(value) {
2442
2533
  return undefined;
2443
2534
  }
2444
2535
 
2445
- const COMMAND_METADATA = '__command__';
2536
+ const COMMAND_METADATA$1 = '__command__';
2446
2537
  /**
2447
2538
  * Get a Chat Model of copilot model and check it's token limitation, record the token usage
2448
2539
  */ class CreateModelClientCommand extends Command {
@@ -2453,10 +2544,26 @@ const COMMAND_METADATA = '__command__';
2453
2544
  }
2454
2545
  }
2455
2546
  CreateModelClientCommand.type = '[AI Model] Create Model Client';
2456
- Reflect.defineMetadata(COMMAND_METADATA, {
2547
+ Reflect.defineMetadata(COMMAND_METADATA$1, {
2457
2548
  id: CreateModelClientCommand.type
2458
2549
  }, CreateModelClientCommand);
2459
2550
 
2551
+ const SKILL_SOURCE_PROVIDER = 'SKILL_SOURCE_PROVIDER';
2552
+ const SkillSourceProviderStrategy = (provider)=>applyDecorators(SetMetadata(SKILL_SOURCE_PROVIDER, provider), SetMetadata(STRATEGY_META_KEY, SKILL_SOURCE_PROVIDER));
2553
+
2554
+ let SkillSourceProviderRegistry = class SkillSourceProviderRegistry extends BaseStrategyRegistry {
2555
+ constructor(discoveryService, reflector){
2556
+ super(SKILL_SOURCE_PROVIDER, discoveryService, reflector);
2557
+ }
2558
+ };
2559
+ SkillSourceProviderRegistry = __decorate([
2560
+ Injectable(),
2561
+ __metadata("design:paramtypes", [
2562
+ DiscoveryService,
2563
+ Reflector
2564
+ ])
2565
+ ], SkillSourceProviderRegistry);
2566
+
2460
2567
  const AGENT_MIDDLEWARE_STRATEGY = 'AGENT_MIDDLEWARE_STRATEGY';
2461
2568
  const AgentMiddlewareStrategy = (provider)=>applyDecorators(SetMetadata(AGENT_MIDDLEWARE_STRATEGY, provider), SetMetadata(STRATEGY_META_KEY, AGENT_MIDDLEWARE_STRATEGY));
2462
2569
 
@@ -2467,10 +2574,9 @@ let AgentMiddlewareRegistry = class AgentMiddlewareRegistry extends BaseStrategy
2467
2574
  };
2468
2575
  AgentMiddlewareRegistry = __decorate([
2469
2576
  Injectable(),
2470
- __metadata("design:type", Function),
2471
2577
  __metadata("design:paramtypes", [
2472
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
2473
- typeof Reflector === "undefined" ? Object : Reflector
2578
+ DiscoveryService,
2579
+ Reflector
2474
2580
  ])
2475
2581
  ], AgentMiddlewareRegistry);
2476
2582
 
@@ -2482,15 +2588,7 @@ AgentMiddlewareRegistry = __decorate([
2482
2588
  "end"
2483
2589
  ];
2484
2590
 
2485
- /**
2486
- * Structured message types (suggested format):
2487
- * - channel.{provider}.{action}.v{number}
2488
- * - agent.{action}.v{number}
2489
- * - system.{action}.v{number}
2490
- * - plugin.{domain}.{action}.v{number}
2491
- *
2492
- * Note: At runtime, any string type is still allowed, facilitating dynamic extension by plugins.
2493
- */ const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
2591
+ const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
2494
2592
  const VERSION_PATTERN = /^v[1-9][0-9]*$/;
2495
2593
  function assertSegment(input, name) {
2496
2594
  if (!SEGMENT_PATTERN.test(input)) {
@@ -2556,10 +2654,9 @@ let HandoffProcessorRegistry = class HandoffProcessorRegistry extends BaseStrate
2556
2654
  };
2557
2655
  HandoffProcessorRegistry = __decorate([
2558
2656
  Injectable(),
2559
- __metadata("design:type", Function),
2560
2657
  __metadata("design:paramtypes", [
2561
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
2562
- typeof Reflector === "undefined" ? Object : Reflector
2658
+ DiscoveryService,
2659
+ Reflector
2563
2660
  ])
2564
2661
  ], HandoffProcessorRegistry);
2565
2662
 
@@ -2668,26 +2765,52 @@ HandoffProcessorRegistry = __decorate([
2668
2765
  * ```
2669
2766
  */ const ChatChannel = (type)=>SetMetadata(CHAT_CHANNEL, type);
2670
2767
 
2671
- let ChatChannelRegistry = class ChatChannelRegistry extends BaseStrategyRegistry {
2768
+ /**
2769
+ * Chat Channel Registry
2770
+ *
2771
+ * Manages all registered chat channel implementations.
2772
+ * Channels are automatically discovered and registered via @ChatChannel decorator.
2773
+ *
2774
+ * Supports:
2775
+ * - Organization-scoped channels
2776
+ * - Global channels (fallback)
2777
+ * - Plugin-based registration/removal
2778
+ * - Dynamic channel lookup
2779
+ *
2780
+ * @example
2781
+ * ```typescript
2782
+ * // Get channel by type
2783
+ * const channel = registry.get('lark')
2784
+ *
2785
+ * // List all available channels for an organization
2786
+ * const channels = registry.list(organizationId)
2787
+ *
2788
+ * // Send message using a channel
2789
+ * await channel.sendText(ctx, 'Hello!')
2790
+ * ```
2791
+ */ let ChatChannelRegistry = class ChatChannelRegistry extends BaseStrategyRegistry {
2672
2792
  constructor(discoveryService, reflector){
2673
2793
  super(CHAT_CHANNEL, discoveryService, reflector);
2674
2794
  }
2675
2795
  };
2676
2796
  ChatChannelRegistry = __decorate([
2677
2797
  Injectable(),
2678
- __metadata("design:type", Function),
2679
2798
  __metadata("design:paramtypes", [
2680
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
2681
- typeof Reflector === "undefined" ? Object : Reflector
2799
+ DiscoveryService,
2800
+ Reflector
2682
2801
  ])
2683
2802
  ], ChatChannelRegistry);
2684
2803
 
2804
+ const COMMAND_METADATA = '__command__';
2685
2805
  class CancelConversationCommand {
2686
2806
  constructor(input){
2687
2807
  this.input = input;
2688
2808
  }
2689
2809
  }
2690
2810
  CancelConversationCommand.type = '[Chat Conversation] Cancel';
2811
+ Reflect.defineMetadata(COMMAND_METADATA, {
2812
+ id: CancelConversationCommand.type
2813
+ }, CancelConversationCommand);
2691
2814
 
2692
2815
  const FILE_STORAGE_PROVIDER = 'FILE_STORAGE_PROVIDER';
2693
2816
  const FileStorageProvider = (provider)=>applyDecorators(SetMetadata(FILE_STORAGE_PROVIDER, provider), SetMetadata(STRATEGY_META_KEY, FILE_STORAGE_PROVIDER));
@@ -2699,10 +2822,9 @@ let FileStorageProviderRegistry = class FileStorageProviderRegistry extends Base
2699
2822
  };
2700
2823
  FileStorageProviderRegistry = __decorate([
2701
2824
  Injectable(),
2702
- __metadata("design:type", Function),
2703
2825
  __metadata("design:paramtypes", [
2704
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
2705
- typeof Reflector === "undefined" ? Object : Reflector
2826
+ DiscoveryService,
2827
+ Reflector
2706
2828
  ])
2707
2829
  ], FileStorageProviderRegistry);
2708
2830
 
@@ -2716,10 +2838,9 @@ let FileUploadTargetRegistry = class FileUploadTargetRegistry extends BaseStrate
2716
2838
  };
2717
2839
  FileUploadTargetRegistry = __decorate([
2718
2840
  Injectable(),
2719
- __metadata("design:type", Function),
2720
2841
  __metadata("design:paramtypes", [
2721
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
2722
- typeof Reflector === "undefined" ? Object : Reflector
2842
+ DiscoveryService,
2843
+ Reflector
2723
2844
  ])
2724
2845
  ], FileUploadTargetRegistry);
2725
2846
 
@@ -2774,8 +2895,18 @@ function resolveSandboxExecutionOptions(options, defaults = DEFAULT_SANDBOX_SHEL
2774
2895
  *
2775
2896
  * @param backend - Backend instance to check
2776
2897
  * @returns True if the backend implements SandboxBackendProtocol
2777
- */ function isSandboxBackend(backend) {
2778
- return typeof backend.execute === 'function' && typeof backend.id === 'string';
2898
+ */ function isObjectLike(value) {
2899
+ return typeof value === 'object' && value !== null;
2900
+ }
2901
+ function isSandboxBackend(backend) {
2902
+ return isObjectLike(backend) && typeof Reflect.get(backend, 'execute') === 'function' && typeof Reflect.get(backend, 'id') === 'string';
2903
+ }
2904
+ function resolveSandboxBackend(sandbox) {
2905
+ if (!isObjectLike(sandbox)) {
2906
+ return null;
2907
+ }
2908
+ const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
2909
+ return isSandboxBackend(candidate) ? candidate : null;
2779
2910
  }
2780
2911
 
2781
2912
  const MAX_LINE_LENGTH = 500;
@@ -3394,10 +3525,10 @@ try {
3394
3525
  * Requires Node.js 20+ on the sandbox host.
3395
3526
  */ class BaseSandbox {
3396
3527
  /**
3397
- * Internal hook for file/search operations. Concrete backends can override
3398
- * this to distinguish "background helper commands" from user-facing shell
3399
- * execute calls.
3400
- */ executeOperation(command, options) {
3528
+ * Internal hook for file/search operations. Concrete backends can override
3529
+ * this to distinguish "background helper commands" from user-facing shell
3530
+ * execute calls.
3531
+ */ executeOperation(command, options) {
3401
3532
  return this.execute(command, options);
3402
3533
  }
3403
3534
  async streamExecute(command, onLine, options) {
@@ -3408,11 +3539,11 @@ try {
3408
3539
  return result;
3409
3540
  }
3410
3541
  /**
3411
- * List files and directories in the specified directory (non-recursive).
3412
- *
3413
- * @param path - Absolute path to directory
3414
- * @returns List of FileInfo objects for files and directories directly in the directory.
3415
- */ async lsInfo(path) {
3542
+ * List files and directories in the specified directory (non-recursive).
3543
+ *
3544
+ * @param path - Absolute path to directory
3545
+ * @returns List of FileInfo objects for files and directories directly in the directory.
3546
+ */ async lsInfo(path) {
3416
3547
  const command = buildLsCommand(path);
3417
3548
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3418
3549
  if (result.exitCode !== 0) {
@@ -3436,14 +3567,14 @@ try {
3436
3567
  return infos;
3437
3568
  }
3438
3569
  /**
3439
- * List directory contents recursively with depth control and pagination.
3440
- *
3441
- * @param dirPath - Absolute path to directory
3442
- * @param offset - 1-indexed entry number to start from (default: 1)
3443
- * @param limit - Maximum number of entries to return (default: 25)
3444
- * @param depth - Maximum depth to traverse (default: 2)
3445
- * @returns Human-readable directory tree with indentation
3446
- */ async listDir(dirPath, offset = 1, limit = 25, depth = 2) {
3570
+ * List directory contents recursively with depth control and pagination.
3571
+ *
3572
+ * @param dirPath - Absolute path to directory
3573
+ * @param offset - 1-indexed entry number to start from (default: 1)
3574
+ * @param limit - Maximum number of entries to return (default: 25)
3575
+ * @param depth - Maximum depth to traverse (default: 2)
3576
+ * @returns Human-readable directory tree with indentation
3577
+ */ async listDir(dirPath, offset = 1, limit = 25, depth = 2) {
3447
3578
  if (offset < 1) {
3448
3579
  return 'Error: offset must be a 1-indexed entry number';
3449
3580
  }
@@ -3461,15 +3592,15 @@ try {
3461
3592
  return result.output;
3462
3593
  }
3463
3594
  /**
3464
- * Read file content with line numbers.
3465
- *
3466
- * @param filePath - Absolute file path
3467
- * @param offset - Line offset to start reading from (1-indexed)
3468
- * @param limit - Maximum number of lines to read
3469
- * @param mode - Read mode: 'slice' (default) or 'indentation'
3470
- * @param indentation - Configuration for indentation mode
3471
- * @returns Formatted file content with line numbers, or error message
3472
- */ async read(filePath, offset = 1, limit = 2000, mode = 'slice', indentation) {
3595
+ * Read file content with line numbers.
3596
+ *
3597
+ * @param filePath - Absolute file path
3598
+ * @param offset - Line offset to start reading from (1-indexed)
3599
+ * @param limit - Maximum number of lines to read
3600
+ * @param mode - Read mode: 'slice' (default) or 'indentation'
3601
+ * @param indentation - Configuration for indentation mode
3602
+ * @returns Formatted file content with line numbers, or error message
3603
+ */ async read(filePath, offset = 1, limit = 2000, mode = 'slice', indentation) {
3473
3604
  const command = mode === 'indentation' ? buildIndentationReadCommand(filePath, offset, limit, indentation != null ? indentation : {}) : buildSliceReadCommand(filePath, offset, limit);
3474
3605
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3475
3606
  if (result.exitCode !== 0) {
@@ -3478,8 +3609,8 @@ try {
3478
3609
  return result.output;
3479
3610
  }
3480
3611
  /**
3481
- * Structured search results or error string for invalid input.
3482
- */ async grepRaw(pattern, path = '/', include = null) {
3612
+ * Structured search results or error string for invalid input.
3613
+ */ async grepRaw(pattern, path = '/', include = null) {
3483
3614
  const command = buildGrepCommand(pattern, path, include);
3484
3615
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
3485
3616
  if (result.exitCode === 1) {
@@ -3505,8 +3636,8 @@ try {
3505
3636
  return matches;
3506
3637
  }
3507
3638
  /**
3508
- * Search file contents for a regex pattern, returning human-readable output.
3509
- */ async grep(pattern, path = '/', include = null) {
3639
+ * Search file contents for a regex pattern, returning human-readable output.
3640
+ */ async grep(pattern, path = '/', include = null) {
3510
3641
  const result = await this.grepRaw(pattern, path, include);
3511
3642
  if (typeof result === 'string') {
3512
3643
  return result;
@@ -3517,8 +3648,8 @@ try {
3517
3648
  return formatGrepOutput(result);
3518
3649
  }
3519
3650
  /**
3520
- * Structured glob matching returning FileInfo objects.
3521
- */ async globInfo(pattern, path = '/') {
3651
+ * Structured glob matching returning FileInfo objects.
3652
+ */ async globInfo(pattern, path = '/') {
3522
3653
  const command = buildGlobCommand(path, pattern);
3523
3654
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
3524
3655
  const infos = [];
@@ -3539,8 +3670,8 @@ try {
3539
3670
  return infos;
3540
3671
  }
3541
3672
  /**
3542
- * Find files matching a glob pattern, returning human-readable output.
3543
- */ async glob(pattern, path = '/') {
3673
+ * Find files matching a glob pattern, returning human-readable output.
3674
+ */ async glob(pattern, path = '/') {
3544
3675
  const files = await this.globInfo(pattern, path);
3545
3676
  if (files.length === 0) {
3546
3677
  return 'No files found';
@@ -3548,8 +3679,8 @@ try {
3548
3679
  return formatGlobOutput(files);
3549
3680
  }
3550
3681
  /**
3551
- * Create a new file with content.
3552
- */ async write(filePath, content) {
3682
+ * Create a new file with content.
3683
+ */ async write(filePath, content) {
3553
3684
  const command = buildWriteCommand(filePath, content);
3554
3685
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3555
3686
  if (result.exitCode !== 0) {
@@ -3602,8 +3733,8 @@ try {
3602
3733
  };
3603
3734
  }
3604
3735
  /**
3605
- * Append content to a file. Creates the file if it doesn't exist.
3606
- */ async append(filePath, content) {
3736
+ * Append content to a file. Creates the file if it doesn't exist.
3737
+ */ async append(filePath, content) {
3607
3738
  const command = buildAppendCommand(filePath, content);
3608
3739
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3609
3740
  if (result.exitCode !== 0) {
@@ -3618,8 +3749,8 @@ try {
3618
3749
  };
3619
3750
  }
3620
3751
  /**
3621
- * Edit a file by replacing string occurrences.
3622
- */ async edit(filePath, oldString, newString, replaceAll = false) {
3752
+ * Edit a file by replacing string occurrences.
3753
+ */ async edit(filePath, oldString, newString, replaceAll = false) {
3623
3754
  const command = buildEditCommand(filePath, oldString, newString, replaceAll);
3624
3755
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3625
3756
  switch(result.exitCode){
@@ -3651,10 +3782,10 @@ try {
3651
3782
  }
3652
3783
  }
3653
3784
  /**
3654
- * Perform multiple sequential edits on a single file.
3655
- * All edits are applied sequentially, with each edit operating on the result of the previous edit.
3656
- * All edits must succeed for the operation to succeed (atomic).
3657
- */ async multiEdit(filePath, edits) {
3785
+ * Perform multiple sequential edits on a single file.
3786
+ * All edits are applied sequentially, with each edit operating on the result of the previous edit.
3787
+ * All edits must succeed for the operation to succeed (atomic).
3788
+ */ async multiEdit(filePath, edits) {
3658
3789
  if (!edits || edits.length === 0) {
3659
3790
  return {
3660
3791
  error: 'No edits provided'
@@ -3694,11 +3825,50 @@ let SandboxProviderRegistry = class SandboxProviderRegistry extends BaseStrategy
3694
3825
  };
3695
3826
  SandboxProviderRegistry = __decorate([
3696
3827
  Injectable(),
3697
- __metadata("design:type", Function),
3698
3828
  __metadata("design:paramtypes", [
3699
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
3700
- typeof Reflector === "undefined" ? Object : Reflector
3829
+ DiscoveryService,
3830
+ Reflector
3701
3831
  ])
3702
3832
  ], SandboxProviderRegistry);
3703
3833
 
3704
- export { AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PERMISSION_SERVICE_TOKEN, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, 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, STRATEGY_META_KEY, SandboxProviderRegistry, SandboxProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VectorStoreRegistry, VectorStoreStrategy, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WrapWorkflowNodeExecutionCommand, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, buildSandboxTimeoutMessage, calcTokenUsage, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, defineAgentMessageType, defineChannelMessageType, downloadRemoteFile, formatSandboxTimeout, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, isRemoteFile, isSandboxBackend, isStructuredMessageType, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, resolveSandboxExecutionOptions, runWithRequestContext, secondsToMilliseconds, sumTokenUsage };
3834
+ const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
3835
+ const ViewExtensionProvider = (providerKey)=>applyDecorators(SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
3836
+
3837
+ let ViewExtensionProviderRegistry = class ViewExtensionProviderRegistry extends BaseStrategyRegistry {
3838
+ listEntries(organizationId) {
3839
+ var _this_strategies_get;
3840
+ const orgKey = this.resolveOrganization(organizationId);
3841
+ const entries = new Map();
3842
+ var _this_strategies_get_entries;
3843
+ for (const [providerKey, provider] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
3844
+ entries.set(providerKey, provider);
3845
+ }
3846
+ if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
3847
+ var _this_strategies_get1;
3848
+ var _this_strategies_get_entries1;
3849
+ for (const [providerKey, provider] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
3850
+ if (!entries.has(providerKey)) {
3851
+ entries.set(providerKey, provider);
3852
+ }
3853
+ }
3854
+ }
3855
+ return Array.from(entries.entries()).map(([providerKey, provider])=>({
3856
+ providerKey,
3857
+ provider
3858
+ }));
3859
+ }
3860
+ constructor(discoveryService, reflector){
3861
+ super(VIEW_EXTENSION_PROVIDER, discoveryService, reflector);
3862
+ }
3863
+ };
3864
+ ViewExtensionProviderRegistry = __decorate([
3865
+ Injectable(),
3866
+ __metadata("design:paramtypes", [
3867
+ DiscoveryService,
3868
+ Reflector
3869
+ ])
3870
+ ], ViewExtensionProviderRegistry);
3871
+
3872
+ const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
3873
+
3874
+ export { AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PERMISSION_SERVICE_TOKEN, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, 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, STRATEGY_META_KEY, SandboxProviderRegistry, SandboxProviderStrategy, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WrapWorkflowNodeExecutionCommand, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, buildSandboxTimeoutMessage, calcTokenUsage, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, defineAgentMessageType, defineChannelMessageType, downloadRemoteFile, formatSandboxTimeout, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, isRemoteFile, isSandboxBackend, isStructuredMessageType, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, resolveSandboxBackend, resolveSandboxExecutionOptions, runWithRequestContext, secondsToMilliseconds, sumTokenUsage };