@xpert-ai/plugin-sdk 3.7.1 → 3.8.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 (41) hide show
  1. package/index.cjs.js +851 -834
  2. package/index.esm.js +826 -837
  3. package/package.json +5 -1
  4. package/src/index.d.ts +2 -0
  5. package/src/lib/agent/handoff/agent-chat.contract.d.ts +20 -0
  6. package/src/lib/agent/handoff/handoff-processor.decorator.d.ts +11 -0
  7. package/src/lib/agent/handoff/handoff-processor.registry.d.ts +6 -0
  8. package/src/lib/agent/handoff/handoff.interface.d.ts +17 -0
  9. package/src/lib/agent/handoff/index.d.ts +6 -0
  10. package/src/lib/agent/handoff/message-type.d.ts +24 -0
  11. package/src/lib/agent/handoff/types.d.ts +110 -0
  12. package/src/lib/agent/index.d.ts +1 -0
  13. package/src/lib/agent/middleware/runtime.d.ts +2 -0
  14. package/src/lib/agent/middleware/strategy.interface.d.ts +5 -1
  15. package/src/lib/agent/middleware/types.d.ts +73 -8
  16. package/src/lib/ai-model/ai-model.d.ts +3 -1
  17. package/src/lib/ai-model/utils/index.d.ts +1 -0
  18. package/src/lib/ai-model/utils/limits.d.ts +4 -0
  19. package/src/lib/channel/cancel-conversation.command.d.ts +14 -0
  20. package/src/lib/channel/index.d.ts +4 -0
  21. package/src/lib/channel/strategy.decorator.d.ts +23 -0
  22. package/src/lib/channel/strategy.interface.d.ts +345 -0
  23. package/src/lib/channel/strategy.registry.d.ts +30 -0
  24. package/src/lib/core/permissions/analytics.d.ts +46 -0
  25. package/src/lib/core/{permissions.d.ts → permissions/general.d.ts} +9 -12
  26. package/src/lib/core/permissions/handoff.d.ts +36 -0
  27. package/src/lib/core/permissions/index.d.ts +24 -0
  28. package/src/lib/core/permissions/operation.d.ts +8 -0
  29. package/src/lib/core/permissions/user.d.ts +29 -0
  30. package/src/lib/core/utils.d.ts +6 -0
  31. package/src/lib/integration/strategy.interface.d.ts +3 -1
  32. package/src/lib/sandbox/index.d.ts +8 -0
  33. package/src/lib/sandbox/protocol.d.ts +265 -0
  34. package/src/lib/sandbox/sandbox.d.ts +70 -0
  35. package/src/lib/sandbox/sandbox.decorator.d.ts +2 -0
  36. package/src/lib/sandbox/sandbox.interface.d.ts +38 -0
  37. package/src/lib/sandbox/sandbox.registry.d.ts +6 -0
  38. package/src/lib/toolset/strategy.interface.d.ts +2 -6
  39. package/src/lib/types.d.ts +7 -1
  40. package/src/lib/workflow/node/strategy.interface.d.ts +4 -2
  41. package/src/lib/workflow/trigger/strategy.interface.d.ts +13 -0
package/index.cjs.js CHANGED
@@ -4,6 +4,7 @@ var common = require('@nestjs/common');
4
4
  var constants = require('@nestjs/common/constants');
5
5
  var lodashEs = require('lodash-es');
6
6
  var core = require('@nestjs/core');
7
+ var rxjs = require('rxjs');
7
8
  var contracts = require('@metad/contracts');
8
9
  var node_async_hooks = require('node:async_hooks');
9
10
  var passportJwt = require('passport-jwt');
@@ -20,6 +21,8 @@ var path = require('path');
20
21
  var i18next = require('i18next');
21
22
  var FsBackend = require('i18next-fs-backend');
22
23
  var yaml = require('yaml');
24
+ var Ajv = require('ajv');
25
+ var schemaDraft04 = require('ajv/dist/refs/json-schema-draft-06.json');
23
26
  var _axios = require('axios');
24
27
  var openai = require('@langchain/openai');
25
28
  var documents = require('@langchain/core/documents');
@@ -27,6 +30,7 @@ var chat_models = require('@langchain/core/language_models/chat_models');
27
30
  var messages = require('@langchain/core/messages');
28
31
  var env = require('@langchain/core/utils/env');
29
32
  require('js-tiktoken');
33
+ var base = require('@langchain/core/language_models/base');
30
34
 
31
35
  function _interopNamespaceDefault(e) {
32
36
  var n = Object.create(null);
@@ -122,44 +126,6 @@ function createPluginLogger(scope, baseMeta = {}) {
122
126
  const INTEGRATION_STRATEGY = 'INTEGRATION_STRATEGY';
123
127
  const IntegrationStrategyKey = (provider)=>common.applyDecorators(common.SetMetadata(INTEGRATION_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, INTEGRATION_STRATEGY));
124
128
 
125
- /******************************************************************************
126
- Copyright (c) Microsoft Corporation.
127
-
128
- Permission to use, copy, modify, and/or distribute this software for any
129
- purpose with or without fee is hereby granted.
130
-
131
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
132
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
133
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
134
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
135
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
136
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
137
- PERFORMANCE OF THIS SOFTWARE.
138
- ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ function _instanceof$2(left, right) {
139
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
140
- return !!right[Symbol.hasInstance](left);
141
- } else {
142
- return left instanceof right;
143
- }
144
- }
145
- var extendStatics = function extendStatics1(d, b) {
146
- extendStatics = Object.setPrototypeOf || _instanceof$2({
147
- __proto__: []
148
- }, Array) && function(d, b) {
149
- d.__proto__ = b;
150
- } || function(d, b) {
151
- for(var p in b)if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
152
- };
153
- return extendStatics(d, b);
154
- };
155
- function __extends(d, b) {
156
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
157
- extendStatics(d, b);
158
- function __() {
159
- this.constructor = d;
160
- }
161
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
162
- }
163
129
  function __decorate(decorators, target, key, desc) {
164
130
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
165
131
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -169,763 +135,11 @@ function __decorate(decorators, target, key, desc) {
169
135
  function __metadata(metadataKey, metadataValue) {
170
136
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
171
137
  }
172
- function __values(o) {
173
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
174
- if (m) return m.call(o);
175
- if (o && typeof o.length === "number") return {
176
- next: function next() {
177
- if (o && i >= o.length) o = void 0;
178
- return {
179
- value: o && o[i++],
180
- done: !o
181
- };
182
- }
183
- };
184
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
185
- }
186
- function __read(o, n) {
187
- var m = typeof Symbol === "function" && o[Symbol.iterator];
188
- if (!m) return o;
189
- var i = m.call(o), r, ar = [], e;
190
- try {
191
- while((n === void 0 || n-- > 0) && !(r = i.next()).done)ar.push(r.value);
192
- } catch (error) {
193
- e = {
194
- error: error
195
- };
196
- } finally{
197
- try {
198
- if (r && !r.done && (m = i["return"])) m.call(i);
199
- } finally{
200
- if (e) throw e.error;
201
- }
202
- }
203
- return ar;
204
- }
205
- function __spreadArray(to, from, pack) {
206
- if (pack || arguments.length === 2) for(var i = 0, l = from.length, ar; i < l; i++){
207
- if (ar || !(i in from)) {
208
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
209
- ar[i] = from[i];
210
- }
211
- }
212
- return to.concat(ar || Array.prototype.slice.call(from));
213
- }
214
138
  typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
215
139
  var e = new Error(message);
216
140
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
217
141
  };
218
142
 
219
- function isFunction(value) {
220
- return typeof value === "function";
221
- }
222
-
223
- function createErrorClass(createImpl) {
224
- var _super = function _super(instance) {
225
- Error.call(instance);
226
- instance.stack = new Error().stack;
227
- };
228
- var ctorFunc = createImpl(_super);
229
- ctorFunc.prototype = Object.create(Error.prototype);
230
- ctorFunc.prototype.constructor = ctorFunc;
231
- return ctorFunc;
232
- }
233
-
234
- var UnsubscriptionError = createErrorClass(function(_super) {
235
- return function UnsubscriptionErrorImpl(errors) {
236
- _super(this);
237
- this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i) {
238
- return i + 1 + ") " + err.toString();
239
- }).join("\n ") : "";
240
- this.name = "UnsubscriptionError";
241
- this.errors = errors;
242
- };
243
- });
244
-
245
- function arrRemove(arr, item) {
246
- if (arr) {
247
- var index = arr.indexOf(item);
248
- 0 <= index && arr.splice(index, 1);
249
- }
250
- }
251
-
252
- function _instanceof$1(left, right) {
253
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
254
- return !!right[Symbol.hasInstance](left);
255
- } else {
256
- return left instanceof right;
257
- }
258
- }
259
- var Subscription = function() {
260
- function Subscription(initialTeardown) {
261
- this.initialTeardown = initialTeardown;
262
- this.closed = false;
263
- this._parentage = null;
264
- this._finalizers = null;
265
- }
266
- Subscription.prototype.unsubscribe = function() {
267
- var e_1, _a, e_2, _b;
268
- var errors;
269
- if (!this.closed) {
270
- this.closed = true;
271
- var _parentage = this._parentage;
272
- if (_parentage) {
273
- this._parentage = null;
274
- if (Array.isArray(_parentage)) {
275
- try {
276
- for(var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()){
277
- var parent_1 = _parentage_1_1.value;
278
- parent_1.remove(this);
279
- }
280
- } catch (e_1_1) {
281
- e_1 = {
282
- error: e_1_1
283
- };
284
- } finally{
285
- try {
286
- if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
287
- } finally{
288
- if (e_1) throw e_1.error;
289
- }
290
- }
291
- } else {
292
- _parentage.remove(this);
293
- }
294
- }
295
- var initialFinalizer = this.initialTeardown;
296
- if (isFunction(initialFinalizer)) {
297
- try {
298
- initialFinalizer();
299
- } catch (e) {
300
- errors = _instanceof$1(e, UnsubscriptionError) ? e.errors : [
301
- e
302
- ];
303
- }
304
- }
305
- var _finalizers = this._finalizers;
306
- if (_finalizers) {
307
- this._finalizers = null;
308
- try {
309
- for(var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()){
310
- var finalizer = _finalizers_1_1.value;
311
- try {
312
- execFinalizer(finalizer);
313
- } catch (err) {
314
- errors = errors !== null && errors !== void 0 ? errors : [];
315
- if (_instanceof$1(err, UnsubscriptionError)) {
316
- errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
317
- } else {
318
- errors.push(err);
319
- }
320
- }
321
- }
322
- } catch (e_2_1) {
323
- e_2 = {
324
- error: e_2_1
325
- };
326
- } finally{
327
- try {
328
- if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
329
- } finally{
330
- if (e_2) throw e_2.error;
331
- }
332
- }
333
- }
334
- if (errors) {
335
- throw new UnsubscriptionError(errors);
336
- }
337
- }
338
- };
339
- Subscription.prototype.add = function(teardown) {
340
- var _a;
341
- if (teardown && teardown !== this) {
342
- if (this.closed) {
343
- execFinalizer(teardown);
344
- } else {
345
- if (_instanceof$1(teardown, Subscription)) {
346
- if (teardown.closed || teardown._hasParent(this)) {
347
- return;
348
- }
349
- teardown._addParent(this);
350
- }
351
- (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
352
- }
353
- }
354
- };
355
- Subscription.prototype._hasParent = function(parent) {
356
- var _parentage = this._parentage;
357
- return _parentage === parent || Array.isArray(_parentage) && _parentage.includes(parent);
358
- };
359
- Subscription.prototype._addParent = function(parent) {
360
- var _parentage = this._parentage;
361
- this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [
362
- _parentage,
363
- parent
364
- ] : parent;
365
- };
366
- Subscription.prototype._removeParent = function(parent) {
367
- var _parentage = this._parentage;
368
- if (_parentage === parent) {
369
- this._parentage = null;
370
- } else if (Array.isArray(_parentage)) {
371
- arrRemove(_parentage, parent);
372
- }
373
- };
374
- Subscription.prototype.remove = function(teardown) {
375
- var _finalizers = this._finalizers;
376
- _finalizers && arrRemove(_finalizers, teardown);
377
- if (_instanceof$1(teardown, Subscription)) {
378
- teardown._removeParent(this);
379
- }
380
- };
381
- Subscription.EMPTY = function() {
382
- var empty = new Subscription();
383
- empty.closed = true;
384
- return empty;
385
- }();
386
- return Subscription;
387
- }();
388
- var EMPTY_SUBSCRIPTION = Subscription.EMPTY;
389
- function isSubscription(value) {
390
- return _instanceof$1(value, Subscription) || value && "closed" in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe);
391
- }
392
- function execFinalizer(finalizer) {
393
- if (isFunction(finalizer)) {
394
- finalizer();
395
- } else {
396
- finalizer.unsubscribe();
397
- }
398
- }
399
-
400
- var config = {
401
- Promise: undefined};
402
-
403
- var timeoutProvider = {
404
- setTimeout: function setTimeout1(handler, timeout) {
405
- var args = [];
406
- for(var _i = 2; _i < arguments.length; _i++){
407
- args[_i - 2] = arguments[_i];
408
- }
409
- return setTimeout.apply(void 0, __spreadArray([
410
- handler,
411
- timeout
412
- ], __read(args)));
413
- },
414
- clearTimeout: function clearTimeout1(handle) {
415
- return (clearTimeout)(handle);
416
- },
417
- delegate: undefined
418
- };
419
-
420
- function reportUnhandledError(err) {
421
- timeoutProvider.setTimeout(function() {
422
- {
423
- throw err;
424
- }
425
- });
426
- }
427
-
428
- function noop() {}
429
-
430
- function errorContext(cb) {
431
- {
432
- cb();
433
- }
434
- }
435
-
436
- var Subscriber = function(_super) {
437
- __extends(Subscriber, _super);
438
- function Subscriber(destination) {
439
- var _this = _super.call(this) || this;
440
- _this.isStopped = false;
441
- if (destination) {
442
- _this.destination = destination;
443
- if (isSubscription(destination)) {
444
- destination.add(_this);
445
- }
446
- } else {
447
- _this.destination = EMPTY_OBSERVER;
448
- }
449
- return _this;
450
- }
451
- Subscriber.create = function(next, error, complete) {
452
- return new SafeSubscriber(next, error, complete);
453
- };
454
- Subscriber.prototype.next = function(value) {
455
- if (this.isStopped) ; else {
456
- this._next(value);
457
- }
458
- };
459
- Subscriber.prototype.error = function(err) {
460
- if (this.isStopped) ; else {
461
- this.isStopped = true;
462
- this._error(err);
463
- }
464
- };
465
- Subscriber.prototype.complete = function() {
466
- if (this.isStopped) ; else {
467
- this.isStopped = true;
468
- this._complete();
469
- }
470
- };
471
- Subscriber.prototype.unsubscribe = function() {
472
- if (!this.closed) {
473
- this.isStopped = true;
474
- _super.prototype.unsubscribe.call(this);
475
- this.destination = null;
476
- }
477
- };
478
- Subscriber.prototype._next = function(value) {
479
- this.destination.next(value);
480
- };
481
- Subscriber.prototype._error = function(err) {
482
- try {
483
- this.destination.error(err);
484
- } finally{
485
- this.unsubscribe();
486
- }
487
- };
488
- Subscriber.prototype._complete = function() {
489
- try {
490
- this.destination.complete();
491
- } finally{
492
- this.unsubscribe();
493
- }
494
- };
495
- return Subscriber;
496
- }(Subscription);
497
- var ConsumerObserver = function() {
498
- function ConsumerObserver(partialObserver) {
499
- this.partialObserver = partialObserver;
500
- }
501
- ConsumerObserver.prototype.next = function(value) {
502
- var partialObserver = this.partialObserver;
503
- if (partialObserver.next) {
504
- try {
505
- partialObserver.next(value);
506
- } catch (error) {
507
- handleUnhandledError(error);
508
- }
509
- }
510
- };
511
- ConsumerObserver.prototype.error = function(err) {
512
- var partialObserver = this.partialObserver;
513
- if (partialObserver.error) {
514
- try {
515
- partialObserver.error(err);
516
- } catch (error) {
517
- handleUnhandledError(error);
518
- }
519
- } else {
520
- handleUnhandledError(err);
521
- }
522
- };
523
- ConsumerObserver.prototype.complete = function() {
524
- var partialObserver = this.partialObserver;
525
- if (partialObserver.complete) {
526
- try {
527
- partialObserver.complete();
528
- } catch (error) {
529
- handleUnhandledError(error);
530
- }
531
- }
532
- };
533
- return ConsumerObserver;
534
- }();
535
- var SafeSubscriber = function(_super) {
536
- __extends(SafeSubscriber, _super);
537
- function SafeSubscriber(observerOrNext, error, complete) {
538
- var _this = _super.call(this) || this;
539
- var partialObserver;
540
- if (isFunction(observerOrNext) || !observerOrNext) {
541
- partialObserver = {
542
- next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined,
543
- error: error !== null && error !== void 0 ? error : undefined,
544
- complete: complete !== null && complete !== void 0 ? complete : undefined
545
- };
546
- } else {
547
- {
548
- partialObserver = observerOrNext;
549
- }
550
- }
551
- _this.destination = new ConsumerObserver(partialObserver);
552
- return _this;
553
- }
554
- return SafeSubscriber;
555
- }(Subscriber);
556
- function handleUnhandledError(error) {
557
- {
558
- reportUnhandledError(error);
559
- }
560
- }
561
- function defaultErrorHandler(err) {
562
- throw err;
563
- }
564
- var EMPTY_OBSERVER = {
565
- closed: true,
566
- next: noop,
567
- error: defaultErrorHandler,
568
- complete: noop
569
- };
570
-
571
- var observable = function() {
572
- return typeof Symbol === "function" && Symbol.observable || "@@observable";
573
- }();
574
-
575
- function identity(x) {
576
- return x;
577
- }
578
-
579
- function pipeFromArray(fns) {
580
- if (fns.length === 0) {
581
- return identity;
582
- }
583
- if (fns.length === 1) {
584
- return fns[0];
585
- }
586
- return function piped(input) {
587
- return fns.reduce(function(prev, fn) {
588
- return fn(prev);
589
- }, input);
590
- };
591
- }
592
-
593
- function _instanceof(left, right) {
594
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
595
- return !!right[Symbol.hasInstance](left);
596
- } else {
597
- return left instanceof right;
598
- }
599
- }
600
- var Observable = function() {
601
- function Observable(subscribe) {
602
- if (subscribe) {
603
- this._subscribe = subscribe;
604
- }
605
- }
606
- Observable.prototype.lift = function(operator) {
607
- var observable = new Observable();
608
- observable.source = this;
609
- observable.operator = operator;
610
- return observable;
611
- };
612
- Observable.prototype.subscribe = function(observerOrNext, error, complete) {
613
- var _this = this;
614
- var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
615
- errorContext(function() {
616
- var _a = _this, operator = _a.operator, source = _a.source;
617
- subscriber.add(operator ? operator.call(subscriber, source) : source ? _this._subscribe(subscriber) : _this._trySubscribe(subscriber));
618
- });
619
- return subscriber;
620
- };
621
- Observable.prototype._trySubscribe = function(sink) {
622
- try {
623
- return this._subscribe(sink);
624
- } catch (err) {
625
- sink.error(err);
626
- }
627
- };
628
- Observable.prototype.forEach = function(next, promiseCtor) {
629
- var _this = this;
630
- promiseCtor = getPromiseCtor(promiseCtor);
631
- return new promiseCtor(function(resolve, reject) {
632
- var subscriber = new SafeSubscriber({
633
- next: function next1(value) {
634
- try {
635
- next(value);
636
- } catch (err) {
637
- reject(err);
638
- subscriber.unsubscribe();
639
- }
640
- },
641
- error: reject,
642
- complete: resolve
643
- });
644
- _this.subscribe(subscriber);
645
- });
646
- };
647
- Observable.prototype._subscribe = function(subscriber) {
648
- var _a;
649
- return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
650
- };
651
- Observable.prototype[observable] = function() {
652
- return this;
653
- };
654
- Observable.prototype.pipe = function() {
655
- var operations = [];
656
- for(var _i = 0; _i < arguments.length; _i++){
657
- operations[_i] = arguments[_i];
658
- }
659
- return pipeFromArray(operations)(this);
660
- };
661
- Observable.prototype.toPromise = function(promiseCtor) {
662
- var _this = this;
663
- promiseCtor = getPromiseCtor(promiseCtor);
664
- return new promiseCtor(function(resolve, reject) {
665
- var value;
666
- _this.subscribe(function(x) {
667
- return value = x;
668
- }, function(err) {
669
- return reject(err);
670
- }, function() {
671
- return resolve(value);
672
- });
673
- });
674
- };
675
- Observable.create = function(subscribe) {
676
- return new Observable(subscribe);
677
- };
678
- return Observable;
679
- }();
680
- function getPromiseCtor(promiseCtor) {
681
- var _a;
682
- return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
683
- }
684
- function isObserver(value) {
685
- return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
686
- }
687
- function isSubscriber(value) {
688
- return value && _instanceof(value, Subscriber) || isObserver(value) && isSubscription(value);
689
- }
690
-
691
- function hasLift(source) {
692
- return isFunction(source === null || source === void 0 ? void 0 : source.lift);
693
- }
694
- function operate(init) {
695
- return function(source) {
696
- if (hasLift(source)) {
697
- return source.lift(function(liftedSource) {
698
- try {
699
- return init(liftedSource, this);
700
- } catch (err) {
701
- this.error(err);
702
- }
703
- });
704
- }
705
- throw new TypeError("Unable to lift unknown Observable type");
706
- };
707
- }
708
-
709
- function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
710
- return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
711
- }
712
- var OperatorSubscriber = function(_super) {
713
- __extends(OperatorSubscriber, _super);
714
- function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
715
- var _this = _super.call(this, destination) || this;
716
- _this.onFinalize = onFinalize;
717
- _this.shouldUnsubscribe = shouldUnsubscribe;
718
- _this._next = onNext ? function(value) {
719
- try {
720
- onNext(value);
721
- } catch (err) {
722
- destination.error(err);
723
- }
724
- } : _super.prototype._next;
725
- _this._error = onError ? function(err) {
726
- try {
727
- onError(err);
728
- } catch (err) {
729
- destination.error(err);
730
- } finally{
731
- this.unsubscribe();
732
- }
733
- } : _super.prototype._error;
734
- _this._complete = onComplete ? function() {
735
- try {
736
- onComplete();
737
- } catch (err) {
738
- destination.error(err);
739
- } finally{
740
- this.unsubscribe();
741
- }
742
- } : _super.prototype._complete;
743
- return _this;
744
- }
745
- OperatorSubscriber.prototype.unsubscribe = function() {
746
- var _a;
747
- if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
748
- var closed_1 = this.closed;
749
- _super.prototype.unsubscribe.call(this);
750
- !closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
751
- }
752
- };
753
- return OperatorSubscriber;
754
- }(Subscriber);
755
-
756
- var ObjectUnsubscribedError = createErrorClass(function(_super) {
757
- return function ObjectUnsubscribedErrorImpl() {
758
- _super(this);
759
- this.name = "ObjectUnsubscribedError";
760
- this.message = "object unsubscribed";
761
- };
762
- });
763
-
764
- var Subject = function(_super) {
765
- __extends(Subject, _super);
766
- function Subject() {
767
- var _this = _super.call(this) || this;
768
- _this.closed = false;
769
- _this.currentObservers = null;
770
- _this.observers = [];
771
- _this.isStopped = false;
772
- _this.hasError = false;
773
- _this.thrownError = null;
774
- return _this;
775
- }
776
- Subject.prototype.lift = function(operator) {
777
- var subject = new AnonymousSubject(this, this);
778
- subject.operator = operator;
779
- return subject;
780
- };
781
- Subject.prototype._throwIfClosed = function() {
782
- if (this.closed) {
783
- throw new ObjectUnsubscribedError();
784
- }
785
- };
786
- Subject.prototype.next = function(value) {
787
- var _this = this;
788
- errorContext(function() {
789
- var e_1, _a;
790
- _this._throwIfClosed();
791
- if (!_this.isStopped) {
792
- if (!_this.currentObservers) {
793
- _this.currentObservers = Array.from(_this.observers);
794
- }
795
- try {
796
- for(var _b = __values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()){
797
- var observer = _c.value;
798
- observer.next(value);
799
- }
800
- } catch (e_1_1) {
801
- e_1 = {
802
- error: e_1_1
803
- };
804
- } finally{
805
- try {
806
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
807
- } finally{
808
- if (e_1) throw e_1.error;
809
- }
810
- }
811
- }
812
- });
813
- };
814
- Subject.prototype.error = function(err) {
815
- var _this = this;
816
- errorContext(function() {
817
- _this._throwIfClosed();
818
- if (!_this.isStopped) {
819
- _this.hasError = _this.isStopped = true;
820
- _this.thrownError = err;
821
- var observers = _this.observers;
822
- while(observers.length){
823
- observers.shift().error(err);
824
- }
825
- }
826
- });
827
- };
828
- Subject.prototype.complete = function() {
829
- var _this = this;
830
- errorContext(function() {
831
- _this._throwIfClosed();
832
- if (!_this.isStopped) {
833
- _this.isStopped = true;
834
- var observers = _this.observers;
835
- while(observers.length){
836
- observers.shift().complete();
837
- }
838
- }
839
- });
840
- };
841
- Subject.prototype.unsubscribe = function() {
842
- this.isStopped = this.closed = true;
843
- this.observers = this.currentObservers = null;
844
- };
845
- Object.defineProperty(Subject.prototype, "observed", {
846
- get: function get() {
847
- var _a;
848
- return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
849
- },
850
- enumerable: false,
851
- configurable: true
852
- });
853
- Subject.prototype._trySubscribe = function(subscriber) {
854
- this._throwIfClosed();
855
- return _super.prototype._trySubscribe.call(this, subscriber);
856
- };
857
- Subject.prototype._subscribe = function(subscriber) {
858
- this._throwIfClosed();
859
- this._checkFinalizedStatuses(subscriber);
860
- return this._innerSubscribe(subscriber);
861
- };
862
- Subject.prototype._innerSubscribe = function(subscriber) {
863
- var _this = this;
864
- var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
865
- if (hasError || isStopped) {
866
- return EMPTY_SUBSCRIPTION;
867
- }
868
- this.currentObservers = null;
869
- observers.push(subscriber);
870
- return new Subscription(function() {
871
- _this.currentObservers = null;
872
- arrRemove(observers, subscriber);
873
- });
874
- };
875
- Subject.prototype._checkFinalizedStatuses = function(subscriber) {
876
- var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
877
- if (hasError) {
878
- subscriber.error(thrownError);
879
- } else if (isStopped) {
880
- subscriber.complete();
881
- }
882
- };
883
- Subject.prototype.asObservable = function() {
884
- var observable = new Observable();
885
- observable.source = this;
886
- return observable;
887
- };
888
- Subject.create = function(destination, source) {
889
- return new AnonymousSubject(destination, source);
890
- };
891
- return Subject;
892
- }(Observable);
893
- var AnonymousSubject = function(_super) {
894
- __extends(AnonymousSubject, _super);
895
- function AnonymousSubject(destination, source) {
896
- var _this = _super.call(this) || this;
897
- _this.destination = destination;
898
- _this.source = source;
899
- return _this;
900
- }
901
- AnonymousSubject.prototype.next = function(value) {
902
- var _a, _b;
903
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
904
- };
905
- AnonymousSubject.prototype.error = function(err) {
906
- var _a, _b;
907
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
908
- };
909
- AnonymousSubject.prototype.complete = function() {
910
- var _a, _b;
911
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
912
- };
913
- AnonymousSubject.prototype._subscribe = function(subscriber) {
914
- var _a, _b;
915
- return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
916
- };
917
- return AnonymousSubject;
918
- }(Subject);
919
-
920
- function filter(predicate, thisArg) {
921
- return operate(function(source, subscriber) {
922
- var index = 0;
923
- source.subscribe(createOperatorSubscriber(subscriber, function(value) {
924
- return predicate.call(thisArg, value, index++) && subscriber.next(value);
925
- }));
926
- });
927
- }
928
-
929
143
  // request-context.ts
930
144
  class RequestContext {
931
145
  static currentRequestContext() {
@@ -1158,7 +372,7 @@ exports.StrategyBus = class StrategyBus {
1158
372
  });
1159
373
  }
1160
374
  constructor(){
1161
- this.subject = new Subject();
375
+ this.subject = new rxjs.Subject();
1162
376
  this.events$ = this.subject.asObservable();
1163
377
  }
1164
378
  };
@@ -1168,8 +382,7 @@ exports.StrategyBus = __decorate([
1168
382
 
1169
383
  class BaseStrategyRegistry {
1170
384
  onModuleInit() {
1171
- this.bus.events$.pipe(filter((event)=>!event.strategyType || event.strategyType === this.strategyKey)).subscribe((evt)=>{
1172
- this.logger.debug(`Received strategy bus event: ${JSON.stringify(evt)}`);
385
+ this.bus.events$.pipe(rxjs.filter((event)=>!event.strategyType || event.strategyType === this.strategyKey)).subscribe((evt)=>{
1173
386
  if (evt.type === 'UPSERT') {
1174
387
  this.upsert(evt.entry.instance);
1175
388
  } else if (evt.type === 'REMOVE') {
@@ -1739,6 +952,52 @@ BuiltinToolset.provider = '';
1739
952
  }
1740
953
  }
1741
954
 
955
+ /**
956
+ * System token for resolving integration read service from plugin context.
957
+ */ const INTEGRATION_PERMISSION_SERVICE_TOKEN = 'XPERT_PLUGIN_INTEGRATION_PERMISSION_SERVICE';
958
+
959
+ /**
960
+ * System token for resolving analytics permission service from plugin context.
961
+ */ const ANALYTICS_PERMISSION_SERVICE_TOKEN = 'XPERT_PLUGIN_ANALYTICS_PERMISSION_SERVICE';
962
+
963
+ const PERMISSION_OPERATION_METADATA_KEY = 'XPERT_PLUGIN_PERMISSION_OPERATION';
964
+ function RequirePermissionOperation(permissionType, operation) {
965
+ return (_target, _propertyKey, descriptor)=>{
966
+ const method = descriptor.value;
967
+ if (typeof method !== 'function') {
968
+ throw new Error('RequirePermissionOperation can only be applied to methods');
969
+ }
970
+ Reflect.defineMetadata(PERMISSION_OPERATION_METADATA_KEY, {
971
+ permissionType,
972
+ operation
973
+ }, method);
974
+ };
975
+ }
976
+ function getPermissionOperationMetadata(method) {
977
+ if (typeof method !== 'function') {
978
+ return undefined;
979
+ }
980
+ return Reflect.getMetadata(PERMISSION_OPERATION_METADATA_KEY, method);
981
+ }
982
+ function getRequiredPermissionOperation(method, permissionType) {
983
+ const metadata = getPermissionOperationMetadata(method);
984
+ if (!metadata || metadata.permissionType !== permissionType) {
985
+ return undefined;
986
+ }
987
+ return metadata.operation;
988
+ }
989
+
990
+ /**
991
+ * System token for resolving handoff queue service from plugin context.
992
+ */ const HANDOFF_PERMISSION_SERVICE_TOKEN = 'XPERT_PLUGIN_HANDOFF_PERMISSION_SERVICE';
993
+ /**
994
+ * Internal system token used by core to expose the handoff queue bridge.
995
+ */ const HANDOFF_QUEUE_SERVICE_TOKEN = 'XPERT_HANDOFF_QUEUE_SERVICE';
996
+
997
+ /**
998
+ * System token for resolving user permission service from plugin context.
999
+ */ const USER_PERMISSION_SERVICE_TOKEN = 'XPERT_PLUGIN_USER_PERMISSION_SERVICE';
1000
+
1742
1001
  async function createI18nInstance(pluginDir, language) {
1743
1002
  const instance = i18next.createInstance();
1744
1003
  const i18nDir = path.join(pluginDir, 'i18n');
@@ -1818,6 +1077,28 @@ function getErrorMessage(err) {
1818
1077
  }
1819
1078
  return error;
1820
1079
  }
1080
+ class JsonSchemaValidator {
1081
+ parseAndValidate(schemaStr) {
1082
+ if (!schemaStr) return undefined;
1083
+ let schema;
1084
+ try {
1085
+ schema = JSON.parse(schemaStr);
1086
+ } catch (e) {
1087
+ throw new Error('Schema is not valid JSON');
1088
+ }
1089
+ const validate = this.ajv.getSchema(schemaDraft04.$id);
1090
+ if (!validate(schema)) {
1091
+ throw new Error('Invalid JSON Schema: ' + this.ajv.errorsText(validate.errors));
1092
+ }
1093
+ return schema;
1094
+ }
1095
+ constructor(){
1096
+ this.ajv = new Ajv({
1097
+ strict: false
1098
+ });
1099
+ this.ajv.addMetaSchema(schemaDraft04);
1100
+ }
1101
+ }
1821
1102
 
1822
1103
  const DATASOURCE_STRATEGY = 'DATASOURCE_STRATEGY';
1823
1104
  const DataSourceStrategy = (provider)=>common.applyDecorators(common.SetMetadata(DATASOURCE_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, DATASOURCE_STRATEGY));
@@ -2131,6 +1412,18 @@ function AIModelProviderStrategy(provider) {
2131
1412
  if (file == null ? void 0 : file.startsWith('file:///')) {
2132
1413
  file = file.replace('file://', '');
2133
1414
  }
1415
+ // Strip :line:col suffix (e.g. "/path/file.js:37:5" -> "/path/file.js")
1416
+ if (file) {
1417
+ file = file.replace(/:\d+:\d+$/, '');
1418
+ }
1419
+ // Decode URL-encoded paths (e.g. Chinese characters: %E9%A1%B9%E7%9B%AE -> 项目)
1420
+ if (file) {
1421
+ try {
1422
+ file = decodeURIComponent(file);
1423
+ } catch (e) {
1424
+ // keep as-is if decode fails
1425
+ }
1426
+ }
2134
1427
  const dir = file ? path.dirname(file) : process.cwd();
2135
1428
  return function(target) {
2136
1429
  common.SetMetadata(STRATEGY_META_KEY, AI_MODEL_PROVIDER)(target);
@@ -2425,6 +1718,46 @@ const PARAMETER_RULE_TEMPLATE = {
2425
1718
  }
2426
1719
  };
2427
1720
 
1721
+ const CommonParameterRules = [
1722
+ {
1723
+ name: 'temperature',
1724
+ label: {
1725
+ zh_Hans: '温度',
1726
+ en_US: `Temperature`
1727
+ },
1728
+ type: contracts.ParameterType.FLOAT,
1729
+ help: {
1730
+ zh_Hans: '控制模型输出的随机性。较高的值(例如 1.0)使响应更具创意,而较低的值(例如 0.1)使响应更具确定性和重点性。',
1731
+ en_US: `Controls the randomness of the model's output. A higher value (e.g., 1.0) makes responses more creative, while a lower value (e.g., 0.1) makes them more deterministic and focused.`
1732
+ },
1733
+ required: false,
1734
+ default: 0.2,
1735
+ min: 0,
1736
+ max: 1,
1737
+ precision: 0.1
1738
+ },
1739
+ {
1740
+ label: {
1741
+ zh_Hans: '最大尝试次数',
1742
+ en_US: 'The maximum number of attempts'
1743
+ },
1744
+ type: contracts.ParameterType.INT,
1745
+ help: {
1746
+ zh_Hans: '如果请求由于网络超时或速率限制等问题而失败,系统将尝试重新发送请求的最大次数',
1747
+ en_US: 'The maximum number of attempts the system will make to resend a request if it fails due to issues like network timeouts or rate limits'
1748
+ },
1749
+ required: false,
1750
+ default: 6,
1751
+ min: 0,
1752
+ max: 10,
1753
+ precision: 0,
1754
+ name: 'maxRetries'
1755
+ }
1756
+ ];
1757
+ function mergeCredentials(credentials, modelProperties) {
1758
+ return _extends({}, credentials != null ? credentials : {}, modelProperties != null ? modelProperties : {});
1759
+ }
1760
+
2428
1761
  let AIModel = class AIModel {
2429
1762
  getChatModel(copilotModel, options) {
2430
1763
  throw new Error(`Unsupport chat model!`);
@@ -2568,6 +1901,15 @@ let AIModel = class AIModel {
2568
1901
  ...parameterRules.filter((_)=>!CommonParameterRules.some((r)=>r.name === _.name))
2569
1902
  ];
2570
1903
  }
1904
+ getModelProfile(model, credentials) {
1905
+ var _modelSchema_model_properties, _modelSchema_features, _modelSchema_features1, _modelSchema_features2, _modelSchema_features3;
1906
+ const modelSchema = this.getModelSchema(model, credentials);
1907
+ return modelSchema && {
1908
+ maxInputTokens: (_modelSchema_model_properties = modelSchema.model_properties) == null ? void 0 : _modelSchema_model_properties.context_size,
1909
+ toolCalling: ((_modelSchema_features = modelSchema.features) == null ? void 0 : _modelSchema_features.includes(contracts.ModelFeature.TOOL_CALL)) || ((_modelSchema_features1 = modelSchema.features) == null ? void 0 : _modelSchema_features1.includes(contracts.ModelFeature.MULTI_TOOL_CALL)) || ((_modelSchema_features2 = modelSchema.features) == null ? void 0 : _modelSchema_features2.includes(contracts.ModelFeature.STREAM_TOOL_CALL)),
1910
+ structuredOutput: (_modelSchema_features3 = modelSchema.features) == null ? void 0 : _modelSchema_features3.includes(contracts.ModelFeature.STRUCTURED_OUTPUT)
1911
+ };
1912
+ }
2571
1913
  constructor(modelProvider, modelType){
2572
1914
  this.modelProvider = modelProvider;
2573
1915
  this.modelType = modelType;
@@ -2607,46 +1949,6 @@ class RerankModel extends AIModel {
2607
1949
  }
2608
1950
  }
2609
1951
 
2610
- const CommonParameterRules = [
2611
- {
2612
- name: 'temperature',
2613
- label: {
2614
- zh_Hans: '温度',
2615
- en_US: `Temperature`
2616
- },
2617
- type: contracts.ParameterType.FLOAT,
2618
- help: {
2619
- zh_Hans: '控制模型输出的随机性。较高的值(例如 1.0)使响应更具创意,而较低的值(例如 0.1)使响应更具确定性和重点性。',
2620
- en_US: `Controls the randomness of the model's output. A higher value (e.g., 1.0) makes responses more creative, while a lower value (e.g., 0.1) makes them more deterministic and focused.`
2621
- },
2622
- required: false,
2623
- default: 0.2,
2624
- min: 0,
2625
- max: 1,
2626
- precision: 0.1
2627
- },
2628
- {
2629
- label: {
2630
- zh_Hans: '最大尝试次数',
2631
- en_US: 'The maximum number of attempts'
2632
- },
2633
- type: contracts.ParameterType.INT,
2634
- help: {
2635
- zh_Hans: '如果请求由于网络超时或速率限制等问题而失败,系统将尝试重新发送请求的最大次数',
2636
- en_US: 'The maximum number of attempts the system will make to resend a request if it fails due to issues like network timeouts or rate limits'
2637
- },
2638
- required: false,
2639
- default: 6,
2640
- min: 0,
2641
- max: 10,
2642
- precision: 0,
2643
- name: 'maxRetries'
2644
- }
2645
- ];
2646
- function mergeCredentials(credentials, modelProperties) {
2647
- return _extends({}, credentials != null ? credentials : {}, modelProperties != null ? modelProperties : {});
2648
- }
2649
-
2650
1952
  class SpeechToTextModel extends AIModel {
2651
1953
  }
2652
1954
 
@@ -2973,7 +2275,7 @@ class OpenAICompatibleReranker {
2973
2275
  if (!Array.isArray(output)) {
2974
2276
  throw new Error('Invalid response format: missing results array');
2975
2277
  }
2976
- // 收集原始分数并进行归一化处理
2278
+ // Collect raw scores and normalize them.
2977
2279
  const scores = output.map((r)=>r.relevance_score);
2978
2280
  const minScore = Math.min(...scores);
2979
2281
  const maxScore = Math.max(...scores);
@@ -3040,6 +2342,48 @@ class Speech2TextChatModel extends chat_models.BaseChatModel {
3040
2342
  return 0;
3041
2343
  }
3042
2344
 
2345
+ function getModelContextSize(input) {
2346
+ if (isCopilotModel(input)) {
2347
+ var _input_options;
2348
+ return normalizeContextSize((_input_options = input.options) == null ? void 0 : _input_options[contracts.ModelPropertyKey.CONTEXT_SIZE]);
2349
+ }
2350
+ // Backward compatibility for langchain <1.0.0
2351
+ if (input.metadata && "profile" in input.metadata) {
2352
+ const profile = input.metadata['profile'];
2353
+ if ("maxInputTokens" in profile && (typeof profile.maxInputTokens === "number" || profile.maxInputTokens == null)) {
2354
+ var _profile_maxInputTokens;
2355
+ return (_profile_maxInputTokens = profile.maxInputTokens) != null ? _profile_maxInputTokens : undefined;
2356
+ }
2357
+ }
2358
+ // Langchain v1.0.0+
2359
+ if ("profile" in input && typeof input.profile === "object" && input.profile && "maxInputTokens" in input.profile && (typeof input.profile.maxInputTokens === "number" || input.profile.maxInputTokens == null)) {
2360
+ var _input_profile_maxInputTokens;
2361
+ return (_input_profile_maxInputTokens = input.profile.maxInputTokens) != null ? _input_profile_maxInputTokens : undefined;
2362
+ }
2363
+ if ("model" in input && typeof input.model === "string") {
2364
+ return base.getModelContextSize(input.model);
2365
+ }
2366
+ if ("modelName" in input && typeof input.modelName === "string") {
2367
+ return base.getModelContextSize(input.modelName);
2368
+ }
2369
+ return undefined;
2370
+ }
2371
+ function isCopilotModel(input) {
2372
+ return typeof input === "object" && input !== null && !("invoke" in input);
2373
+ }
2374
+ function normalizeContextSize(value) {
2375
+ if (typeof value === "number" && Number.isFinite(value) && value > 0) {
2376
+ return Math.floor(value);
2377
+ }
2378
+ if (typeof value === "string") {
2379
+ const parsed = Number.parseInt(value, 10);
2380
+ if (Number.isFinite(parsed) && parsed > 0) {
2381
+ return parsed;
2382
+ }
2383
+ }
2384
+ return undefined;
2385
+ }
2386
+
3043
2387
  /**
3044
2388
  * Get a Chat Model of copilot model and check it's token limitation, record the token usage
3045
2389
  */ class CreateModelClientCommand extends cqrs.Command {
@@ -3076,6 +2420,651 @@ exports.AgentMiddlewareRegistry = __decorate([
3076
2420
  "end"
3077
2421
  ];
3078
2422
 
2423
+ /**
2424
+ * Structured message types (suggested format):
2425
+ * - channel.{provider}.{action}.v{number}
2426
+ * - agent.{action}.v{number}
2427
+ * - system.{action}.v{number}
2428
+ * - plugin.{domain}.{action}.v{number}
2429
+ *
2430
+ * Note: At runtime, any string type is still allowed, facilitating dynamic extension by plugins.
2431
+ */ const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
2432
+ const VERSION_PATTERN = /^v[1-9][0-9]*$/;
2433
+ function assertSegment(input, name) {
2434
+ if (!SEGMENT_PATTERN.test(input)) {
2435
+ throw new Error(`Invalid ${name} segment: "${input}"`);
2436
+ }
2437
+ }
2438
+ /**
2439
+ * Unified construction of channel message types to avoid manual string errors.
2440
+ * Example: channel.lark.inbound.v1
2441
+ */ function defineChannelMessageType(provider, action, version) {
2442
+ assertSegment(provider, 'provider');
2443
+ assertSegment(action, 'action');
2444
+ if (!Number.isInteger(version) || version <= 0) {
2445
+ throw new Error(`Invalid version: "${version}"`);
2446
+ }
2447
+ return `channel.${provider}.${action}.v${version}`;
2448
+ }
2449
+ /**
2450
+ * Unified construction of agent message types.
2451
+ * Example: agent.handoff.v1
2452
+ */ function defineAgentMessageType(action, version) {
2453
+ assertSegment(action, 'action');
2454
+ if (!Number.isInteger(version) || version <= 0) {
2455
+ throw new Error(`Invalid version: "${version}"`);
2456
+ }
2457
+ return `agent.${action}.v${version}`;
2458
+ }
2459
+ /**
2460
+ * Check if a type conforms to the structured naming convention (format only, no semantic validation).
2461
+ */ function isStructuredMessageType(type) {
2462
+ const parts = type.split('.');
2463
+ if (parts.length < 3) {
2464
+ return false;
2465
+ }
2466
+ const version = parts[parts.length - 1];
2467
+ if (!VERSION_PATTERN.test(version)) {
2468
+ return false;
2469
+ }
2470
+ return parts.slice(0, -1).every((part)=>SEGMENT_PATTERN.test(part));
2471
+ }
2472
+
2473
+ const AGENT_CHAT_DISPATCH_MESSAGE_TYPE = defineAgentMessageType('chat_dispatch', 1);
2474
+
2475
+ /**
2476
+ * Handoff Processor meta key。
2477
+ */ const HANDOFF_PROCESSOR_STRATEGY = 'HANDOFF_PROCESSOR_STRATEGY';
2478
+ /**
2479
+ * Declare on a provider:
2480
+ * 1) Which message types it handles
2481
+ * 2) Default execution policy (lane/timeout)
2482
+ */ function HandoffProcessorStrategy(provider, metadata) {
2483
+ var _metadata_types;
2484
+ if (!(metadata == null ? void 0 : (_metadata_types = metadata.types) == null ? void 0 : _metadata_types.length)) {
2485
+ throw new Error('HandoffProcessor requires at least one message type');
2486
+ }
2487
+ return common.applyDecorators(common.SetMetadata(HANDOFF_PROCESSOR_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, HANDOFF_PROCESSOR_STRATEGY));
2488
+ }
2489
+
2490
+ exports.HandoffProcessorRegistry = class HandoffProcessorRegistry extends BaseStrategyRegistry {
2491
+ constructor(discoveryService, reflector){
2492
+ super(HANDOFF_PROCESSOR_STRATEGY, discoveryService, reflector);
2493
+ }
2494
+ };
2495
+ exports.HandoffProcessorRegistry = __decorate([
2496
+ common.Injectable(),
2497
+ __metadata("design:type", Function),
2498
+ __metadata("design:paramtypes", [
2499
+ typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
2500
+ typeof core.Reflector === "undefined" ? Object : core.Reflector
2501
+ ])
2502
+ ], exports.HandoffProcessorRegistry);
2503
+
2504
+ /**
2505
+ * Handoff execution types.
2506
+ *
2507
+ * Note:
2508
+ * - Two-gate lane/session permit logic has been removed.
2509
+ * - Lane is now an execution tag for observability and soft policy only.
2510
+ */ const DEFAULT_EXECUTION_CONFIG = {
2511
+ lanes: {
2512
+ main: 8,
2513
+ subagent: 16,
2514
+ cron: 4,
2515
+ nested: 8
2516
+ },
2517
+ runTtlMs: 10 * 60 * 1000
2518
+ };
2519
+
2520
+ /**
2521
+ * Common platform message length limits
2522
+ */ const CHAT_CHANNEL_TEXT_LIMITS = {
2523
+ lark: 4000,
2524
+ wecom: 2048,
2525
+ dingtalk: 4000,
2526
+ slack: 4000,
2527
+ telegram: 4096,
2528
+ discord: 2000
2529
+ };
2530
+ /**
2531
+ * Chunk long text by specified length
2532
+ *
2533
+ * @param text - Text to chunk
2534
+ * @param limit - Maximum characters per chunk
2535
+ * @param mode - Chunking mode: 'text' splits by character, 'markdown' tries to preserve paragraphs
2536
+ * @returns Array of chunked text
2537
+ */ function chunkText(text, limit, mode = 'text') {
2538
+ if (!text || text.length <= limit) {
2539
+ return [
2540
+ text
2541
+ ];
2542
+ }
2543
+ const chunks = [];
2544
+ if (mode === 'markdown') {
2545
+ // Markdown mode: try to split at paragraph boundaries
2546
+ const paragraphs = text.split(/\n\n+/);
2547
+ let currentChunk = '';
2548
+ for (const para of paragraphs){
2549
+ if (currentChunk.length + para.length + 2 <= limit) {
2550
+ currentChunk += (currentChunk ? '\n\n' : '') + para;
2551
+ } else if (para.length > limit) {
2552
+ // Paragraph itself is too long, need hard split
2553
+ if (currentChunk) {
2554
+ chunks.push(currentChunk);
2555
+ currentChunk = '';
2556
+ }
2557
+ let remaining = para;
2558
+ while(remaining.length > limit){
2559
+ chunks.push(remaining.slice(0, limit));
2560
+ remaining = remaining.slice(limit);
2561
+ }
2562
+ currentChunk = remaining;
2563
+ } else {
2564
+ if (currentChunk) {
2565
+ chunks.push(currentChunk);
2566
+ }
2567
+ currentChunk = para;
2568
+ }
2569
+ }
2570
+ if (currentChunk) {
2571
+ chunks.push(currentChunk);
2572
+ }
2573
+ } else {
2574
+ // Plain text mode: split directly by length
2575
+ let remaining = text;
2576
+ while(remaining.length > limit){
2577
+ chunks.push(remaining.slice(0, limit));
2578
+ remaining = remaining.slice(limit);
2579
+ }
2580
+ if (remaining) {
2581
+ chunks.push(remaining);
2582
+ }
2583
+ }
2584
+ return chunks;
2585
+ }
2586
+
2587
+ /**
2588
+ * Metadata key for chat channel
2589
+ */ const CHAT_CHANNEL = 'CHAT_CHANNEL';
2590
+ /**
2591
+ * Decorator for chat channel implementations
2592
+ *
2593
+ * Use this decorator to register a chat channel implementation.
2594
+ * The decorated class will be automatically discovered and registered
2595
+ * to ChatChannelRegistry on module initialization.
2596
+ *
2597
+ * @param type - The channel type identifier (e.g., 'lark', 'wecom', 'dingtalk')
2598
+ *
2599
+ * @example
2600
+ * ```typescript
2601
+ * @Injectable()
2602
+ * @ChatChannel('lark')
2603
+ * export class LarkChatChannel implements IChatChannel {
2604
+ * // Implementation
2605
+ * }
2606
+ * ```
2607
+ */ const ChatChannel = (type)=>common.SetMetadata(CHAT_CHANNEL, type);
2608
+
2609
+ exports.ChatChannelRegistry = class ChatChannelRegistry extends BaseStrategyRegistry {
2610
+ constructor(discoveryService, reflector){
2611
+ super(CHAT_CHANNEL, discoveryService, reflector);
2612
+ }
2613
+ };
2614
+ exports.ChatChannelRegistry = __decorate([
2615
+ common.Injectable(),
2616
+ __metadata("design:type", Function),
2617
+ __metadata("design:paramtypes", [
2618
+ typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
2619
+ typeof core.Reflector === "undefined" ? Object : core.Reflector
2620
+ ])
2621
+ ], exports.ChatChannelRegistry);
2622
+
2623
+ class CancelConversationCommand {
2624
+ constructor(input){
2625
+ this.input = input;
2626
+ }
2627
+ }
2628
+ CancelConversationCommand.type = '[Chat Conversation] Cancel';
2629
+
2630
+ /**
2631
+ * Protocol definition for pluggable memory backends.
2632
+ *
2633
+ * This module defines the BackendProtocol that all backend implementations
2634
+ * must follow. Backends can store files in different locations (state, filesystem,
2635
+ * database, etc.) and provide a uniform interface for file operations.
2636
+ */ /**
2637
+ * Type guard to check if a backend supports execution.
2638
+ *
2639
+ * @param backend - Backend instance to check
2640
+ * @returns True if the backend implements SandboxBackendProtocol
2641
+ */ function isSandboxBackend(backend) {
2642
+ return typeof backend.execute === "function" && typeof backend.id === "string";
2643
+ }
2644
+
2645
+ /**
2646
+ * BaseSandbox: Abstract base class for sandbox backends with command execution.
2647
+ *
2648
+ * This class provides default implementations for all SandboxBackendProtocol
2649
+ * methods using shell commands executed via execute(). Concrete implementations
2650
+ * only need to implement the execute() method.
2651
+ *
2652
+ * Requires Node.js 20+ on the sandbox host.
2653
+ */ /**
2654
+ * Node.js command template for glob operations.
2655
+ * Uses web-standard atob() for base64 decoding.
2656
+ */ function buildGlobCommand(searchPath, pattern) {
2657
+ const pathB64 = btoa(searchPath);
2658
+ const patternB64 = btoa(pattern);
2659
+ return `node -e "
2660
+ const fs = require('fs');
2661
+ const path = require('path');
2662
+
2663
+ const searchPath = atob('${pathB64}');
2664
+ const pattern = atob('${patternB64}');
2665
+
2666
+ function globMatch(relativePath, pattern) {
2667
+ const regexPattern = pattern
2668
+ .replace(/\\*\\*/g, '<<<GLOBSTAR>>>')
2669
+ .replace(/\\*/g, '[^/]*')
2670
+ .replace(/\\?/g, '.')
2671
+ .replace(/<<<GLOBSTAR>>>/g, '.*');
2672
+ return new RegExp('^' + regexPattern + '$').test(relativePath);
2673
+ }
2674
+
2675
+ function walkDir(dir, baseDir, results) {
2676
+ try {
2677
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
2678
+ for (const entry of entries) {
2679
+ const fullPath = path.join(dir, entry.name);
2680
+ const relativePath = path.relative(baseDir, fullPath);
2681
+ if (entry.isDirectory()) {
2682
+ walkDir(fullPath, baseDir, results);
2683
+ } else if (globMatch(relativePath, pattern)) {
2684
+ const stat = fs.statSync(fullPath);
2685
+ console.log(JSON.stringify({
2686
+ path: relativePath,
2687
+ size: stat.size,
2688
+ mtime: stat.mtimeMs,
2689
+ isDir: false
2690
+ }));
2691
+ }
2692
+ }
2693
+ } catch (e) {
2694
+ // Silent failure for non-existent paths
2695
+ }
2696
+ }
2697
+
2698
+ try {
2699
+ process.chdir(searchPath);
2700
+ walkDir('.', '.', []);
2701
+ } catch (e) {
2702
+ // Silent failure for non-existent paths
2703
+ }
2704
+ "`;
2705
+ }
2706
+ /**
2707
+ * Node.js command template for listing directory contents.
2708
+ */ function buildLsCommand(dirPath) {
2709
+ const pathB64 = btoa(dirPath);
2710
+ return `node -e "
2711
+ const fs = require('fs');
2712
+ const path = require('path');
2713
+
2714
+ const dirPath = atob('${pathB64}');
2715
+
2716
+ try {
2717
+ const entries = fs.readdirSync(dirPath, { withFileTypes: true });
2718
+ for (const entry of entries) {
2719
+ const fullPath = path.join(dirPath, entry.name);
2720
+ const stat = fs.statSync(fullPath);
2721
+ console.log(JSON.stringify({
2722
+ path: entry.isDirectory() ? fullPath + '/' : fullPath,
2723
+ size: stat.size,
2724
+ mtime: stat.mtimeMs,
2725
+ isDir: entry.isDirectory()
2726
+ }));
2727
+ }
2728
+ } catch (e) {
2729
+ console.error('Error: ' + e.message);
2730
+ process.exit(1);
2731
+ }
2732
+ "`;
2733
+ }
2734
+ /**
2735
+ * Node.js command template for reading files.
2736
+ */ function buildReadCommand(filePath, offset, limit) {
2737
+ const pathB64 = btoa(filePath);
2738
+ // Coerce offset and limit to safe non-negative integers before embedding in the shell command.
2739
+ const safeOffset = Number.isFinite(offset) && offset > 0 ? Math.floor(offset) : 0;
2740
+ const safeLimit = Number.isFinite(limit) && limit > 0 && limit < Number.MAX_SAFE_INTEGER ? Math.floor(limit) : 0;
2741
+ return `node -e "
2742
+ const fs = require('fs');
2743
+
2744
+ const filePath = atob('${pathB64}');
2745
+ const offset = ${safeOffset};
2746
+ const limit = ${safeLimit};
2747
+
2748
+ if (!fs.existsSync(filePath)) {
2749
+ console.log('Error: File not found');
2750
+ process.exit(1);
2751
+ }
2752
+
2753
+ const stat = fs.statSync(filePath);
2754
+ if (stat.size === 0) {
2755
+ console.log('System reminder: File exists but has empty contents');
2756
+ process.exit(0);
2757
+ }
2758
+
2759
+ const content = fs.readFileSync(filePath, 'utf-8');
2760
+ const lines = content.split('\\n');
2761
+ const selected = lines.slice(offset, offset + limit);
2762
+
2763
+ for (let i = 0; i < selected.length; i++) {
2764
+ const lineNum = offset + i + 1;
2765
+ console.log(String(lineNum).padStart(6) + '\\t' + selected[i]);
2766
+ }
2767
+ "`;
2768
+ }
2769
+ /**
2770
+ * Node.js command template for writing files.
2771
+ */ function buildWriteCommand(filePath, content) {
2772
+ const pathB64 = btoa(filePath);
2773
+ const contentB64 = btoa(content);
2774
+ return `node -e "
2775
+ const fs = require('fs');
2776
+ const path = require('path');
2777
+
2778
+ const filePath = atob('${pathB64}');
2779
+ const content = atob('${contentB64}');
2780
+
2781
+ if (fs.existsSync(filePath)) {
2782
+ console.error('Error: File already exists');
2783
+ process.exit(1);
2784
+ }
2785
+
2786
+ const parentDir = path.dirname(filePath) || '.';
2787
+ fs.mkdirSync(parentDir, { recursive: true });
2788
+
2789
+ fs.writeFileSync(filePath, content, 'utf-8');
2790
+ console.log('OK');
2791
+ "`;
2792
+ }
2793
+ /**
2794
+ * Node.js command template for editing files.
2795
+ */ function buildEditCommand(filePath, oldStr, newStr, replaceAll) {
2796
+ const pathB64 = btoa(filePath);
2797
+ const oldB64 = btoa(oldStr);
2798
+ const newB64 = btoa(newStr);
2799
+ return `node -e "
2800
+ const fs = require('fs');
2801
+
2802
+ const filePath = atob('${pathB64}');
2803
+ const oldStr = atob('${oldB64}');
2804
+ const newStr = atob('${newB64}');
2805
+ const replaceAll = ${Boolean(replaceAll)};
2806
+
2807
+ let text;
2808
+ try {
2809
+ text = fs.readFileSync(filePath, 'utf-8');
2810
+ } catch (e) {
2811
+ process.exit(3);
2812
+ }
2813
+
2814
+ const count = text.split(oldStr).length - 1;
2815
+
2816
+ if (count === 0) {
2817
+ process.exit(1);
2818
+ }
2819
+ if (count > 1 && !replaceAll) {
2820
+ process.exit(2);
2821
+ }
2822
+
2823
+ const result = text.split(oldStr).join(newStr);
2824
+ fs.writeFileSync(filePath, result, 'utf-8');
2825
+ console.log(count);
2826
+ "`;
2827
+ }
2828
+ /**
2829
+ * Node.js command template for grep operations.
2830
+ */ function buildGrepCommand(pattern, searchPath, globPattern) {
2831
+ const patternB64 = btoa(pattern);
2832
+ const pathB64 = btoa(searchPath);
2833
+ const globB64 = globPattern ? btoa(globPattern) : "";
2834
+ return `node -e "
2835
+ const fs = require('fs');
2836
+ const path = require('path');
2837
+
2838
+ const pattern = atob('${patternB64}');
2839
+ const searchPath = atob('${pathB64}');
2840
+ const globPattern = ${globPattern ? `atob('${globB64}')` : "null"};
2841
+
2842
+ let regex;
2843
+ try {
2844
+ regex = new RegExp(pattern);
2845
+ } catch (e) {
2846
+ console.error('Invalid regex: ' + e.message);
2847
+ process.exit(1);
2848
+ }
2849
+
2850
+ function globMatch(filePath, pattern) {
2851
+ if (!pattern) return true;
2852
+ const regexPattern = pattern
2853
+ .replace(/\\*\\*/g, '<<<GLOBSTAR>>>')
2854
+ .replace(/\\*/g, '[^/]*')
2855
+ .replace(/\\?/g, '.')
2856
+ .replace(/<<<GLOBSTAR>>>/g, '.*');
2857
+ return new RegExp('^' + regexPattern + '$').test(filePath);
2858
+ }
2859
+
2860
+ function walkDir(dir, results) {
2861
+ try {
2862
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
2863
+ for (const entry of entries) {
2864
+ const fullPath = path.join(dir, entry.name);
2865
+ if (entry.isDirectory()) {
2866
+ walkDir(fullPath, results);
2867
+ } else {
2868
+ const relativePath = path.relative(searchPath, fullPath);
2869
+ if (globMatch(relativePath, globPattern)) {
2870
+ try {
2871
+ const content = fs.readFileSync(fullPath, 'utf-8');
2872
+ const lines = content.split('\\n');
2873
+ for (let i = 0; i < lines.length; i++) {
2874
+ if (regex.test(lines[i])) {
2875
+ console.log(JSON.stringify({
2876
+ path: fullPath,
2877
+ line: i + 1,
2878
+ text: lines[i]
2879
+ }));
2880
+ }
2881
+ }
2882
+ } catch (e) {
2883
+ // Skip unreadable files
2884
+ }
2885
+ }
2886
+ }
2887
+ }
2888
+ } catch (e) {
2889
+ // Skip unreadable directories
2890
+ }
2891
+ }
2892
+
2893
+ try {
2894
+ walkDir(searchPath, []);
2895
+ } catch (e) {
2896
+ // Silent failure
2897
+ }
2898
+ "`;
2899
+ }
2900
+ /**
2901
+ * Base sandbox implementation with execute() as the only abstract method.
2902
+ *
2903
+ * This class provides default implementations for all SandboxBackendProtocol
2904
+ * methods using shell commands executed via execute(). Concrete implementations
2905
+ * only need to implement the execute() method.
2906
+ *
2907
+ * Requires Node.js 20+ on the sandbox host.
2908
+ */ class BaseSandbox {
2909
+ /**
2910
+ * List files and directories in the specified directory (non-recursive).
2911
+ *
2912
+ * @param path - Absolute path to directory
2913
+ * @returns List of FileInfo objects for files and directories directly in the directory.
2914
+ */ async lsInfo(path) {
2915
+ const command = buildLsCommand(path);
2916
+ const result = await this.execute(command);
2917
+ if (result.exitCode !== 0) {
2918
+ return [];
2919
+ }
2920
+ const infos = [];
2921
+ const lines = result.output.trim().split("\n").filter(Boolean);
2922
+ for (const line of lines){
2923
+ try {
2924
+ const parsed = JSON.parse(line);
2925
+ infos.push({
2926
+ path: parsed.path,
2927
+ is_dir: parsed.isDir,
2928
+ size: parsed.size,
2929
+ modified_at: parsed.mtime ? new Date(parsed.mtime).toISOString() : undefined
2930
+ });
2931
+ } catch (e) {
2932
+ // Skip invalid JSON lines
2933
+ }
2934
+ }
2935
+ return infos;
2936
+ }
2937
+ /**
2938
+ * Read file content with line numbers.
2939
+ *
2940
+ * @param filePath - Absolute file path
2941
+ * @param offset - Line offset to start reading from (0-indexed)
2942
+ * @param limit - Maximum number of lines to read
2943
+ * @returns Formatted file content with line numbers, or error message
2944
+ */ async read(filePath, offset = 0, limit = 500) {
2945
+ const command = buildReadCommand(filePath, offset, limit);
2946
+ const result = await this.execute(command);
2947
+ if (result.exitCode !== 0) {
2948
+ return `Error: File '${filePath}' not found`;
2949
+ }
2950
+ return result.output;
2951
+ }
2952
+ /**
2953
+ * Structured search results or error string for invalid input.
2954
+ */ async grepRaw(pattern, path = "/", glob = null) {
2955
+ const command = buildGrepCommand(pattern, path, glob);
2956
+ const result = await this.execute(command);
2957
+ if (result.exitCode === 1) {
2958
+ // Check if it's a regex error
2959
+ if (result.output.includes("Invalid regex:")) {
2960
+ return result.output.trim();
2961
+ }
2962
+ }
2963
+ const matches = [];
2964
+ const lines = result.output.trim().split("\n").filter(Boolean);
2965
+ for (const line of lines){
2966
+ try {
2967
+ const parsed = JSON.parse(line);
2968
+ matches.push({
2969
+ path: parsed.path,
2970
+ line: parsed.line,
2971
+ text: parsed.text
2972
+ });
2973
+ } catch (e) {
2974
+ // Skip invalid JSON lines
2975
+ }
2976
+ }
2977
+ return matches;
2978
+ }
2979
+ /**
2980
+ * Structured glob matching returning FileInfo objects.
2981
+ */ async globInfo(pattern, path = "/") {
2982
+ const command = buildGlobCommand(path, pattern);
2983
+ const result = await this.execute(command);
2984
+ const infos = [];
2985
+ const lines = result.output.trim().split("\n").filter(Boolean);
2986
+ for (const line of lines){
2987
+ try {
2988
+ const parsed = JSON.parse(line);
2989
+ infos.push({
2990
+ path: parsed.path,
2991
+ is_dir: parsed.isDir,
2992
+ size: parsed.size,
2993
+ modified_at: parsed.mtime ? new Date(parsed.mtime).toISOString() : undefined
2994
+ });
2995
+ } catch (e) {
2996
+ // Skip invalid JSON lines
2997
+ }
2998
+ }
2999
+ return infos;
3000
+ }
3001
+ /**
3002
+ * Create a new file with content.
3003
+ */ async write(filePath, content) {
3004
+ const command = buildWriteCommand(filePath, content);
3005
+ const result = await this.execute(command);
3006
+ if (result.exitCode !== 0) {
3007
+ return {
3008
+ error: `Cannot write to ${filePath} because it already exists. Read and then make an edit, or write to a new path.`
3009
+ };
3010
+ }
3011
+ return {
3012
+ path: filePath,
3013
+ filesUpdate: null
3014
+ };
3015
+ }
3016
+ /**
3017
+ * Edit a file by replacing string occurrences.
3018
+ */ async edit(filePath, oldString, newString, replaceAll = false) {
3019
+ const command = buildEditCommand(filePath, oldString, newString, replaceAll);
3020
+ const result = await this.execute(command);
3021
+ switch(result.exitCode){
3022
+ case 0:
3023
+ {
3024
+ const occurrences = parseInt(result.output.trim(), 10) || 1;
3025
+ return {
3026
+ path: filePath,
3027
+ filesUpdate: null,
3028
+ occurrences
3029
+ };
3030
+ }
3031
+ case 1:
3032
+ return {
3033
+ error: `String not found in file '${filePath}'`
3034
+ };
3035
+ case 2:
3036
+ return {
3037
+ error: `Multiple occurrences found in '${filePath}'. Use replaceAll=true to replace all.`
3038
+ };
3039
+ case 3:
3040
+ return {
3041
+ error: `Error: File '${filePath}' not found`
3042
+ };
3043
+ default:
3044
+ return {
3045
+ error: `Unknown error editing file '${filePath}'`
3046
+ };
3047
+ }
3048
+ }
3049
+ }
3050
+
3051
+ const SANDBOX_PROVIDER = 'SANDBOX_PROVIDER';
3052
+ const SandboxProviderStrategy = (provider)=>common.applyDecorators(common.SetMetadata(SANDBOX_PROVIDER, provider), common.SetMetadata(STRATEGY_META_KEY, SANDBOX_PROVIDER));
3053
+
3054
+ exports.SandboxProviderRegistry = class SandboxProviderRegistry extends BaseStrategyRegistry {
3055
+ constructor(discoveryService, reflector){
3056
+ super(SANDBOX_PROVIDER, discoveryService, reflector);
3057
+ }
3058
+ };
3059
+ exports.SandboxProviderRegistry = __decorate([
3060
+ common.Injectable(),
3061
+ __metadata("design:type", Function),
3062
+ __metadata("design:paramtypes", [
3063
+ typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
3064
+ typeof core.Reflector === "undefined" ? Object : core.Reflector
3065
+ ])
3066
+ ], exports.SandboxProviderRegistry);
3067
+
3079
3068
  Object.defineProperty(exports, "IColumnDef", {
3080
3069
  enumerable: true,
3081
3070
  get: function () { return contracts.IColumnDef; }
@@ -3092,42 +3081,57 @@ Object.defineProperty(exports, "TDocumentAsset", {
3092
3081
  enumerable: true,
3093
3082
  get: function () { return contracts.TDocumentAsset; }
3094
3083
  });
3084
+ exports.AGENT_CHAT_DISPATCH_MESSAGE_TYPE = AGENT_CHAT_DISPATCH_MESSAGE_TYPE;
3095
3085
  exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
3096
3086
  exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
3097
3087
  exports.AIModelProviderStrategy = AIModelProviderStrategy;
3098
3088
  exports.AI_MODEL_PROVIDER = AI_MODEL_PROVIDER;
3089
+ exports.ANALYTICS_PERMISSION_SERVICE_TOKEN = ANALYTICS_PERMISSION_SERVICE_TOKEN;
3099
3090
  exports.AdapterDataSourceStrategy = AdapterDataSourceStrategy;
3100
3091
  exports.AgentMiddlewareStrategy = AgentMiddlewareStrategy;
3101
3092
  exports.AiModelNotFoundException = AiModelNotFoundException;
3102
3093
  exports.BaseHTTPQueryRunner = BaseHTTPQueryRunner;
3103
3094
  exports.BaseQueryRunner = BaseQueryRunner;
3104
3095
  exports.BaseSQLQueryRunner = BaseSQLQueryRunner;
3096
+ exports.BaseSandbox = BaseSandbox;
3105
3097
  exports.BaseStrategyRegistry = BaseStrategyRegistry;
3106
3098
  exports.BaseTool = BaseTool;
3107
3099
  exports.BaseToolset = BaseToolset;
3108
3100
  exports.BuiltinToolset = BuiltinToolset;
3101
+ exports.CHAT_CHANNEL = CHAT_CHANNEL;
3102
+ exports.CHAT_CHANNEL_TEXT_LIMITS = CHAT_CHANNEL_TEXT_LIMITS;
3103
+ exports.CancelConversationCommand = CancelConversationCommand;
3104
+ exports.ChatChannel = ChatChannel;
3109
3105
  exports.ChatOAICompatReasoningModel = ChatOAICompatReasoningModel;
3110
3106
  exports.CommonParameterRules = CommonParameterRules;
3111
3107
  exports.CreateModelClientCommand = CreateModelClientCommand;
3112
3108
  exports.CredentialsValidateFailedError = CredentialsValidateFailedError;
3113
3109
  exports.DATASOURCE_STRATEGY = DATASOURCE_STRATEGY;
3110
+ exports.DEFAULT_EXECUTION_CONFIG = DEFAULT_EXECUTION_CONFIG;
3114
3111
  exports.DOCUMENT_SOURCE_STRATEGY = DOCUMENT_SOURCE_STRATEGY;
3115
3112
  exports.DOCUMENT_TRANSFORMER_STRATEGY = DOCUMENT_TRANSFORMER_STRATEGY;
3116
3113
  exports.DataSourceStrategy = DataSourceStrategy;
3117
3114
  exports.DocumentSourceStrategy = DocumentSourceStrategy;
3118
3115
  exports.DocumentTransformerStrategy = DocumentTransformerStrategy;
3119
3116
  exports.GLOBAL_ORGANIZATION_SCOPE = GLOBAL_ORGANIZATION_SCOPE;
3117
+ exports.HANDOFF_PERMISSION_SERVICE_TOKEN = HANDOFF_PERMISSION_SERVICE_TOKEN;
3118
+ exports.HANDOFF_PROCESSOR_STRATEGY = HANDOFF_PROCESSOR_STRATEGY;
3119
+ exports.HANDOFF_QUEUE_SERVICE_TOKEN = HANDOFF_QUEUE_SERVICE_TOKEN;
3120
+ exports.HandoffProcessorStrategy = HandoffProcessorStrategy;
3120
3121
  exports.IMAGE_UNDERSTANDING_STRATEGY = IMAGE_UNDERSTANDING_STRATEGY;
3122
+ exports.INTEGRATION_PERMISSION_SERVICE_TOKEN = INTEGRATION_PERMISSION_SERVICE_TOKEN;
3121
3123
  exports.INTEGRATION_STRATEGY = INTEGRATION_STRATEGY;
3122
3124
  exports.ImageUnderstandingStrategy = ImageUnderstandingStrategy;
3123
3125
  exports.IntegrationStrategyKey = IntegrationStrategyKey;
3124
3126
  exports.JUMP_TO_TARGETS = JUMP_TO_TARGETS;
3127
+ exports.JsonSchemaValidator = JsonSchemaValidator;
3125
3128
  exports.KNOWLEDGE_STRATEGY = KNOWLEDGE_STRATEGY;
3126
3129
  exports.KnowledgeStrategyKey = KnowledgeStrategyKey;
3127
3130
  exports.LLMUsage = LLMUsage;
3128
3131
  exports.LargeLanguageModel = LargeLanguageModel;
3129
3132
  exports.ORGANIZATION_METADATA_KEY = ORGANIZATION_METADATA_KEY;
3130
3133
  exports.OpenAICompatibleReranker = OpenAICompatibleReranker;
3134
+ exports.PERMISSION_OPERATION_METADATA_KEY = PERMISSION_OPERATION_METADATA_KEY;
3131
3135
  exports.PLUGIN_METADATA = PLUGIN_METADATA;
3132
3136
  exports.PLUGIN_METADATA_KEY = PLUGIN_METADATA_KEY;
3133
3137
  exports.PROVIDE_AI_MODEL_LLM = PROVIDE_AI_MODEL_LLM;
@@ -3138,9 +3142,12 @@ exports.PROVIDE_AI_MODEL_TEXT_EMBEDDING = PROVIDE_AI_MODEL_TEXT_EMBEDDING;
3138
3142
  exports.PROVIDE_AI_MODEL_TTS = PROVIDE_AI_MODEL_TTS;
3139
3143
  exports.RETRIEVER_STRATEGY = RETRIEVER_STRATEGY;
3140
3144
  exports.RequestContext = RequestContext;
3145
+ exports.RequirePermissionOperation = RequirePermissionOperation;
3141
3146
  exports.RerankModel = RerankModel;
3142
3147
  exports.RetrieverStrategy = RetrieverStrategy;
3148
+ exports.SANDBOX_PROVIDER = SANDBOX_PROVIDER;
3143
3149
  exports.STRATEGY_META_KEY = STRATEGY_META_KEY;
3150
+ exports.SandboxProviderStrategy = SandboxProviderStrategy;
3144
3151
  exports.Speech2TextChatModel = Speech2TextChatModel;
3145
3152
  exports.SpeechToTextModel = SpeechToTextModel;
3146
3153
  exports.TEXT_SPLITTER_STRATEGY = TEXT_SPLITTER_STRATEGY;
@@ -3149,6 +3156,7 @@ exports.TextEmbeddingModelManager = TextEmbeddingModelManager;
3149
3156
  exports.TextSplitterStrategy = TextSplitterStrategy;
3150
3157
  exports.TextToSpeechModel = TextToSpeechModel;
3151
3158
  exports.ToolsetStrategy = ToolsetStrategy;
3159
+ exports.USER_PERMISSION_SERVICE_TOKEN = USER_PERMISSION_SERVICE_TOKEN;
3152
3160
  exports.VECTOR_STORE_STRATEGY = VECTOR_STORE_STRATEGY;
3153
3161
  exports.VectorStoreStrategy = VectorStoreStrategy;
3154
3162
  exports.WORKFLOW_NODE_STRATEGY = WORKFLOW_NODE_STRATEGY;
@@ -3160,17 +3168,26 @@ exports.XpFileSystem = XpFileSystem;
3160
3168
  exports.XpertServerPlugin = XpertServerPlugin;
3161
3169
  exports.als = als;
3162
3170
  exports.calcTokenUsage = calcTokenUsage;
3171
+ exports.chunkText = chunkText;
3163
3172
  exports.countTokensSafe = countTokensSafe;
3164
3173
  exports.createI18nInstance = createI18nInstance;
3165
3174
  exports.createPluginLogger = createPluginLogger;
3175
+ exports.defineAgentMessageType = defineAgentMessageType;
3176
+ exports.defineChannelMessageType = defineChannelMessageType;
3166
3177
  exports.downloadRemoteFile = downloadRemoteFile;
3167
3178
  exports.getErrorMessage = getErrorMessage;
3179
+ exports.getModelContextSize = getModelContextSize;
3180
+ exports.getPermissionOperationMetadata = getPermissionOperationMetadata;
3168
3181
  exports.getPositionList = getPositionList;
3169
3182
  exports.getPositionMap = getPositionMap;
3170
3183
  exports.getRequestContext = getRequestContext;
3184
+ exports.getRequiredPermissionOperation = getRequiredPermissionOperation;
3171
3185
  exports.isRemoteFile = isRemoteFile;
3186
+ exports.isSandboxBackend = isSandboxBackend;
3187
+ exports.isStructuredMessageType = isStructuredMessageType;
3172
3188
  exports.loadYamlFile = loadYamlFile;
3173
3189
  exports.mergeCredentials = mergeCredentials;
3174
3190
  exports.mergeParentChildChunks = mergeParentChildChunks;
3191
+ exports.normalizeContextSize = normalizeContextSize;
3175
3192
  exports.runWithRequestContext = runWithRequestContext;
3176
3193
  exports.sumTokenUsage = sumTokenUsage;