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