@xpert-ai/plugin-sdk 3.8.4 → 3.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/index.cjs.js +486 -325
- package/index.esm.js +468 -298
- package/package.json +8 -9
- package/src/index.d.ts +1 -0
- package/src/lib/agent/handoff/agent-chat.contract.d.ts +1 -1
- package/src/lib/agent/handoff/handoff-processor.decorator.d.ts +1 -1
- package/src/lib/agent/index.d.ts +1 -0
- package/src/lib/agent/middleware/runtime.d.ts +1 -1
- package/src/lib/agent/middleware/strategy.decorator.d.ts +1 -1
- package/src/lib/agent/middleware/strategy.interface.d.ts +2 -1
- package/src/lib/agent/skill/skill-source-provider.decorator.d.ts +1 -1
- package/src/lib/agent/skill/skill-source-provider.interface.d.ts +1 -1
- package/src/lib/ai-model/abstract-provider.d.ts +1 -1
- package/src/lib/ai-model/ai-model-provider.interface.d.ts +1 -1
- package/src/lib/ai-model/ai-model.d.ts +1 -1
- package/src/lib/ai-model/commands/create-model-client.command.d.ts +1 -1
- package/src/lib/ai-model/entities/defaults.d.ts +1 -1
- package/src/lib/ai-model/llm.d.ts +1 -1
- package/src/lib/ai-model/types/model.d.ts +1 -1
- package/src/lib/ai-model/types/rerank.d.ts +1 -1
- package/src/lib/ai-model/types/text-embedding-model.d.ts +1 -1
- package/src/lib/ai-model/types/tts.d.ts +1 -1
- package/src/lib/ai-model/utils/limits.d.ts +1 -1
- package/src/lib/channel/strategy.interface.d.ts +1 -3
- package/src/lib/core/context/request-context.d.ts +9 -4
- package/src/lib/core/context/request-context.middleware.d.ts +1 -2
- package/src/lib/core/file-system.d.ts +3 -3
- package/src/lib/core/permissions/analytics.d.ts +2 -3
- package/src/lib/core/permissions/general.d.ts +1 -1
- package/src/lib/core/permissions/user.d.ts +1 -1
- package/src/lib/data/datasource/strategy.decorator.d.ts +1 -1
- package/src/lib/data/datasource/types.d.ts +2 -5
- package/src/lib/file/file-storage/provider.decorator.d.ts +1 -1
- package/src/lib/file/file-storage/provider.interface.d.ts +1 -3
- package/src/lib/file/file-upload/strategy.decorator.d.ts +1 -1
- package/src/lib/file/file-upload/strategy.interface.d.ts +1 -3
- package/src/lib/integration/strategy.decorator.d.ts +1 -1
- package/src/lib/integration/strategy.interface.d.ts +1 -1
- package/src/lib/rag/image/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/image/strategy.interface.d.ts +1 -1
- package/src/lib/rag/knowledge/knowledge-strategy.decorator.d.ts +1 -1
- package/src/lib/rag/knowledge/knowledge-strategy.interface.d.ts +1 -1
- package/src/lib/rag/retriever/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/retriever/strategy.interface.d.ts +1 -1
- package/src/lib/rag/source/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/source/strategy.interface.d.ts +1 -1
- package/src/lib/rag/textsplitter/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/textsplitter/strategy.interface.d.ts +1 -1
- package/src/lib/rag/transformer/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/transformer/strategy.interface.d.ts +1 -1
- package/src/lib/rag/types.d.ts +2 -2
- package/src/lib/sandbox/protocol.d.ts +4 -8
- package/src/lib/sandbox/sandbox.decorator.d.ts +1 -1
- package/src/lib/sandbox/sandbox.interface.d.ts +1 -1
- package/src/lib/strategy.d.ts +3 -3
- package/src/lib/toolset/builtin.d.ts +1 -1
- package/src/lib/toolset/strategy.decorator.d.ts +1 -1
- package/src/lib/toolset/strategy.interface.d.ts +1 -1
- package/src/lib/toolset/toolset.d.ts +1 -1
- package/src/lib/types.d.ts +1 -1
- package/src/lib/vectorstore/strategy.decorator.d.ts +1 -1
- package/src/lib/view-extension/index.d.ts +4 -0
- package/src/lib/view-extension/provider.decorator.d.ts +2 -0
- package/src/lib/view-extension/provider.interface.d.ts +7 -0
- package/src/lib/view-extension/provider.registry.d.ts +10 -0
- package/src/lib/view-extension/tokens.d.ts +1 -0
- package/src/lib/workflow/commands/wrap-workflow-node-execution.command.d.ts +1 -1
- package/src/lib/workflow/node/strategy.decorator.d.ts +1 -1
- package/src/lib/workflow/node/strategy.interface.d.ts +1 -1
- package/src/lib/workflow/trigger/strategy.decorator.d.ts +1 -1
- package/src/lib/workflow/trigger/strategy.interface.d.ts +1 -1
- package/index.esm.d.ts +0 -1
- /package/{index.cjs.d.ts → index.d.ts} +0 -0
package/index.cjs.js
CHANGED
|
@@ -5,7 +5,7 @@ var constants = require('@nestjs/common/constants');
|
|
|
5
5
|
var lodashEs = require('lodash-es');
|
|
6
6
|
var core = require('@nestjs/core');
|
|
7
7
|
var rxjs = require('rxjs');
|
|
8
|
-
var contracts = require('@
|
|
8
|
+
var contracts = require('@xpert-ai/contracts');
|
|
9
9
|
var node_async_hooks = require('node:async_hooks');
|
|
10
10
|
var passportJwt = require('passport-jwt');
|
|
11
11
|
var jsonwebtoken = require('jsonwebtoken');
|
|
@@ -33,20 +33,20 @@ require('js-tiktoken');
|
|
|
33
33
|
var base = require('@langchain/core/language_models/base');
|
|
34
34
|
|
|
35
35
|
function _interopNamespaceDefault(e) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
var n = Object.create(null);
|
|
37
|
+
if (e) {
|
|
38
|
+
Object.keys(e).forEach(function (k) {
|
|
39
|
+
if (k !== 'default') {
|
|
40
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
41
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return e[k]; }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
n.default = e;
|
|
49
|
+
return Object.freeze(n);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
@@ -58,11 +58,11 @@ var _axios__namespace = /*#__PURE__*/_interopNamespaceDefault(_axios);
|
|
|
58
58
|
* Metadata keys used in plugins for defining various aspects like entities, subscribers, and configurations.
|
|
59
59
|
*/ const PLUGIN_METADATA = {
|
|
60
60
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
* Key representing the entities registered within the plugin.
|
|
62
|
+
*/ ENTITIES: 'entities',
|
|
63
63
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
* Key representing event subscribers within the plugin.
|
|
65
|
+
*/ SUBSCRIBERS: 'subscribers'
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -107,10 +107,10 @@ function _extends() {
|
|
|
107
107
|
function createPluginLogger(scope, baseMeta = {}) {
|
|
108
108
|
const nestLogger = new common.Logger(scope);
|
|
109
109
|
const wrap = (level, msg, meta)=>{
|
|
110
|
-
var
|
|
110
|
+
var // 保持与 Nest Logger 接口对齐
|
|
111
|
+
_nestLogger_level;
|
|
111
112
|
const payload = meta ? _extends({}, baseMeta, meta) : baseMeta;
|
|
112
|
-
(_nestLogger_level =
|
|
113
|
-
nestLogger[level]) == null ? void 0 : _nestLogger_level.call(nestLogger, msg + (Object.keys(payload).length ? ` ${JSON.stringify(payload)}` : ''));
|
|
113
|
+
(_nestLogger_level = nestLogger[level]) == null ? void 0 : _nestLogger_level.call(nestLogger, msg + (Object.keys(payload).length ? ` ${JSON.stringify(payload)}` : ''));
|
|
114
114
|
};
|
|
115
115
|
return {
|
|
116
116
|
child (meta) {
|
|
@@ -141,11 +141,22 @@ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedEr
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
// request-context.ts
|
|
144
|
+
const TENANT_SCOPE = 'tenant';
|
|
145
|
+
const ORGANIZATION_SCOPE = 'organization';
|
|
144
146
|
class RequestContext {
|
|
145
147
|
static currentRequestContext() {
|
|
146
148
|
const session = getRequestContext();
|
|
147
149
|
return session;
|
|
148
150
|
}
|
|
151
|
+
static currentApiKey() {
|
|
152
|
+
var _RequestContext_currentApiPrincipal;
|
|
153
|
+
var _RequestContext_currentApiPrincipal_apiKey;
|
|
154
|
+
return (_RequestContext_currentApiPrincipal_apiKey = (_RequestContext_currentApiPrincipal = RequestContext.currentApiPrincipal()) == null ? void 0 : _RequestContext_currentApiPrincipal.apiKey) != null ? _RequestContext_currentApiPrincipal_apiKey : null;
|
|
155
|
+
}
|
|
156
|
+
static currentApiPrincipal() {
|
|
157
|
+
const user = RequestContext.currentUser();
|
|
158
|
+
return (user == null ? void 0 : user.apiKey) ? user : null;
|
|
159
|
+
}
|
|
149
160
|
static currentRequest() {
|
|
150
161
|
const requestContext = RequestContext.currentRequestContext();
|
|
151
162
|
if (requestContext) {
|
|
@@ -194,9 +205,9 @@ class RequestContext {
|
|
|
194
205
|
], throwError);
|
|
195
206
|
}
|
|
196
207
|
/**
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
208
|
+
* Retrieves the language code from the headers of the current request.
|
|
209
|
+
* @returns The language code (LanguagesEnum) extracted from the headers, or the default language (ENGLISH) if not found.
|
|
210
|
+
*/ static getLanguageCode() {
|
|
200
211
|
// Retrieve the current request
|
|
201
212
|
const req = RequestContext.currentRequest();
|
|
202
213
|
// Variable to store the extracted language code
|
|
@@ -212,21 +223,71 @@ class RequestContext {
|
|
|
212
223
|
// Return the extracted language code or the default language (ENGLISH) if not found
|
|
213
224
|
return lang || contracts.LanguagesEnum.English;
|
|
214
225
|
}
|
|
215
|
-
static
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
226
|
+
static getScope() {
|
|
227
|
+
const request = this.currentRequest();
|
|
228
|
+
const user = this.currentUser();
|
|
229
|
+
var _user_tenantId, _ref;
|
|
230
|
+
const tenantId = (_ref = (_user_tenantId = user == null ? void 0 : user.tenantId) != null ? _user_tenantId : getHeaderValue(request, [
|
|
231
|
+
'tenant-id'
|
|
232
|
+
])) != null ? _ref : null;
|
|
233
|
+
var _getHeaderValue;
|
|
234
|
+
const organizationId = (_getHeaderValue = getHeaderValue(request, [
|
|
219
235
|
'organization-id'
|
|
220
|
-
];
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
236
|
+
])) != null ? _getHeaderValue : null;
|
|
237
|
+
const scopeLevelHeader = getHeaderValue(request, [
|
|
238
|
+
'x-scope-level'
|
|
239
|
+
]);
|
|
240
|
+
if (scopeLevelHeader) {
|
|
241
|
+
if (scopeLevelHeader !== TENANT_SCOPE && scopeLevelHeader !== ORGANIZATION_SCOPE) {
|
|
242
|
+
throw new common.BadRequestException(`Unsupported scope level: ${scopeLevelHeader}`);
|
|
243
|
+
}
|
|
244
|
+
if (scopeLevelHeader === TENANT_SCOPE) {
|
|
245
|
+
if (organizationId) {
|
|
246
|
+
throw new common.BadRequestException('Tenant scope requests must not include Organization-Id.');
|
|
226
247
|
}
|
|
248
|
+
return {
|
|
249
|
+
tenantId,
|
|
250
|
+
level: TENANT_SCOPE,
|
|
251
|
+
organizationId: null
|
|
252
|
+
};
|
|
227
253
|
}
|
|
254
|
+
if (!organizationId) {
|
|
255
|
+
throw new common.BadRequestException('Organization scope requests require Organization-Id.');
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
tenantId,
|
|
259
|
+
level: ORGANIZATION_SCOPE,
|
|
260
|
+
organizationId
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
if (organizationId) {
|
|
264
|
+
return {
|
|
265
|
+
tenantId,
|
|
266
|
+
level: ORGANIZATION_SCOPE,
|
|
267
|
+
organizationId
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
tenantId,
|
|
272
|
+
level: TENANT_SCOPE,
|
|
273
|
+
organizationId: null
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
static getOrganizationId() {
|
|
277
|
+
return this.getScope().organizationId;
|
|
278
|
+
}
|
|
279
|
+
static isTenantScope() {
|
|
280
|
+
return this.getScope().level === TENANT_SCOPE;
|
|
281
|
+
}
|
|
282
|
+
static isOrganizationScope() {
|
|
283
|
+
return this.getScope().level === ORGANIZATION_SCOPE;
|
|
284
|
+
}
|
|
285
|
+
static requireOrganizationScope() {
|
|
286
|
+
const scope = this.getScope();
|
|
287
|
+
if (scope.level !== ORGANIZATION_SCOPE || !scope.organizationId) {
|
|
288
|
+
throw new common.BadRequestException('Organization scope is required for this operation.');
|
|
228
289
|
}
|
|
229
|
-
return organizationId;
|
|
290
|
+
return scope.organizationId;
|
|
230
291
|
}
|
|
231
292
|
static hasPermissions(findPermissions, throwError) {
|
|
232
293
|
const requestContext = RequestContext.currentRequestContext();
|
|
@@ -280,22 +341,22 @@ class RequestContext {
|
|
|
280
341
|
return null;
|
|
281
342
|
}
|
|
282
343
|
/**
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
344
|
+
* Checks if the current user has a specific role.
|
|
345
|
+
* @param {RolesEnum} role - The role to check.
|
|
346
|
+
* @param {boolean} throwError - Flag indicating whether to throw an error if the role is not granted.
|
|
347
|
+
* @returns {boolean} - True if the user has the role, otherwise false.
|
|
348
|
+
*/ static hasRole(role, throwError) {
|
|
288
349
|
return this.hasRoles([
|
|
289
350
|
role
|
|
290
351
|
], throwError);
|
|
291
352
|
}
|
|
292
353
|
/**
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
354
|
+
* Checks if the current request context has any of the specified roles.
|
|
355
|
+
*
|
|
356
|
+
* @param roles - An array of roles to check.
|
|
357
|
+
* @param throwError - Whether to throw an error if no roles are found.
|
|
358
|
+
* @returns True if any of the required roles are found, otherwise false.
|
|
359
|
+
*/ static hasRoles(roles, throwError) {
|
|
299
360
|
const context = RequestContext.currentRequestContext();
|
|
300
361
|
if (context) {
|
|
301
362
|
try {
|
|
@@ -332,8 +393,23 @@ const als = new node_async_hooks.AsyncLocalStorage();
|
|
|
332
393
|
function getRequestContext() {
|
|
333
394
|
return als.getStore();
|
|
334
395
|
}
|
|
396
|
+
function getHeaderValue(req, keys) {
|
|
397
|
+
if (!(req == null ? void 0 : req.headers)) {
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
for (const key of keys){
|
|
401
|
+
const value = req.headers[key];
|
|
402
|
+
if (Array.isArray(value)) {
|
|
403
|
+
var _value_;
|
|
404
|
+
return (_value_ = value[0]) != null ? _value_ : null;
|
|
405
|
+
}
|
|
406
|
+
if (typeof value === 'string' && value) {
|
|
407
|
+
return value;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
335
412
|
|
|
336
|
-
// request-context.middleware.ts
|
|
337
413
|
exports.RequestContextMiddleware = class RequestContextMiddleware {
|
|
338
414
|
use(req, _res, next) {
|
|
339
415
|
var _req_user;
|
|
@@ -434,10 +510,10 @@ class BaseStrategyRegistry {
|
|
|
434
510
|
}
|
|
435
511
|
/**
|
|
436
512
|
* Get strategy by type from the given organization including global strategies as fallback.
|
|
437
|
-
*
|
|
438
|
-
* @param type
|
|
439
|
-
* @param organizationId
|
|
440
|
-
* @returns
|
|
513
|
+
*
|
|
514
|
+
* @param type
|
|
515
|
+
* @param organizationId
|
|
516
|
+
* @returns
|
|
441
517
|
*/ get(type, organizationId) {
|
|
442
518
|
var _this_strategies_get, _this_strategies_get1;
|
|
443
519
|
organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
|
|
@@ -451,34 +527,42 @@ class BaseStrategyRegistry {
|
|
|
451
527
|
}
|
|
452
528
|
/**
|
|
453
529
|
* List all strategies for the given organization including global strategies, or only global strategies if global org is specified.
|
|
454
|
-
*
|
|
455
|
-
* @param organizationId
|
|
456
|
-
* @returns
|
|
530
|
+
*
|
|
531
|
+
* @param organizationId
|
|
532
|
+
* @returns
|
|
457
533
|
*/ list(organizationId) {
|
|
458
|
-
var _this_strategies_get
|
|
534
|
+
var _this_strategies_get;
|
|
459
535
|
organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
|
|
460
536
|
const orgKey = this.resolveOrganization(organizationId);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
537
|
+
const effective = new Map();
|
|
538
|
+
var _this_strategies_get_entries;
|
|
539
|
+
for (const [type, strategy] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
|
|
540
|
+
effective.set(type, strategy);
|
|
541
|
+
}
|
|
542
|
+
if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
|
|
543
|
+
var _this_strategies_get1;
|
|
544
|
+
var _this_strategies_get_entries1;
|
|
545
|
+
for (const [type, strategy] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
|
|
546
|
+
if (!effective.has(type)) {
|
|
547
|
+
effective.set(type, strategy);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return Array.from(effective.values());
|
|
469
552
|
}
|
|
470
553
|
constructor(strategyKey, discoveryService, reflector){
|
|
471
|
-
this.strategyKey = strategyKey;
|
|
472
|
-
this.discoveryService = discoveryService;
|
|
473
|
-
this.reflector = reflector;
|
|
474
554
|
this.logger = new common.Logger(BaseStrategyRegistry.name);
|
|
555
|
+
// Map<organizationId, Map<type, strategy>>
|
|
475
556
|
this.strategies = new Map();
|
|
476
557
|
this.pluginStrategies = new Map();
|
|
558
|
+
this.strategyKey = strategyKey;
|
|
559
|
+
this.discoveryService = discoveryService;
|
|
560
|
+
this.reflector = reflector;
|
|
477
561
|
}
|
|
478
562
|
}
|
|
479
563
|
__decorate([
|
|
480
564
|
common.Inject(exports.StrategyBus),
|
|
481
|
-
__metadata("design:type",
|
|
565
|
+
__metadata("design:type", exports.StrategyBus)
|
|
482
566
|
], BaseStrategyRegistry.prototype, "bus", void 0);
|
|
483
567
|
|
|
484
568
|
exports.IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends BaseStrategyRegistry {
|
|
@@ -488,10 +572,9 @@ exports.IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends
|
|
|
488
572
|
};
|
|
489
573
|
exports.IntegrationStrategyRegistry = __decorate([
|
|
490
574
|
common.Injectable(),
|
|
491
|
-
__metadata("design:type", Function),
|
|
492
575
|
__metadata("design:paramtypes", [
|
|
493
|
-
|
|
494
|
-
|
|
576
|
+
core.DiscoveryService,
|
|
577
|
+
core.Reflector
|
|
495
578
|
])
|
|
496
579
|
], exports.IntegrationStrategyRegistry);
|
|
497
580
|
|
|
@@ -505,10 +588,9 @@ exports.WorkflowTriggerRegistry = class WorkflowTriggerRegistry extends BaseStra
|
|
|
505
588
|
};
|
|
506
589
|
exports.WorkflowTriggerRegistry = __decorate([
|
|
507
590
|
common.Injectable(),
|
|
508
|
-
__metadata("design:type", Function),
|
|
509
591
|
__metadata("design:paramtypes", [
|
|
510
|
-
|
|
511
|
-
|
|
592
|
+
core.DiscoveryService,
|
|
593
|
+
core.Reflector
|
|
512
594
|
])
|
|
513
595
|
], exports.WorkflowTriggerRegistry);
|
|
514
596
|
|
|
@@ -517,21 +599,22 @@ const WORKFLOW_NODE_STRATEGY = 'WORKFLOW_NODE_STRATEGY';
|
|
|
517
599
|
* Decorator to mark a provider as a Workflow Node Strategy
|
|
518
600
|
*/ const WorkflowNodeStrategy = (provider)=>common.applyDecorators(common.SetMetadata(WORKFLOW_NODE_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, WORKFLOW_NODE_STRATEGY));
|
|
519
601
|
|
|
520
|
-
|
|
602
|
+
/**
|
|
603
|
+
* Registry for Workflow Node Strategies
|
|
604
|
+
*/ exports.WorkflowNodeRegistry = class WorkflowNodeRegistry extends BaseStrategyRegistry {
|
|
521
605
|
constructor(discoveryService, reflector){
|
|
522
606
|
super(WORKFLOW_NODE_STRATEGY, discoveryService, reflector);
|
|
523
607
|
}
|
|
524
608
|
};
|
|
525
609
|
exports.WorkflowNodeRegistry = __decorate([
|
|
526
610
|
common.Injectable(),
|
|
527
|
-
__metadata("design:type", Function),
|
|
528
611
|
__metadata("design:paramtypes", [
|
|
529
|
-
|
|
530
|
-
|
|
612
|
+
core.DiscoveryService,
|
|
613
|
+
core.Reflector
|
|
531
614
|
])
|
|
532
615
|
], exports.WorkflowNodeRegistry);
|
|
533
616
|
|
|
534
|
-
const COMMAND_METADATA$
|
|
617
|
+
const COMMAND_METADATA$2 = '__command__';
|
|
535
618
|
/**
|
|
536
619
|
* Wrap Workflow Node Execution Command
|
|
537
620
|
*/ class WrapWorkflowNodeExecutionCommand extends cqrs.Command {
|
|
@@ -542,7 +625,7 @@ const COMMAND_METADATA$1 = '__command__';
|
|
|
542
625
|
}
|
|
543
626
|
}
|
|
544
627
|
WrapWorkflowNodeExecutionCommand.type = '[Workflow] Wrap Workflow Node Execution';
|
|
545
|
-
Reflect.defineMetadata(COMMAND_METADATA$
|
|
628
|
+
Reflect.defineMetadata(COMMAND_METADATA$2, {
|
|
546
629
|
id: WrapWorkflowNodeExecutionCommand.type
|
|
547
630
|
}, WrapWorkflowNodeExecutionCommand);
|
|
548
631
|
|
|
@@ -556,10 +639,9 @@ exports.VectorStoreRegistry = class VectorStoreRegistry extends BaseStrategyRegi
|
|
|
556
639
|
};
|
|
557
640
|
exports.VectorStoreRegistry = __decorate([
|
|
558
641
|
common.Injectable(),
|
|
559
|
-
__metadata("design:type", Function),
|
|
560
642
|
__metadata("design:paramtypes", [
|
|
561
|
-
|
|
562
|
-
|
|
643
|
+
core.DiscoveryService,
|
|
644
|
+
core.Reflector
|
|
563
645
|
])
|
|
564
646
|
], exports.VectorStoreRegistry);
|
|
565
647
|
|
|
@@ -573,10 +655,9 @@ exports.TextSplitterRegistry = class TextSplitterRegistry extends BaseStrategyRe
|
|
|
573
655
|
};
|
|
574
656
|
exports.TextSplitterRegistry = __decorate([
|
|
575
657
|
common.Injectable(),
|
|
576
|
-
__metadata("design:type", Function),
|
|
577
658
|
__metadata("design:paramtypes", [
|
|
578
|
-
|
|
579
|
-
|
|
659
|
+
core.DiscoveryService,
|
|
660
|
+
core.Reflector
|
|
580
661
|
])
|
|
581
662
|
], exports.TextSplitterRegistry);
|
|
582
663
|
|
|
@@ -592,10 +673,9 @@ exports.DocumentSourceRegistry = class DocumentSourceRegistry extends BaseStrate
|
|
|
592
673
|
};
|
|
593
674
|
exports.DocumentSourceRegistry = __decorate([
|
|
594
675
|
common.Injectable(),
|
|
595
|
-
__metadata("design:type", Function),
|
|
596
676
|
__metadata("design:paramtypes", [
|
|
597
|
-
|
|
598
|
-
|
|
677
|
+
core.DiscoveryService,
|
|
678
|
+
core.Reflector
|
|
599
679
|
])
|
|
600
680
|
], exports.DocumentSourceRegistry);
|
|
601
681
|
|
|
@@ -611,10 +691,9 @@ exports.DocumentTransformerRegistry = class DocumentTransformerRegistry extends
|
|
|
611
691
|
};
|
|
612
692
|
exports.DocumentTransformerRegistry = __decorate([
|
|
613
693
|
common.Injectable(),
|
|
614
|
-
__metadata("design:type", Function),
|
|
615
694
|
__metadata("design:paramtypes", [
|
|
616
|
-
|
|
617
|
-
|
|
695
|
+
core.DiscoveryService,
|
|
696
|
+
core.Reflector
|
|
618
697
|
])
|
|
619
698
|
], exports.DocumentTransformerRegistry);
|
|
620
699
|
|
|
@@ -630,16 +709,15 @@ exports.RetrieverRegistry = class RetrieverRegistry extends BaseStrategyRegistry
|
|
|
630
709
|
};
|
|
631
710
|
exports.RetrieverRegistry = __decorate([
|
|
632
711
|
common.Injectable(),
|
|
633
|
-
__metadata("design:type", Function),
|
|
634
712
|
__metadata("design:paramtypes", [
|
|
635
|
-
|
|
636
|
-
|
|
713
|
+
core.DiscoveryService,
|
|
714
|
+
core.Reflector
|
|
637
715
|
])
|
|
638
716
|
], exports.RetrieverRegistry);
|
|
639
717
|
|
|
640
718
|
/**
|
|
641
719
|
* Merge parent chunks with their child chunks based on metadata (parentId and chunkId)
|
|
642
|
-
*
|
|
720
|
+
*
|
|
643
721
|
* @deprecated use buildChunkTreeAndFindLeaves instead
|
|
644
722
|
*/ function mergeParentChildChunks(chunks, children // Child chunks
|
|
645
723
|
) {
|
|
@@ -705,10 +783,9 @@ exports.ImageUnderstandingRegistry = class ImageUnderstandingRegistry extends Ba
|
|
|
705
783
|
};
|
|
706
784
|
exports.ImageUnderstandingRegistry = __decorate([
|
|
707
785
|
common.Injectable(),
|
|
708
|
-
__metadata("design:type", Function),
|
|
709
786
|
__metadata("design:paramtypes", [
|
|
710
|
-
|
|
711
|
-
|
|
787
|
+
core.DiscoveryService,
|
|
788
|
+
core.Reflector
|
|
712
789
|
])
|
|
713
790
|
], exports.ImageUnderstandingRegistry);
|
|
714
791
|
|
|
@@ -722,10 +799,9 @@ exports.KnowledgeStrategyRegistry = class KnowledgeStrategyRegistry extends Base
|
|
|
722
799
|
};
|
|
723
800
|
exports.KnowledgeStrategyRegistry = __decorate([
|
|
724
801
|
common.Injectable(),
|
|
725
|
-
__metadata("design:type", Function),
|
|
726
802
|
__metadata("design:paramtypes", [
|
|
727
|
-
|
|
728
|
-
|
|
803
|
+
core.DiscoveryService,
|
|
804
|
+
core.Reflector
|
|
729
805
|
])
|
|
730
806
|
], exports.KnowledgeStrategyRegistry);
|
|
731
807
|
|
|
@@ -741,10 +817,9 @@ exports.ToolsetRegistry = class ToolsetRegistry extends BaseStrategyRegistry {
|
|
|
741
817
|
};
|
|
742
818
|
exports.ToolsetRegistry = __decorate([
|
|
743
819
|
common.Injectable(),
|
|
744
|
-
__metadata("design:type", Function),
|
|
745
820
|
__metadata("design:paramtypes", [
|
|
746
|
-
|
|
747
|
-
|
|
821
|
+
core.DiscoveryService,
|
|
822
|
+
core.Reflector
|
|
748
823
|
])
|
|
749
824
|
], exports.ToolsetRegistry);
|
|
750
825
|
|
|
@@ -752,26 +827,26 @@ exports.ToolsetRegistry = __decorate([
|
|
|
752
827
|
* Base ability for all toolsets
|
|
753
828
|
*/ class BaseToolset extends tools.BaseToolkit {
|
|
754
829
|
/**
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
830
|
+
* Async init tools
|
|
831
|
+
*
|
|
832
|
+
* @returns
|
|
833
|
+
*/ async initTools() {
|
|
759
834
|
return this.tools;
|
|
760
835
|
}
|
|
761
836
|
/**
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
837
|
+
* Get one tool
|
|
838
|
+
*
|
|
839
|
+
* @param toolName
|
|
840
|
+
* @returns
|
|
841
|
+
*/ getTool(toolName) {
|
|
767
842
|
var _this_getTools;
|
|
768
843
|
return (_this_getTools = this.getTools()) == null ? void 0 : _this_getTools.find((tool)=>tool.name === toolName);
|
|
769
844
|
}
|
|
770
845
|
/**
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
846
|
+
* Get state variables config
|
|
847
|
+
*
|
|
848
|
+
* @returns State variables
|
|
849
|
+
*/ async getVariables() {
|
|
775
850
|
return null;
|
|
776
851
|
}
|
|
777
852
|
/**
|
|
@@ -829,26 +904,26 @@ class BuiltinToolset extends BaseToolset {
|
|
|
829
904
|
return (_this_toolset = this.toolset) == null ? void 0 : _this_toolset.credentials;
|
|
830
905
|
}
|
|
831
906
|
getToolTitle(name) {
|
|
832
|
-
var _this_toolset_tools, _this_toolset,
|
|
907
|
+
var _this_toolset_tools, _this_toolset, _tool_schema;
|
|
833
908
|
const tool = (_this_toolset = this.toolset) == null ? void 0 : (_this_toolset_tools = _this_toolset.tools) == null ? void 0 : _this_toolset_tools.find((tool)=>tool.name === name);
|
|
834
|
-
const identity =
|
|
909
|
+
const identity = tool == null ? void 0 : (_tool_schema = tool.schema) == null ? void 0 : _tool_schema.identity;
|
|
835
910
|
if (identity) {
|
|
836
911
|
return identity.label;
|
|
837
912
|
}
|
|
838
913
|
return null;
|
|
839
914
|
}
|
|
840
915
|
/**
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
916
|
+
* Get credentials schema
|
|
917
|
+
*
|
|
918
|
+
* @returns Credentials schema
|
|
919
|
+
*/ getCredentialsSchema() {
|
|
845
920
|
return _extends({}, this.credentialsSchema);
|
|
846
921
|
}
|
|
847
922
|
/**
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
923
|
+
* Get toolset entity
|
|
924
|
+
*
|
|
925
|
+
* @returns XpertToolset
|
|
926
|
+
*/ getToolset() {
|
|
852
927
|
return this.toolset;
|
|
853
928
|
}
|
|
854
929
|
getName() {
|
|
@@ -857,27 +932,27 @@ class BuiltinToolset extends BaseToolset {
|
|
|
857
932
|
}
|
|
858
933
|
constructor(providerName, toolset, params){
|
|
859
934
|
super(params);
|
|
935
|
+
this.logger = new common.Logger(this.constructor.name);
|
|
860
936
|
this.providerName = providerName;
|
|
861
937
|
this.toolset = toolset;
|
|
862
938
|
this.params = params;
|
|
863
|
-
this.logger = new common.Logger(this.constructor.name);
|
|
864
939
|
}
|
|
865
|
-
}
|
|
940
|
+
}
|
|
866
941
|
BuiltinToolset.provider = '';
|
|
867
942
|
|
|
868
943
|
/**
|
|
869
944
|
* Restricted FileSystem based on granted permissions
|
|
870
945
|
*/ class XpFileSystem {
|
|
871
946
|
/**
|
|
872
|
-
|
|
873
|
-
|
|
947
|
+
* Check if operation is allowed
|
|
948
|
+
*/ ensureAllowed(op) {
|
|
874
949
|
if (!this.allowedOps.has(op)) {
|
|
875
950
|
throw new Error(`Permission denied: ${op} operation not allowed`);
|
|
876
951
|
}
|
|
877
952
|
}
|
|
878
953
|
/**
|
|
879
|
-
|
|
880
|
-
|
|
954
|
+
* Check if path is within scope
|
|
955
|
+
*/ ensureInScope(targetPath) {
|
|
881
956
|
if (!this.scope || this.scope.length === 0) return;
|
|
882
957
|
const resolved = path.resolve(targetPath);
|
|
883
958
|
for (const s of this.scope){
|
|
@@ -887,33 +962,32 @@ BuiltinToolset.provider = '';
|
|
|
887
962
|
throw new Error(`Permission denied: path "${targetPath}" is out of scope`);
|
|
888
963
|
}
|
|
889
964
|
/**
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
965
|
+
* Get the absolute path of file in the file system.
|
|
966
|
+
*
|
|
967
|
+
* @param filePath Relative file path
|
|
968
|
+
* @returns Absolute file path
|
|
969
|
+
*/ fullPath(filePath) {
|
|
895
970
|
return path.join(this.basePath, filePath);
|
|
896
971
|
}
|
|
897
972
|
/**
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
return url.href;
|
|
973
|
+
* Get web url for a given file path in the file system.
|
|
974
|
+
*
|
|
975
|
+
* @param filePath Relative file path
|
|
976
|
+
* @returns Web URL of file
|
|
977
|
+
*/ fullUrl(filePath) {
|
|
978
|
+
return this.buildUrl(filePath);
|
|
905
979
|
}
|
|
906
980
|
/**
|
|
907
|
-
|
|
908
|
-
|
|
981
|
+
* Read file contents
|
|
982
|
+
*/ async readFile(filePath, encoding = 'utf-8') {
|
|
909
983
|
this.ensureAllowed('read');
|
|
910
984
|
const fullPath = this.fullPath(filePath);
|
|
911
985
|
this.ensureInScope(fullPath);
|
|
912
986
|
return await fsPromises.readFile(fullPath);
|
|
913
987
|
}
|
|
914
988
|
/**
|
|
915
|
-
|
|
916
|
-
|
|
989
|
+
* Write file contents
|
|
990
|
+
*/ async writeFile(filePath, content) {
|
|
917
991
|
this.ensureAllowed('write');
|
|
918
992
|
const fullPath = this.fullPath(filePath);
|
|
919
993
|
this.ensureInScope(fullPath);
|
|
@@ -921,26 +995,25 @@ BuiltinToolset.provider = '';
|
|
|
921
995
|
recursive: true
|
|
922
996
|
});
|
|
923
997
|
await fsPromises.writeFile(fullPath, content);
|
|
924
|
-
|
|
925
|
-
return url.href;
|
|
998
|
+
return this.buildUrl(filePath);
|
|
926
999
|
}
|
|
927
1000
|
/**
|
|
928
|
-
|
|
929
|
-
|
|
1001
|
+
* Delete a file
|
|
1002
|
+
*/ async deleteFile(filePath) {
|
|
930
1003
|
this.ensureAllowed('delete');
|
|
931
1004
|
this.ensureInScope(filePath);
|
|
932
1005
|
await fsPromises.unlink(filePath);
|
|
933
1006
|
}
|
|
934
1007
|
/**
|
|
935
|
-
|
|
936
|
-
|
|
1008
|
+
* List directory contents
|
|
1009
|
+
*/ async listDir(dirPath) {
|
|
937
1010
|
this.ensureAllowed('list');
|
|
938
1011
|
this.ensureInScope(dirPath);
|
|
939
1012
|
return fsPromises.readdir(dirPath);
|
|
940
1013
|
}
|
|
941
1014
|
/**
|
|
942
|
-
|
|
943
|
-
|
|
1015
|
+
* Utility: check if a file or directory exists
|
|
1016
|
+
*/ async exists(targetPath) {
|
|
944
1017
|
try {
|
|
945
1018
|
await fsPromises.access(targetPath);
|
|
946
1019
|
return true;
|
|
@@ -948,6 +1021,23 @@ BuiltinToolset.provider = '';
|
|
|
948
1021
|
return false;
|
|
949
1022
|
}
|
|
950
1023
|
}
|
|
1024
|
+
// Keep URL generation tolerant of protocol-relative base URLs like "//localhost:3000",
|
|
1025
|
+
// which are used by the current dev config and would otherwise make `new URL()` throw.
|
|
1026
|
+
buildUrl(filePath) {
|
|
1027
|
+
if (/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(filePath) || filePath.startsWith('//')) {
|
|
1028
|
+
return filePath;
|
|
1029
|
+
}
|
|
1030
|
+
const normalizedPath = this.encodePath(`${filePath}`.replace(/^\/+/, ''));
|
|
1031
|
+
const normalizedBaseUrl = `${this.baseUrl}`.replace(/\/+$/, '');
|
|
1032
|
+
if (normalizedBaseUrl.startsWith('//')) {
|
|
1033
|
+
return `${normalizedBaseUrl}/${normalizedPath}`;
|
|
1034
|
+
}
|
|
1035
|
+
const url = new URL(normalizedPath, `${normalizedBaseUrl}/`);
|
|
1036
|
+
return url.href;
|
|
1037
|
+
}
|
|
1038
|
+
encodePath(filePath) {
|
|
1039
|
+
return filePath.split('/').map((segment)=>encodeURIComponent(segment)).join('/');
|
|
1040
|
+
}
|
|
951
1041
|
constructor(permission, basePath, baseUrl){
|
|
952
1042
|
this.basePath = basePath;
|
|
953
1043
|
this.baseUrl = baseUrl;
|
|
@@ -1047,7 +1137,7 @@ function loadYamlFile(filePath, logger, ignoreError = true, defaultValue = {}) {
|
|
|
1047
1137
|
}
|
|
1048
1138
|
/**
|
|
1049
1139
|
* Get the mapping from name to index from a YAML file
|
|
1050
|
-
*
|
|
1140
|
+
*
|
|
1051
1141
|
* @param folderPath
|
|
1052
1142
|
* @param fileName the YAML file name, default to '_position.yaml'
|
|
1053
1143
|
* @return a dict with name as key and index as value
|
|
@@ -1116,10 +1206,9 @@ exports.DataSourceStrategyRegistry = class DataSourceStrategyRegistry extends Ba
|
|
|
1116
1206
|
};
|
|
1117
1207
|
exports.DataSourceStrategyRegistry = __decorate([
|
|
1118
1208
|
common.Injectable(),
|
|
1119
|
-
__metadata("design:type", Function),
|
|
1120
1209
|
__metadata("design:paramtypes", [
|
|
1121
|
-
|
|
1122
|
-
|
|
1210
|
+
core.DiscoveryService,
|
|
1211
|
+
core.Reflector
|
|
1123
1212
|
])
|
|
1124
1213
|
], exports.DataSourceStrategyRegistry);
|
|
1125
1214
|
|
|
@@ -1128,12 +1217,12 @@ exports.DataSourceStrategyRegistry = __decorate([
|
|
|
1128
1217
|
* into datasource strategies consumable by the plugin SDK.
|
|
1129
1218
|
*/ class AdapterDataSourceStrategy {
|
|
1130
1219
|
/**
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1220
|
+
* Get from cache or create new instance of DB adapter.
|
|
1221
|
+
*
|
|
1222
|
+
* @param options
|
|
1223
|
+
* @param id
|
|
1224
|
+
* @returns
|
|
1225
|
+
*/ async create(options, id) {
|
|
1137
1226
|
if (id) {
|
|
1138
1227
|
if (this.runners.has(id)) {
|
|
1139
1228
|
return this.runners.get(id);
|
|
@@ -1169,9 +1258,10 @@ exports.DataSourceStrategyRegistry = __decorate([
|
|
|
1169
1258
|
return this.runnerClass;
|
|
1170
1259
|
}
|
|
1171
1260
|
constructor(runnerClass, extraArgs = []){
|
|
1261
|
+
this.runners = new Map() // dataSourceId -> runner instance
|
|
1262
|
+
;
|
|
1172
1263
|
this.runnerClass = runnerClass;
|
|
1173
1264
|
this.extraArgs = extraArgs;
|
|
1174
|
-
this.runners = new Map();
|
|
1175
1265
|
}
|
|
1176
1266
|
}
|
|
1177
1267
|
|
|
@@ -1271,13 +1361,13 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1271
1361
|
await this.runQuery(`SELECT 1`);
|
|
1272
1362
|
}
|
|
1273
1363
|
/**
|
|
1274
|
-
|
|
1275
|
-
|
|
1364
|
+
* Default implementation for table operations
|
|
1365
|
+
*/ async tableOp(action, params, options) {
|
|
1276
1366
|
switch(action){
|
|
1277
|
-
case
|
|
1367
|
+
case exports.DBTableAction.CREATE_TABLE:
|
|
1278
1368
|
{
|
|
1279
1369
|
// Default implementation for creating table (generic SQL syntax)
|
|
1280
|
-
const { schema, table, columns, createMode =
|
|
1370
|
+
const { schema, table, columns, createMode = exports.DBCreateTableMode.ERROR } = params;
|
|
1281
1371
|
const tableName = schema ? `${schema}.${table}` : table;
|
|
1282
1372
|
// Check if table exists (try to query table info)
|
|
1283
1373
|
let exists = false;
|
|
@@ -1289,17 +1379,17 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1289
1379
|
exists = false;
|
|
1290
1380
|
}
|
|
1291
1381
|
// --- MODE: ERROR → throw error if table exists ---
|
|
1292
|
-
if (exists && createMode ===
|
|
1382
|
+
if (exists && createMode === exports.DBCreateTableMode.ERROR) {
|
|
1293
1383
|
throw new Error(`Table "${tableName}" already exists`);
|
|
1294
1384
|
}
|
|
1295
1385
|
// --- MODE: IGNORE → do nothing if exists ---
|
|
1296
|
-
if (exists && createMode ===
|
|
1386
|
+
if (exists && createMode === exports.DBCreateTableMode.IGNORE) {
|
|
1297
1387
|
return;
|
|
1298
1388
|
}
|
|
1299
1389
|
// --- MODE: UPGRADE → auto upgrade (simple implementation: only add new columns) ---
|
|
1300
1390
|
// Note: This default implementation does not support modifying column types,
|
|
1301
1391
|
// recommend each database to implement its own version
|
|
1302
|
-
if (exists && createMode ===
|
|
1392
|
+
if (exists && createMode === exports.DBCreateTableMode.UPGRADE) {
|
|
1303
1393
|
console.warn(`[BaseSQLQueryRunner] UPGRADE mode uses basic implementation. Consider implementing tableOp for better support.`);
|
|
1304
1394
|
// Try to add new columns (will fail if column already exists, but doesn't affect)
|
|
1305
1395
|
for (const col of columns){
|
|
@@ -1324,7 +1414,7 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1324
1414
|
await this.runQuery(createTableStatement, options);
|
|
1325
1415
|
return;
|
|
1326
1416
|
}
|
|
1327
|
-
case
|
|
1417
|
+
case exports.DBTableAction.DROP_TABLE:
|
|
1328
1418
|
{
|
|
1329
1419
|
// Default implementation for dropping table
|
|
1330
1420
|
const { schema, table } = params;
|
|
@@ -1338,8 +1428,8 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1338
1428
|
}
|
|
1339
1429
|
}
|
|
1340
1430
|
/**
|
|
1341
|
-
|
|
1342
|
-
|
|
1431
|
+
* Generic type mapping (subclasses can override)
|
|
1432
|
+
*/ mapColumnType(type, isKey, length) {
|
|
1343
1433
|
switch(type == null ? void 0 : type.toLowerCase()){
|
|
1344
1434
|
case 'string':
|
|
1345
1435
|
return length ? `VARCHAR(${length})` : isKey ? 'VARCHAR(255)' : 'VARCHAR(1000)';
|
|
@@ -1359,8 +1449,8 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1359
1449
|
}
|
|
1360
1450
|
constructor(...args){
|
|
1361
1451
|
super(...args);
|
|
1362
|
-
this.syntax =
|
|
1363
|
-
this.protocol =
|
|
1452
|
+
this.syntax = exports.DBSyntaxEnum.SQL;
|
|
1453
|
+
this.protocol = exports.DBProtocolEnum.SQL;
|
|
1364
1454
|
}
|
|
1365
1455
|
}
|
|
1366
1456
|
exports.DBTableAction = void 0;
|
|
@@ -1381,7 +1471,9 @@ exports.DBTableAction = void 0;
|
|
|
1381
1471
|
DBTableAction["CLONE_TABLE"] = "cloneTable";
|
|
1382
1472
|
DBTableAction["OPTIMIZE_TABLE"] = "optimizeTable";
|
|
1383
1473
|
})(exports.DBTableAction || (exports.DBTableAction = {}));
|
|
1384
|
-
|
|
1474
|
+
/**
|
|
1475
|
+
* Modes for creating a table, if the table already exists
|
|
1476
|
+
*/ exports.DBCreateTableMode = void 0;
|
|
1385
1477
|
(function(DBCreateTableMode) {
|
|
1386
1478
|
DBCreateTableMode["ERROR"] = "error";
|
|
1387
1479
|
DBCreateTableMode["IGNORE"] = "ignore";
|
|
@@ -1411,8 +1503,7 @@ function AIModelProviderStrategy(provider) {
|
|
|
1411
1503
|
const match = (callerLine == null ? void 0 : callerLine.match(/\((file:\/\/\/[^\s)]+)\)/)) || (// case 1: file:///path...
|
|
1412
1504
|
callerLine == null ? void 0 : callerLine.match(/\((\/[^\s)]+)\)/)) || (// case 2: (/Users/xxx)
|
|
1413
1505
|
callerLine == null ? void 0 : callerLine.match(/at (file:\/\/\/[^\s]+)/)) || (// case 3: at file:///...
|
|
1414
|
-
callerLine == null ? void 0 : callerLine.match(/at (\/[^\s]+)/) // case 4: at /Users/xxx
|
|
1415
|
-
);
|
|
1506
|
+
callerLine == null ? void 0 : callerLine.match(/at (\/[^\s]+)/)); // case 4: at /Users/xxx
|
|
1416
1507
|
let file = match == null ? void 0 : match[1];
|
|
1417
1508
|
// remove the file:/// prefix
|
|
1418
1509
|
if (file == null ? void 0 : file.startsWith('file:///')) {
|
|
@@ -1447,10 +1538,9 @@ exports.AIModelProviderRegistry = class AIModelProviderRegistry extends BaseStra
|
|
|
1447
1538
|
};
|
|
1448
1539
|
exports.AIModelProviderRegistry = __decorate([
|
|
1449
1540
|
common.Injectable(),
|
|
1450
|
-
__metadata("design:type", Function),
|
|
1451
1541
|
__metadata("design:paramtypes", [
|
|
1452
|
-
|
|
1453
|
-
|
|
1542
|
+
core.DiscoveryService,
|
|
1543
|
+
core.Reflector
|
|
1454
1544
|
])
|
|
1455
1545
|
], exports.AIModelProviderRegistry);
|
|
1456
1546
|
|
|
@@ -1461,7 +1551,8 @@ class CredentialsValidateFailedError extends common.ForbiddenException {
|
|
|
1461
1551
|
class AIModelProviderNotFoundException extends common.NotFoundException {
|
|
1462
1552
|
}
|
|
1463
1553
|
|
|
1464
|
-
|
|
1554
|
+
var ModelProvider_1;
|
|
1555
|
+
exports.ModelProvider = ModelProvider_1 = class ModelProvider {
|
|
1465
1556
|
get name() {
|
|
1466
1557
|
return this.getProviderSchema().provider;
|
|
1467
1558
|
}
|
|
@@ -1469,10 +1560,10 @@ exports.ModelProvider = class ModelProvider {
|
|
|
1469
1560
|
await this.validateProviderCredentials(credentials);
|
|
1470
1561
|
}
|
|
1471
1562
|
/**
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1563
|
+
* Get provider lib root path.
|
|
1564
|
+
*
|
|
1565
|
+
* @returns Root of library
|
|
1566
|
+
*/ getProviderServerPath() {
|
|
1476
1567
|
return this.dir;
|
|
1477
1568
|
}
|
|
1478
1569
|
getProviderSchema() {
|
|
@@ -1507,11 +1598,11 @@ exports.ModelProvider = class ModelProvider {
|
|
|
1507
1598
|
return modelInstance;
|
|
1508
1599
|
}
|
|
1509
1600
|
/**
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1601
|
+
* Get provider models.
|
|
1602
|
+
* @param modelType - model type
|
|
1603
|
+
* @param onlyActive - only active models
|
|
1604
|
+
* @return provider models
|
|
1605
|
+
*/ getProviderModels(modelType, onlyActive = false) {
|
|
1515
1606
|
let modelTypes = [];
|
|
1516
1607
|
if (modelType) {
|
|
1517
1608
|
modelTypes.push(modelType);
|
|
@@ -1563,7 +1654,7 @@ exports.ModelProvider = class ModelProvider {
|
|
|
1563
1654
|
return null;
|
|
1564
1655
|
}
|
|
1565
1656
|
constructor(){
|
|
1566
|
-
this.logger = new common.Logger(
|
|
1657
|
+
this.logger = new common.Logger(ModelProvider_1.name);
|
|
1567
1658
|
// protected providerSchema: IAiProviderEntity | null = null
|
|
1568
1659
|
this.modelManagers = new Map();
|
|
1569
1660
|
const provider = Reflect.getMetadata(AI_MODEL_PROVIDER, this.constructor);
|
|
@@ -1573,9 +1664,8 @@ exports.ModelProvider = class ModelProvider {
|
|
|
1573
1664
|
this.dir = dir;
|
|
1574
1665
|
}
|
|
1575
1666
|
};
|
|
1576
|
-
exports.ModelProvider = __decorate([
|
|
1667
|
+
exports.ModelProvider = ModelProvider_1 = __decorate([
|
|
1577
1668
|
common.Injectable(),
|
|
1578
|
-
__metadata("design:type", Function),
|
|
1579
1669
|
__metadata("design:paramtypes", [])
|
|
1580
1670
|
], exports.ModelProvider);
|
|
1581
1671
|
|
|
@@ -1764,7 +1854,8 @@ function mergeCredentials(credentials, modelProperties) {
|
|
|
1764
1854
|
return _extends({}, credentials != null ? credentials : {}, modelProperties != null ? modelProperties : {});
|
|
1765
1855
|
}
|
|
1766
1856
|
|
|
1767
|
-
|
|
1857
|
+
var AIModel_1;
|
|
1858
|
+
let AIModel = AIModel_1 = class AIModel {
|
|
1768
1859
|
getChatModel(copilotModel, options) {
|
|
1769
1860
|
throw new Error(`Unsupport chat model!`);
|
|
1770
1861
|
}
|
|
@@ -1839,13 +1930,13 @@ let AIModel = class AIModel {
|
|
|
1839
1930
|
return null;
|
|
1840
1931
|
}
|
|
1841
1932
|
/**
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1933
|
+
* Get customizable model schema.
|
|
1934
|
+
* Implement this method in ai model sub class that can customize model
|
|
1935
|
+
*
|
|
1936
|
+
* @param model model name
|
|
1937
|
+
* @param credentials model credentials
|
|
1938
|
+
* @returns model schema
|
|
1939
|
+
*/ getCustomizableModelSchemaFromCredentials(model, credentials) {
|
|
1849
1940
|
return null;
|
|
1850
1941
|
}
|
|
1851
1942
|
processParameterRules(yamlData) {
|
|
@@ -1917,29 +2008,28 @@ let AIModel = class AIModel {
|
|
|
1917
2008
|
};
|
|
1918
2009
|
}
|
|
1919
2010
|
constructor(modelProvider, modelType){
|
|
1920
|
-
this.
|
|
1921
|
-
this.modelType = modelType;
|
|
1922
|
-
this.logger = new common.Logger(AIModel.name);
|
|
2011
|
+
this.logger = new common.Logger(AIModel_1.name);
|
|
1923
2012
|
this.modelSchemas = null;
|
|
1924
2013
|
this.positions = null;
|
|
2014
|
+
this.modelProvider = modelProvider;
|
|
2015
|
+
this.modelType = modelType;
|
|
1925
2016
|
this.modelProvider.registerAIModelInstance(this.modelType, this);
|
|
1926
2017
|
}
|
|
1927
2018
|
};
|
|
1928
|
-
AIModel = __decorate([
|
|
2019
|
+
AIModel = AIModel_1 = __decorate([
|
|
1929
2020
|
common.Injectable(),
|
|
1930
|
-
__metadata("design:type", Function),
|
|
1931
2021
|
__metadata("design:paramtypes", [
|
|
1932
|
-
|
|
1933
|
-
|
|
2022
|
+
exports.ModelProvider,
|
|
2023
|
+
String
|
|
1934
2024
|
])
|
|
1935
2025
|
], AIModel);
|
|
1936
2026
|
function getDefaultParameterRuleVariableMap(name) {
|
|
1937
2027
|
/**
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2028
|
+
* Get default parameter rule for given name
|
|
2029
|
+
*
|
|
2030
|
+
* @param name - parameter name
|
|
2031
|
+
* @return parameter rule
|
|
2032
|
+
*/ const defaultParameterRule = PARAMETER_RULE_TEMPLATE[name];
|
|
1943
2033
|
if (!defaultParameterRule) {
|
|
1944
2034
|
throw new Error(`Invalid model parameter rule name ${name}`);
|
|
1945
2035
|
}
|
|
@@ -2005,17 +2095,18 @@ function _class_private_field_loose_key(name) {
|
|
|
2005
2095
|
return "__private_" + id++ + "_" + name;
|
|
2006
2096
|
}
|
|
2007
2097
|
|
|
2098
|
+
var _a;
|
|
2008
2099
|
class LLMUsage {
|
|
2009
2100
|
static emptyUsage() {
|
|
2010
2101
|
return new LLMUsage(0, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0, 0.0, 'USD', 0.0);
|
|
2011
2102
|
}
|
|
2012
2103
|
plus(other) {
|
|
2013
2104
|
/**
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2105
|
+
* Add two LLMUsage instances together.
|
|
2106
|
+
*
|
|
2107
|
+
* @param other: Another LLMUsage instance to add
|
|
2108
|
+
* @return: A new LLMUsage instance with summed values
|
|
2109
|
+
*/ if (this.totalTokens === 0) {
|
|
2019
2110
|
return other;
|
|
2020
2111
|
} else {
|
|
2021
2112
|
return new LLMUsage(this.promptTokens + other.promptTokens, other.promptUnitPrice, other.promptPriceUnit, this.promptPrice + other.promptPrice, this.completionTokens + other.completionTokens, other.completionUnitPrice, other.completionPriceUnit, this.completionPrice + other.completionPrice, this.totalTokens + other.totalTokens, this.totalPrice + other.totalPrice, other.currency, this.latency + other.latency);
|
|
@@ -2023,11 +2114,11 @@ class LLMUsage {
|
|
|
2023
2114
|
}
|
|
2024
2115
|
add(other) {
|
|
2025
2116
|
/**
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2117
|
+
* Overload the + operator to add two LLMUsage instances.
|
|
2118
|
+
*
|
|
2119
|
+
* @param other: Another LLMUsage instance to add
|
|
2120
|
+
* @return: A new LLMUsage instance with summed values
|
|
2121
|
+
*/ return this.plus(other);
|
|
2031
2122
|
}
|
|
2032
2123
|
constructor(promptTokens, promptUnitPrice, promptPriceUnit, promptPrice, completionTokens, completionUnitPrice, completionPriceUnit, completionPrice, totalTokens, totalPrice, currency, latency){
|
|
2033
2124
|
this.promptTokens = promptTokens;
|
|
@@ -2225,9 +2316,10 @@ class LargeLanguageModel extends AIModel {
|
|
|
2225
2316
|
writable: true,
|
|
2226
2317
|
value: void 0
|
|
2227
2318
|
});
|
|
2228
|
-
_class_private_field_loose_base(this, _logger)[_logger] = new common.Logger(
|
|
2319
|
+
_class_private_field_loose_base(this, _logger)[_logger] = new common.Logger(_a.name);
|
|
2229
2320
|
}
|
|
2230
2321
|
}
|
|
2322
|
+
_a = LargeLanguageModel;
|
|
2231
2323
|
function calcTokenUsage(output) {
|
|
2232
2324
|
var _output_generations;
|
|
2233
2325
|
const tokenUsage = {
|
|
@@ -2275,8 +2367,8 @@ function calcTokenUsage(output) {
|
|
|
2275
2367
|
* In this way, the reasoning process in the model output can be separated from the main content, making it easier for subsequent structured processing and display.
|
|
2276
2368
|
*/ class ChatOAICompatReasoningModel extends openai.ChatOpenAICompletions {
|
|
2277
2369
|
/**
|
|
2278
|
-
|
|
2279
|
-
|
|
2370
|
+
*
|
|
2371
|
+
*/ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2280
2372
|
delta, rawResponse, defaultRole) {
|
|
2281
2373
|
const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole);
|
|
2282
2374
|
if (delta['content'] === '<think>') {
|
|
@@ -2462,7 +2554,7 @@ function normalizeContextSize(value) {
|
|
|
2462
2554
|
return undefined;
|
|
2463
2555
|
}
|
|
2464
2556
|
|
|
2465
|
-
const COMMAND_METADATA = '__command__';
|
|
2557
|
+
const COMMAND_METADATA$1 = '__command__';
|
|
2466
2558
|
/**
|
|
2467
2559
|
* Get a Chat Model of copilot model and check it's token limitation, record the token usage
|
|
2468
2560
|
*/ class CreateModelClientCommand extends cqrs.Command {
|
|
@@ -2473,10 +2565,26 @@ const COMMAND_METADATA = '__command__';
|
|
|
2473
2565
|
}
|
|
2474
2566
|
}
|
|
2475
2567
|
CreateModelClientCommand.type = '[AI Model] Create Model Client';
|
|
2476
|
-
Reflect.defineMetadata(COMMAND_METADATA, {
|
|
2568
|
+
Reflect.defineMetadata(COMMAND_METADATA$1, {
|
|
2477
2569
|
id: CreateModelClientCommand.type
|
|
2478
2570
|
}, CreateModelClientCommand);
|
|
2479
2571
|
|
|
2572
|
+
const SKILL_SOURCE_PROVIDER = 'SKILL_SOURCE_PROVIDER';
|
|
2573
|
+
const SkillSourceProviderStrategy = (provider)=>common.applyDecorators(common.SetMetadata(SKILL_SOURCE_PROVIDER, provider), common.SetMetadata(STRATEGY_META_KEY, SKILL_SOURCE_PROVIDER));
|
|
2574
|
+
|
|
2575
|
+
exports.SkillSourceProviderRegistry = class SkillSourceProviderRegistry extends BaseStrategyRegistry {
|
|
2576
|
+
constructor(discoveryService, reflector){
|
|
2577
|
+
super(SKILL_SOURCE_PROVIDER, discoveryService, reflector);
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
exports.SkillSourceProviderRegistry = __decorate([
|
|
2581
|
+
common.Injectable(),
|
|
2582
|
+
__metadata("design:paramtypes", [
|
|
2583
|
+
core.DiscoveryService,
|
|
2584
|
+
core.Reflector
|
|
2585
|
+
])
|
|
2586
|
+
], exports.SkillSourceProviderRegistry);
|
|
2587
|
+
|
|
2480
2588
|
const AGENT_MIDDLEWARE_STRATEGY = 'AGENT_MIDDLEWARE_STRATEGY';
|
|
2481
2589
|
const AgentMiddlewareStrategy = (provider)=>common.applyDecorators(common.SetMetadata(AGENT_MIDDLEWARE_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, AGENT_MIDDLEWARE_STRATEGY));
|
|
2482
2590
|
|
|
@@ -2487,10 +2595,9 @@ exports.AgentMiddlewareRegistry = class AgentMiddlewareRegistry extends BaseStra
|
|
|
2487
2595
|
};
|
|
2488
2596
|
exports.AgentMiddlewareRegistry = __decorate([
|
|
2489
2597
|
common.Injectable(),
|
|
2490
|
-
__metadata("design:type", Function),
|
|
2491
2598
|
__metadata("design:paramtypes", [
|
|
2492
|
-
|
|
2493
|
-
|
|
2599
|
+
core.DiscoveryService,
|
|
2600
|
+
core.Reflector
|
|
2494
2601
|
])
|
|
2495
2602
|
], exports.AgentMiddlewareRegistry);
|
|
2496
2603
|
|
|
@@ -2502,15 +2609,7 @@ exports.AgentMiddlewareRegistry = __decorate([
|
|
|
2502
2609
|
"end"
|
|
2503
2610
|
];
|
|
2504
2611
|
|
|
2505
|
-
|
|
2506
|
-
* Structured message types (suggested format):
|
|
2507
|
-
* - channel.{provider}.{action}.v{number}
|
|
2508
|
-
* - agent.{action}.v{number}
|
|
2509
|
-
* - system.{action}.v{number}
|
|
2510
|
-
* - plugin.{domain}.{action}.v{number}
|
|
2511
|
-
*
|
|
2512
|
-
* Note: At runtime, any string type is still allowed, facilitating dynamic extension by plugins.
|
|
2513
|
-
*/ const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
|
|
2612
|
+
const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
|
|
2514
2613
|
const VERSION_PATTERN = /^v[1-9][0-9]*$/;
|
|
2515
2614
|
function assertSegment(input, name) {
|
|
2516
2615
|
if (!SEGMENT_PATTERN.test(input)) {
|
|
@@ -2576,10 +2675,9 @@ exports.HandoffProcessorRegistry = class HandoffProcessorRegistry extends BaseSt
|
|
|
2576
2675
|
};
|
|
2577
2676
|
exports.HandoffProcessorRegistry = __decorate([
|
|
2578
2677
|
common.Injectable(),
|
|
2579
|
-
__metadata("design:type", Function),
|
|
2580
2678
|
__metadata("design:paramtypes", [
|
|
2581
|
-
|
|
2582
|
-
|
|
2679
|
+
core.DiscoveryService,
|
|
2680
|
+
core.Reflector
|
|
2583
2681
|
])
|
|
2584
2682
|
], exports.HandoffProcessorRegistry);
|
|
2585
2683
|
|
|
@@ -2688,26 +2786,52 @@ exports.HandoffProcessorRegistry = __decorate([
|
|
|
2688
2786
|
* ```
|
|
2689
2787
|
*/ const ChatChannel = (type)=>common.SetMetadata(CHAT_CHANNEL, type);
|
|
2690
2788
|
|
|
2691
|
-
|
|
2789
|
+
/**
|
|
2790
|
+
* Chat Channel Registry
|
|
2791
|
+
*
|
|
2792
|
+
* Manages all registered chat channel implementations.
|
|
2793
|
+
* Channels are automatically discovered and registered via @ChatChannel decorator.
|
|
2794
|
+
*
|
|
2795
|
+
* Supports:
|
|
2796
|
+
* - Organization-scoped channels
|
|
2797
|
+
* - Global channels (fallback)
|
|
2798
|
+
* - Plugin-based registration/removal
|
|
2799
|
+
* - Dynamic channel lookup
|
|
2800
|
+
*
|
|
2801
|
+
* @example
|
|
2802
|
+
* ```typescript
|
|
2803
|
+
* // Get channel by type
|
|
2804
|
+
* const channel = registry.get('lark')
|
|
2805
|
+
*
|
|
2806
|
+
* // List all available channels for an organization
|
|
2807
|
+
* const channels = registry.list(organizationId)
|
|
2808
|
+
*
|
|
2809
|
+
* // Send message using a channel
|
|
2810
|
+
* await channel.sendText(ctx, 'Hello!')
|
|
2811
|
+
* ```
|
|
2812
|
+
*/ exports.ChatChannelRegistry = class ChatChannelRegistry extends BaseStrategyRegistry {
|
|
2692
2813
|
constructor(discoveryService, reflector){
|
|
2693
2814
|
super(CHAT_CHANNEL, discoveryService, reflector);
|
|
2694
2815
|
}
|
|
2695
2816
|
};
|
|
2696
2817
|
exports.ChatChannelRegistry = __decorate([
|
|
2697
2818
|
common.Injectable(),
|
|
2698
|
-
__metadata("design:type", Function),
|
|
2699
2819
|
__metadata("design:paramtypes", [
|
|
2700
|
-
|
|
2701
|
-
|
|
2820
|
+
core.DiscoveryService,
|
|
2821
|
+
core.Reflector
|
|
2702
2822
|
])
|
|
2703
2823
|
], exports.ChatChannelRegistry);
|
|
2704
2824
|
|
|
2825
|
+
const COMMAND_METADATA = '__command__';
|
|
2705
2826
|
class CancelConversationCommand {
|
|
2706
2827
|
constructor(input){
|
|
2707
2828
|
this.input = input;
|
|
2708
2829
|
}
|
|
2709
2830
|
}
|
|
2710
2831
|
CancelConversationCommand.type = '[Chat Conversation] Cancel';
|
|
2832
|
+
Reflect.defineMetadata(COMMAND_METADATA, {
|
|
2833
|
+
id: CancelConversationCommand.type
|
|
2834
|
+
}, CancelConversationCommand);
|
|
2711
2835
|
|
|
2712
2836
|
const FILE_STORAGE_PROVIDER = 'FILE_STORAGE_PROVIDER';
|
|
2713
2837
|
const FileStorageProvider = (provider)=>common.applyDecorators(common.SetMetadata(FILE_STORAGE_PROVIDER, provider), common.SetMetadata(STRATEGY_META_KEY, FILE_STORAGE_PROVIDER));
|
|
@@ -2719,10 +2843,9 @@ exports.FileStorageProviderRegistry = class FileStorageProviderRegistry extends
|
|
|
2719
2843
|
};
|
|
2720
2844
|
exports.FileStorageProviderRegistry = __decorate([
|
|
2721
2845
|
common.Injectable(),
|
|
2722
|
-
__metadata("design:type", Function),
|
|
2723
2846
|
__metadata("design:paramtypes", [
|
|
2724
|
-
|
|
2725
|
-
|
|
2847
|
+
core.DiscoveryService,
|
|
2848
|
+
core.Reflector
|
|
2726
2849
|
])
|
|
2727
2850
|
], exports.FileStorageProviderRegistry);
|
|
2728
2851
|
|
|
@@ -2736,10 +2859,9 @@ exports.FileUploadTargetRegistry = class FileUploadTargetRegistry extends BaseSt
|
|
|
2736
2859
|
};
|
|
2737
2860
|
exports.FileUploadTargetRegistry = __decorate([
|
|
2738
2861
|
common.Injectable(),
|
|
2739
|
-
__metadata("design:type", Function),
|
|
2740
2862
|
__metadata("design:paramtypes", [
|
|
2741
|
-
|
|
2742
|
-
|
|
2863
|
+
core.DiscoveryService,
|
|
2864
|
+
core.Reflector
|
|
2743
2865
|
])
|
|
2744
2866
|
], exports.FileUploadTargetRegistry);
|
|
2745
2867
|
|
|
@@ -2794,8 +2916,18 @@ function resolveSandboxExecutionOptions(options, defaults = DEFAULT_SANDBOX_SHEL
|
|
|
2794
2916
|
*
|
|
2795
2917
|
* @param backend - Backend instance to check
|
|
2796
2918
|
* @returns True if the backend implements SandboxBackendProtocol
|
|
2797
|
-
*/ function
|
|
2798
|
-
return typeof
|
|
2919
|
+
*/ function isObjectLike(value) {
|
|
2920
|
+
return typeof value === 'object' && value !== null;
|
|
2921
|
+
}
|
|
2922
|
+
function isSandboxBackend(backend) {
|
|
2923
|
+
return isObjectLike(backend) && typeof Reflect.get(backend, 'execute') === 'function' && typeof Reflect.get(backend, 'id') === 'string';
|
|
2924
|
+
}
|
|
2925
|
+
function resolveSandboxBackend(sandbox) {
|
|
2926
|
+
if (!isObjectLike(sandbox)) {
|
|
2927
|
+
return null;
|
|
2928
|
+
}
|
|
2929
|
+
const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
|
|
2930
|
+
return isSandboxBackend(candidate) ? candidate : null;
|
|
2799
2931
|
}
|
|
2800
2932
|
|
|
2801
2933
|
const MAX_LINE_LENGTH = 500;
|
|
@@ -3414,10 +3546,10 @@ try {
|
|
|
3414
3546
|
* Requires Node.js 20+ on the sandbox host.
|
|
3415
3547
|
*/ class BaseSandbox {
|
|
3416
3548
|
/**
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3549
|
+
* Internal hook for file/search operations. Concrete backends can override
|
|
3550
|
+
* this to distinguish "background helper commands" from user-facing shell
|
|
3551
|
+
* execute calls.
|
|
3552
|
+
*/ executeOperation(command, options) {
|
|
3421
3553
|
return this.execute(command, options);
|
|
3422
3554
|
}
|
|
3423
3555
|
async streamExecute(command, onLine, options) {
|
|
@@ -3428,11 +3560,11 @@ try {
|
|
|
3428
3560
|
return result;
|
|
3429
3561
|
}
|
|
3430
3562
|
/**
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3563
|
+
* List files and directories in the specified directory (non-recursive).
|
|
3564
|
+
*
|
|
3565
|
+
* @param path - Absolute path to directory
|
|
3566
|
+
* @returns List of FileInfo objects for files and directories directly in the directory.
|
|
3567
|
+
*/ async lsInfo(path) {
|
|
3436
3568
|
const command = buildLsCommand(path);
|
|
3437
3569
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
|
|
3438
3570
|
if (result.exitCode !== 0) {
|
|
@@ -3456,14 +3588,14 @@ try {
|
|
|
3456
3588
|
return infos;
|
|
3457
3589
|
}
|
|
3458
3590
|
/**
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3591
|
+
* List directory contents recursively with depth control and pagination.
|
|
3592
|
+
*
|
|
3593
|
+
* @param dirPath - Absolute path to directory
|
|
3594
|
+
* @param offset - 1-indexed entry number to start from (default: 1)
|
|
3595
|
+
* @param limit - Maximum number of entries to return (default: 25)
|
|
3596
|
+
* @param depth - Maximum depth to traverse (default: 2)
|
|
3597
|
+
* @returns Human-readable directory tree with indentation
|
|
3598
|
+
*/ async listDir(dirPath, offset = 1, limit = 25, depth = 2) {
|
|
3467
3599
|
if (offset < 1) {
|
|
3468
3600
|
return 'Error: offset must be a 1-indexed entry number';
|
|
3469
3601
|
}
|
|
@@ -3481,15 +3613,15 @@ try {
|
|
|
3481
3613
|
return result.output;
|
|
3482
3614
|
}
|
|
3483
3615
|
/**
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3616
|
+
* Read file content with line numbers.
|
|
3617
|
+
*
|
|
3618
|
+
* @param filePath - Absolute file path
|
|
3619
|
+
* @param offset - Line offset to start reading from (1-indexed)
|
|
3620
|
+
* @param limit - Maximum number of lines to read
|
|
3621
|
+
* @param mode - Read mode: 'slice' (default) or 'indentation'
|
|
3622
|
+
* @param indentation - Configuration for indentation mode
|
|
3623
|
+
* @returns Formatted file content with line numbers, or error message
|
|
3624
|
+
*/ async read(filePath, offset = 1, limit = 2000, mode = 'slice', indentation) {
|
|
3493
3625
|
const command = mode === 'indentation' ? buildIndentationReadCommand(filePath, offset, limit, indentation != null ? indentation : {}) : buildSliceReadCommand(filePath, offset, limit);
|
|
3494
3626
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
|
|
3495
3627
|
if (result.exitCode !== 0) {
|
|
@@ -3498,8 +3630,8 @@ try {
|
|
|
3498
3630
|
return result.output;
|
|
3499
3631
|
}
|
|
3500
3632
|
/**
|
|
3501
|
-
|
|
3502
|
-
|
|
3633
|
+
* Structured search results or error string for invalid input.
|
|
3634
|
+
*/ async grepRaw(pattern, path = '/', include = null) {
|
|
3503
3635
|
const command = buildGrepCommand(pattern, path, include);
|
|
3504
3636
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
|
|
3505
3637
|
if (result.exitCode === 1) {
|
|
@@ -3525,8 +3657,8 @@ try {
|
|
|
3525
3657
|
return matches;
|
|
3526
3658
|
}
|
|
3527
3659
|
/**
|
|
3528
|
-
|
|
3529
|
-
|
|
3660
|
+
* Search file contents for a regex pattern, returning human-readable output.
|
|
3661
|
+
*/ async grep(pattern, path = '/', include = null) {
|
|
3530
3662
|
const result = await this.grepRaw(pattern, path, include);
|
|
3531
3663
|
if (typeof result === 'string') {
|
|
3532
3664
|
return result;
|
|
@@ -3537,8 +3669,8 @@ try {
|
|
|
3537
3669
|
return formatGrepOutput(result);
|
|
3538
3670
|
}
|
|
3539
3671
|
/**
|
|
3540
|
-
|
|
3541
|
-
|
|
3672
|
+
* Structured glob matching returning FileInfo objects.
|
|
3673
|
+
*/ async globInfo(pattern, path = '/') {
|
|
3542
3674
|
const command = buildGlobCommand(path, pattern);
|
|
3543
3675
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
|
|
3544
3676
|
const infos = [];
|
|
@@ -3559,8 +3691,8 @@ try {
|
|
|
3559
3691
|
return infos;
|
|
3560
3692
|
}
|
|
3561
3693
|
/**
|
|
3562
|
-
|
|
3563
|
-
|
|
3694
|
+
* Find files matching a glob pattern, returning human-readable output.
|
|
3695
|
+
*/ async glob(pattern, path = '/') {
|
|
3564
3696
|
const files = await this.globInfo(pattern, path);
|
|
3565
3697
|
if (files.length === 0) {
|
|
3566
3698
|
return 'No files found';
|
|
@@ -3568,8 +3700,8 @@ try {
|
|
|
3568
3700
|
return formatGlobOutput(files);
|
|
3569
3701
|
}
|
|
3570
3702
|
/**
|
|
3571
|
-
|
|
3572
|
-
|
|
3703
|
+
* Create a new file with content.
|
|
3704
|
+
*/ async write(filePath, content) {
|
|
3573
3705
|
const command = buildWriteCommand(filePath, content);
|
|
3574
3706
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
|
|
3575
3707
|
if (result.exitCode !== 0) {
|
|
@@ -3622,8 +3754,8 @@ try {
|
|
|
3622
3754
|
};
|
|
3623
3755
|
}
|
|
3624
3756
|
/**
|
|
3625
|
-
|
|
3626
|
-
|
|
3757
|
+
* Append content to a file. Creates the file if it doesn't exist.
|
|
3758
|
+
*/ async append(filePath, content) {
|
|
3627
3759
|
const command = buildAppendCommand(filePath, content);
|
|
3628
3760
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
|
|
3629
3761
|
if (result.exitCode !== 0) {
|
|
@@ -3638,8 +3770,8 @@ try {
|
|
|
3638
3770
|
};
|
|
3639
3771
|
}
|
|
3640
3772
|
/**
|
|
3641
|
-
|
|
3642
|
-
|
|
3773
|
+
* Edit a file by replacing string occurrences.
|
|
3774
|
+
*/ async edit(filePath, oldString, newString, replaceAll = false) {
|
|
3643
3775
|
const command = buildEditCommand(filePath, oldString, newString, replaceAll);
|
|
3644
3776
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
|
|
3645
3777
|
switch(result.exitCode){
|
|
@@ -3671,10 +3803,10 @@ try {
|
|
|
3671
3803
|
}
|
|
3672
3804
|
}
|
|
3673
3805
|
/**
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3806
|
+
* Perform multiple sequential edits on a single file.
|
|
3807
|
+
* All edits are applied sequentially, with each edit operating on the result of the previous edit.
|
|
3808
|
+
* All edits must succeed for the operation to succeed (atomic).
|
|
3809
|
+
*/ async multiEdit(filePath, edits) {
|
|
3678
3810
|
if (!edits || edits.length === 0) {
|
|
3679
3811
|
return {
|
|
3680
3812
|
error: 'No edits provided'
|
|
@@ -3714,29 +3846,52 @@ exports.SandboxProviderRegistry = class SandboxProviderRegistry extends BaseStra
|
|
|
3714
3846
|
};
|
|
3715
3847
|
exports.SandboxProviderRegistry = __decorate([
|
|
3716
3848
|
common.Injectable(),
|
|
3717
|
-
__metadata("design:type", Function),
|
|
3718
3849
|
__metadata("design:paramtypes", [
|
|
3719
|
-
|
|
3720
|
-
|
|
3850
|
+
core.DiscoveryService,
|
|
3851
|
+
core.Reflector
|
|
3721
3852
|
])
|
|
3722
3853
|
], exports.SandboxProviderRegistry);
|
|
3723
3854
|
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
}
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3855
|
+
const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
|
|
3856
|
+
const ViewExtensionProvider = (providerKey)=>common.applyDecorators(common.SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), common.SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
|
|
3857
|
+
|
|
3858
|
+
exports.ViewExtensionProviderRegistry = class ViewExtensionProviderRegistry extends BaseStrategyRegistry {
|
|
3859
|
+
listEntries(organizationId) {
|
|
3860
|
+
var _this_strategies_get;
|
|
3861
|
+
const orgKey = this.resolveOrganization(organizationId);
|
|
3862
|
+
const entries = new Map();
|
|
3863
|
+
var _this_strategies_get_entries;
|
|
3864
|
+
for (const [providerKey, provider] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
|
|
3865
|
+
entries.set(providerKey, provider);
|
|
3866
|
+
}
|
|
3867
|
+
if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
|
|
3868
|
+
var _this_strategies_get1;
|
|
3869
|
+
var _this_strategies_get_entries1;
|
|
3870
|
+
for (const [providerKey, provider] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
|
|
3871
|
+
if (!entries.has(providerKey)) {
|
|
3872
|
+
entries.set(providerKey, provider);
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
return Array.from(entries.entries()).map(([providerKey, provider])=>({
|
|
3877
|
+
providerKey,
|
|
3878
|
+
provider
|
|
3879
|
+
}));
|
|
3880
|
+
}
|
|
3881
|
+
constructor(discoveryService, reflector){
|
|
3882
|
+
super(VIEW_EXTENSION_PROVIDER, discoveryService, reflector);
|
|
3883
|
+
}
|
|
3884
|
+
};
|
|
3885
|
+
exports.ViewExtensionProviderRegistry = __decorate([
|
|
3886
|
+
common.Injectable(),
|
|
3887
|
+
__metadata("design:paramtypes", [
|
|
3888
|
+
core.DiscoveryService,
|
|
3889
|
+
core.Reflector
|
|
3890
|
+
])
|
|
3891
|
+
], exports.ViewExtensionProviderRegistry);
|
|
3892
|
+
|
|
3893
|
+
const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
|
|
3894
|
+
|
|
3740
3895
|
exports.AGENT_CHAT_DISPATCH_MESSAGE_TYPE = AGENT_CHAT_DISPATCH_MESSAGE_TYPE;
|
|
3741
3896
|
exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
|
|
3742
3897
|
exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
|
|
@@ -3818,8 +3973,10 @@ exports.RerankModel = RerankModel;
|
|
|
3818
3973
|
exports.RetrieverStrategy = RetrieverStrategy;
|
|
3819
3974
|
exports.SANDBOX_PROVIDER = SANDBOX_PROVIDER;
|
|
3820
3975
|
exports.SANDBOX_SHELL_TIMEOUT_LIMITS_SEC = SANDBOX_SHELL_TIMEOUT_LIMITS_SEC;
|
|
3976
|
+
exports.SKILL_SOURCE_PROVIDER = SKILL_SOURCE_PROVIDER;
|
|
3821
3977
|
exports.STRATEGY_META_KEY = STRATEGY_META_KEY;
|
|
3822
3978
|
exports.SandboxProviderStrategy = SandboxProviderStrategy;
|
|
3979
|
+
exports.SkillSourceProviderStrategy = SkillSourceProviderStrategy;
|
|
3823
3980
|
exports.Speech2TextChatModel = Speech2TextChatModel;
|
|
3824
3981
|
exports.SpeechToTextModel = SpeechToTextModel;
|
|
3825
3982
|
exports.TEXT_SPLITTER_STRATEGY = TEXT_SPLITTER_STRATEGY;
|
|
@@ -3830,7 +3987,10 @@ exports.TextToSpeechModel = TextToSpeechModel;
|
|
|
3830
3987
|
exports.ToolsetStrategy = ToolsetStrategy;
|
|
3831
3988
|
exports.USER_PERMISSION_SERVICE_TOKEN = USER_PERMISSION_SERVICE_TOKEN;
|
|
3832
3989
|
exports.VECTOR_STORE_STRATEGY = VECTOR_STORE_STRATEGY;
|
|
3990
|
+
exports.VIEW_EXTENSION_CACHE_SERVICE_TOKEN = VIEW_EXTENSION_CACHE_SERVICE_TOKEN;
|
|
3991
|
+
exports.VIEW_EXTENSION_PROVIDER = VIEW_EXTENSION_PROVIDER;
|
|
3833
3992
|
exports.VectorStoreStrategy = VectorStoreStrategy;
|
|
3993
|
+
exports.ViewExtensionProvider = ViewExtensionProvider;
|
|
3834
3994
|
exports.WORKFLOW_NODE_STRATEGY = WORKFLOW_NODE_STRATEGY;
|
|
3835
3995
|
exports.WORKFLOW_TRIGGER_STRATEGY = WORKFLOW_TRIGGER_STRATEGY;
|
|
3836
3996
|
exports.WorkflowNodeStrategy = WorkflowNodeStrategy;
|
|
@@ -3864,6 +4024,7 @@ exports.loadYamlFile = loadYamlFile;
|
|
|
3864
4024
|
exports.mergeCredentials = mergeCredentials;
|
|
3865
4025
|
exports.mergeParentChildChunks = mergeParentChildChunks;
|
|
3866
4026
|
exports.normalizeContextSize = normalizeContextSize;
|
|
4027
|
+
exports.resolveSandboxBackend = resolveSandboxBackend;
|
|
3867
4028
|
exports.resolveSandboxExecutionOptions = resolveSandboxExecutionOptions;
|
|
3868
4029
|
exports.runWithRequestContext = runWithRequestContext;
|
|
3869
4030
|
exports.secondsToMilliseconds = secondsToMilliseconds;
|