@xpert-ai/plugin-sdk 3.8.3 → 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 (45) hide show
  1. package/index.cjs.js +543 -325
  2. package/index.esm.js +526 -298
  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/ai-model/llm.d.ts +9 -0
  11. package/src/lib/channel/strategy.interface.d.ts +0 -2
  12. package/src/lib/core/context/request-context.d.ts +7 -4
  13. package/src/lib/core/context/request-context.middleware.d.ts +0 -1
  14. package/src/lib/core/file-system.d.ts +1 -3
  15. package/src/lib/core/permissions/analytics.d.ts +2 -3
  16. package/src/lib/core/permissions/general.d.ts +2 -1
  17. package/src/lib/data/datasource/strategy.decorator.d.ts +1 -1
  18. package/src/lib/data/datasource/types.d.ts +0 -3
  19. package/src/lib/file/file-storage/provider.decorator.d.ts +1 -1
  20. package/src/lib/file/file-storage/provider.interface.d.ts +0 -2
  21. package/src/lib/file/file-upload/strategy.decorator.d.ts +1 -1
  22. package/src/lib/file/file-upload/strategy.interface.d.ts +0 -2
  23. package/src/lib/integration/strategy.decorator.d.ts +1 -1
  24. package/src/lib/integration/strategy.interface.d.ts +15 -3
  25. package/src/lib/rag/image/strategy.decorator.d.ts +1 -1
  26. package/src/lib/rag/knowledge/knowledge-strategy.decorator.d.ts +1 -1
  27. package/src/lib/rag/retriever/strategy.decorator.d.ts +1 -1
  28. package/src/lib/rag/source/strategy.decorator.d.ts +1 -1
  29. package/src/lib/rag/textsplitter/strategy.decorator.d.ts +1 -1
  30. package/src/lib/rag/transformer/strategy.decorator.d.ts +1 -1
  31. package/src/lib/sandbox/protocol.d.ts +6 -8
  32. package/src/lib/sandbox/sandbox.d.ts +6 -0
  33. package/src/lib/sandbox/sandbox.decorator.d.ts +1 -1
  34. package/src/lib/sandbox/sandbox.interface.d.ts +7 -11
  35. package/src/lib/strategy.d.ts +3 -3
  36. package/src/lib/toolset/strategy.decorator.d.ts +1 -1
  37. package/src/lib/vectorstore/strategy.decorator.d.ts +1 -1
  38. package/src/lib/view-extension/index.d.ts +3 -0
  39. package/src/lib/view-extension/provider.decorator.d.ts +2 -0
  40. package/src/lib/view-extension/provider.interface.d.ts +7 -0
  41. package/src/lib/view-extension/provider.registry.d.ts +10 -0
  42. package/src/lib/workflow/node/strategy.decorator.d.ts +1 -1
  43. package/src/lib/workflow/trigger/strategy.decorator.d.ts +1 -1
  44. package/index.esm.d.ts +0 -1
  45. /package/{index.cjs.d.ts → index.d.ts} +0 -0
package/index.cjs.js CHANGED
@@ -33,20 +33,20 @@ require('js-tiktoken');
33
33
  var base = require('@langchain/core/language_models/base');
34
34
 
35
35
  function _interopNamespaceDefault(e) {
36
- var n = Object.create(null);
37
- if (e) {
38
- Object.keys(e).forEach(function (k) {
39
- if (k !== 'default') {
40
- var d = Object.getOwnPropertyDescriptor(e, k);
41
- Object.defineProperty(n, k, d.get ? d : {
42
- enumerable: true,
43
- get: function () { return e[k]; }
44
- });
45
- }
46
- });
47
- }
48
- n.default = e;
49
- return Object.freeze(n);
36
+ var n = Object.create(null);
37
+ if (e) {
38
+ Object.keys(e).forEach(function (k) {
39
+ if (k !== 'default') {
40
+ var d = Object.getOwnPropertyDescriptor(e, k);
41
+ Object.defineProperty(n, k, d.get ? d : {
42
+ enumerable: true,
43
+ get: function () { return e[k]; }
44
+ });
45
+ }
46
+ });
47
+ }
48
+ n.default = e;
49
+ return Object.freeze(n);
50
50
  }
51
51
 
52
52
  var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
@@ -58,11 +58,11 @@ var _axios__namespace = /*#__PURE__*/_interopNamespaceDefault(_axios);
58
58
  * Metadata keys used in plugins for defining various aspects like entities, subscribers, and configurations.
59
59
  */ const PLUGIN_METADATA = {
60
60
  /**
61
- * Key representing the entities registered within the plugin.
62
- */ ENTITIES: 'entities',
61
+ * Key representing the entities registered within the plugin.
62
+ */ ENTITIES: 'entities',
63
63
  /**
64
- * Key representing event subscribers within the plugin.
65
- */ SUBSCRIBERS: 'subscribers'
64
+ * Key representing event subscribers within the plugin.
65
+ */ SUBSCRIBERS: 'subscribers'
66
66
  };
67
67
 
68
68
  /**
@@ -107,10 +107,10 @@ function _extends() {
107
107
  function createPluginLogger(scope, baseMeta = {}) {
108
108
  const nestLogger = new common.Logger(scope);
109
109
  const wrap = (level, msg, meta)=>{
110
- var _nestLogger_level;
110
+ var // 保持与 Nest Logger 接口对齐
111
+ _nestLogger_level;
111
112
  const payload = meta ? _extends({}, baseMeta, meta) : baseMeta;
112
- (_nestLogger_level = // 保持与 Nest Logger 接口对齐
113
- nestLogger[level]) == null ? void 0 : _nestLogger_level.call(nestLogger, msg + (Object.keys(payload).length ? ` ${JSON.stringify(payload)}` : ''));
113
+ (_nestLogger_level = nestLogger[level]) == null ? void 0 : _nestLogger_level.call(nestLogger, msg + (Object.keys(payload).length ? ` ${JSON.stringify(payload)}` : ''));
114
114
  };
115
115
  return {
116
116
  child (meta) {
@@ -141,6 +141,8 @@ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedEr
141
141
  };
142
142
 
143
143
  // request-context.ts
144
+ const TENANT_SCOPE = 'tenant';
145
+ const ORGANIZATION_SCOPE = 'organization';
144
146
  class RequestContext {
145
147
  static currentRequestContext() {
146
148
  const session = getRequestContext();
@@ -153,6 +155,11 @@ class RequestContext {
153
155
  }
154
156
  return null;
155
157
  }
158
+ static currentApiKey() {
159
+ const user = RequestContext.currentUser();
160
+ var _user_apiKey;
161
+ return (_user_apiKey = user == null ? void 0 : user.apiKey) != null ? _user_apiKey : null;
162
+ }
156
163
  static currentTenantId() {
157
164
  const user = RequestContext.currentUser();
158
165
  if (user) {
@@ -194,9 +201,9 @@ class RequestContext {
194
201
  ], throwError);
195
202
  }
196
203
  /**
197
- * Retrieves the language code from the headers of the current request.
198
- * @returns The language code (LanguagesEnum) extracted from the headers, or the default language (ENGLISH) if not found.
199
- */ static getLanguageCode() {
204
+ * Retrieves the language code from the headers of the current request.
205
+ * @returns The language code (LanguagesEnum) extracted from the headers, or the default language (ENGLISH) if not found.
206
+ */ static getLanguageCode() {
200
207
  // Retrieve the current request
201
208
  const req = RequestContext.currentRequest();
202
209
  // Variable to store the extracted language code
@@ -212,21 +219,71 @@ class RequestContext {
212
219
  // Return the extracted language code or the default language (ENGLISH) if not found
213
220
  return lang || contracts.LanguagesEnum.English;
214
221
  }
215
- static getOrganizationId() {
216
- const req = this.currentRequest();
217
- let organizationId;
218
- const keys = [
222
+ static getScope() {
223
+ const request = this.currentRequest();
224
+ const user = this.currentUser();
225
+ var _user_tenantId, _ref;
226
+ const tenantId = (_ref = (_user_tenantId = user == null ? void 0 : user.tenantId) != null ? _user_tenantId : getHeaderValue(request, [
227
+ 'tenant-id'
228
+ ])) != null ? _ref : null;
229
+ var _getHeaderValue;
230
+ const organizationId = (_getHeaderValue = getHeaderValue(request, [
219
231
  'organization-id'
220
- ];
221
- if (req) {
222
- for (const key of keys){
223
- if (req.headers && req.headers[key]) {
224
- organizationId = req.headers[key];
225
- break;
232
+ ])) != null ? _getHeaderValue : null;
233
+ const scopeLevelHeader = getHeaderValue(request, [
234
+ 'x-scope-level'
235
+ ]);
236
+ if (scopeLevelHeader) {
237
+ if (scopeLevelHeader !== TENANT_SCOPE && scopeLevelHeader !== ORGANIZATION_SCOPE) {
238
+ throw new common.BadRequestException(`Unsupported scope level: ${scopeLevelHeader}`);
239
+ }
240
+ if (scopeLevelHeader === TENANT_SCOPE) {
241
+ if (organizationId) {
242
+ throw new common.BadRequestException('Tenant scope requests must not include Organization-Id.');
226
243
  }
244
+ return {
245
+ tenantId,
246
+ level: TENANT_SCOPE,
247
+ organizationId: null
248
+ };
249
+ }
250
+ if (!organizationId) {
251
+ throw new common.BadRequestException('Organization scope requests require Organization-Id.');
227
252
  }
253
+ return {
254
+ tenantId,
255
+ level: ORGANIZATION_SCOPE,
256
+ organizationId
257
+ };
258
+ }
259
+ if (organizationId) {
260
+ return {
261
+ tenantId,
262
+ level: ORGANIZATION_SCOPE,
263
+ organizationId
264
+ };
228
265
  }
229
- return organizationId;
266
+ return {
267
+ tenantId,
268
+ level: TENANT_SCOPE,
269
+ organizationId: null
270
+ };
271
+ }
272
+ static getOrganizationId() {
273
+ return this.getScope().organizationId;
274
+ }
275
+ static isTenantScope() {
276
+ return this.getScope().level === TENANT_SCOPE;
277
+ }
278
+ static isOrganizationScope() {
279
+ return this.getScope().level === ORGANIZATION_SCOPE;
280
+ }
281
+ static requireOrganizationScope() {
282
+ const scope = this.getScope();
283
+ if (scope.level !== ORGANIZATION_SCOPE || !scope.organizationId) {
284
+ throw new common.BadRequestException('Organization scope is required for this operation.');
285
+ }
286
+ return scope.organizationId;
230
287
  }
231
288
  static hasPermissions(findPermissions, throwError) {
232
289
  const requestContext = RequestContext.currentRequestContext();
@@ -280,22 +337,22 @@ class RequestContext {
280
337
  return null;
281
338
  }
282
339
  /**
283
- * Checks if the current user has a specific role.
284
- * @param {RolesEnum} role - The role to check.
285
- * @param {boolean} throwError - Flag indicating whether to throw an error if the role is not granted.
286
- * @returns {boolean} - True if the user has the role, otherwise false.
287
- */ static hasRole(role, throwError) {
340
+ * Checks if the current user has a specific role.
341
+ * @param {RolesEnum} role - The role to check.
342
+ * @param {boolean} throwError - Flag indicating whether to throw an error if the role is not granted.
343
+ * @returns {boolean} - True if the user has the role, otherwise false.
344
+ */ static hasRole(role, throwError) {
288
345
  return this.hasRoles([
289
346
  role
290
347
  ], throwError);
291
348
  }
292
349
  /**
293
- * Checks if the current request context has any of the specified roles.
294
- *
295
- * @param roles - An array of roles to check.
296
- * @param throwError - Whether to throw an error if no roles are found.
297
- * @returns True if any of the required roles are found, otherwise false.
298
- */ static hasRoles(roles, throwError) {
350
+ * Checks if the current request context has any of the specified roles.
351
+ *
352
+ * @param roles - An array of roles to check.
353
+ * @param throwError - Whether to throw an error if no roles are found.
354
+ * @returns True if any of the required roles are found, otherwise false.
355
+ */ static hasRoles(roles, throwError) {
299
356
  const context = RequestContext.currentRequestContext();
300
357
  if (context) {
301
358
  try {
@@ -332,8 +389,23 @@ const als = new node_async_hooks.AsyncLocalStorage();
332
389
  function getRequestContext() {
333
390
  return als.getStore();
334
391
  }
392
+ function getHeaderValue(req, keys) {
393
+ if (!(req == null ? void 0 : req.headers)) {
394
+ return null;
395
+ }
396
+ for (const key of keys){
397
+ const value = req.headers[key];
398
+ if (Array.isArray(value)) {
399
+ var _value_;
400
+ return (_value_ = value[0]) != null ? _value_ : null;
401
+ }
402
+ if (typeof value === 'string' && value) {
403
+ return value;
404
+ }
405
+ }
406
+ return null;
407
+ }
335
408
 
336
- // request-context.middleware.ts
337
409
  exports.RequestContextMiddleware = class RequestContextMiddleware {
338
410
  use(req, _res, next) {
339
411
  var _req_user;
@@ -434,10 +506,10 @@ class BaseStrategyRegistry {
434
506
  }
435
507
  /**
436
508
  * Get strategy by type from the given organization including global strategies as fallback.
437
- *
438
- * @param type
439
- * @param organizationId
440
- * @returns
509
+ *
510
+ * @param type
511
+ * @param organizationId
512
+ * @returns
441
513
  */ get(type, organizationId) {
442
514
  var _this_strategies_get, _this_strategies_get1;
443
515
  organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
@@ -451,34 +523,42 @@ class BaseStrategyRegistry {
451
523
  }
452
524
  /**
453
525
  * List all strategies for the given organization including global strategies, or only global strategies if global org is specified.
454
- *
455
- * @param organizationId
456
- * @returns
526
+ *
527
+ * @param organizationId
528
+ * @returns
457
529
  */ list(organizationId) {
458
- var _this_strategies_get, _this_strategies_get1;
530
+ var _this_strategies_get;
459
531
  organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
460
532
  const orgKey = this.resolveOrganization(organizationId);
461
- var _this_strategies_get_values;
462
- 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 : [];
463
- var _this_strategies_get_values1;
464
- 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 : [];
465
- return Array.from(new Set([
466
- ...scoped,
467
- ...global
468
- ]));
533
+ const effective = new Map();
534
+ var _this_strategies_get_entries;
535
+ 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 : []){
536
+ effective.set(type, strategy);
537
+ }
538
+ if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
539
+ var _this_strategies_get1;
540
+ var _this_strategies_get_entries1;
541
+ 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 : []){
542
+ if (!effective.has(type)) {
543
+ effective.set(type, strategy);
544
+ }
545
+ }
546
+ }
547
+ return Array.from(effective.values());
469
548
  }
470
549
  constructor(strategyKey, discoveryService, reflector){
471
- this.strategyKey = strategyKey;
472
- this.discoveryService = discoveryService;
473
- this.reflector = reflector;
474
550
  this.logger = new common.Logger(BaseStrategyRegistry.name);
551
+ // Map<organizationId, Map<type, strategy>>
475
552
  this.strategies = new Map();
476
553
  this.pluginStrategies = new Map();
554
+ this.strategyKey = strategyKey;
555
+ this.discoveryService = discoveryService;
556
+ this.reflector = reflector;
477
557
  }
478
558
  }
479
559
  __decorate([
480
560
  common.Inject(exports.StrategyBus),
481
- __metadata("design:type", typeof exports.StrategyBus === "undefined" ? Object : exports.StrategyBus)
561
+ __metadata("design:type", exports.StrategyBus)
482
562
  ], BaseStrategyRegistry.prototype, "bus", void 0);
483
563
 
484
564
  exports.IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends BaseStrategyRegistry {
@@ -488,10 +568,9 @@ exports.IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends
488
568
  };
489
569
  exports.IntegrationStrategyRegistry = __decorate([
490
570
  common.Injectable(),
491
- __metadata("design:type", Function),
492
571
  __metadata("design:paramtypes", [
493
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
494
- typeof core.Reflector === "undefined" ? Object : core.Reflector
572
+ core.DiscoveryService,
573
+ core.Reflector
495
574
  ])
496
575
  ], exports.IntegrationStrategyRegistry);
497
576
 
@@ -505,10 +584,9 @@ exports.WorkflowTriggerRegistry = class WorkflowTriggerRegistry extends BaseStra
505
584
  };
506
585
  exports.WorkflowTriggerRegistry = __decorate([
507
586
  common.Injectable(),
508
- __metadata("design:type", Function),
509
587
  __metadata("design:paramtypes", [
510
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
511
- typeof core.Reflector === "undefined" ? Object : core.Reflector
588
+ core.DiscoveryService,
589
+ core.Reflector
512
590
  ])
513
591
  ], exports.WorkflowTriggerRegistry);
514
592
 
@@ -517,21 +595,22 @@ const WORKFLOW_NODE_STRATEGY = 'WORKFLOW_NODE_STRATEGY';
517
595
  * Decorator to mark a provider as a Workflow Node Strategy
518
596
  */ const WorkflowNodeStrategy = (provider)=>common.applyDecorators(common.SetMetadata(WORKFLOW_NODE_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, WORKFLOW_NODE_STRATEGY));
519
597
 
520
- exports.WorkflowNodeRegistry = class WorkflowNodeRegistry extends BaseStrategyRegistry {
598
+ /**
599
+ * Registry for Workflow Node Strategies
600
+ */ exports.WorkflowNodeRegistry = class WorkflowNodeRegistry extends BaseStrategyRegistry {
521
601
  constructor(discoveryService, reflector){
522
602
  super(WORKFLOW_NODE_STRATEGY, discoveryService, reflector);
523
603
  }
524
604
  };
525
605
  exports.WorkflowNodeRegistry = __decorate([
526
606
  common.Injectable(),
527
- __metadata("design:type", Function),
528
607
  __metadata("design:paramtypes", [
529
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
530
- typeof core.Reflector === "undefined" ? Object : core.Reflector
608
+ core.DiscoveryService,
609
+ core.Reflector
531
610
  ])
532
611
  ], exports.WorkflowNodeRegistry);
533
612
 
534
- const COMMAND_METADATA$1 = '__command__';
613
+ const COMMAND_METADATA$2 = '__command__';
535
614
  /**
536
615
  * Wrap Workflow Node Execution Command
537
616
  */ class WrapWorkflowNodeExecutionCommand extends cqrs.Command {
@@ -542,7 +621,7 @@ const COMMAND_METADATA$1 = '__command__';
542
621
  }
543
622
  }
544
623
  WrapWorkflowNodeExecutionCommand.type = '[Workflow] Wrap Workflow Node Execution';
545
- Reflect.defineMetadata(COMMAND_METADATA$1, {
624
+ Reflect.defineMetadata(COMMAND_METADATA$2, {
546
625
  id: WrapWorkflowNodeExecutionCommand.type
547
626
  }, WrapWorkflowNodeExecutionCommand);
548
627
 
@@ -556,10 +635,9 @@ exports.VectorStoreRegistry = class VectorStoreRegistry extends BaseStrategyRegi
556
635
  };
557
636
  exports.VectorStoreRegistry = __decorate([
558
637
  common.Injectable(),
559
- __metadata("design:type", Function),
560
638
  __metadata("design:paramtypes", [
561
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
562
- typeof core.Reflector === "undefined" ? Object : core.Reflector
639
+ core.DiscoveryService,
640
+ core.Reflector
563
641
  ])
564
642
  ], exports.VectorStoreRegistry);
565
643
 
@@ -573,10 +651,9 @@ exports.TextSplitterRegistry = class TextSplitterRegistry extends BaseStrategyRe
573
651
  };
574
652
  exports.TextSplitterRegistry = __decorate([
575
653
  common.Injectable(),
576
- __metadata("design:type", Function),
577
654
  __metadata("design:paramtypes", [
578
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
579
- typeof core.Reflector === "undefined" ? Object : core.Reflector
655
+ core.DiscoveryService,
656
+ core.Reflector
580
657
  ])
581
658
  ], exports.TextSplitterRegistry);
582
659
 
@@ -592,10 +669,9 @@ exports.DocumentSourceRegistry = class DocumentSourceRegistry extends BaseStrate
592
669
  };
593
670
  exports.DocumentSourceRegistry = __decorate([
594
671
  common.Injectable(),
595
- __metadata("design:type", Function),
596
672
  __metadata("design:paramtypes", [
597
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
598
- typeof core.Reflector === "undefined" ? Object : core.Reflector
673
+ core.DiscoveryService,
674
+ core.Reflector
599
675
  ])
600
676
  ], exports.DocumentSourceRegistry);
601
677
 
@@ -611,10 +687,9 @@ exports.DocumentTransformerRegistry = class DocumentTransformerRegistry extends
611
687
  };
612
688
  exports.DocumentTransformerRegistry = __decorate([
613
689
  common.Injectable(),
614
- __metadata("design:type", Function),
615
690
  __metadata("design:paramtypes", [
616
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
617
- typeof core.Reflector === "undefined" ? Object : core.Reflector
691
+ core.DiscoveryService,
692
+ core.Reflector
618
693
  ])
619
694
  ], exports.DocumentTransformerRegistry);
620
695
 
@@ -630,16 +705,15 @@ exports.RetrieverRegistry = class RetrieverRegistry extends BaseStrategyRegistry
630
705
  };
631
706
  exports.RetrieverRegistry = __decorate([
632
707
  common.Injectable(),
633
- __metadata("design:type", Function),
634
708
  __metadata("design:paramtypes", [
635
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
636
- typeof core.Reflector === "undefined" ? Object : core.Reflector
709
+ core.DiscoveryService,
710
+ core.Reflector
637
711
  ])
638
712
  ], exports.RetrieverRegistry);
639
713
 
640
714
  /**
641
715
  * Merge parent chunks with their child chunks based on metadata (parentId and chunkId)
642
- *
716
+ *
643
717
  * @deprecated use buildChunkTreeAndFindLeaves instead
644
718
  */ function mergeParentChildChunks(chunks, children // Child chunks
645
719
  ) {
@@ -705,10 +779,9 @@ exports.ImageUnderstandingRegistry = class ImageUnderstandingRegistry extends Ba
705
779
  };
706
780
  exports.ImageUnderstandingRegistry = __decorate([
707
781
  common.Injectable(),
708
- __metadata("design:type", Function),
709
782
  __metadata("design:paramtypes", [
710
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
711
- typeof core.Reflector === "undefined" ? Object : core.Reflector
783
+ core.DiscoveryService,
784
+ core.Reflector
712
785
  ])
713
786
  ], exports.ImageUnderstandingRegistry);
714
787
 
@@ -722,10 +795,9 @@ exports.KnowledgeStrategyRegistry = class KnowledgeStrategyRegistry extends Base
722
795
  };
723
796
  exports.KnowledgeStrategyRegistry = __decorate([
724
797
  common.Injectable(),
725
- __metadata("design:type", Function),
726
798
  __metadata("design:paramtypes", [
727
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
728
- typeof core.Reflector === "undefined" ? Object : core.Reflector
799
+ core.DiscoveryService,
800
+ core.Reflector
729
801
  ])
730
802
  ], exports.KnowledgeStrategyRegistry);
731
803
 
@@ -741,10 +813,9 @@ exports.ToolsetRegistry = class ToolsetRegistry extends BaseStrategyRegistry {
741
813
  };
742
814
  exports.ToolsetRegistry = __decorate([
743
815
  common.Injectable(),
744
- __metadata("design:type", Function),
745
816
  __metadata("design:paramtypes", [
746
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
747
- typeof core.Reflector === "undefined" ? Object : core.Reflector
817
+ core.DiscoveryService,
818
+ core.Reflector
748
819
  ])
749
820
  ], exports.ToolsetRegistry);
750
821
 
@@ -752,26 +823,26 @@ exports.ToolsetRegistry = __decorate([
752
823
  * Base ability for all toolsets
753
824
  */ class BaseToolset extends tools.BaseToolkit {
754
825
  /**
755
- * Async init tools
756
- *
757
- * @returns
758
- */ async initTools() {
826
+ * Async init tools
827
+ *
828
+ * @returns
829
+ */ async initTools() {
759
830
  return this.tools;
760
831
  }
761
832
  /**
762
- * Get one tool
763
- *
764
- * @param toolName
765
- * @returns
766
- */ getTool(toolName) {
833
+ * Get one tool
834
+ *
835
+ * @param toolName
836
+ * @returns
837
+ */ getTool(toolName) {
767
838
  var _this_getTools;
768
839
  return (_this_getTools = this.getTools()) == null ? void 0 : _this_getTools.find((tool)=>tool.name === toolName);
769
840
  }
770
841
  /**
771
- * Get state variables config
772
- *
773
- * @returns State variables
774
- */ async getVariables() {
842
+ * Get state variables config
843
+ *
844
+ * @returns State variables
845
+ */ async getVariables() {
775
846
  return null;
776
847
  }
777
848
  /**
@@ -829,26 +900,26 @@ class BuiltinToolset extends BaseToolset {
829
900
  return (_this_toolset = this.toolset) == null ? void 0 : _this_toolset.credentials;
830
901
  }
831
902
  getToolTitle(name) {
832
- var _this_toolset_tools, _this_toolset, _this;
903
+ var _this_toolset_tools, _this_toolset, _tool_schema;
833
904
  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);
834
- const identity = (_this = tool == null ? void 0 : tool.schema) == null ? void 0 : _this.identity;
905
+ const identity = tool == null ? void 0 : (_tool_schema = tool.schema) == null ? void 0 : _tool_schema.identity;
835
906
  if (identity) {
836
907
  return identity.label;
837
908
  }
838
909
  return null;
839
910
  }
840
911
  /**
841
- * Get credentials schema
842
- *
843
- * @returns Credentials schema
844
- */ getCredentialsSchema() {
912
+ * Get credentials schema
913
+ *
914
+ * @returns Credentials schema
915
+ */ getCredentialsSchema() {
845
916
  return _extends({}, this.credentialsSchema);
846
917
  }
847
918
  /**
848
- * Get toolset entity
849
- *
850
- * @returns XpertToolset
851
- */ getToolset() {
919
+ * Get toolset entity
920
+ *
921
+ * @returns XpertToolset
922
+ */ getToolset() {
852
923
  return this.toolset;
853
924
  }
854
925
  getName() {
@@ -857,27 +928,27 @@ class BuiltinToolset extends BaseToolset {
857
928
  }
858
929
  constructor(providerName, toolset, params){
859
930
  super(params);
931
+ this.logger = new common.Logger(this.constructor.name);
860
932
  this.providerName = providerName;
861
933
  this.toolset = toolset;
862
934
  this.params = params;
863
- this.logger = new common.Logger(this.constructor.name);
864
935
  }
865
- }
936
+ }
866
937
  BuiltinToolset.provider = '';
867
938
 
868
939
  /**
869
940
  * Restricted FileSystem based on granted permissions
870
941
  */ class XpFileSystem {
871
942
  /**
872
- * Check if operation is allowed
873
- */ ensureAllowed(op) {
943
+ * Check if operation is allowed
944
+ */ ensureAllowed(op) {
874
945
  if (!this.allowedOps.has(op)) {
875
946
  throw new Error(`Permission denied: ${op} operation not allowed`);
876
947
  }
877
948
  }
878
949
  /**
879
- * Check if path is within scope
880
- */ ensureInScope(targetPath) {
950
+ * Check if path is within scope
951
+ */ ensureInScope(targetPath) {
881
952
  if (!this.scope || this.scope.length === 0) return;
882
953
  const resolved = path.resolve(targetPath);
883
954
  for (const s of this.scope){
@@ -887,33 +958,33 @@ BuiltinToolset.provider = '';
887
958
  throw new Error(`Permission denied: path "${targetPath}" is out of scope`);
888
959
  }
889
960
  /**
890
- * Get the absolute path of file in the file system.
891
- *
892
- * @param filePath Relative file path
893
- * @returns Absolute file path
894
- */ fullPath(filePath) {
961
+ * Get the absolute path of file in the file system.
962
+ *
963
+ * @param filePath Relative file path
964
+ * @returns Absolute file path
965
+ */ fullPath(filePath) {
895
966
  return path.join(this.basePath, filePath);
896
967
  }
897
968
  /**
898
- * Get web url for a given file path in the file system.
899
- *
900
- * @param filePath Relative file path
901
- * @returns Web URL of file
902
- */ fullUrl(filePath) {
969
+ * Get web url for a given file path in the file system.
970
+ *
971
+ * @param filePath Relative file path
972
+ * @returns Web URL of file
973
+ */ fullUrl(filePath) {
903
974
  const url = new URL(filePath, this.baseUrl);
904
975
  return url.href;
905
976
  }
906
977
  /**
907
- * Read file contents
908
- */ async readFile(filePath, encoding = 'utf-8') {
978
+ * Read file contents
979
+ */ async readFile(filePath, encoding = 'utf-8') {
909
980
  this.ensureAllowed('read');
910
981
  const fullPath = this.fullPath(filePath);
911
982
  this.ensureInScope(fullPath);
912
983
  return await fsPromises.readFile(fullPath);
913
984
  }
914
985
  /**
915
- * Write file contents
916
- */ async writeFile(filePath, content) {
986
+ * Write file contents
987
+ */ async writeFile(filePath, content) {
917
988
  this.ensureAllowed('write');
918
989
  const fullPath = this.fullPath(filePath);
919
990
  this.ensureInScope(fullPath);
@@ -925,22 +996,22 @@ BuiltinToolset.provider = '';
925
996
  return url.href;
926
997
  }
927
998
  /**
928
- * Delete a file
929
- */ async deleteFile(filePath) {
999
+ * Delete a file
1000
+ */ async deleteFile(filePath) {
930
1001
  this.ensureAllowed('delete');
931
1002
  this.ensureInScope(filePath);
932
1003
  await fsPromises.unlink(filePath);
933
1004
  }
934
1005
  /**
935
- * List directory contents
936
- */ async listDir(dirPath) {
1006
+ * List directory contents
1007
+ */ async listDir(dirPath) {
937
1008
  this.ensureAllowed('list');
938
1009
  this.ensureInScope(dirPath);
939
1010
  return fsPromises.readdir(dirPath);
940
1011
  }
941
1012
  /**
942
- * Utility: check if a file or directory exists
943
- */ async exists(targetPath) {
1013
+ * Utility: check if a file or directory exists
1014
+ */ async exists(targetPath) {
944
1015
  try {
945
1016
  await fsPromises.access(targetPath);
946
1017
  return true;
@@ -1047,7 +1118,7 @@ function loadYamlFile(filePath, logger, ignoreError = true, defaultValue = {}) {
1047
1118
  }
1048
1119
  /**
1049
1120
  * Get the mapping from name to index from a YAML file
1050
- *
1121
+ *
1051
1122
  * @param folderPath
1052
1123
  * @param fileName the YAML file name, default to '_position.yaml'
1053
1124
  * @return a dict with name as key and index as value
@@ -1116,10 +1187,9 @@ exports.DataSourceStrategyRegistry = class DataSourceStrategyRegistry extends Ba
1116
1187
  };
1117
1188
  exports.DataSourceStrategyRegistry = __decorate([
1118
1189
  common.Injectable(),
1119
- __metadata("design:type", Function),
1120
1190
  __metadata("design:paramtypes", [
1121
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
1122
- typeof core.Reflector === "undefined" ? Object : core.Reflector
1191
+ core.DiscoveryService,
1192
+ core.Reflector
1123
1193
  ])
1124
1194
  ], exports.DataSourceStrategyRegistry);
1125
1195
 
@@ -1128,12 +1198,12 @@ exports.DataSourceStrategyRegistry = __decorate([
1128
1198
  * into datasource strategies consumable by the plugin SDK.
1129
1199
  */ class AdapterDataSourceStrategy {
1130
1200
  /**
1131
- * Get from cache or create new instance of DB adapter.
1132
- *
1133
- * @param options
1134
- * @param id
1135
- * @returns
1136
- */ async create(options, id) {
1201
+ * Get from cache or create new instance of DB adapter.
1202
+ *
1203
+ * @param options
1204
+ * @param id
1205
+ * @returns
1206
+ */ async create(options, id) {
1137
1207
  if (id) {
1138
1208
  if (this.runners.has(id)) {
1139
1209
  return this.runners.get(id);
@@ -1169,9 +1239,10 @@ exports.DataSourceStrategyRegistry = __decorate([
1169
1239
  return this.runnerClass;
1170
1240
  }
1171
1241
  constructor(runnerClass, extraArgs = []){
1242
+ this.runners = new Map() // dataSourceId -> runner instance
1243
+ ;
1172
1244
  this.runnerClass = runnerClass;
1173
1245
  this.extraArgs = extraArgs;
1174
- this.runners = new Map();
1175
1246
  }
1176
1247
  }
1177
1248
 
@@ -1271,13 +1342,13 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1271
1342
  await this.runQuery(`SELECT 1`);
1272
1343
  }
1273
1344
  /**
1274
- * Default implementation for table operations
1275
- */ async tableOp(action, params, options) {
1345
+ * Default implementation for table operations
1346
+ */ async tableOp(action, params, options) {
1276
1347
  switch(action){
1277
- case "createTable":
1348
+ case exports.DBTableAction.CREATE_TABLE:
1278
1349
  {
1279
1350
  // Default implementation for creating table (generic SQL syntax)
1280
- const { schema, table, columns, createMode = "error" } = params;
1351
+ const { schema, table, columns, createMode = exports.DBCreateTableMode.ERROR } = params;
1281
1352
  const tableName = schema ? `${schema}.${table}` : table;
1282
1353
  // Check if table exists (try to query table info)
1283
1354
  let exists = false;
@@ -1289,17 +1360,17 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1289
1360
  exists = false;
1290
1361
  }
1291
1362
  // --- MODE: ERROR → throw error if table exists ---
1292
- if (exists && createMode === "error") {
1363
+ if (exists && createMode === exports.DBCreateTableMode.ERROR) {
1293
1364
  throw new Error(`Table "${tableName}" already exists`);
1294
1365
  }
1295
1366
  // --- MODE: IGNORE → do nothing if exists ---
1296
- if (exists && createMode === "ignore") {
1367
+ if (exists && createMode === exports.DBCreateTableMode.IGNORE) {
1297
1368
  return;
1298
1369
  }
1299
1370
  // --- MODE: UPGRADE → auto upgrade (simple implementation: only add new columns) ---
1300
1371
  // Note: This default implementation does not support modifying column types,
1301
1372
  // recommend each database to implement its own version
1302
- if (exists && createMode === "upgrade") {
1373
+ if (exists && createMode === exports.DBCreateTableMode.UPGRADE) {
1303
1374
  console.warn(`[BaseSQLQueryRunner] UPGRADE mode uses basic implementation. Consider implementing tableOp for better support.`);
1304
1375
  // Try to add new columns (will fail if column already exists, but doesn't affect)
1305
1376
  for (const col of columns){
@@ -1324,7 +1395,7 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1324
1395
  await this.runQuery(createTableStatement, options);
1325
1396
  return;
1326
1397
  }
1327
- case "dropTable":
1398
+ case exports.DBTableAction.DROP_TABLE:
1328
1399
  {
1329
1400
  // Default implementation for dropping table
1330
1401
  const { schema, table } = params;
@@ -1338,8 +1409,8 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1338
1409
  }
1339
1410
  }
1340
1411
  /**
1341
- * Generic type mapping (subclasses can override)
1342
- */ mapColumnType(type, isKey, length) {
1412
+ * Generic type mapping (subclasses can override)
1413
+ */ mapColumnType(type, isKey, length) {
1343
1414
  switch(type == null ? void 0 : type.toLowerCase()){
1344
1415
  case 'string':
1345
1416
  return length ? `VARCHAR(${length})` : isKey ? 'VARCHAR(255)' : 'VARCHAR(1000)';
@@ -1359,8 +1430,8 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
1359
1430
  }
1360
1431
  constructor(...args){
1361
1432
  super(...args);
1362
- this.syntax = "sql";
1363
- this.protocol = "sql";
1433
+ this.syntax = exports.DBSyntaxEnum.SQL;
1434
+ this.protocol = exports.DBProtocolEnum.SQL;
1364
1435
  }
1365
1436
  }
1366
1437
  exports.DBTableAction = void 0;
@@ -1381,7 +1452,9 @@ exports.DBTableAction = void 0;
1381
1452
  DBTableAction["CLONE_TABLE"] = "cloneTable";
1382
1453
  DBTableAction["OPTIMIZE_TABLE"] = "optimizeTable";
1383
1454
  })(exports.DBTableAction || (exports.DBTableAction = {}));
1384
- exports.DBCreateTableMode = void 0;
1455
+ /**
1456
+ * Modes for creating a table, if the table already exists
1457
+ */ exports.DBCreateTableMode = void 0;
1385
1458
  (function(DBCreateTableMode) {
1386
1459
  DBCreateTableMode["ERROR"] = "error";
1387
1460
  DBCreateTableMode["IGNORE"] = "ignore";
@@ -1411,8 +1484,7 @@ function AIModelProviderStrategy(provider) {
1411
1484
  const match = (callerLine == null ? void 0 : callerLine.match(/\((file:\/\/\/[^\s)]+)\)/)) || (// case 1: file:///path...
1412
1485
  callerLine == null ? void 0 : callerLine.match(/\((\/[^\s)]+)\)/)) || (// case 2: (/Users/xxx)
1413
1486
  callerLine == null ? void 0 : callerLine.match(/at (file:\/\/\/[^\s]+)/)) || (// case 3: at file:///...
1414
- callerLine == null ? void 0 : callerLine.match(/at (\/[^\s]+)/) // case 4: at /Users/xxx
1415
- );
1487
+ callerLine == null ? void 0 : callerLine.match(/at (\/[^\s]+)/)); // case 4: at /Users/xxx
1416
1488
  let file = match == null ? void 0 : match[1];
1417
1489
  // remove the file:/// prefix
1418
1490
  if (file == null ? void 0 : file.startsWith('file:///')) {
@@ -1447,10 +1519,9 @@ exports.AIModelProviderRegistry = class AIModelProviderRegistry extends BaseStra
1447
1519
  };
1448
1520
  exports.AIModelProviderRegistry = __decorate([
1449
1521
  common.Injectable(),
1450
- __metadata("design:type", Function),
1451
1522
  __metadata("design:paramtypes", [
1452
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
1453
- typeof core.Reflector === "undefined" ? Object : core.Reflector
1523
+ core.DiscoveryService,
1524
+ core.Reflector
1454
1525
  ])
1455
1526
  ], exports.AIModelProviderRegistry);
1456
1527
 
@@ -1461,7 +1532,8 @@ class CredentialsValidateFailedError extends common.ForbiddenException {
1461
1532
  class AIModelProviderNotFoundException extends common.NotFoundException {
1462
1533
  }
1463
1534
 
1464
- exports.ModelProvider = class ModelProvider {
1535
+ var ModelProvider_1;
1536
+ exports.ModelProvider = ModelProvider_1 = class ModelProvider {
1465
1537
  get name() {
1466
1538
  return this.getProviderSchema().provider;
1467
1539
  }
@@ -1469,10 +1541,10 @@ exports.ModelProvider = class ModelProvider {
1469
1541
  await this.validateProviderCredentials(credentials);
1470
1542
  }
1471
1543
  /**
1472
- * Get provider lib root path.
1473
- *
1474
- * @returns Root of library
1475
- */ getProviderServerPath() {
1544
+ * Get provider lib root path.
1545
+ *
1546
+ * @returns Root of library
1547
+ */ getProviderServerPath() {
1476
1548
  return this.dir;
1477
1549
  }
1478
1550
  getProviderSchema() {
@@ -1507,11 +1579,11 @@ exports.ModelProvider = class ModelProvider {
1507
1579
  return modelInstance;
1508
1580
  }
1509
1581
  /**
1510
- * Get provider models.
1511
- * @param modelType - model type
1512
- * @param onlyActive - only active models
1513
- * @return provider models
1514
- */ getProviderModels(modelType, onlyActive = false) {
1582
+ * Get provider models.
1583
+ * @param modelType - model type
1584
+ * @param onlyActive - only active models
1585
+ * @return provider models
1586
+ */ getProviderModels(modelType, onlyActive = false) {
1515
1587
  let modelTypes = [];
1516
1588
  if (modelType) {
1517
1589
  modelTypes.push(modelType);
@@ -1563,7 +1635,7 @@ exports.ModelProvider = class ModelProvider {
1563
1635
  return null;
1564
1636
  }
1565
1637
  constructor(){
1566
- this.logger = new common.Logger(ModelProvider.name);
1638
+ this.logger = new common.Logger(ModelProvider_1.name);
1567
1639
  // protected providerSchema: IAiProviderEntity | null = null
1568
1640
  this.modelManagers = new Map();
1569
1641
  const provider = Reflect.getMetadata(AI_MODEL_PROVIDER, this.constructor);
@@ -1573,9 +1645,8 @@ exports.ModelProvider = class ModelProvider {
1573
1645
  this.dir = dir;
1574
1646
  }
1575
1647
  };
1576
- exports.ModelProvider = __decorate([
1648
+ exports.ModelProvider = ModelProvider_1 = __decorate([
1577
1649
  common.Injectable(),
1578
- __metadata("design:type", Function),
1579
1650
  __metadata("design:paramtypes", [])
1580
1651
  ], exports.ModelProvider);
1581
1652
 
@@ -1764,7 +1835,8 @@ function mergeCredentials(credentials, modelProperties) {
1764
1835
  return _extends({}, credentials != null ? credentials : {}, modelProperties != null ? modelProperties : {});
1765
1836
  }
1766
1837
 
1767
- let AIModel = class AIModel {
1838
+ var AIModel_1;
1839
+ let AIModel = AIModel_1 = class AIModel {
1768
1840
  getChatModel(copilotModel, options) {
1769
1841
  throw new Error(`Unsupport chat model!`);
1770
1842
  }
@@ -1839,13 +1911,13 @@ let AIModel = class AIModel {
1839
1911
  return null;
1840
1912
  }
1841
1913
  /**
1842
- * Get customizable model schema.
1843
- * Implement this method in ai model sub class that can customize model
1844
- *
1845
- * @param model model name
1846
- * @param credentials model credentials
1847
- * @returns model schema
1848
- */ getCustomizableModelSchemaFromCredentials(model, credentials) {
1914
+ * Get customizable model schema.
1915
+ * Implement this method in ai model sub class that can customize model
1916
+ *
1917
+ * @param model model name
1918
+ * @param credentials model credentials
1919
+ * @returns model schema
1920
+ */ getCustomizableModelSchemaFromCredentials(model, credentials) {
1849
1921
  return null;
1850
1922
  }
1851
1923
  processParameterRules(yamlData) {
@@ -1917,29 +1989,28 @@ let AIModel = class AIModel {
1917
1989
  };
1918
1990
  }
1919
1991
  constructor(modelProvider, modelType){
1920
- this.modelProvider = modelProvider;
1921
- this.modelType = modelType;
1922
- this.logger = new common.Logger(AIModel.name);
1992
+ this.logger = new common.Logger(AIModel_1.name);
1923
1993
  this.modelSchemas = null;
1924
1994
  this.positions = null;
1995
+ this.modelProvider = modelProvider;
1996
+ this.modelType = modelType;
1925
1997
  this.modelProvider.registerAIModelInstance(this.modelType, this);
1926
1998
  }
1927
1999
  };
1928
- AIModel = __decorate([
2000
+ AIModel = AIModel_1 = __decorate([
1929
2001
  common.Injectable(),
1930
- __metadata("design:type", Function),
1931
2002
  __metadata("design:paramtypes", [
1932
- typeof exports.ModelProvider === "undefined" ? Object : exports.ModelProvider,
1933
- typeof contracts.AiModelTypeEnum === "undefined" ? Object : contracts.AiModelTypeEnum
2003
+ exports.ModelProvider,
2004
+ String
1934
2005
  ])
1935
2006
  ], AIModel);
1936
2007
  function getDefaultParameterRuleVariableMap(name) {
1937
2008
  /**
1938
- * Get default parameter rule for given name
1939
- *
1940
- * @param name - parameter name
1941
- * @return parameter rule
1942
- */ const defaultParameterRule = PARAMETER_RULE_TEMPLATE[name];
2009
+ * Get default parameter rule for given name
2010
+ *
2011
+ * @param name - parameter name
2012
+ * @return parameter rule
2013
+ */ const defaultParameterRule = PARAMETER_RULE_TEMPLATE[name];
1943
2014
  if (!defaultParameterRule) {
1944
2015
  throw new Error(`Invalid model parameter rule name ${name}`);
1945
2016
  }
@@ -2005,17 +2076,18 @@ function _class_private_field_loose_key(name) {
2005
2076
  return "__private_" + id++ + "_" + name;
2006
2077
  }
2007
2078
 
2079
+ var _a;
2008
2080
  class LLMUsage {
2009
2081
  static emptyUsage() {
2010
2082
  return new LLMUsage(0, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0, 0.0, 'USD', 0.0);
2011
2083
  }
2012
2084
  plus(other) {
2013
2085
  /**
2014
- * Add two LLMUsage instances together.
2015
- *
2016
- * @param other: Another LLMUsage instance to add
2017
- * @return: A new LLMUsage instance with summed values
2018
- */ if (this.totalTokens === 0) {
2086
+ * Add two LLMUsage instances together.
2087
+ *
2088
+ * @param other: Another LLMUsage instance to add
2089
+ * @return: A new LLMUsage instance with summed values
2090
+ */ if (this.totalTokens === 0) {
2019
2091
  return other;
2020
2092
  } else {
2021
2093
  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);
@@ -2023,11 +2095,11 @@ class LLMUsage {
2023
2095
  }
2024
2096
  add(other) {
2025
2097
  /**
2026
- * Overload the + operator to add two LLMUsage instances.
2027
- *
2028
- * @param other: Another LLMUsage instance to add
2029
- * @return: A new LLMUsage instance with summed values
2030
- */ return this.plus(other);
2098
+ * Overload the + operator to add two LLMUsage instances.
2099
+ *
2100
+ * @param other: Another LLMUsage instance to add
2101
+ * @return: A new LLMUsage instance with summed values
2102
+ */ return this.plus(other);
2031
2103
  }
2032
2104
  constructor(promptTokens, promptUnitPrice, promptPriceUnit, promptPrice, completionTokens, completionUnitPrice, completionPriceUnit, completionPrice, totalTokens, totalPrice, currency, latency){
2033
2105
  this.promptTokens = promptTokens;
@@ -2147,15 +2219,88 @@ class LargeLanguageModel extends AIModel {
2147
2219
  }
2148
2220
  };
2149
2221
  }
2222
+ createHandleVerboseCallbacks(enabled, logger) {
2223
+ if (!enabled) {
2224
+ return [];
2225
+ }
2226
+ const targetLogger = logger != null ? logger : _class_private_field_loose_base(this, _logger)[_logger];
2227
+ return [
2228
+ {
2229
+ handleChatModelStart: (llm, messages, runId, parentRunId, extraParams, tags, metadata, runName)=>{
2230
+ targetLogger.verbose(this.formatVerboseLog('chat_model/start', {
2231
+ runId,
2232
+ parentRunId,
2233
+ runName,
2234
+ model: llm,
2235
+ messages,
2236
+ extraParams,
2237
+ tags,
2238
+ metadata
2239
+ }));
2240
+ },
2241
+ handleLLMStart: (llm, prompts, runId, parentRunId, extraParams, tags, metadata, runName)=>{
2242
+ targetLogger.verbose(this.formatVerboseLog('llm/start', {
2243
+ runId,
2244
+ parentRunId,
2245
+ runName,
2246
+ model: llm,
2247
+ prompts,
2248
+ extraParams,
2249
+ tags,
2250
+ metadata
2251
+ }));
2252
+ },
2253
+ handleLLMEnd: (output, runId, parentRunId, tags, extraParams)=>{
2254
+ targetLogger.verbose(this.formatVerboseLog('llm/end', {
2255
+ runId,
2256
+ parentRunId,
2257
+ output,
2258
+ tags,
2259
+ extraParams
2260
+ }));
2261
+ },
2262
+ handleLLMError: (err, runId, parentRunId, tags, extraParams)=>{
2263
+ targetLogger.verbose(this.formatVerboseLog('llm/error', {
2264
+ runId,
2265
+ parentRunId,
2266
+ error: this.formatError(err),
2267
+ tags,
2268
+ extraParams
2269
+ }));
2270
+ }
2271
+ }
2272
+ ];
2273
+ }
2274
+ formatVerboseLog(event, payload) {
2275
+ return `[langchain][${event}] ${this.stringifyLogPayload(payload)}`;
2276
+ }
2277
+ stringifyLogPayload(payload) {
2278
+ try {
2279
+ return JSON.stringify(payload, null, 2);
2280
+ } catch (error) {
2281
+ return `[unserializable payload: ${this.formatError(error)}]`;
2282
+ }
2283
+ }
2284
+ formatError(error) {
2285
+ if (error instanceof Error) {
2286
+ return {
2287
+ name: error.name,
2288
+ message: error.message,
2289
+ stack: error.stack
2290
+ };
2291
+ }
2292
+ return error;
2293
+ }
2150
2294
  constructor(...args){
2151
2295
  super(...args);
2152
2296
  Object.defineProperty(this, _logger, {
2153
2297
  writable: true,
2154
2298
  value: void 0
2155
2299
  });
2156
- _class_private_field_loose_base(this, _logger)[_logger] = new common.Logger(LargeLanguageModel.name);
2300
+ _class_private_field_loose_base(this, _logger)[_logger] = new common.Logger(_a.name);
2157
2301
  }
2158
2302
  }
2303
+ _a = LargeLanguageModel;
2159
2304
  function calcTokenUsage(output) {
2160
2305
  var _output_generations;
2161
2306
  const tokenUsage = {
@@ -2203,8 +2348,8 @@ function calcTokenUsage(output) {
2203
2348
  * 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.
2204
2349
  */ class ChatOAICompatReasoningModel extends openai.ChatOpenAICompletions {
2205
2350
  /**
2206
- *
2207
- */ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
2351
+ *
2352
+ */ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
2208
2353
  delta, rawResponse, defaultRole) {
2209
2354
  const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole);
2210
2355
  if (delta['content'] === '<think>') {
@@ -2390,7 +2535,7 @@ function normalizeContextSize(value) {
2390
2535
  return undefined;
2391
2536
  }
2392
2537
 
2393
- const COMMAND_METADATA = '__command__';
2538
+ const COMMAND_METADATA$1 = '__command__';
2394
2539
  /**
2395
2540
  * Get a Chat Model of copilot model and check it's token limitation, record the token usage
2396
2541
  */ class CreateModelClientCommand extends cqrs.Command {
@@ -2401,10 +2546,26 @@ const COMMAND_METADATA = '__command__';
2401
2546
  }
2402
2547
  }
2403
2548
  CreateModelClientCommand.type = '[AI Model] Create Model Client';
2404
- Reflect.defineMetadata(COMMAND_METADATA, {
2549
+ Reflect.defineMetadata(COMMAND_METADATA$1, {
2405
2550
  id: CreateModelClientCommand.type
2406
2551
  }, CreateModelClientCommand);
2407
2552
 
2553
+ const SKILL_SOURCE_PROVIDER = 'SKILL_SOURCE_PROVIDER';
2554
+ const SkillSourceProviderStrategy = (provider)=>common.applyDecorators(common.SetMetadata(SKILL_SOURCE_PROVIDER, provider), common.SetMetadata(STRATEGY_META_KEY, SKILL_SOURCE_PROVIDER));
2555
+
2556
+ exports.SkillSourceProviderRegistry = class SkillSourceProviderRegistry extends BaseStrategyRegistry {
2557
+ constructor(discoveryService, reflector){
2558
+ super(SKILL_SOURCE_PROVIDER, discoveryService, reflector);
2559
+ }
2560
+ };
2561
+ exports.SkillSourceProviderRegistry = __decorate([
2562
+ common.Injectable(),
2563
+ __metadata("design:paramtypes", [
2564
+ core.DiscoveryService,
2565
+ core.Reflector
2566
+ ])
2567
+ ], exports.SkillSourceProviderRegistry);
2568
+
2408
2569
  const AGENT_MIDDLEWARE_STRATEGY = 'AGENT_MIDDLEWARE_STRATEGY';
2409
2570
  const AgentMiddlewareStrategy = (provider)=>common.applyDecorators(common.SetMetadata(AGENT_MIDDLEWARE_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, AGENT_MIDDLEWARE_STRATEGY));
2410
2571
 
@@ -2415,10 +2576,9 @@ exports.AgentMiddlewareRegistry = class AgentMiddlewareRegistry extends BaseStra
2415
2576
  };
2416
2577
  exports.AgentMiddlewareRegistry = __decorate([
2417
2578
  common.Injectable(),
2418
- __metadata("design:type", Function),
2419
2579
  __metadata("design:paramtypes", [
2420
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
2421
- typeof core.Reflector === "undefined" ? Object : core.Reflector
2580
+ core.DiscoveryService,
2581
+ core.Reflector
2422
2582
  ])
2423
2583
  ], exports.AgentMiddlewareRegistry);
2424
2584
 
@@ -2430,15 +2590,7 @@ exports.AgentMiddlewareRegistry = __decorate([
2430
2590
  "end"
2431
2591
  ];
2432
2592
 
2433
- /**
2434
- * Structured message types (suggested format):
2435
- * - channel.{provider}.{action}.v{number}
2436
- * - agent.{action}.v{number}
2437
- * - system.{action}.v{number}
2438
- * - plugin.{domain}.{action}.v{number}
2439
- *
2440
- * Note: At runtime, any string type is still allowed, facilitating dynamic extension by plugins.
2441
- */ const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
2593
+ const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
2442
2594
  const VERSION_PATTERN = /^v[1-9][0-9]*$/;
2443
2595
  function assertSegment(input, name) {
2444
2596
  if (!SEGMENT_PATTERN.test(input)) {
@@ -2504,10 +2656,9 @@ exports.HandoffProcessorRegistry = class HandoffProcessorRegistry extends BaseSt
2504
2656
  };
2505
2657
  exports.HandoffProcessorRegistry = __decorate([
2506
2658
  common.Injectable(),
2507
- __metadata("design:type", Function),
2508
2659
  __metadata("design:paramtypes", [
2509
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
2510
- typeof core.Reflector === "undefined" ? Object : core.Reflector
2660
+ core.DiscoveryService,
2661
+ core.Reflector
2511
2662
  ])
2512
2663
  ], exports.HandoffProcessorRegistry);
2513
2664
 
@@ -2616,26 +2767,52 @@ exports.HandoffProcessorRegistry = __decorate([
2616
2767
  * ```
2617
2768
  */ const ChatChannel = (type)=>common.SetMetadata(CHAT_CHANNEL, type);
2618
2769
 
2619
- exports.ChatChannelRegistry = class ChatChannelRegistry extends BaseStrategyRegistry {
2770
+ /**
2771
+ * Chat Channel Registry
2772
+ *
2773
+ * Manages all registered chat channel implementations.
2774
+ * Channels are automatically discovered and registered via @ChatChannel decorator.
2775
+ *
2776
+ * Supports:
2777
+ * - Organization-scoped channels
2778
+ * - Global channels (fallback)
2779
+ * - Plugin-based registration/removal
2780
+ * - Dynamic channel lookup
2781
+ *
2782
+ * @example
2783
+ * ```typescript
2784
+ * // Get channel by type
2785
+ * const channel = registry.get('lark')
2786
+ *
2787
+ * // List all available channels for an organization
2788
+ * const channels = registry.list(organizationId)
2789
+ *
2790
+ * // Send message using a channel
2791
+ * await channel.sendText(ctx, 'Hello!')
2792
+ * ```
2793
+ */ exports.ChatChannelRegistry = class ChatChannelRegistry extends BaseStrategyRegistry {
2620
2794
  constructor(discoveryService, reflector){
2621
2795
  super(CHAT_CHANNEL, discoveryService, reflector);
2622
2796
  }
2623
2797
  };
2624
2798
  exports.ChatChannelRegistry = __decorate([
2625
2799
  common.Injectable(),
2626
- __metadata("design:type", Function),
2627
2800
  __metadata("design:paramtypes", [
2628
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
2629
- typeof core.Reflector === "undefined" ? Object : core.Reflector
2801
+ core.DiscoveryService,
2802
+ core.Reflector
2630
2803
  ])
2631
2804
  ], exports.ChatChannelRegistry);
2632
2805
 
2806
+ const COMMAND_METADATA = '__command__';
2633
2807
  class CancelConversationCommand {
2634
2808
  constructor(input){
2635
2809
  this.input = input;
2636
2810
  }
2637
2811
  }
2638
2812
  CancelConversationCommand.type = '[Chat Conversation] Cancel';
2813
+ Reflect.defineMetadata(COMMAND_METADATA, {
2814
+ id: CancelConversationCommand.type
2815
+ }, CancelConversationCommand);
2639
2816
 
2640
2817
  const FILE_STORAGE_PROVIDER = 'FILE_STORAGE_PROVIDER';
2641
2818
  const FileStorageProvider = (provider)=>common.applyDecorators(common.SetMetadata(FILE_STORAGE_PROVIDER, provider), common.SetMetadata(STRATEGY_META_KEY, FILE_STORAGE_PROVIDER));
@@ -2647,10 +2824,9 @@ exports.FileStorageProviderRegistry = class FileStorageProviderRegistry extends
2647
2824
  };
2648
2825
  exports.FileStorageProviderRegistry = __decorate([
2649
2826
  common.Injectable(),
2650
- __metadata("design:type", Function),
2651
2827
  __metadata("design:paramtypes", [
2652
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
2653
- typeof core.Reflector === "undefined" ? Object : core.Reflector
2828
+ core.DiscoveryService,
2829
+ core.Reflector
2654
2830
  ])
2655
2831
  ], exports.FileStorageProviderRegistry);
2656
2832
 
@@ -2664,10 +2840,9 @@ exports.FileUploadTargetRegistry = class FileUploadTargetRegistry extends BaseSt
2664
2840
  };
2665
2841
  exports.FileUploadTargetRegistry = __decorate([
2666
2842
  common.Injectable(),
2667
- __metadata("design:type", Function),
2668
2843
  __metadata("design:paramtypes", [
2669
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
2670
- typeof core.Reflector === "undefined" ? Object : core.Reflector
2844
+ core.DiscoveryService,
2845
+ core.Reflector
2671
2846
  ])
2672
2847
  ], exports.FileUploadTargetRegistry);
2673
2848
 
@@ -2722,8 +2897,18 @@ function resolveSandboxExecutionOptions(options, defaults = DEFAULT_SANDBOX_SHEL
2722
2897
  *
2723
2898
  * @param backend - Backend instance to check
2724
2899
  * @returns True if the backend implements SandboxBackendProtocol
2725
- */ function isSandboxBackend(backend) {
2726
- return typeof backend.execute === 'function' && typeof backend.id === 'string';
2900
+ */ function isObjectLike(value) {
2901
+ return typeof value === 'object' && value !== null;
2902
+ }
2903
+ function isSandboxBackend(backend) {
2904
+ return isObjectLike(backend) && typeof Reflect.get(backend, 'execute') === 'function' && typeof Reflect.get(backend, 'id') === 'string';
2905
+ }
2906
+ function resolveSandboxBackend(sandbox) {
2907
+ if (!isObjectLike(sandbox)) {
2908
+ return null;
2909
+ }
2910
+ const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
2911
+ return isSandboxBackend(candidate) ? candidate : null;
2727
2912
  }
2728
2913
 
2729
2914
  const MAX_LINE_LENGTH = 500;
@@ -3341,6 +3526,13 @@ try {
3341
3526
  *
3342
3527
  * Requires Node.js 20+ on the sandbox host.
3343
3528
  */ class BaseSandbox {
3529
+ /**
3530
+ * Internal hook for file/search operations. Concrete backends can override
3531
+ * this to distinguish "background helper commands" from user-facing shell
3532
+ * execute calls.
3533
+ */ executeOperation(command, options) {
3534
+ return this.execute(command, options);
3535
+ }
3344
3536
  async streamExecute(command, onLine, options) {
3345
3537
  const result = await this.execute(command, options);
3346
3538
  if (result.output) {
@@ -3349,13 +3541,13 @@ try {
3349
3541
  return result;
3350
3542
  }
3351
3543
  /**
3352
- * List files and directories in the specified directory (non-recursive).
3353
- *
3354
- * @param path - Absolute path to directory
3355
- * @returns List of FileInfo objects for files and directories directly in the directory.
3356
- */ async lsInfo(path) {
3544
+ * List files and directories in the specified directory (non-recursive).
3545
+ *
3546
+ * @param path - Absolute path to directory
3547
+ * @returns List of FileInfo objects for files and directories directly in the directory.
3548
+ */ async lsInfo(path) {
3357
3549
  const command = buildLsCommand(path);
3358
- const result = await this.execute(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3550
+ const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3359
3551
  if (result.exitCode !== 0) {
3360
3552
  return [];
3361
3553
  }
@@ -3377,14 +3569,14 @@ try {
3377
3569
  return infos;
3378
3570
  }
3379
3571
  /**
3380
- * List directory contents recursively with depth control and pagination.
3381
- *
3382
- * @param dirPath - Absolute path to directory
3383
- * @param offset - 1-indexed entry number to start from (default: 1)
3384
- * @param limit - Maximum number of entries to return (default: 25)
3385
- * @param depth - Maximum depth to traverse (default: 2)
3386
- * @returns Human-readable directory tree with indentation
3387
- */ async listDir(dirPath, offset = 1, limit = 25, depth = 2) {
3572
+ * List directory contents recursively with depth control and pagination.
3573
+ *
3574
+ * @param dirPath - Absolute path to directory
3575
+ * @param offset - 1-indexed entry number to start from (default: 1)
3576
+ * @param limit - Maximum number of entries to return (default: 25)
3577
+ * @param depth - Maximum depth to traverse (default: 2)
3578
+ * @returns Human-readable directory tree with indentation
3579
+ */ async listDir(dirPath, offset = 1, limit = 25, depth = 2) {
3388
3580
  if (offset < 1) {
3389
3581
  return 'Error: offset must be a 1-indexed entry number';
3390
3582
  }
@@ -3395,34 +3587,34 @@ try {
3395
3587
  return 'Error: depth must be greater than zero';
3396
3588
  }
3397
3589
  const command = buildListDirCommand(dirPath, offset, limit, depth);
3398
- const result = await this.execute(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3590
+ const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3399
3591
  if (result.exitCode !== 0) {
3400
3592
  return result.output || `Error: Failed to list directory '${dirPath}'`;
3401
3593
  }
3402
3594
  return result.output;
3403
3595
  }
3404
3596
  /**
3405
- * Read file content with line numbers.
3406
- *
3407
- * @param filePath - Absolute file path
3408
- * @param offset - Line offset to start reading from (1-indexed)
3409
- * @param limit - Maximum number of lines to read
3410
- * @param mode - Read mode: 'slice' (default) or 'indentation'
3411
- * @param indentation - Configuration for indentation mode
3412
- * @returns Formatted file content with line numbers, or error message
3413
- */ async read(filePath, offset = 1, limit = 2000, mode = 'slice', indentation) {
3597
+ * Read file content with line numbers.
3598
+ *
3599
+ * @param filePath - Absolute file path
3600
+ * @param offset - Line offset to start reading from (1-indexed)
3601
+ * @param limit - Maximum number of lines to read
3602
+ * @param mode - Read mode: 'slice' (default) or 'indentation'
3603
+ * @param indentation - Configuration for indentation mode
3604
+ * @returns Formatted file content with line numbers, or error message
3605
+ */ async read(filePath, offset = 1, limit = 2000, mode = 'slice', indentation) {
3414
3606
  const command = mode === 'indentation' ? buildIndentationReadCommand(filePath, offset, limit, indentation != null ? indentation : {}) : buildSliceReadCommand(filePath, offset, limit);
3415
- const result = await this.execute(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3607
+ const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3416
3608
  if (result.exitCode !== 0) {
3417
3609
  return result.output || `Error: File '${filePath}' not found`;
3418
3610
  }
3419
3611
  return result.output;
3420
3612
  }
3421
3613
  /**
3422
- * Structured search results or error string for invalid input.
3423
- */ async grepRaw(pattern, path = '/', include = null) {
3614
+ * Structured search results or error string for invalid input.
3615
+ */ async grepRaw(pattern, path = '/', include = null) {
3424
3616
  const command = buildGrepCommand(pattern, path, include);
3425
- const result = await this.execute(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
3617
+ const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
3426
3618
  if (result.exitCode === 1) {
3427
3619
  // Check if it's a regex error
3428
3620
  if (result.output.includes('Invalid regex:')) {
@@ -3446,8 +3638,8 @@ try {
3446
3638
  return matches;
3447
3639
  }
3448
3640
  /**
3449
- * Search file contents for a regex pattern, returning human-readable output.
3450
- */ async grep(pattern, path = '/', include = null) {
3641
+ * Search file contents for a regex pattern, returning human-readable output.
3642
+ */ async grep(pattern, path = '/', include = null) {
3451
3643
  const result = await this.grepRaw(pattern, path, include);
3452
3644
  if (typeof result === 'string') {
3453
3645
  return result;
@@ -3458,10 +3650,10 @@ try {
3458
3650
  return formatGrepOutput(result);
3459
3651
  }
3460
3652
  /**
3461
- * Structured glob matching returning FileInfo objects.
3462
- */ async globInfo(pattern, path = '/') {
3653
+ * Structured glob matching returning FileInfo objects.
3654
+ */ async globInfo(pattern, path = '/') {
3463
3655
  const command = buildGlobCommand(path, pattern);
3464
- const result = await this.execute(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
3656
+ const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
3465
3657
  const infos = [];
3466
3658
  const lines = result.output.trim().split('\n').filter(Boolean);
3467
3659
  for (const line of lines){
@@ -3480,8 +3672,8 @@ try {
3480
3672
  return infos;
3481
3673
  }
3482
3674
  /**
3483
- * Find files matching a glob pattern, returning human-readable output.
3484
- */ async glob(pattern, path = '/') {
3675
+ * Find files matching a glob pattern, returning human-readable output.
3676
+ */ async glob(pattern, path = '/') {
3485
3677
  const files = await this.globInfo(pattern, path);
3486
3678
  if (files.length === 0) {
3487
3679
  return 'No files found';
@@ -3489,10 +3681,10 @@ try {
3489
3681
  return formatGlobOutput(files);
3490
3682
  }
3491
3683
  /**
3492
- * Create a new file with content.
3493
- */ async write(filePath, content) {
3684
+ * Create a new file with content.
3685
+ */ async write(filePath, content) {
3494
3686
  const command = buildWriteCommand(filePath, content);
3495
- const result = await this.execute(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3687
+ const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3496
3688
  if (result.exitCode !== 0) {
3497
3689
  const output = (result.output || '').trim();
3498
3690
  if (output.includes(WRITE_EXISTS_OUTPUT)) {
@@ -3514,7 +3706,7 @@ try {
3514
3706
  };
3515
3707
  }
3516
3708
  async writeViaUpload(filePath, content) {
3517
- const existsCheck = await this.execute(buildExistsCommand(filePath), DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3709
+ const existsCheck = await this.executeOperation(buildExistsCommand(filePath), DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3518
3710
  if (existsCheck.exitCode === 0) {
3519
3711
  return {
3520
3712
  error: `Cannot write to ${filePath} because it already exists. Read and then make an edit, or write to a new path.`
@@ -3543,10 +3735,10 @@ try {
3543
3735
  };
3544
3736
  }
3545
3737
  /**
3546
- * Append content to a file. Creates the file if it doesn't exist.
3547
- */ async append(filePath, content) {
3738
+ * Append content to a file. Creates the file if it doesn't exist.
3739
+ */ async append(filePath, content) {
3548
3740
  const command = buildAppendCommand(filePath, content);
3549
- const result = await this.execute(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3741
+ const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3550
3742
  if (result.exitCode !== 0) {
3551
3743
  const output = (result.output || '').trim();
3552
3744
  return {
@@ -3559,10 +3751,10 @@ try {
3559
3751
  };
3560
3752
  }
3561
3753
  /**
3562
- * Edit a file by replacing string occurrences.
3563
- */ async edit(filePath, oldString, newString, replaceAll = false) {
3754
+ * Edit a file by replacing string occurrences.
3755
+ */ async edit(filePath, oldString, newString, replaceAll = false) {
3564
3756
  const command = buildEditCommand(filePath, oldString, newString, replaceAll);
3565
- const result = await this.execute(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3757
+ const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
3566
3758
  switch(result.exitCode){
3567
3759
  case 0:
3568
3760
  {
@@ -3592,10 +3784,10 @@ try {
3592
3784
  }
3593
3785
  }
3594
3786
  /**
3595
- * Perform multiple sequential edits on a single file.
3596
- * All edits are applied sequentially, with each edit operating on the result of the previous edit.
3597
- * All edits must succeed for the operation to succeed (atomic).
3598
- */ async multiEdit(filePath, edits) {
3787
+ * Perform multiple sequential edits on a single file.
3788
+ * All edits are applied sequentially, with each edit operating on the result of the previous edit.
3789
+ * All edits must succeed for the operation to succeed (atomic).
3790
+ */ async multiEdit(filePath, edits) {
3599
3791
  if (!edits || edits.length === 0) {
3600
3792
  return {
3601
3793
  error: 'No edits provided'
@@ -3635,29 +3827,50 @@ exports.SandboxProviderRegistry = class SandboxProviderRegistry extends BaseStra
3635
3827
  };
3636
3828
  exports.SandboxProviderRegistry = __decorate([
3637
3829
  common.Injectable(),
3638
- __metadata("design:type", Function),
3639
3830
  __metadata("design:paramtypes", [
3640
- typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
3641
- typeof core.Reflector === "undefined" ? Object : core.Reflector
3831
+ core.DiscoveryService,
3832
+ core.Reflector
3642
3833
  ])
3643
3834
  ], exports.SandboxProviderRegistry);
3644
3835
 
3645
- Object.defineProperty(exports, "IColumnDef", {
3646
- enumerable: true,
3647
- get: function () { return contracts.IColumnDef; }
3648
- });
3649
- Object.defineProperty(exports, "IDSSchema", {
3650
- enumerable: true,
3651
- get: function () { return contracts.IDSSchema; }
3652
- });
3653
- Object.defineProperty(exports, "IDSTable", {
3654
- enumerable: true,
3655
- get: function () { return contracts.IDSTable; }
3656
- });
3657
- Object.defineProperty(exports, "TDocumentAsset", {
3658
- enumerable: true,
3659
- get: function () { return contracts.TDocumentAsset; }
3660
- });
3836
+ const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
3837
+ const ViewExtensionProvider = (providerKey)=>common.applyDecorators(common.SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), common.SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
3838
+
3839
+ exports.ViewExtensionProviderRegistry = class ViewExtensionProviderRegistry extends BaseStrategyRegistry {
3840
+ listEntries(organizationId) {
3841
+ var _this_strategies_get;
3842
+ const orgKey = this.resolveOrganization(organizationId);
3843
+ const entries = new Map();
3844
+ var _this_strategies_get_entries;
3845
+ 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 : []){
3846
+ entries.set(providerKey, provider);
3847
+ }
3848
+ if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
3849
+ var _this_strategies_get1;
3850
+ var _this_strategies_get_entries1;
3851
+ 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 : []){
3852
+ if (!entries.has(providerKey)) {
3853
+ entries.set(providerKey, provider);
3854
+ }
3855
+ }
3856
+ }
3857
+ return Array.from(entries.entries()).map(([providerKey, provider])=>({
3858
+ providerKey,
3859
+ provider
3860
+ }));
3861
+ }
3862
+ constructor(discoveryService, reflector){
3863
+ super(VIEW_EXTENSION_PROVIDER, discoveryService, reflector);
3864
+ }
3865
+ };
3866
+ exports.ViewExtensionProviderRegistry = __decorate([
3867
+ common.Injectable(),
3868
+ __metadata("design:paramtypes", [
3869
+ core.DiscoveryService,
3870
+ core.Reflector
3871
+ ])
3872
+ ], exports.ViewExtensionProviderRegistry);
3873
+
3661
3874
  exports.AGENT_CHAT_DISPATCH_MESSAGE_TYPE = AGENT_CHAT_DISPATCH_MESSAGE_TYPE;
3662
3875
  exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
3663
3876
  exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
@@ -3739,8 +3952,10 @@ exports.RerankModel = RerankModel;
3739
3952
  exports.RetrieverStrategy = RetrieverStrategy;
3740
3953
  exports.SANDBOX_PROVIDER = SANDBOX_PROVIDER;
3741
3954
  exports.SANDBOX_SHELL_TIMEOUT_LIMITS_SEC = SANDBOX_SHELL_TIMEOUT_LIMITS_SEC;
3955
+ exports.SKILL_SOURCE_PROVIDER = SKILL_SOURCE_PROVIDER;
3742
3956
  exports.STRATEGY_META_KEY = STRATEGY_META_KEY;
3743
3957
  exports.SandboxProviderStrategy = SandboxProviderStrategy;
3958
+ exports.SkillSourceProviderStrategy = SkillSourceProviderStrategy;
3744
3959
  exports.Speech2TextChatModel = Speech2TextChatModel;
3745
3960
  exports.SpeechToTextModel = SpeechToTextModel;
3746
3961
  exports.TEXT_SPLITTER_STRATEGY = TEXT_SPLITTER_STRATEGY;
@@ -3751,7 +3966,9 @@ exports.TextToSpeechModel = TextToSpeechModel;
3751
3966
  exports.ToolsetStrategy = ToolsetStrategy;
3752
3967
  exports.USER_PERMISSION_SERVICE_TOKEN = USER_PERMISSION_SERVICE_TOKEN;
3753
3968
  exports.VECTOR_STORE_STRATEGY = VECTOR_STORE_STRATEGY;
3969
+ exports.VIEW_EXTENSION_PROVIDER = VIEW_EXTENSION_PROVIDER;
3754
3970
  exports.VectorStoreStrategy = VectorStoreStrategy;
3971
+ exports.ViewExtensionProvider = ViewExtensionProvider;
3755
3972
  exports.WORKFLOW_NODE_STRATEGY = WORKFLOW_NODE_STRATEGY;
3756
3973
  exports.WORKFLOW_TRIGGER_STRATEGY = WORKFLOW_TRIGGER_STRATEGY;
3757
3974
  exports.WorkflowNodeStrategy = WorkflowNodeStrategy;
@@ -3785,6 +4002,7 @@ exports.loadYamlFile = loadYamlFile;
3785
4002
  exports.mergeCredentials = mergeCredentials;
3786
4003
  exports.mergeParentChildChunks = mergeParentChildChunks;
3787
4004
  exports.normalizeContextSize = normalizeContextSize;
4005
+ exports.resolveSandboxBackend = resolveSandboxBackend;
3788
4006
  exports.resolveSandboxExecutionOptions = resolveSandboxExecutionOptions;
3789
4007
  exports.runWithRequestContext = runWithRequestContext;
3790
4008
  exports.secondsToMilliseconds = secondsToMilliseconds;