@xpert-ai/plugin-sdk 3.8.4 → 3.9.0-beta.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.
Files changed (40) hide show
  1. package/index.cjs.js +459 -320
  2. package/index.esm.js +442 -293
  3. package/package.json +4 -3
  4. package/src/index.d.ts +1 -0
  5. package/src/lib/agent/handoff/handoff-processor.decorator.d.ts +1 -1
  6. package/src/lib/agent/index.d.ts +1 -0
  7. package/src/lib/agent/middleware/strategy.decorator.d.ts +1 -1
  8. package/src/lib/agent/skill/skill-source-provider.decorator.d.ts +1 -1
  9. package/src/lib/agent/skill/skill-source-provider.interface.d.ts +1 -1
  10. package/src/lib/channel/strategy.interface.d.ts +0 -2
  11. package/src/lib/core/context/request-context.d.ts +7 -4
  12. package/src/lib/core/context/request-context.middleware.d.ts +0 -1
  13. package/src/lib/core/file-system.d.ts +1 -3
  14. package/src/lib/core/permissions/analytics.d.ts +2 -3
  15. package/src/lib/data/datasource/strategy.decorator.d.ts +1 -1
  16. package/src/lib/data/datasource/types.d.ts +0 -3
  17. package/src/lib/file/file-storage/provider.decorator.d.ts +1 -1
  18. package/src/lib/file/file-storage/provider.interface.d.ts +0 -2
  19. package/src/lib/file/file-upload/strategy.decorator.d.ts +1 -1
  20. package/src/lib/file/file-upload/strategy.interface.d.ts +0 -2
  21. package/src/lib/integration/strategy.decorator.d.ts +1 -1
  22. package/src/lib/rag/image/strategy.decorator.d.ts +1 -1
  23. package/src/lib/rag/knowledge/knowledge-strategy.decorator.d.ts +1 -1
  24. package/src/lib/rag/retriever/strategy.decorator.d.ts +1 -1
  25. package/src/lib/rag/source/strategy.decorator.d.ts +1 -1
  26. package/src/lib/rag/textsplitter/strategy.decorator.d.ts +1 -1
  27. package/src/lib/rag/transformer/strategy.decorator.d.ts +1 -1
  28. package/src/lib/sandbox/protocol.d.ts +4 -8
  29. package/src/lib/sandbox/sandbox.decorator.d.ts +1 -1
  30. package/src/lib/strategy.d.ts +3 -3
  31. package/src/lib/toolset/strategy.decorator.d.ts +1 -1
  32. package/src/lib/vectorstore/strategy.decorator.d.ts +1 -1
  33. package/src/lib/view-extension/index.d.ts +3 -0
  34. package/src/lib/view-extension/provider.decorator.d.ts +2 -0
  35. package/src/lib/view-extension/provider.interface.d.ts +7 -0
  36. package/src/lib/view-extension/provider.registry.d.ts +10 -0
  37. package/src/lib/workflow/node/strategy.decorator.d.ts +1 -1
  38. package/src/lib/workflow/trigger/strategy.decorator.d.ts +1 -1
  39. package/index.esm.d.ts +0 -1
  40. /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
6
  import { LanguagesEnum, AiModelTypeEnum, ParameterType, PriceType, FetchFrom, ModelFeature, ModelPropertyKey } from '@metad/contracts';
7
- export { IColumnDef, IDSSchema, IDSTable, TDocumentAsset } from '@metad/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,6 +120,8 @@ 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();
@@ -133,6 +134,11 @@ class RequestContext {
133
134
  }
134
135
  return null;
135
136
  }
137
+ static currentApiKey() {
138
+ const user = RequestContext.currentUser();
139
+ var _user_apiKey;
140
+ return (_user_apiKey = user == null ? void 0 : user.apiKey) != null ? _user_apiKey : null;
141
+ }
136
142
  static currentTenantId() {
137
143
  const user = RequestContext.currentUser();
138
144
  if (user) {
@@ -174,9 +180,9 @@ class RequestContext {
174
180
  ], throwError);
175
181
  }
176
182
  /**
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() {
183
+ * Retrieves the language code from the headers of the current request.
184
+ * @returns The language code (LanguagesEnum) extracted from the headers, or the default language (ENGLISH) if not found.
185
+ */ static getLanguageCode() {
180
186
  // Retrieve the current request
181
187
  const req = RequestContext.currentRequest();
182
188
  // Variable to store the extracted language code
@@ -192,21 +198,71 @@ class RequestContext {
192
198
  // Return the extracted language code or the default language (ENGLISH) if not found
193
199
  return lang || LanguagesEnum.English;
194
200
  }
195
- static getOrganizationId() {
196
- const req = this.currentRequest();
197
- let organizationId;
198
- const keys = [
201
+ static getScope() {
202
+ const request = this.currentRequest();
203
+ const user = this.currentUser();
204
+ var _user_tenantId, _ref;
205
+ const tenantId = (_ref = (_user_tenantId = user == null ? void 0 : user.tenantId) != null ? _user_tenantId : getHeaderValue(request, [
206
+ 'tenant-id'
207
+ ])) != null ? _ref : null;
208
+ var _getHeaderValue;
209
+ const organizationId = (_getHeaderValue = getHeaderValue(request, [
199
210
  '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;
211
+ ])) != null ? _getHeaderValue : null;
212
+ const scopeLevelHeader = getHeaderValue(request, [
213
+ 'x-scope-level'
214
+ ]);
215
+ if (scopeLevelHeader) {
216
+ if (scopeLevelHeader !== TENANT_SCOPE && scopeLevelHeader !== ORGANIZATION_SCOPE) {
217
+ throw new BadRequestException(`Unsupported scope level: ${scopeLevelHeader}`);
218
+ }
219
+ if (scopeLevelHeader === TENANT_SCOPE) {
220
+ if (organizationId) {
221
+ throw new BadRequestException('Tenant scope requests must not include Organization-Id.');
206
222
  }
223
+ return {
224
+ tenantId,
225
+ level: TENANT_SCOPE,
226
+ organizationId: null
227
+ };
228
+ }
229
+ if (!organizationId) {
230
+ throw new BadRequestException('Organization scope requests require Organization-Id.');
207
231
  }
232
+ return {
233
+ tenantId,
234
+ level: ORGANIZATION_SCOPE,
235
+ organizationId
236
+ };
237
+ }
238
+ if (organizationId) {
239
+ return {
240
+ tenantId,
241
+ level: ORGANIZATION_SCOPE,
242
+ organizationId
243
+ };
208
244
  }
209
- return organizationId;
245
+ return {
246
+ tenantId,
247
+ level: TENANT_SCOPE,
248
+ organizationId: null
249
+ };
250
+ }
251
+ static getOrganizationId() {
252
+ return this.getScope().organizationId;
253
+ }
254
+ static isTenantScope() {
255
+ return this.getScope().level === TENANT_SCOPE;
256
+ }
257
+ static isOrganizationScope() {
258
+ return this.getScope().level === ORGANIZATION_SCOPE;
259
+ }
260
+ static requireOrganizationScope() {
261
+ const scope = this.getScope();
262
+ if (scope.level !== ORGANIZATION_SCOPE || !scope.organizationId) {
263
+ throw new BadRequestException('Organization scope is required for this operation.');
264
+ }
265
+ return scope.organizationId;
210
266
  }
211
267
  static hasPermissions(findPermissions, throwError) {
212
268
  const requestContext = RequestContext.currentRequestContext();
@@ -260,22 +316,22 @@ class RequestContext {
260
316
  return null;
261
317
  }
262
318
  /**
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) {
319
+ * Checks if the current user has a specific role.
320
+ * @param {RolesEnum} role - The role to check.
321
+ * @param {boolean} throwError - Flag indicating whether to throw an error if the role is not granted.
322
+ * @returns {boolean} - True if the user has the role, otherwise false.
323
+ */ static hasRole(role, throwError) {
268
324
  return this.hasRoles([
269
325
  role
270
326
  ], throwError);
271
327
  }
272
328
  /**
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) {
329
+ * Checks if the current request context has any of the specified roles.
330
+ *
331
+ * @param roles - An array of roles to check.
332
+ * @param throwError - Whether to throw an error if no roles are found.
333
+ * @returns True if any of the required roles are found, otherwise false.
334
+ */ static hasRoles(roles, throwError) {
279
335
  const context = RequestContext.currentRequestContext();
280
336
  if (context) {
281
337
  try {
@@ -312,8 +368,23 @@ const als = new AsyncLocalStorage();
312
368
  function getRequestContext() {
313
369
  return als.getStore();
314
370
  }
371
+ function getHeaderValue(req, keys) {
372
+ if (!(req == null ? void 0 : req.headers)) {
373
+ return null;
374
+ }
375
+ for (const key of keys){
376
+ const value = req.headers[key];
377
+ if (Array.isArray(value)) {
378
+ var _value_;
379
+ return (_value_ = value[0]) != null ? _value_ : null;
380
+ }
381
+ if (typeof value === 'string' && value) {
382
+ return value;
383
+ }
384
+ }
385
+ return null;
386
+ }
315
387
 
316
- // request-context.middleware.ts
317
388
  let RequestContextMiddleware = class RequestContextMiddleware {
318
389
  use(req, _res, next) {
319
390
  var _req_user;
@@ -414,10 +485,10 @@ class BaseStrategyRegistry {
414
485
  }
415
486
  /**
416
487
  * Get strategy by type from the given organization including global strategies as fallback.
417
- *
418
- * @param type
419
- * @param organizationId
420
- * @returns
488
+ *
489
+ * @param type
490
+ * @param organizationId
491
+ * @returns
421
492
  */ get(type, organizationId) {
422
493
  var _this_strategies_get, _this_strategies_get1;
423
494
  organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
@@ -431,34 +502,42 @@ class BaseStrategyRegistry {
431
502
  }
432
503
  /**
433
504
  * 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
505
+ *
506
+ * @param organizationId
507
+ * @returns
437
508
  */ list(organizationId) {
438
- var _this_strategies_get, _this_strategies_get1;
509
+ var _this_strategies_get;
439
510
  organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
440
511
  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
- ]));
512
+ const effective = new Map();
513
+ var _this_strategies_get_entries;
514
+ 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 : []){
515
+ effective.set(type, strategy);
516
+ }
517
+ if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
518
+ var _this_strategies_get1;
519
+ var _this_strategies_get_entries1;
520
+ 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 : []){
521
+ if (!effective.has(type)) {
522
+ effective.set(type, strategy);
523
+ }
524
+ }
525
+ }
526
+ return Array.from(effective.values());
449
527
  }
450
528
  constructor(strategyKey, discoveryService, reflector){
451
- this.strategyKey = strategyKey;
452
- this.discoveryService = discoveryService;
453
- this.reflector = reflector;
454
529
  this.logger = new Logger(BaseStrategyRegistry.name);
530
+ // Map<organizationId, Map<type, strategy>>
455
531
  this.strategies = new Map();
456
532
  this.pluginStrategies = new Map();
533
+ this.strategyKey = strategyKey;
534
+ this.discoveryService = discoveryService;
535
+ this.reflector = reflector;
457
536
  }
458
537
  }
459
538
  __decorate([
460
539
  Inject(StrategyBus),
461
- __metadata("design:type", typeof StrategyBus === "undefined" ? Object : StrategyBus)
540
+ __metadata("design:type", StrategyBus)
462
541
  ], BaseStrategyRegistry.prototype, "bus", void 0);
463
542
 
464
543
  let IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends BaseStrategyRegistry {
@@ -468,10 +547,9 @@ let IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends Base
468
547
  };
469
548
  IntegrationStrategyRegistry = __decorate([
470
549
  Injectable(),
471
- __metadata("design:type", Function),
472
550
  __metadata("design:paramtypes", [
473
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
474
- typeof Reflector === "undefined" ? Object : Reflector
551
+ DiscoveryService,
552
+ Reflector
475
553
  ])
476
554
  ], IntegrationStrategyRegistry);
477
555
 
@@ -485,10 +563,9 @@ let WorkflowTriggerRegistry = class WorkflowTriggerRegistry extends BaseStrategy
485
563
  };
486
564
  WorkflowTriggerRegistry = __decorate([
487
565
  Injectable(),
488
- __metadata("design:type", Function),
489
566
  __metadata("design:paramtypes", [
490
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
491
- typeof Reflector === "undefined" ? Object : Reflector
567
+ DiscoveryService,
568
+ Reflector
492
569
  ])
493
570
  ], WorkflowTriggerRegistry);
494
571
 
@@ -497,21 +574,22 @@ const WORKFLOW_NODE_STRATEGY = 'WORKFLOW_NODE_STRATEGY';
497
574
  * Decorator to mark a provider as a Workflow Node Strategy
498
575
  */ const WorkflowNodeStrategy = (provider)=>applyDecorators(SetMetadata(WORKFLOW_NODE_STRATEGY, provider), SetMetadata(STRATEGY_META_KEY, WORKFLOW_NODE_STRATEGY));
499
576
 
500
- let WorkflowNodeRegistry = class WorkflowNodeRegistry extends BaseStrategyRegistry {
577
+ /**
578
+ * Registry for Workflow Node Strategies
579
+ */ let WorkflowNodeRegistry = class WorkflowNodeRegistry extends BaseStrategyRegistry {
501
580
  constructor(discoveryService, reflector){
502
581
  super(WORKFLOW_NODE_STRATEGY, discoveryService, reflector);
503
582
  }
504
583
  };
505
584
  WorkflowNodeRegistry = __decorate([
506
585
  Injectable(),
507
- __metadata("design:type", Function),
508
586
  __metadata("design:paramtypes", [
509
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
510
- typeof Reflector === "undefined" ? Object : Reflector
587
+ DiscoveryService,
588
+ Reflector
511
589
  ])
512
590
  ], WorkflowNodeRegistry);
513
591
 
514
- const COMMAND_METADATA$1 = '__command__';
592
+ const COMMAND_METADATA$2 = '__command__';
515
593
  /**
516
594
  * Wrap Workflow Node Execution Command
517
595
  */ class WrapWorkflowNodeExecutionCommand extends Command {
@@ -522,7 +600,7 @@ const COMMAND_METADATA$1 = '__command__';
522
600
  }
523
601
  }
524
602
  WrapWorkflowNodeExecutionCommand.type = '[Workflow] Wrap Workflow Node Execution';
525
- Reflect.defineMetadata(COMMAND_METADATA$1, {
603
+ Reflect.defineMetadata(COMMAND_METADATA$2, {
526
604
  id: WrapWorkflowNodeExecutionCommand.type
527
605
  }, WrapWorkflowNodeExecutionCommand);
528
606
 
@@ -536,10 +614,9 @@ let VectorStoreRegistry = class VectorStoreRegistry extends BaseStrategyRegistry
536
614
  };
537
615
  VectorStoreRegistry = __decorate([
538
616
  Injectable(),
539
- __metadata("design:type", Function),
540
617
  __metadata("design:paramtypes", [
541
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
542
- typeof Reflector === "undefined" ? Object : Reflector
618
+ DiscoveryService,
619
+ Reflector
543
620
  ])
544
621
  ], VectorStoreRegistry);
545
622
 
@@ -553,10 +630,9 @@ let TextSplitterRegistry = class TextSplitterRegistry extends BaseStrategyRegist
553
630
  };
554
631
  TextSplitterRegistry = __decorate([
555
632
  Injectable(),
556
- __metadata("design:type", Function),
557
633
  __metadata("design:paramtypes", [
558
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
559
- typeof Reflector === "undefined" ? Object : Reflector
634
+ DiscoveryService,
635
+ Reflector
560
636
  ])
561
637
  ], TextSplitterRegistry);
562
638
 
@@ -572,10 +648,9 @@ let DocumentSourceRegistry = class DocumentSourceRegistry extends BaseStrategyRe
572
648
  };
573
649
  DocumentSourceRegistry = __decorate([
574
650
  Injectable(),
575
- __metadata("design:type", Function),
576
651
  __metadata("design:paramtypes", [
577
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
578
- typeof Reflector === "undefined" ? Object : Reflector
652
+ DiscoveryService,
653
+ Reflector
579
654
  ])
580
655
  ], DocumentSourceRegistry);
581
656
 
@@ -591,10 +666,9 @@ let DocumentTransformerRegistry = class DocumentTransformerRegistry extends Base
591
666
  };
592
667
  DocumentTransformerRegistry = __decorate([
593
668
  Injectable(),
594
- __metadata("design:type", Function),
595
669
  __metadata("design:paramtypes", [
596
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
597
- typeof Reflector === "undefined" ? Object : Reflector
670
+ DiscoveryService,
671
+ Reflector
598
672
  ])
599
673
  ], DocumentTransformerRegistry);
600
674
 
@@ -610,16 +684,15 @@ let RetrieverRegistry = class RetrieverRegistry extends BaseStrategyRegistry {
610
684
  };
611
685
  RetrieverRegistry = __decorate([
612
686
  Injectable(),
613
- __metadata("design:type", Function),
614
687
  __metadata("design:paramtypes", [
615
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
616
- typeof Reflector === "undefined" ? Object : Reflector
688
+ DiscoveryService,
689
+ Reflector
617
690
  ])
618
691
  ], RetrieverRegistry);
619
692
 
620
693
  /**
621
694
  * Merge parent chunks with their child chunks based on metadata (parentId and chunkId)
622
- *
695
+ *
623
696
  * @deprecated use buildChunkTreeAndFindLeaves instead
624
697
  */ function mergeParentChildChunks(chunks, children // Child chunks
625
698
  ) {
@@ -685,10 +758,9 @@ let ImageUnderstandingRegistry = class ImageUnderstandingRegistry extends BaseSt
685
758
  };
686
759
  ImageUnderstandingRegistry = __decorate([
687
760
  Injectable(),
688
- __metadata("design:type", Function),
689
761
  __metadata("design:paramtypes", [
690
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
691
- typeof Reflector === "undefined" ? Object : Reflector
762
+ DiscoveryService,
763
+ Reflector
692
764
  ])
693
765
  ], ImageUnderstandingRegistry);
694
766
 
@@ -702,10 +774,9 @@ let KnowledgeStrategyRegistry = class KnowledgeStrategyRegistry extends BaseStra
702
774
  };
703
775
  KnowledgeStrategyRegistry = __decorate([
704
776
  Injectable(),
705
- __metadata("design:type", Function),
706
777
  __metadata("design:paramtypes", [
707
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
708
- typeof Reflector === "undefined" ? Object : Reflector
778
+ DiscoveryService,
779
+ Reflector
709
780
  ])
710
781
  ], KnowledgeStrategyRegistry);
711
782
 
@@ -721,10 +792,9 @@ let ToolsetRegistry = class ToolsetRegistry extends BaseStrategyRegistry {
721
792
  };
722
793
  ToolsetRegistry = __decorate([
723
794
  Injectable(),
724
- __metadata("design:type", Function),
725
795
  __metadata("design:paramtypes", [
726
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
727
- typeof Reflector === "undefined" ? Object : Reflector
796
+ DiscoveryService,
797
+ Reflector
728
798
  ])
729
799
  ], ToolsetRegistry);
730
800
 
@@ -732,26 +802,26 @@ ToolsetRegistry = __decorate([
732
802
  * Base ability for all toolsets
733
803
  */ class BaseToolset extends BaseToolkit {
734
804
  /**
735
- * Async init tools
736
- *
737
- * @returns
738
- */ async initTools() {
805
+ * Async init tools
806
+ *
807
+ * @returns
808
+ */ async initTools() {
739
809
  return this.tools;
740
810
  }
741
811
  /**
742
- * Get one tool
743
- *
744
- * @param toolName
745
- * @returns
746
- */ getTool(toolName) {
812
+ * Get one tool
813
+ *
814
+ * @param toolName
815
+ * @returns
816
+ */ getTool(toolName) {
747
817
  var _this_getTools;
748
818
  return (_this_getTools = this.getTools()) == null ? void 0 : _this_getTools.find((tool)=>tool.name === toolName);
749
819
  }
750
820
  /**
751
- * Get state variables config
752
- *
753
- * @returns State variables
754
- */ async getVariables() {
821
+ * Get state variables config
822
+ *
823
+ * @returns State variables
824
+ */ async getVariables() {
755
825
  return null;
756
826
  }
757
827
  /**
@@ -809,26 +879,26 @@ class BuiltinToolset extends BaseToolset {
809
879
  return (_this_toolset = this.toolset) == null ? void 0 : _this_toolset.credentials;
810
880
  }
811
881
  getToolTitle(name) {
812
- var _this_toolset_tools, _this_toolset, _this;
882
+ var _this_toolset_tools, _this_toolset, _tool_schema;
813
883
  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;
884
+ const identity = tool == null ? void 0 : (_tool_schema = tool.schema) == null ? void 0 : _tool_schema.identity;
815
885
  if (identity) {
816
886
  return identity.label;
817
887
  }
818
888
  return null;
819
889
  }
820
890
  /**
821
- * Get credentials schema
822
- *
823
- * @returns Credentials schema
824
- */ getCredentialsSchema() {
891
+ * Get credentials schema
892
+ *
893
+ * @returns Credentials schema
894
+ */ getCredentialsSchema() {
825
895
  return _extends({}, this.credentialsSchema);
826
896
  }
827
897
  /**
828
- * Get toolset entity
829
- *
830
- * @returns XpertToolset
831
- */ getToolset() {
898
+ * Get toolset entity
899
+ *
900
+ * @returns XpertToolset
901
+ */ getToolset() {
832
902
  return this.toolset;
833
903
  }
834
904
  getName() {
@@ -837,27 +907,27 @@ class BuiltinToolset extends BaseToolset {
837
907
  }
838
908
  constructor(providerName, toolset, params){
839
909
  super(params);
910
+ this.logger = new Logger(this.constructor.name);
840
911
  this.providerName = providerName;
841
912
  this.toolset = toolset;
842
913
  this.params = params;
843
- this.logger = new Logger(this.constructor.name);
844
914
  }
845
- }
915
+ }
846
916
  BuiltinToolset.provider = '';
847
917
 
848
918
  /**
849
919
  * Restricted FileSystem based on granted permissions
850
920
  */ class XpFileSystem {
851
921
  /**
852
- * Check if operation is allowed
853
- */ ensureAllowed(op) {
922
+ * Check if operation is allowed
923
+ */ ensureAllowed(op) {
854
924
  if (!this.allowedOps.has(op)) {
855
925
  throw new Error(`Permission denied: ${op} operation not allowed`);
856
926
  }
857
927
  }
858
928
  /**
859
- * Check if path is within scope
860
- */ ensureInScope(targetPath) {
929
+ * Check if path is within scope
930
+ */ ensureInScope(targetPath) {
861
931
  if (!this.scope || this.scope.length === 0) return;
862
932
  const resolved = path__default.resolve(targetPath);
863
933
  for (const s of this.scope){
@@ -867,33 +937,33 @@ BuiltinToolset.provider = '';
867
937
  throw new Error(`Permission denied: path "${targetPath}" is out of scope`);
868
938
  }
869
939
  /**
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) {
940
+ * Get the absolute path of file in the file system.
941
+ *
942
+ * @param filePath Relative file path
943
+ * @returns Absolute file path
944
+ */ fullPath(filePath) {
875
945
  return path__default.join(this.basePath, filePath);
876
946
  }
877
947
  /**
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) {
948
+ * Get web url for a given file path in the file system.
949
+ *
950
+ * @param filePath Relative file path
951
+ * @returns Web URL of file
952
+ */ fullUrl(filePath) {
883
953
  const url = new URL(filePath, this.baseUrl);
884
954
  return url.href;
885
955
  }
886
956
  /**
887
- * Read file contents
888
- */ async readFile(filePath, encoding = 'utf-8') {
957
+ * Read file contents
958
+ */ async readFile(filePath, encoding = 'utf-8') {
889
959
  this.ensureAllowed('read');
890
960
  const fullPath = this.fullPath(filePath);
891
961
  this.ensureInScope(fullPath);
892
962
  return await fsPromises.readFile(fullPath);
893
963
  }
894
964
  /**
895
- * Write file contents
896
- */ async writeFile(filePath, content) {
965
+ * Write file contents
966
+ */ async writeFile(filePath, content) {
897
967
  this.ensureAllowed('write');
898
968
  const fullPath = this.fullPath(filePath);
899
969
  this.ensureInScope(fullPath);
@@ -905,22 +975,22 @@ BuiltinToolset.provider = '';
905
975
  return url.href;
906
976
  }
907
977
  /**
908
- * Delete a file
909
- */ async deleteFile(filePath) {
978
+ * Delete a file
979
+ */ async deleteFile(filePath) {
910
980
  this.ensureAllowed('delete');
911
981
  this.ensureInScope(filePath);
912
982
  await fsPromises.unlink(filePath);
913
983
  }
914
984
  /**
915
- * List directory contents
916
- */ async listDir(dirPath) {
985
+ * List directory contents
986
+ */ async listDir(dirPath) {
917
987
  this.ensureAllowed('list');
918
988
  this.ensureInScope(dirPath);
919
989
  return fsPromises.readdir(dirPath);
920
990
  }
921
991
  /**
922
- * Utility: check if a file or directory exists
923
- */ async exists(targetPath) {
992
+ * Utility: check if a file or directory exists
993
+ */ async exists(targetPath) {
924
994
  try {
925
995
  await fsPromises.access(targetPath);
926
996
  return true;
@@ -1027,7 +1097,7 @@ function loadYamlFile(filePath, logger, ignoreError = true, defaultValue = {}) {
1027
1097
  }
1028
1098
  /**
1029
1099
  * Get the mapping from name to index from a YAML file
1030
- *
1100
+ *
1031
1101
  * @param folderPath
1032
1102
  * @param fileName the YAML file name, default to '_position.yaml'
1033
1103
  * @return a dict with name as key and index as value
@@ -1096,10 +1166,9 @@ let DataSourceStrategyRegistry = class DataSourceStrategyRegistry extends BaseSt
1096
1166
  };
1097
1167
  DataSourceStrategyRegistry = __decorate([
1098
1168
  Injectable(),
1099
- __metadata("design:type", Function),
1100
1169
  __metadata("design:paramtypes", [
1101
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
1102
- typeof Reflector === "undefined" ? Object : Reflector
1170
+ DiscoveryService,
1171
+ Reflector
1103
1172
  ])
1104
1173
  ], DataSourceStrategyRegistry);
1105
1174
 
@@ -1108,12 +1177,12 @@ DataSourceStrategyRegistry = __decorate([
1108
1177
  * into datasource strategies consumable by the plugin SDK.
1109
1178
  */ class AdapterDataSourceStrategy {
1110
1179
  /**
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) {
1180
+ * Get from cache or create new instance of DB adapter.
1181
+ *
1182
+ * @param options
1183
+ * @param id
1184
+ * @returns
1185
+ */ async create(options, id) {
1117
1186
  if (id) {
1118
1187
  if (this.runners.has(id)) {
1119
1188
  return this.runners.get(id);
@@ -1149,9 +1218,10 @@ DataSourceStrategyRegistry = __decorate([
1149
1218
  return this.runnerClass;
1150
1219
  }
1151
1220
  constructor(runnerClass, extraArgs = []){
1221
+ this.runners = new Map() // dataSourceId -> runner instance
1222
+ ;
1152
1223
  this.runnerClass = runnerClass;
1153
1224
  this.extraArgs = extraArgs;
1154
- this.runners = new Map();
1155
1225
  }
1156
1226
  }
1157
1227
 
@@ -1251,13 +1321,13 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1251
1321
  await this.runQuery(`SELECT 1`);
1252
1322
  }
1253
1323
  /**
1254
- * Default implementation for table operations
1255
- */ async tableOp(action, params, options) {
1324
+ * Default implementation for table operations
1325
+ */ async tableOp(action, params, options) {
1256
1326
  switch(action){
1257
- case "createTable":
1327
+ case DBTableAction.CREATE_TABLE:
1258
1328
  {
1259
1329
  // Default implementation for creating table (generic SQL syntax)
1260
- const { schema, table, columns, createMode = "error" } = params;
1330
+ const { schema, table, columns, createMode = DBCreateTableMode.ERROR } = params;
1261
1331
  const tableName = schema ? `${schema}.${table}` : table;
1262
1332
  // Check if table exists (try to query table info)
1263
1333
  let exists = false;
@@ -1269,17 +1339,17 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1269
1339
  exists = false;
1270
1340
  }
1271
1341
  // --- MODE: ERROR → throw error if table exists ---
1272
- if (exists && createMode === "error") {
1342
+ if (exists && createMode === DBCreateTableMode.ERROR) {
1273
1343
  throw new Error(`Table "${tableName}" already exists`);
1274
1344
  }
1275
1345
  // --- MODE: IGNORE → do nothing if exists ---
1276
- if (exists && createMode === "ignore") {
1346
+ if (exists && createMode === DBCreateTableMode.IGNORE) {
1277
1347
  return;
1278
1348
  }
1279
1349
  // --- MODE: UPGRADE → auto upgrade (simple implementation: only add new columns) ---
1280
1350
  // Note: This default implementation does not support modifying column types,
1281
1351
  // recommend each database to implement its own version
1282
- if (exists && createMode === "upgrade") {
1352
+ if (exists && createMode === DBCreateTableMode.UPGRADE) {
1283
1353
  console.warn(`[BaseSQLQueryRunner] UPGRADE mode uses basic implementation. Consider implementing tableOp for better support.`);
1284
1354
  // Try to add new columns (will fail if column already exists, but doesn't affect)
1285
1355
  for (const col of columns){
@@ -1304,7 +1374,7 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1304
1374
  await this.runQuery(createTableStatement, options);
1305
1375
  return;
1306
1376
  }
1307
- case "dropTable":
1377
+ case DBTableAction.DROP_TABLE:
1308
1378
  {
1309
1379
  // Default implementation for dropping table
1310
1380
  const { schema, table } = params;
@@ -1318,8 +1388,8 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1318
1388
  }
1319
1389
  }
1320
1390
  /**
1321
- * Generic type mapping (subclasses can override)
1322
- */ mapColumnType(type, isKey, length) {
1391
+ * Generic type mapping (subclasses can override)
1392
+ */ mapColumnType(type, isKey, length) {
1323
1393
  switch(type == null ? void 0 : type.toLowerCase()){
1324
1394
  case 'string':
1325
1395
  return length ? `VARCHAR(${length})` : isKey ? 'VARCHAR(255)' : 'VARCHAR(1000)';
@@ -1339,8 +1409,8 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1339
1409
  }
1340
1410
  constructor(...args){
1341
1411
  super(...args);
1342
- this.syntax = "sql";
1343
- this.protocol = "sql";
1412
+ this.syntax = DBSyntaxEnum.SQL;
1413
+ this.protocol = DBProtocolEnum.SQL;
1344
1414
  }
1345
1415
  }
1346
1416
  var DBTableAction;
@@ -1361,7 +1431,9 @@ var DBTableAction;
1361
1431
  DBTableAction["CLONE_TABLE"] = "cloneTable";
1362
1432
  DBTableAction["OPTIMIZE_TABLE"] = "optimizeTable";
1363
1433
  })(DBTableAction || (DBTableAction = {}));
1364
- var DBCreateTableMode;
1434
+ /**
1435
+ * Modes for creating a table, if the table already exists
1436
+ */ var DBCreateTableMode;
1365
1437
  (function(DBCreateTableMode) {
1366
1438
  DBCreateTableMode["ERROR"] = "error";
1367
1439
  DBCreateTableMode["IGNORE"] = "ignore";
@@ -1391,8 +1463,7 @@ function AIModelProviderStrategy(provider) {
1391
1463
  const match = (callerLine == null ? void 0 : callerLine.match(/\((file:\/\/\/[^\s)]+)\)/)) || (// case 1: file:///path...
1392
1464
  callerLine == null ? void 0 : callerLine.match(/\((\/[^\s)]+)\)/)) || (// case 2: (/Users/xxx)
1393
1465
  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
- );
1466
+ callerLine == null ? void 0 : callerLine.match(/at (\/[^\s]+)/)); // case 4: at /Users/xxx
1396
1467
  let file = match == null ? void 0 : match[1];
1397
1468
  // remove the file:/// prefix
1398
1469
  if (file == null ? void 0 : file.startsWith('file:///')) {
@@ -1427,10 +1498,9 @@ let AIModelProviderRegistry = class AIModelProviderRegistry extends BaseStrategy
1427
1498
  };
1428
1499
  AIModelProviderRegistry = __decorate([
1429
1500
  Injectable(),
1430
- __metadata("design:type", Function),
1431
1501
  __metadata("design:paramtypes", [
1432
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
1433
- typeof Reflector === "undefined" ? Object : Reflector
1502
+ DiscoveryService,
1503
+ Reflector
1434
1504
  ])
1435
1505
  ], AIModelProviderRegistry);
1436
1506
 
@@ -1441,7 +1511,8 @@ class CredentialsValidateFailedError extends ForbiddenException {
1441
1511
  class AIModelProviderNotFoundException extends NotFoundException {
1442
1512
  }
1443
1513
 
1444
- let ModelProvider = class ModelProvider {
1514
+ var ModelProvider_1;
1515
+ let ModelProvider = ModelProvider_1 = class ModelProvider {
1445
1516
  get name() {
1446
1517
  return this.getProviderSchema().provider;
1447
1518
  }
@@ -1449,10 +1520,10 @@ let ModelProvider = class ModelProvider {
1449
1520
  await this.validateProviderCredentials(credentials);
1450
1521
  }
1451
1522
  /**
1452
- * Get provider lib root path.
1453
- *
1454
- * @returns Root of library
1455
- */ getProviderServerPath() {
1523
+ * Get provider lib root path.
1524
+ *
1525
+ * @returns Root of library
1526
+ */ getProviderServerPath() {
1456
1527
  return this.dir;
1457
1528
  }
1458
1529
  getProviderSchema() {
@@ -1487,11 +1558,11 @@ let ModelProvider = class ModelProvider {
1487
1558
  return modelInstance;
1488
1559
  }
1489
1560
  /**
1490
- * Get provider models.
1491
- * @param modelType - model type
1492
- * @param onlyActive - only active models
1493
- * @return provider models
1494
- */ getProviderModels(modelType, onlyActive = false) {
1561
+ * Get provider models.
1562
+ * @param modelType - model type
1563
+ * @param onlyActive - only active models
1564
+ * @return provider models
1565
+ */ getProviderModels(modelType, onlyActive = false) {
1495
1566
  let modelTypes = [];
1496
1567
  if (modelType) {
1497
1568
  modelTypes.push(modelType);
@@ -1543,7 +1614,7 @@ let ModelProvider = class ModelProvider {
1543
1614
  return null;
1544
1615
  }
1545
1616
  constructor(){
1546
- this.logger = new Logger(ModelProvider.name);
1617
+ this.logger = new Logger(ModelProvider_1.name);
1547
1618
  // protected providerSchema: IAiProviderEntity | null = null
1548
1619
  this.modelManagers = new Map();
1549
1620
  const provider = Reflect.getMetadata(AI_MODEL_PROVIDER, this.constructor);
@@ -1553,9 +1624,8 @@ let ModelProvider = class ModelProvider {
1553
1624
  this.dir = dir;
1554
1625
  }
1555
1626
  };
1556
- ModelProvider = __decorate([
1627
+ ModelProvider = ModelProvider_1 = __decorate([
1557
1628
  Injectable(),
1558
- __metadata("design:type", Function),
1559
1629
  __metadata("design:paramtypes", [])
1560
1630
  ], ModelProvider);
1561
1631
 
@@ -1744,7 +1814,8 @@ function mergeCredentials(credentials, modelProperties) {
1744
1814
  return _extends({}, credentials != null ? credentials : {}, modelProperties != null ? modelProperties : {});
1745
1815
  }
1746
1816
 
1747
- let AIModel = class AIModel {
1817
+ var AIModel_1;
1818
+ let AIModel = AIModel_1 = class AIModel {
1748
1819
  getChatModel(copilotModel, options) {
1749
1820
  throw new Error(`Unsupport chat model!`);
1750
1821
  }
@@ -1819,13 +1890,13 @@ let AIModel = class AIModel {
1819
1890
  return null;
1820
1891
  }
1821
1892
  /**
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) {
1893
+ * Get customizable model schema.
1894
+ * Implement this method in ai model sub class that can customize model
1895
+ *
1896
+ * @param model model name
1897
+ * @param credentials model credentials
1898
+ * @returns model schema
1899
+ */ getCustomizableModelSchemaFromCredentials(model, credentials) {
1829
1900
  return null;
1830
1901
  }
1831
1902
  processParameterRules(yamlData) {
@@ -1897,29 +1968,28 @@ let AIModel = class AIModel {
1897
1968
  };
1898
1969
  }
1899
1970
  constructor(modelProvider, modelType){
1900
- this.modelProvider = modelProvider;
1901
- this.modelType = modelType;
1902
- this.logger = new Logger(AIModel.name);
1971
+ this.logger = new Logger(AIModel_1.name);
1903
1972
  this.modelSchemas = null;
1904
1973
  this.positions = null;
1974
+ this.modelProvider = modelProvider;
1975
+ this.modelType = modelType;
1905
1976
  this.modelProvider.registerAIModelInstance(this.modelType, this);
1906
1977
  }
1907
1978
  };
1908
- AIModel = __decorate([
1979
+ AIModel = AIModel_1 = __decorate([
1909
1980
  Injectable(),
1910
- __metadata("design:type", Function),
1911
1981
  __metadata("design:paramtypes", [
1912
- typeof ModelProvider === "undefined" ? Object : ModelProvider,
1913
- typeof AiModelTypeEnum === "undefined" ? Object : AiModelTypeEnum
1982
+ ModelProvider,
1983
+ String
1914
1984
  ])
1915
1985
  ], AIModel);
1916
1986
  function getDefaultParameterRuleVariableMap(name) {
1917
1987
  /**
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];
1988
+ * Get default parameter rule for given name
1989
+ *
1990
+ * @param name - parameter name
1991
+ * @return parameter rule
1992
+ */ const defaultParameterRule = PARAMETER_RULE_TEMPLATE[name];
1923
1993
  if (!defaultParameterRule) {
1924
1994
  throw new Error(`Invalid model parameter rule name ${name}`);
1925
1995
  }
@@ -1985,17 +2055,18 @@ function _class_private_field_loose_key(name) {
1985
2055
  return "__private_" + id++ + "_" + name;
1986
2056
  }
1987
2057
 
2058
+ var _a;
1988
2059
  class LLMUsage {
1989
2060
  static emptyUsage() {
1990
2061
  return new LLMUsage(0, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0, 0.0, 'USD', 0.0);
1991
2062
  }
1992
2063
  plus(other) {
1993
2064
  /**
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) {
2065
+ * Add two LLMUsage instances together.
2066
+ *
2067
+ * @param other: Another LLMUsage instance to add
2068
+ * @return: A new LLMUsage instance with summed values
2069
+ */ if (this.totalTokens === 0) {
1999
2070
  return other;
2000
2071
  } else {
2001
2072
  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 +2074,11 @@ class LLMUsage {
2003
2074
  }
2004
2075
  add(other) {
2005
2076
  /**
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);
2077
+ * Overload the + operator to add two LLMUsage instances.
2078
+ *
2079
+ * @param other: Another LLMUsage instance to add
2080
+ * @return: A new LLMUsage instance with summed values
2081
+ */ return this.plus(other);
2011
2082
  }
2012
2083
  constructor(promptTokens, promptUnitPrice, promptPriceUnit, promptPrice, completionTokens, completionUnitPrice, completionPriceUnit, completionPrice, totalTokens, totalPrice, currency, latency){
2013
2084
  this.promptTokens = promptTokens;
@@ -2205,9 +2276,10 @@ class LargeLanguageModel extends AIModel {
2205
2276
  writable: true,
2206
2277
  value: void 0
2207
2278
  });
2208
- _class_private_field_loose_base(this, _logger)[_logger] = new Logger(LargeLanguageModel.name);
2279
+ _class_private_field_loose_base(this, _logger)[_logger] = new Logger(_a.name);
2209
2280
  }
2210
2281
  }
2282
+ _a = LargeLanguageModel;
2211
2283
  function calcTokenUsage(output) {
2212
2284
  var _output_generations;
2213
2285
  const tokenUsage = {
@@ -2255,8 +2327,8 @@ function calcTokenUsage(output) {
2255
2327
  * 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
2328
  */ class ChatOAICompatReasoningModel extends ChatOpenAICompletions {
2257
2329
  /**
2258
- *
2259
- */ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
2330
+ *
2331
+ */ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
2260
2332
  delta, rawResponse, defaultRole) {
2261
2333
  const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole);
2262
2334
  if (delta['content'] === '<think>') {
@@ -2442,7 +2514,7 @@ function normalizeContextSize(value) {
2442
2514
  return undefined;
2443
2515
  }
2444
2516
 
2445
- const COMMAND_METADATA = '__command__';
2517
+ const COMMAND_METADATA$1 = '__command__';
2446
2518
  /**
2447
2519
  * Get a Chat Model of copilot model and check it's token limitation, record the token usage
2448
2520
  */ class CreateModelClientCommand extends Command {
@@ -2453,10 +2525,26 @@ const COMMAND_METADATA = '__command__';
2453
2525
  }
2454
2526
  }
2455
2527
  CreateModelClientCommand.type = '[AI Model] Create Model Client';
2456
- Reflect.defineMetadata(COMMAND_METADATA, {
2528
+ Reflect.defineMetadata(COMMAND_METADATA$1, {
2457
2529
  id: CreateModelClientCommand.type
2458
2530
  }, CreateModelClientCommand);
2459
2531
 
2532
+ const SKILL_SOURCE_PROVIDER = 'SKILL_SOURCE_PROVIDER';
2533
+ const SkillSourceProviderStrategy = (provider)=>applyDecorators(SetMetadata(SKILL_SOURCE_PROVIDER, provider), SetMetadata(STRATEGY_META_KEY, SKILL_SOURCE_PROVIDER));
2534
+
2535
+ let SkillSourceProviderRegistry = class SkillSourceProviderRegistry extends BaseStrategyRegistry {
2536
+ constructor(discoveryService, reflector){
2537
+ super(SKILL_SOURCE_PROVIDER, discoveryService, reflector);
2538
+ }
2539
+ };
2540
+ SkillSourceProviderRegistry = __decorate([
2541
+ Injectable(),
2542
+ __metadata("design:paramtypes", [
2543
+ DiscoveryService,
2544
+ Reflector
2545
+ ])
2546
+ ], SkillSourceProviderRegistry);
2547
+
2460
2548
  const AGENT_MIDDLEWARE_STRATEGY = 'AGENT_MIDDLEWARE_STRATEGY';
2461
2549
  const AgentMiddlewareStrategy = (provider)=>applyDecorators(SetMetadata(AGENT_MIDDLEWARE_STRATEGY, provider), SetMetadata(STRATEGY_META_KEY, AGENT_MIDDLEWARE_STRATEGY));
2462
2550
 
@@ -2467,10 +2555,9 @@ let AgentMiddlewareRegistry = class AgentMiddlewareRegistry extends BaseStrategy
2467
2555
  };
2468
2556
  AgentMiddlewareRegistry = __decorate([
2469
2557
  Injectable(),
2470
- __metadata("design:type", Function),
2471
2558
  __metadata("design:paramtypes", [
2472
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
2473
- typeof Reflector === "undefined" ? Object : Reflector
2559
+ DiscoveryService,
2560
+ Reflector
2474
2561
  ])
2475
2562
  ], AgentMiddlewareRegistry);
2476
2563
 
@@ -2482,15 +2569,7 @@ AgentMiddlewareRegistry = __decorate([
2482
2569
  "end"
2483
2570
  ];
2484
2571
 
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;
2572
+ const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
2494
2573
  const VERSION_PATTERN = /^v[1-9][0-9]*$/;
2495
2574
  function assertSegment(input, name) {
2496
2575
  if (!SEGMENT_PATTERN.test(input)) {
@@ -2556,10 +2635,9 @@ let HandoffProcessorRegistry = class HandoffProcessorRegistry extends BaseStrate
2556
2635
  };
2557
2636
  HandoffProcessorRegistry = __decorate([
2558
2637
  Injectable(),
2559
- __metadata("design:type", Function),
2560
2638
  __metadata("design:paramtypes", [
2561
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
2562
- typeof Reflector === "undefined" ? Object : Reflector
2639
+ DiscoveryService,
2640
+ Reflector
2563
2641
  ])
2564
2642
  ], HandoffProcessorRegistry);
2565
2643
 
@@ -2668,26 +2746,52 @@ HandoffProcessorRegistry = __decorate([
2668
2746
  * ```
2669
2747
  */ const ChatChannel = (type)=>SetMetadata(CHAT_CHANNEL, type);
2670
2748
 
2671
- let ChatChannelRegistry = class ChatChannelRegistry extends BaseStrategyRegistry {
2749
+ /**
2750
+ * Chat Channel Registry
2751
+ *
2752
+ * Manages all registered chat channel implementations.
2753
+ * Channels are automatically discovered and registered via @ChatChannel decorator.
2754
+ *
2755
+ * Supports:
2756
+ * - Organization-scoped channels
2757
+ * - Global channels (fallback)
2758
+ * - Plugin-based registration/removal
2759
+ * - Dynamic channel lookup
2760
+ *
2761
+ * @example
2762
+ * ```typescript
2763
+ * // Get channel by type
2764
+ * const channel = registry.get('lark')
2765
+ *
2766
+ * // List all available channels for an organization
2767
+ * const channels = registry.list(organizationId)
2768
+ *
2769
+ * // Send message using a channel
2770
+ * await channel.sendText(ctx, 'Hello!')
2771
+ * ```
2772
+ */ let ChatChannelRegistry = class ChatChannelRegistry extends BaseStrategyRegistry {
2672
2773
  constructor(discoveryService, reflector){
2673
2774
  super(CHAT_CHANNEL, discoveryService, reflector);
2674
2775
  }
2675
2776
  };
2676
2777
  ChatChannelRegistry = __decorate([
2677
2778
  Injectable(),
2678
- __metadata("design:type", Function),
2679
2779
  __metadata("design:paramtypes", [
2680
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
2681
- typeof Reflector === "undefined" ? Object : Reflector
2780
+ DiscoveryService,
2781
+ Reflector
2682
2782
  ])
2683
2783
  ], ChatChannelRegistry);
2684
2784
 
2785
+ const COMMAND_METADATA = '__command__';
2685
2786
  class CancelConversationCommand {
2686
2787
  constructor(input){
2687
2788
  this.input = input;
2688
2789
  }
2689
2790
  }
2690
2791
  CancelConversationCommand.type = '[Chat Conversation] Cancel';
2792
+ Reflect.defineMetadata(COMMAND_METADATA, {
2793
+ id: CancelConversationCommand.type
2794
+ }, CancelConversationCommand);
2691
2795
 
2692
2796
  const FILE_STORAGE_PROVIDER = 'FILE_STORAGE_PROVIDER';
2693
2797
  const FileStorageProvider = (provider)=>applyDecorators(SetMetadata(FILE_STORAGE_PROVIDER, provider), SetMetadata(STRATEGY_META_KEY, FILE_STORAGE_PROVIDER));
@@ -2699,10 +2803,9 @@ let FileStorageProviderRegistry = class FileStorageProviderRegistry extends Base
2699
2803
  };
2700
2804
  FileStorageProviderRegistry = __decorate([
2701
2805
  Injectable(),
2702
- __metadata("design:type", Function),
2703
2806
  __metadata("design:paramtypes", [
2704
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
2705
- typeof Reflector === "undefined" ? Object : Reflector
2807
+ DiscoveryService,
2808
+ Reflector
2706
2809
  ])
2707
2810
  ], FileStorageProviderRegistry);
2708
2811
 
@@ -2716,10 +2819,9 @@ let FileUploadTargetRegistry = class FileUploadTargetRegistry extends BaseStrate
2716
2819
  };
2717
2820
  FileUploadTargetRegistry = __decorate([
2718
2821
  Injectable(),
2719
- __metadata("design:type", Function),
2720
2822
  __metadata("design:paramtypes", [
2721
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
2722
- typeof Reflector === "undefined" ? Object : Reflector
2823
+ DiscoveryService,
2824
+ Reflector
2723
2825
  ])
2724
2826
  ], FileUploadTargetRegistry);
2725
2827
 
@@ -2774,8 +2876,18 @@ function resolveSandboxExecutionOptions(options, defaults = DEFAULT_SANDBOX_SHEL
2774
2876
  *
2775
2877
  * @param backend - Backend instance to check
2776
2878
  * @returns True if the backend implements SandboxBackendProtocol
2777
- */ function isSandboxBackend(backend) {
2778
- return typeof backend.execute === 'function' && typeof backend.id === 'string';
2879
+ */ function isObjectLike(value) {
2880
+ return typeof value === 'object' && value !== null;
2881
+ }
2882
+ function isSandboxBackend(backend) {
2883
+ return isObjectLike(backend) && typeof Reflect.get(backend, 'execute') === 'function' && typeof Reflect.get(backend, 'id') === 'string';
2884
+ }
2885
+ function resolveSandboxBackend(sandbox) {
2886
+ if (!isObjectLike(sandbox)) {
2887
+ return null;
2888
+ }
2889
+ const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
2890
+ return isSandboxBackend(candidate) ? candidate : null;
2779
2891
  }
2780
2892
 
2781
2893
  const MAX_LINE_LENGTH = 500;
@@ -3394,10 +3506,10 @@ try {
3394
3506
  * Requires Node.js 20+ on the sandbox host.
3395
3507
  */ class BaseSandbox {
3396
3508
  /**
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) {
3509
+ * Internal hook for file/search operations. Concrete backends can override
3510
+ * this to distinguish "background helper commands" from user-facing shell
3511
+ * execute calls.
3512
+ */ executeOperation(command, options) {
3401
3513
  return this.execute(command, options);
3402
3514
  }
3403
3515
  async streamExecute(command, onLine, options) {
@@ -3408,11 +3520,11 @@ try {
3408
3520
  return result;
3409
3521
  }
3410
3522
  /**
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) {
3523
+ * List files and directories in the specified directory (non-recursive).
3524
+ *
3525
+ * @param path - Absolute path to directory
3526
+ * @returns List of FileInfo objects for files and directories directly in the directory.
3527
+ */ async lsInfo(path) {
3416
3528
  const command = buildLsCommand(path);
3417
3529
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3418
3530
  if (result.exitCode !== 0) {
@@ -3436,14 +3548,14 @@ try {
3436
3548
  return infos;
3437
3549
  }
3438
3550
  /**
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) {
3551
+ * List directory contents recursively with depth control and pagination.
3552
+ *
3553
+ * @param dirPath - Absolute path to directory
3554
+ * @param offset - 1-indexed entry number to start from (default: 1)
3555
+ * @param limit - Maximum number of entries to return (default: 25)
3556
+ * @param depth - Maximum depth to traverse (default: 2)
3557
+ * @returns Human-readable directory tree with indentation
3558
+ */ async listDir(dirPath, offset = 1, limit = 25, depth = 2) {
3447
3559
  if (offset < 1) {
3448
3560
  return 'Error: offset must be a 1-indexed entry number';
3449
3561
  }
@@ -3461,15 +3573,15 @@ try {
3461
3573
  return result.output;
3462
3574
  }
3463
3575
  /**
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) {
3576
+ * Read file content with line numbers.
3577
+ *
3578
+ * @param filePath - Absolute file path
3579
+ * @param offset - Line offset to start reading from (1-indexed)
3580
+ * @param limit - Maximum number of lines to read
3581
+ * @param mode - Read mode: 'slice' (default) or 'indentation'
3582
+ * @param indentation - Configuration for indentation mode
3583
+ * @returns Formatted file content with line numbers, or error message
3584
+ */ async read(filePath, offset = 1, limit = 2000, mode = 'slice', indentation) {
3473
3585
  const command = mode === 'indentation' ? buildIndentationReadCommand(filePath, offset, limit, indentation != null ? indentation : {}) : buildSliceReadCommand(filePath, offset, limit);
3474
3586
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3475
3587
  if (result.exitCode !== 0) {
@@ -3478,8 +3590,8 @@ try {
3478
3590
  return result.output;
3479
3591
  }
3480
3592
  /**
3481
- * Structured search results or error string for invalid input.
3482
- */ async grepRaw(pattern, path = '/', include = null) {
3593
+ * Structured search results or error string for invalid input.
3594
+ */ async grepRaw(pattern, path = '/', include = null) {
3483
3595
  const command = buildGrepCommand(pattern, path, include);
3484
3596
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
3485
3597
  if (result.exitCode === 1) {
@@ -3505,8 +3617,8 @@ try {
3505
3617
  return matches;
3506
3618
  }
3507
3619
  /**
3508
- * Search file contents for a regex pattern, returning human-readable output.
3509
- */ async grep(pattern, path = '/', include = null) {
3620
+ * Search file contents for a regex pattern, returning human-readable output.
3621
+ */ async grep(pattern, path = '/', include = null) {
3510
3622
  const result = await this.grepRaw(pattern, path, include);
3511
3623
  if (typeof result === 'string') {
3512
3624
  return result;
@@ -3517,8 +3629,8 @@ try {
3517
3629
  return formatGrepOutput(result);
3518
3630
  }
3519
3631
  /**
3520
- * Structured glob matching returning FileInfo objects.
3521
- */ async globInfo(pattern, path = '/') {
3632
+ * Structured glob matching returning FileInfo objects.
3633
+ */ async globInfo(pattern, path = '/') {
3522
3634
  const command = buildGlobCommand(path, pattern);
3523
3635
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
3524
3636
  const infos = [];
@@ -3539,8 +3651,8 @@ try {
3539
3651
  return infos;
3540
3652
  }
3541
3653
  /**
3542
- * Find files matching a glob pattern, returning human-readable output.
3543
- */ async glob(pattern, path = '/') {
3654
+ * Find files matching a glob pattern, returning human-readable output.
3655
+ */ async glob(pattern, path = '/') {
3544
3656
  const files = await this.globInfo(pattern, path);
3545
3657
  if (files.length === 0) {
3546
3658
  return 'No files found';
@@ -3548,8 +3660,8 @@ try {
3548
3660
  return formatGlobOutput(files);
3549
3661
  }
3550
3662
  /**
3551
- * Create a new file with content.
3552
- */ async write(filePath, content) {
3663
+ * Create a new file with content.
3664
+ */ async write(filePath, content) {
3553
3665
  const command = buildWriteCommand(filePath, content);
3554
3666
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3555
3667
  if (result.exitCode !== 0) {
@@ -3602,8 +3714,8 @@ try {
3602
3714
  };
3603
3715
  }
3604
3716
  /**
3605
- * Append content to a file. Creates the file if it doesn't exist.
3606
- */ async append(filePath, content) {
3717
+ * Append content to a file. Creates the file if it doesn't exist.
3718
+ */ async append(filePath, content) {
3607
3719
  const command = buildAppendCommand(filePath, content);
3608
3720
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3609
3721
  if (result.exitCode !== 0) {
@@ -3618,8 +3730,8 @@ try {
3618
3730
  };
3619
3731
  }
3620
3732
  /**
3621
- * Edit a file by replacing string occurrences.
3622
- */ async edit(filePath, oldString, newString, replaceAll = false) {
3733
+ * Edit a file by replacing string occurrences.
3734
+ */ async edit(filePath, oldString, newString, replaceAll = false) {
3623
3735
  const command = buildEditCommand(filePath, oldString, newString, replaceAll);
3624
3736
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3625
3737
  switch(result.exitCode){
@@ -3651,10 +3763,10 @@ try {
3651
3763
  }
3652
3764
  }
3653
3765
  /**
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) {
3766
+ * Perform multiple sequential edits on a single file.
3767
+ * All edits are applied sequentially, with each edit operating on the result of the previous edit.
3768
+ * All edits must succeed for the operation to succeed (atomic).
3769
+ */ async multiEdit(filePath, edits) {
3658
3770
  if (!edits || edits.length === 0) {
3659
3771
  return {
3660
3772
  error: 'No edits provided'
@@ -3694,11 +3806,48 @@ let SandboxProviderRegistry = class SandboxProviderRegistry extends BaseStrategy
3694
3806
  };
3695
3807
  SandboxProviderRegistry = __decorate([
3696
3808
  Injectable(),
3697
- __metadata("design:type", Function),
3698
3809
  __metadata("design:paramtypes", [
3699
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
3700
- typeof Reflector === "undefined" ? Object : Reflector
3810
+ DiscoveryService,
3811
+ Reflector
3701
3812
  ])
3702
3813
  ], SandboxProviderRegistry);
3703
3814
 
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 };
3815
+ const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
3816
+ const ViewExtensionProvider = (providerKey)=>applyDecorators(SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
3817
+
3818
+ let ViewExtensionProviderRegistry = class ViewExtensionProviderRegistry extends BaseStrategyRegistry {
3819
+ listEntries(organizationId) {
3820
+ var _this_strategies_get;
3821
+ const orgKey = this.resolveOrganization(organizationId);
3822
+ const entries = new Map();
3823
+ var _this_strategies_get_entries;
3824
+ 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 : []){
3825
+ entries.set(providerKey, provider);
3826
+ }
3827
+ if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
3828
+ var _this_strategies_get1;
3829
+ var _this_strategies_get_entries1;
3830
+ 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 : []){
3831
+ if (!entries.has(providerKey)) {
3832
+ entries.set(providerKey, provider);
3833
+ }
3834
+ }
3835
+ }
3836
+ return Array.from(entries.entries()).map(([providerKey, provider])=>({
3837
+ providerKey,
3838
+ provider
3839
+ }));
3840
+ }
3841
+ constructor(discoveryService, reflector){
3842
+ super(VIEW_EXTENSION_PROVIDER, discoveryService, reflector);
3843
+ }
3844
+ };
3845
+ ViewExtensionProviderRegistry = __decorate([
3846
+ Injectable(),
3847
+ __metadata("design:paramtypes", [
3848
+ DiscoveryService,
3849
+ Reflector
3850
+ ])
3851
+ ], ViewExtensionProviderRegistry);
3852
+
3853
+ 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_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 };