@xpert-ai/plugin-sdk 3.8.4 → 3.9.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +459 -320
- package/index.esm.js +442 -293
- package/package.json +4 -3
- package/src/index.d.ts +1 -0
- 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/strategy.decorator.d.ts +1 -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/channel/strategy.interface.d.ts +0 -2
- package/src/lib/core/context/request-context.d.ts +7 -4
- package/src/lib/core/context/request-context.middleware.d.ts +0 -1
- package/src/lib/core/file-system.d.ts +1 -3
- package/src/lib/core/permissions/analytics.d.ts +2 -3
- package/src/lib/data/datasource/strategy.decorator.d.ts +1 -1
- package/src/lib/data/datasource/types.d.ts +0 -3
- package/src/lib/file/file-storage/provider.decorator.d.ts +1 -1
- package/src/lib/file/file-storage/provider.interface.d.ts +0 -2
- package/src/lib/file/file-upload/strategy.decorator.d.ts +1 -1
- package/src/lib/file/file-upload/strategy.interface.d.ts +0 -2
- package/src/lib/integration/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/image/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/knowledge/knowledge-strategy.decorator.d.ts +1 -1
- package/src/lib/rag/retriever/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/source/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/textsplitter/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/transformer/strategy.decorator.d.ts +1 -1
- package/src/lib/sandbox/protocol.d.ts +4 -8
- package/src/lib/sandbox/sandbox.decorator.d.ts +1 -1
- package/src/lib/strategy.d.ts +3 -3
- package/src/lib/toolset/strategy.decorator.d.ts +1 -1
- package/src/lib/vectorstore/strategy.decorator.d.ts +1 -1
- package/src/lib/view-extension/index.d.ts +3 -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/workflow/node/strategy.decorator.d.ts +1 -1
- package/src/lib/workflow/trigger/strategy.decorator.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
|
@@ -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,6 +141,8 @@ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedEr
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
// request-context.ts
|
|
144
|
+
const TENANT_SCOPE = 'tenant';
|
|
145
|
+
const ORGANIZATION_SCOPE = 'organization';
|
|
144
146
|
class RequestContext {
|
|
145
147
|
static currentRequestContext() {
|
|
146
148
|
const session = getRequestContext();
|
|
@@ -153,6 +155,11 @@ class RequestContext {
|
|
|
153
155
|
}
|
|
154
156
|
return null;
|
|
155
157
|
}
|
|
158
|
+
static currentApiKey() {
|
|
159
|
+
const user = RequestContext.currentUser();
|
|
160
|
+
var _user_apiKey;
|
|
161
|
+
return (_user_apiKey = user == null ? void 0 : user.apiKey) != null ? _user_apiKey : null;
|
|
162
|
+
}
|
|
156
163
|
static currentTenantId() {
|
|
157
164
|
const user = RequestContext.currentUser();
|
|
158
165
|
if (user) {
|
|
@@ -194,9 +201,9 @@ class RequestContext {
|
|
|
194
201
|
], throwError);
|
|
195
202
|
}
|
|
196
203
|
/**
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
204
|
+
* Retrieves the language code from the headers of the current request.
|
|
205
|
+
* @returns The language code (LanguagesEnum) extracted from the headers, or the default language (ENGLISH) if not found.
|
|
206
|
+
*/ static getLanguageCode() {
|
|
200
207
|
// Retrieve the current request
|
|
201
208
|
const req = RequestContext.currentRequest();
|
|
202
209
|
// Variable to store the extracted language code
|
|
@@ -212,21 +219,71 @@ class RequestContext {
|
|
|
212
219
|
// Return the extracted language code or the default language (ENGLISH) if not found
|
|
213
220
|
return lang || contracts.LanguagesEnum.English;
|
|
214
221
|
}
|
|
215
|
-
static
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
222
|
+
static getScope() {
|
|
223
|
+
const request = this.currentRequest();
|
|
224
|
+
const user = this.currentUser();
|
|
225
|
+
var _user_tenantId, _ref;
|
|
226
|
+
const tenantId = (_ref = (_user_tenantId = user == null ? void 0 : user.tenantId) != null ? _user_tenantId : getHeaderValue(request, [
|
|
227
|
+
'tenant-id'
|
|
228
|
+
])) != null ? _ref : null;
|
|
229
|
+
var _getHeaderValue;
|
|
230
|
+
const organizationId = (_getHeaderValue = getHeaderValue(request, [
|
|
219
231
|
'organization-id'
|
|
220
|
-
];
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
232
|
+
])) != null ? _getHeaderValue : null;
|
|
233
|
+
const scopeLevelHeader = getHeaderValue(request, [
|
|
234
|
+
'x-scope-level'
|
|
235
|
+
]);
|
|
236
|
+
if (scopeLevelHeader) {
|
|
237
|
+
if (scopeLevelHeader !== TENANT_SCOPE && scopeLevelHeader !== ORGANIZATION_SCOPE) {
|
|
238
|
+
throw new common.BadRequestException(`Unsupported scope level: ${scopeLevelHeader}`);
|
|
239
|
+
}
|
|
240
|
+
if (scopeLevelHeader === TENANT_SCOPE) {
|
|
241
|
+
if (organizationId) {
|
|
242
|
+
throw new common.BadRequestException('Tenant scope requests must not include Organization-Id.');
|
|
226
243
|
}
|
|
244
|
+
return {
|
|
245
|
+
tenantId,
|
|
246
|
+
level: TENANT_SCOPE,
|
|
247
|
+
organizationId: null
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
if (!organizationId) {
|
|
251
|
+
throw new common.BadRequestException('Organization scope requests require Organization-Id.');
|
|
227
252
|
}
|
|
253
|
+
return {
|
|
254
|
+
tenantId,
|
|
255
|
+
level: ORGANIZATION_SCOPE,
|
|
256
|
+
organizationId
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
if (organizationId) {
|
|
260
|
+
return {
|
|
261
|
+
tenantId,
|
|
262
|
+
level: ORGANIZATION_SCOPE,
|
|
263
|
+
organizationId
|
|
264
|
+
};
|
|
228
265
|
}
|
|
229
|
-
return
|
|
266
|
+
return {
|
|
267
|
+
tenantId,
|
|
268
|
+
level: TENANT_SCOPE,
|
|
269
|
+
organizationId: null
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
static getOrganizationId() {
|
|
273
|
+
return this.getScope().organizationId;
|
|
274
|
+
}
|
|
275
|
+
static isTenantScope() {
|
|
276
|
+
return this.getScope().level === TENANT_SCOPE;
|
|
277
|
+
}
|
|
278
|
+
static isOrganizationScope() {
|
|
279
|
+
return this.getScope().level === ORGANIZATION_SCOPE;
|
|
280
|
+
}
|
|
281
|
+
static requireOrganizationScope() {
|
|
282
|
+
const scope = this.getScope();
|
|
283
|
+
if (scope.level !== ORGANIZATION_SCOPE || !scope.organizationId) {
|
|
284
|
+
throw new common.BadRequestException('Organization scope is required for this operation.');
|
|
285
|
+
}
|
|
286
|
+
return scope.organizationId;
|
|
230
287
|
}
|
|
231
288
|
static hasPermissions(findPermissions, throwError) {
|
|
232
289
|
const requestContext = RequestContext.currentRequestContext();
|
|
@@ -280,22 +337,22 @@ class RequestContext {
|
|
|
280
337
|
return null;
|
|
281
338
|
}
|
|
282
339
|
/**
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
340
|
+
* Checks if the current user has a specific role.
|
|
341
|
+
* @param {RolesEnum} role - The role to check.
|
|
342
|
+
* @param {boolean} throwError - Flag indicating whether to throw an error if the role is not granted.
|
|
343
|
+
* @returns {boolean} - True if the user has the role, otherwise false.
|
|
344
|
+
*/ static hasRole(role, throwError) {
|
|
288
345
|
return this.hasRoles([
|
|
289
346
|
role
|
|
290
347
|
], throwError);
|
|
291
348
|
}
|
|
292
349
|
/**
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
350
|
+
* Checks if the current request context has any of the specified roles.
|
|
351
|
+
*
|
|
352
|
+
* @param roles - An array of roles to check.
|
|
353
|
+
* @param throwError - Whether to throw an error if no roles are found.
|
|
354
|
+
* @returns True if any of the required roles are found, otherwise false.
|
|
355
|
+
*/ static hasRoles(roles, throwError) {
|
|
299
356
|
const context = RequestContext.currentRequestContext();
|
|
300
357
|
if (context) {
|
|
301
358
|
try {
|
|
@@ -332,8 +389,23 @@ const als = new node_async_hooks.AsyncLocalStorage();
|
|
|
332
389
|
function getRequestContext() {
|
|
333
390
|
return als.getStore();
|
|
334
391
|
}
|
|
392
|
+
function getHeaderValue(req, keys) {
|
|
393
|
+
if (!(req == null ? void 0 : req.headers)) {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
for (const key of keys){
|
|
397
|
+
const value = req.headers[key];
|
|
398
|
+
if (Array.isArray(value)) {
|
|
399
|
+
var _value_;
|
|
400
|
+
return (_value_ = value[0]) != null ? _value_ : null;
|
|
401
|
+
}
|
|
402
|
+
if (typeof value === 'string' && value) {
|
|
403
|
+
return value;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
335
408
|
|
|
336
|
-
// request-context.middleware.ts
|
|
337
409
|
exports.RequestContextMiddleware = class RequestContextMiddleware {
|
|
338
410
|
use(req, _res, next) {
|
|
339
411
|
var _req_user;
|
|
@@ -434,10 +506,10 @@ class BaseStrategyRegistry {
|
|
|
434
506
|
}
|
|
435
507
|
/**
|
|
436
508
|
* Get strategy by type from the given organization including global strategies as fallback.
|
|
437
|
-
*
|
|
438
|
-
* @param type
|
|
439
|
-
* @param organizationId
|
|
440
|
-
* @returns
|
|
509
|
+
*
|
|
510
|
+
* @param type
|
|
511
|
+
* @param organizationId
|
|
512
|
+
* @returns
|
|
441
513
|
*/ get(type, organizationId) {
|
|
442
514
|
var _this_strategies_get, _this_strategies_get1;
|
|
443
515
|
organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
|
|
@@ -451,34 +523,42 @@ class BaseStrategyRegistry {
|
|
|
451
523
|
}
|
|
452
524
|
/**
|
|
453
525
|
* List all strategies for the given organization including global strategies, or only global strategies if global org is specified.
|
|
454
|
-
*
|
|
455
|
-
* @param organizationId
|
|
456
|
-
* @returns
|
|
526
|
+
*
|
|
527
|
+
* @param organizationId
|
|
528
|
+
* @returns
|
|
457
529
|
*/ list(organizationId) {
|
|
458
|
-
var _this_strategies_get
|
|
530
|
+
var _this_strategies_get;
|
|
459
531
|
organizationId != null ? organizationId : organizationId = RequestContext.getOrganizationId();
|
|
460
532
|
const orgKey = this.resolveOrganization(organizationId);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
533
|
+
const effective = new Map();
|
|
534
|
+
var _this_strategies_get_entries;
|
|
535
|
+
for (const [type, strategy] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
|
|
536
|
+
effective.set(type, strategy);
|
|
537
|
+
}
|
|
538
|
+
if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
|
|
539
|
+
var _this_strategies_get1;
|
|
540
|
+
var _this_strategies_get_entries1;
|
|
541
|
+
for (const [type, strategy] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
|
|
542
|
+
if (!effective.has(type)) {
|
|
543
|
+
effective.set(type, strategy);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return Array.from(effective.values());
|
|
469
548
|
}
|
|
470
549
|
constructor(strategyKey, discoveryService, reflector){
|
|
471
|
-
this.strategyKey = strategyKey;
|
|
472
|
-
this.discoveryService = discoveryService;
|
|
473
|
-
this.reflector = reflector;
|
|
474
550
|
this.logger = new common.Logger(BaseStrategyRegistry.name);
|
|
551
|
+
// Map<organizationId, Map<type, strategy>>
|
|
475
552
|
this.strategies = new Map();
|
|
476
553
|
this.pluginStrategies = new Map();
|
|
554
|
+
this.strategyKey = strategyKey;
|
|
555
|
+
this.discoveryService = discoveryService;
|
|
556
|
+
this.reflector = reflector;
|
|
477
557
|
}
|
|
478
558
|
}
|
|
479
559
|
__decorate([
|
|
480
560
|
common.Inject(exports.StrategyBus),
|
|
481
|
-
__metadata("design:type",
|
|
561
|
+
__metadata("design:type", exports.StrategyBus)
|
|
482
562
|
], BaseStrategyRegistry.prototype, "bus", void 0);
|
|
483
563
|
|
|
484
564
|
exports.IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends BaseStrategyRegistry {
|
|
@@ -488,10 +568,9 @@ exports.IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends
|
|
|
488
568
|
};
|
|
489
569
|
exports.IntegrationStrategyRegistry = __decorate([
|
|
490
570
|
common.Injectable(),
|
|
491
|
-
__metadata("design:type", Function),
|
|
492
571
|
__metadata("design:paramtypes", [
|
|
493
|
-
|
|
494
|
-
|
|
572
|
+
core.DiscoveryService,
|
|
573
|
+
core.Reflector
|
|
495
574
|
])
|
|
496
575
|
], exports.IntegrationStrategyRegistry);
|
|
497
576
|
|
|
@@ -505,10 +584,9 @@ exports.WorkflowTriggerRegistry = class WorkflowTriggerRegistry extends BaseStra
|
|
|
505
584
|
};
|
|
506
585
|
exports.WorkflowTriggerRegistry = __decorate([
|
|
507
586
|
common.Injectable(),
|
|
508
|
-
__metadata("design:type", Function),
|
|
509
587
|
__metadata("design:paramtypes", [
|
|
510
|
-
|
|
511
|
-
|
|
588
|
+
core.DiscoveryService,
|
|
589
|
+
core.Reflector
|
|
512
590
|
])
|
|
513
591
|
], exports.WorkflowTriggerRegistry);
|
|
514
592
|
|
|
@@ -517,21 +595,22 @@ const WORKFLOW_NODE_STRATEGY = 'WORKFLOW_NODE_STRATEGY';
|
|
|
517
595
|
* Decorator to mark a provider as a Workflow Node Strategy
|
|
518
596
|
*/ const WorkflowNodeStrategy = (provider)=>common.applyDecorators(common.SetMetadata(WORKFLOW_NODE_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, WORKFLOW_NODE_STRATEGY));
|
|
519
597
|
|
|
520
|
-
|
|
598
|
+
/**
|
|
599
|
+
* Registry for Workflow Node Strategies
|
|
600
|
+
*/ exports.WorkflowNodeRegistry = class WorkflowNodeRegistry extends BaseStrategyRegistry {
|
|
521
601
|
constructor(discoveryService, reflector){
|
|
522
602
|
super(WORKFLOW_NODE_STRATEGY, discoveryService, reflector);
|
|
523
603
|
}
|
|
524
604
|
};
|
|
525
605
|
exports.WorkflowNodeRegistry = __decorate([
|
|
526
606
|
common.Injectable(),
|
|
527
|
-
__metadata("design:type", Function),
|
|
528
607
|
__metadata("design:paramtypes", [
|
|
529
|
-
|
|
530
|
-
|
|
608
|
+
core.DiscoveryService,
|
|
609
|
+
core.Reflector
|
|
531
610
|
])
|
|
532
611
|
], exports.WorkflowNodeRegistry);
|
|
533
612
|
|
|
534
|
-
const COMMAND_METADATA$
|
|
613
|
+
const COMMAND_METADATA$2 = '__command__';
|
|
535
614
|
/**
|
|
536
615
|
* Wrap Workflow Node Execution Command
|
|
537
616
|
*/ class WrapWorkflowNodeExecutionCommand extends cqrs.Command {
|
|
@@ -542,7 +621,7 @@ const COMMAND_METADATA$1 = '__command__';
|
|
|
542
621
|
}
|
|
543
622
|
}
|
|
544
623
|
WrapWorkflowNodeExecutionCommand.type = '[Workflow] Wrap Workflow Node Execution';
|
|
545
|
-
Reflect.defineMetadata(COMMAND_METADATA$
|
|
624
|
+
Reflect.defineMetadata(COMMAND_METADATA$2, {
|
|
546
625
|
id: WrapWorkflowNodeExecutionCommand.type
|
|
547
626
|
}, WrapWorkflowNodeExecutionCommand);
|
|
548
627
|
|
|
@@ -556,10 +635,9 @@ exports.VectorStoreRegistry = class VectorStoreRegistry extends BaseStrategyRegi
|
|
|
556
635
|
};
|
|
557
636
|
exports.VectorStoreRegistry = __decorate([
|
|
558
637
|
common.Injectable(),
|
|
559
|
-
__metadata("design:type", Function),
|
|
560
638
|
__metadata("design:paramtypes", [
|
|
561
|
-
|
|
562
|
-
|
|
639
|
+
core.DiscoveryService,
|
|
640
|
+
core.Reflector
|
|
563
641
|
])
|
|
564
642
|
], exports.VectorStoreRegistry);
|
|
565
643
|
|
|
@@ -573,10 +651,9 @@ exports.TextSplitterRegistry = class TextSplitterRegistry extends BaseStrategyRe
|
|
|
573
651
|
};
|
|
574
652
|
exports.TextSplitterRegistry = __decorate([
|
|
575
653
|
common.Injectable(),
|
|
576
|
-
__metadata("design:type", Function),
|
|
577
654
|
__metadata("design:paramtypes", [
|
|
578
|
-
|
|
579
|
-
|
|
655
|
+
core.DiscoveryService,
|
|
656
|
+
core.Reflector
|
|
580
657
|
])
|
|
581
658
|
], exports.TextSplitterRegistry);
|
|
582
659
|
|
|
@@ -592,10 +669,9 @@ exports.DocumentSourceRegistry = class DocumentSourceRegistry extends BaseStrate
|
|
|
592
669
|
};
|
|
593
670
|
exports.DocumentSourceRegistry = __decorate([
|
|
594
671
|
common.Injectable(),
|
|
595
|
-
__metadata("design:type", Function),
|
|
596
672
|
__metadata("design:paramtypes", [
|
|
597
|
-
|
|
598
|
-
|
|
673
|
+
core.DiscoveryService,
|
|
674
|
+
core.Reflector
|
|
599
675
|
])
|
|
600
676
|
], exports.DocumentSourceRegistry);
|
|
601
677
|
|
|
@@ -611,10 +687,9 @@ exports.DocumentTransformerRegistry = class DocumentTransformerRegistry extends
|
|
|
611
687
|
};
|
|
612
688
|
exports.DocumentTransformerRegistry = __decorate([
|
|
613
689
|
common.Injectable(),
|
|
614
|
-
__metadata("design:type", Function),
|
|
615
690
|
__metadata("design:paramtypes", [
|
|
616
|
-
|
|
617
|
-
|
|
691
|
+
core.DiscoveryService,
|
|
692
|
+
core.Reflector
|
|
618
693
|
])
|
|
619
694
|
], exports.DocumentTransformerRegistry);
|
|
620
695
|
|
|
@@ -630,16 +705,15 @@ exports.RetrieverRegistry = class RetrieverRegistry extends BaseStrategyRegistry
|
|
|
630
705
|
};
|
|
631
706
|
exports.RetrieverRegistry = __decorate([
|
|
632
707
|
common.Injectable(),
|
|
633
|
-
__metadata("design:type", Function),
|
|
634
708
|
__metadata("design:paramtypes", [
|
|
635
|
-
|
|
636
|
-
|
|
709
|
+
core.DiscoveryService,
|
|
710
|
+
core.Reflector
|
|
637
711
|
])
|
|
638
712
|
], exports.RetrieverRegistry);
|
|
639
713
|
|
|
640
714
|
/**
|
|
641
715
|
* Merge parent chunks with their child chunks based on metadata (parentId and chunkId)
|
|
642
|
-
*
|
|
716
|
+
*
|
|
643
717
|
* @deprecated use buildChunkTreeAndFindLeaves instead
|
|
644
718
|
*/ function mergeParentChildChunks(chunks, children // Child chunks
|
|
645
719
|
) {
|
|
@@ -705,10 +779,9 @@ exports.ImageUnderstandingRegistry = class ImageUnderstandingRegistry extends Ba
|
|
|
705
779
|
};
|
|
706
780
|
exports.ImageUnderstandingRegistry = __decorate([
|
|
707
781
|
common.Injectable(),
|
|
708
|
-
__metadata("design:type", Function),
|
|
709
782
|
__metadata("design:paramtypes", [
|
|
710
|
-
|
|
711
|
-
|
|
783
|
+
core.DiscoveryService,
|
|
784
|
+
core.Reflector
|
|
712
785
|
])
|
|
713
786
|
], exports.ImageUnderstandingRegistry);
|
|
714
787
|
|
|
@@ -722,10 +795,9 @@ exports.KnowledgeStrategyRegistry = class KnowledgeStrategyRegistry extends Base
|
|
|
722
795
|
};
|
|
723
796
|
exports.KnowledgeStrategyRegistry = __decorate([
|
|
724
797
|
common.Injectable(),
|
|
725
|
-
__metadata("design:type", Function),
|
|
726
798
|
__metadata("design:paramtypes", [
|
|
727
|
-
|
|
728
|
-
|
|
799
|
+
core.DiscoveryService,
|
|
800
|
+
core.Reflector
|
|
729
801
|
])
|
|
730
802
|
], exports.KnowledgeStrategyRegistry);
|
|
731
803
|
|
|
@@ -741,10 +813,9 @@ exports.ToolsetRegistry = class ToolsetRegistry extends BaseStrategyRegistry {
|
|
|
741
813
|
};
|
|
742
814
|
exports.ToolsetRegistry = __decorate([
|
|
743
815
|
common.Injectable(),
|
|
744
|
-
__metadata("design:type", Function),
|
|
745
816
|
__metadata("design:paramtypes", [
|
|
746
|
-
|
|
747
|
-
|
|
817
|
+
core.DiscoveryService,
|
|
818
|
+
core.Reflector
|
|
748
819
|
])
|
|
749
820
|
], exports.ToolsetRegistry);
|
|
750
821
|
|
|
@@ -752,26 +823,26 @@ exports.ToolsetRegistry = __decorate([
|
|
|
752
823
|
* Base ability for all toolsets
|
|
753
824
|
*/ class BaseToolset extends tools.BaseToolkit {
|
|
754
825
|
/**
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
826
|
+
* Async init tools
|
|
827
|
+
*
|
|
828
|
+
* @returns
|
|
829
|
+
*/ async initTools() {
|
|
759
830
|
return this.tools;
|
|
760
831
|
}
|
|
761
832
|
/**
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
833
|
+
* Get one tool
|
|
834
|
+
*
|
|
835
|
+
* @param toolName
|
|
836
|
+
* @returns
|
|
837
|
+
*/ getTool(toolName) {
|
|
767
838
|
var _this_getTools;
|
|
768
839
|
return (_this_getTools = this.getTools()) == null ? void 0 : _this_getTools.find((tool)=>tool.name === toolName);
|
|
769
840
|
}
|
|
770
841
|
/**
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
842
|
+
* Get state variables config
|
|
843
|
+
*
|
|
844
|
+
* @returns State variables
|
|
845
|
+
*/ async getVariables() {
|
|
775
846
|
return null;
|
|
776
847
|
}
|
|
777
848
|
/**
|
|
@@ -829,26 +900,26 @@ class BuiltinToolset extends BaseToolset {
|
|
|
829
900
|
return (_this_toolset = this.toolset) == null ? void 0 : _this_toolset.credentials;
|
|
830
901
|
}
|
|
831
902
|
getToolTitle(name) {
|
|
832
|
-
var _this_toolset_tools, _this_toolset,
|
|
903
|
+
var _this_toolset_tools, _this_toolset, _tool_schema;
|
|
833
904
|
const tool = (_this_toolset = this.toolset) == null ? void 0 : (_this_toolset_tools = _this_toolset.tools) == null ? void 0 : _this_toolset_tools.find((tool)=>tool.name === name);
|
|
834
|
-
const identity =
|
|
905
|
+
const identity = tool == null ? void 0 : (_tool_schema = tool.schema) == null ? void 0 : _tool_schema.identity;
|
|
835
906
|
if (identity) {
|
|
836
907
|
return identity.label;
|
|
837
908
|
}
|
|
838
909
|
return null;
|
|
839
910
|
}
|
|
840
911
|
/**
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
912
|
+
* Get credentials schema
|
|
913
|
+
*
|
|
914
|
+
* @returns Credentials schema
|
|
915
|
+
*/ getCredentialsSchema() {
|
|
845
916
|
return _extends({}, this.credentialsSchema);
|
|
846
917
|
}
|
|
847
918
|
/**
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
919
|
+
* Get toolset entity
|
|
920
|
+
*
|
|
921
|
+
* @returns XpertToolset
|
|
922
|
+
*/ getToolset() {
|
|
852
923
|
return this.toolset;
|
|
853
924
|
}
|
|
854
925
|
getName() {
|
|
@@ -857,27 +928,27 @@ class BuiltinToolset extends BaseToolset {
|
|
|
857
928
|
}
|
|
858
929
|
constructor(providerName, toolset, params){
|
|
859
930
|
super(params);
|
|
931
|
+
this.logger = new common.Logger(this.constructor.name);
|
|
860
932
|
this.providerName = providerName;
|
|
861
933
|
this.toolset = toolset;
|
|
862
934
|
this.params = params;
|
|
863
|
-
this.logger = new common.Logger(this.constructor.name);
|
|
864
935
|
}
|
|
865
|
-
}
|
|
936
|
+
}
|
|
866
937
|
BuiltinToolset.provider = '';
|
|
867
938
|
|
|
868
939
|
/**
|
|
869
940
|
* Restricted FileSystem based on granted permissions
|
|
870
941
|
*/ class XpFileSystem {
|
|
871
942
|
/**
|
|
872
|
-
|
|
873
|
-
|
|
943
|
+
* Check if operation is allowed
|
|
944
|
+
*/ ensureAllowed(op) {
|
|
874
945
|
if (!this.allowedOps.has(op)) {
|
|
875
946
|
throw new Error(`Permission denied: ${op} operation not allowed`);
|
|
876
947
|
}
|
|
877
948
|
}
|
|
878
949
|
/**
|
|
879
|
-
|
|
880
|
-
|
|
950
|
+
* Check if path is within scope
|
|
951
|
+
*/ ensureInScope(targetPath) {
|
|
881
952
|
if (!this.scope || this.scope.length === 0) return;
|
|
882
953
|
const resolved = path.resolve(targetPath);
|
|
883
954
|
for (const s of this.scope){
|
|
@@ -887,33 +958,33 @@ BuiltinToolset.provider = '';
|
|
|
887
958
|
throw new Error(`Permission denied: path "${targetPath}" is out of scope`);
|
|
888
959
|
}
|
|
889
960
|
/**
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
961
|
+
* Get the absolute path of file in the file system.
|
|
962
|
+
*
|
|
963
|
+
* @param filePath Relative file path
|
|
964
|
+
* @returns Absolute file path
|
|
965
|
+
*/ fullPath(filePath) {
|
|
895
966
|
return path.join(this.basePath, filePath);
|
|
896
967
|
}
|
|
897
968
|
/**
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
969
|
+
* Get web url for a given file path in the file system.
|
|
970
|
+
*
|
|
971
|
+
* @param filePath Relative file path
|
|
972
|
+
* @returns Web URL of file
|
|
973
|
+
*/ fullUrl(filePath) {
|
|
903
974
|
const url = new URL(filePath, this.baseUrl);
|
|
904
975
|
return url.href;
|
|
905
976
|
}
|
|
906
977
|
/**
|
|
907
|
-
|
|
908
|
-
|
|
978
|
+
* Read file contents
|
|
979
|
+
*/ async readFile(filePath, encoding = 'utf-8') {
|
|
909
980
|
this.ensureAllowed('read');
|
|
910
981
|
const fullPath = this.fullPath(filePath);
|
|
911
982
|
this.ensureInScope(fullPath);
|
|
912
983
|
return await fsPromises.readFile(fullPath);
|
|
913
984
|
}
|
|
914
985
|
/**
|
|
915
|
-
|
|
916
|
-
|
|
986
|
+
* Write file contents
|
|
987
|
+
*/ async writeFile(filePath, content) {
|
|
917
988
|
this.ensureAllowed('write');
|
|
918
989
|
const fullPath = this.fullPath(filePath);
|
|
919
990
|
this.ensureInScope(fullPath);
|
|
@@ -925,22 +996,22 @@ BuiltinToolset.provider = '';
|
|
|
925
996
|
return url.href;
|
|
926
997
|
}
|
|
927
998
|
/**
|
|
928
|
-
|
|
929
|
-
|
|
999
|
+
* Delete a file
|
|
1000
|
+
*/ async deleteFile(filePath) {
|
|
930
1001
|
this.ensureAllowed('delete');
|
|
931
1002
|
this.ensureInScope(filePath);
|
|
932
1003
|
await fsPromises.unlink(filePath);
|
|
933
1004
|
}
|
|
934
1005
|
/**
|
|
935
|
-
|
|
936
|
-
|
|
1006
|
+
* List directory contents
|
|
1007
|
+
*/ async listDir(dirPath) {
|
|
937
1008
|
this.ensureAllowed('list');
|
|
938
1009
|
this.ensureInScope(dirPath);
|
|
939
1010
|
return fsPromises.readdir(dirPath);
|
|
940
1011
|
}
|
|
941
1012
|
/**
|
|
942
|
-
|
|
943
|
-
|
|
1013
|
+
* Utility: check if a file or directory exists
|
|
1014
|
+
*/ async exists(targetPath) {
|
|
944
1015
|
try {
|
|
945
1016
|
await fsPromises.access(targetPath);
|
|
946
1017
|
return true;
|
|
@@ -1047,7 +1118,7 @@ function loadYamlFile(filePath, logger, ignoreError = true, defaultValue = {}) {
|
|
|
1047
1118
|
}
|
|
1048
1119
|
/**
|
|
1049
1120
|
* Get the mapping from name to index from a YAML file
|
|
1050
|
-
*
|
|
1121
|
+
*
|
|
1051
1122
|
* @param folderPath
|
|
1052
1123
|
* @param fileName the YAML file name, default to '_position.yaml'
|
|
1053
1124
|
* @return a dict with name as key and index as value
|
|
@@ -1116,10 +1187,9 @@ exports.DataSourceStrategyRegistry = class DataSourceStrategyRegistry extends Ba
|
|
|
1116
1187
|
};
|
|
1117
1188
|
exports.DataSourceStrategyRegistry = __decorate([
|
|
1118
1189
|
common.Injectable(),
|
|
1119
|
-
__metadata("design:type", Function),
|
|
1120
1190
|
__metadata("design:paramtypes", [
|
|
1121
|
-
|
|
1122
|
-
|
|
1191
|
+
core.DiscoveryService,
|
|
1192
|
+
core.Reflector
|
|
1123
1193
|
])
|
|
1124
1194
|
], exports.DataSourceStrategyRegistry);
|
|
1125
1195
|
|
|
@@ -1128,12 +1198,12 @@ exports.DataSourceStrategyRegistry = __decorate([
|
|
|
1128
1198
|
* into datasource strategies consumable by the plugin SDK.
|
|
1129
1199
|
*/ class AdapterDataSourceStrategy {
|
|
1130
1200
|
/**
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1201
|
+
* Get from cache or create new instance of DB adapter.
|
|
1202
|
+
*
|
|
1203
|
+
* @param options
|
|
1204
|
+
* @param id
|
|
1205
|
+
* @returns
|
|
1206
|
+
*/ async create(options, id) {
|
|
1137
1207
|
if (id) {
|
|
1138
1208
|
if (this.runners.has(id)) {
|
|
1139
1209
|
return this.runners.get(id);
|
|
@@ -1169,9 +1239,10 @@ exports.DataSourceStrategyRegistry = __decorate([
|
|
|
1169
1239
|
return this.runnerClass;
|
|
1170
1240
|
}
|
|
1171
1241
|
constructor(runnerClass, extraArgs = []){
|
|
1242
|
+
this.runners = new Map() // dataSourceId -> runner instance
|
|
1243
|
+
;
|
|
1172
1244
|
this.runnerClass = runnerClass;
|
|
1173
1245
|
this.extraArgs = extraArgs;
|
|
1174
|
-
this.runners = new Map();
|
|
1175
1246
|
}
|
|
1176
1247
|
}
|
|
1177
1248
|
|
|
@@ -1271,13 +1342,13 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1271
1342
|
await this.runQuery(`SELECT 1`);
|
|
1272
1343
|
}
|
|
1273
1344
|
/**
|
|
1274
|
-
|
|
1275
|
-
|
|
1345
|
+
* Default implementation for table operations
|
|
1346
|
+
*/ async tableOp(action, params, options) {
|
|
1276
1347
|
switch(action){
|
|
1277
|
-
case
|
|
1348
|
+
case exports.DBTableAction.CREATE_TABLE:
|
|
1278
1349
|
{
|
|
1279
1350
|
// Default implementation for creating table (generic SQL syntax)
|
|
1280
|
-
const { schema, table, columns, createMode =
|
|
1351
|
+
const { schema, table, columns, createMode = exports.DBCreateTableMode.ERROR } = params;
|
|
1281
1352
|
const tableName = schema ? `${schema}.${table}` : table;
|
|
1282
1353
|
// Check if table exists (try to query table info)
|
|
1283
1354
|
let exists = false;
|
|
@@ -1289,17 +1360,17 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1289
1360
|
exists = false;
|
|
1290
1361
|
}
|
|
1291
1362
|
// --- MODE: ERROR → throw error if table exists ---
|
|
1292
|
-
if (exists && createMode ===
|
|
1363
|
+
if (exists && createMode === exports.DBCreateTableMode.ERROR) {
|
|
1293
1364
|
throw new Error(`Table "${tableName}" already exists`);
|
|
1294
1365
|
}
|
|
1295
1366
|
// --- MODE: IGNORE → do nothing if exists ---
|
|
1296
|
-
if (exists && createMode ===
|
|
1367
|
+
if (exists && createMode === exports.DBCreateTableMode.IGNORE) {
|
|
1297
1368
|
return;
|
|
1298
1369
|
}
|
|
1299
1370
|
// --- MODE: UPGRADE → auto upgrade (simple implementation: only add new columns) ---
|
|
1300
1371
|
// Note: This default implementation does not support modifying column types,
|
|
1301
1372
|
// recommend each database to implement its own version
|
|
1302
|
-
if (exists && createMode ===
|
|
1373
|
+
if (exists && createMode === exports.DBCreateTableMode.UPGRADE) {
|
|
1303
1374
|
console.warn(`[BaseSQLQueryRunner] UPGRADE mode uses basic implementation. Consider implementing tableOp for better support.`);
|
|
1304
1375
|
// Try to add new columns (will fail if column already exists, but doesn't affect)
|
|
1305
1376
|
for (const col of columns){
|
|
@@ -1324,7 +1395,7 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1324
1395
|
await this.runQuery(createTableStatement, options);
|
|
1325
1396
|
return;
|
|
1326
1397
|
}
|
|
1327
|
-
case
|
|
1398
|
+
case exports.DBTableAction.DROP_TABLE:
|
|
1328
1399
|
{
|
|
1329
1400
|
// Default implementation for dropping table
|
|
1330
1401
|
const { schema, table } = params;
|
|
@@ -1338,8 +1409,8 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1338
1409
|
}
|
|
1339
1410
|
}
|
|
1340
1411
|
/**
|
|
1341
|
-
|
|
1342
|
-
|
|
1412
|
+
* Generic type mapping (subclasses can override)
|
|
1413
|
+
*/ mapColumnType(type, isKey, length) {
|
|
1343
1414
|
switch(type == null ? void 0 : type.toLowerCase()){
|
|
1344
1415
|
case 'string':
|
|
1345
1416
|
return length ? `VARCHAR(${length})` : isKey ? 'VARCHAR(255)' : 'VARCHAR(1000)';
|
|
@@ -1359,8 +1430,8 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1359
1430
|
}
|
|
1360
1431
|
constructor(...args){
|
|
1361
1432
|
super(...args);
|
|
1362
|
-
this.syntax =
|
|
1363
|
-
this.protocol =
|
|
1433
|
+
this.syntax = exports.DBSyntaxEnum.SQL;
|
|
1434
|
+
this.protocol = exports.DBProtocolEnum.SQL;
|
|
1364
1435
|
}
|
|
1365
1436
|
}
|
|
1366
1437
|
exports.DBTableAction = void 0;
|
|
@@ -1381,7 +1452,9 @@ exports.DBTableAction = void 0;
|
|
|
1381
1452
|
DBTableAction["CLONE_TABLE"] = "cloneTable";
|
|
1382
1453
|
DBTableAction["OPTIMIZE_TABLE"] = "optimizeTable";
|
|
1383
1454
|
})(exports.DBTableAction || (exports.DBTableAction = {}));
|
|
1384
|
-
|
|
1455
|
+
/**
|
|
1456
|
+
* Modes for creating a table, if the table already exists
|
|
1457
|
+
*/ exports.DBCreateTableMode = void 0;
|
|
1385
1458
|
(function(DBCreateTableMode) {
|
|
1386
1459
|
DBCreateTableMode["ERROR"] = "error";
|
|
1387
1460
|
DBCreateTableMode["IGNORE"] = "ignore";
|
|
@@ -1411,8 +1484,7 @@ function AIModelProviderStrategy(provider) {
|
|
|
1411
1484
|
const match = (callerLine == null ? void 0 : callerLine.match(/\((file:\/\/\/[^\s)]+)\)/)) || (// case 1: file:///path...
|
|
1412
1485
|
callerLine == null ? void 0 : callerLine.match(/\((\/[^\s)]+)\)/)) || (// case 2: (/Users/xxx)
|
|
1413
1486
|
callerLine == null ? void 0 : callerLine.match(/at (file:\/\/\/[^\s]+)/)) || (// case 3: at file:///...
|
|
1414
|
-
callerLine == null ? void 0 : callerLine.match(/at (\/[^\s]+)/) // case 4: at /Users/xxx
|
|
1415
|
-
);
|
|
1487
|
+
callerLine == null ? void 0 : callerLine.match(/at (\/[^\s]+)/)); // case 4: at /Users/xxx
|
|
1416
1488
|
let file = match == null ? void 0 : match[1];
|
|
1417
1489
|
// remove the file:/// prefix
|
|
1418
1490
|
if (file == null ? void 0 : file.startsWith('file:///')) {
|
|
@@ -1447,10 +1519,9 @@ exports.AIModelProviderRegistry = class AIModelProviderRegistry extends BaseStra
|
|
|
1447
1519
|
};
|
|
1448
1520
|
exports.AIModelProviderRegistry = __decorate([
|
|
1449
1521
|
common.Injectable(),
|
|
1450
|
-
__metadata("design:type", Function),
|
|
1451
1522
|
__metadata("design:paramtypes", [
|
|
1452
|
-
|
|
1453
|
-
|
|
1523
|
+
core.DiscoveryService,
|
|
1524
|
+
core.Reflector
|
|
1454
1525
|
])
|
|
1455
1526
|
], exports.AIModelProviderRegistry);
|
|
1456
1527
|
|
|
@@ -1461,7 +1532,8 @@ class CredentialsValidateFailedError extends common.ForbiddenException {
|
|
|
1461
1532
|
class AIModelProviderNotFoundException extends common.NotFoundException {
|
|
1462
1533
|
}
|
|
1463
1534
|
|
|
1464
|
-
|
|
1535
|
+
var ModelProvider_1;
|
|
1536
|
+
exports.ModelProvider = ModelProvider_1 = class ModelProvider {
|
|
1465
1537
|
get name() {
|
|
1466
1538
|
return this.getProviderSchema().provider;
|
|
1467
1539
|
}
|
|
@@ -1469,10 +1541,10 @@ exports.ModelProvider = class ModelProvider {
|
|
|
1469
1541
|
await this.validateProviderCredentials(credentials);
|
|
1470
1542
|
}
|
|
1471
1543
|
/**
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1544
|
+
* Get provider lib root path.
|
|
1545
|
+
*
|
|
1546
|
+
* @returns Root of library
|
|
1547
|
+
*/ getProviderServerPath() {
|
|
1476
1548
|
return this.dir;
|
|
1477
1549
|
}
|
|
1478
1550
|
getProviderSchema() {
|
|
@@ -1507,11 +1579,11 @@ exports.ModelProvider = class ModelProvider {
|
|
|
1507
1579
|
return modelInstance;
|
|
1508
1580
|
}
|
|
1509
1581
|
/**
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1582
|
+
* Get provider models.
|
|
1583
|
+
* @param modelType - model type
|
|
1584
|
+
* @param onlyActive - only active models
|
|
1585
|
+
* @return provider models
|
|
1586
|
+
*/ getProviderModels(modelType, onlyActive = false) {
|
|
1515
1587
|
let modelTypes = [];
|
|
1516
1588
|
if (modelType) {
|
|
1517
1589
|
modelTypes.push(modelType);
|
|
@@ -1563,7 +1635,7 @@ exports.ModelProvider = class ModelProvider {
|
|
|
1563
1635
|
return null;
|
|
1564
1636
|
}
|
|
1565
1637
|
constructor(){
|
|
1566
|
-
this.logger = new common.Logger(
|
|
1638
|
+
this.logger = new common.Logger(ModelProvider_1.name);
|
|
1567
1639
|
// protected providerSchema: IAiProviderEntity | null = null
|
|
1568
1640
|
this.modelManagers = new Map();
|
|
1569
1641
|
const provider = Reflect.getMetadata(AI_MODEL_PROVIDER, this.constructor);
|
|
@@ -1573,9 +1645,8 @@ exports.ModelProvider = class ModelProvider {
|
|
|
1573
1645
|
this.dir = dir;
|
|
1574
1646
|
}
|
|
1575
1647
|
};
|
|
1576
|
-
exports.ModelProvider = __decorate([
|
|
1648
|
+
exports.ModelProvider = ModelProvider_1 = __decorate([
|
|
1577
1649
|
common.Injectable(),
|
|
1578
|
-
__metadata("design:type", Function),
|
|
1579
1650
|
__metadata("design:paramtypes", [])
|
|
1580
1651
|
], exports.ModelProvider);
|
|
1581
1652
|
|
|
@@ -1764,7 +1835,8 @@ function mergeCredentials(credentials, modelProperties) {
|
|
|
1764
1835
|
return _extends({}, credentials != null ? credentials : {}, modelProperties != null ? modelProperties : {});
|
|
1765
1836
|
}
|
|
1766
1837
|
|
|
1767
|
-
|
|
1838
|
+
var AIModel_1;
|
|
1839
|
+
let AIModel = AIModel_1 = class AIModel {
|
|
1768
1840
|
getChatModel(copilotModel, options) {
|
|
1769
1841
|
throw new Error(`Unsupport chat model!`);
|
|
1770
1842
|
}
|
|
@@ -1839,13 +1911,13 @@ let AIModel = class AIModel {
|
|
|
1839
1911
|
return null;
|
|
1840
1912
|
}
|
|
1841
1913
|
/**
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1914
|
+
* Get customizable model schema.
|
|
1915
|
+
* Implement this method in ai model sub class that can customize model
|
|
1916
|
+
*
|
|
1917
|
+
* @param model model name
|
|
1918
|
+
* @param credentials model credentials
|
|
1919
|
+
* @returns model schema
|
|
1920
|
+
*/ getCustomizableModelSchemaFromCredentials(model, credentials) {
|
|
1849
1921
|
return null;
|
|
1850
1922
|
}
|
|
1851
1923
|
processParameterRules(yamlData) {
|
|
@@ -1917,29 +1989,28 @@ let AIModel = class AIModel {
|
|
|
1917
1989
|
};
|
|
1918
1990
|
}
|
|
1919
1991
|
constructor(modelProvider, modelType){
|
|
1920
|
-
this.
|
|
1921
|
-
this.modelType = modelType;
|
|
1922
|
-
this.logger = new common.Logger(AIModel.name);
|
|
1992
|
+
this.logger = new common.Logger(AIModel_1.name);
|
|
1923
1993
|
this.modelSchemas = null;
|
|
1924
1994
|
this.positions = null;
|
|
1995
|
+
this.modelProvider = modelProvider;
|
|
1996
|
+
this.modelType = modelType;
|
|
1925
1997
|
this.modelProvider.registerAIModelInstance(this.modelType, this);
|
|
1926
1998
|
}
|
|
1927
1999
|
};
|
|
1928
|
-
AIModel = __decorate([
|
|
2000
|
+
AIModel = AIModel_1 = __decorate([
|
|
1929
2001
|
common.Injectable(),
|
|
1930
|
-
__metadata("design:type", Function),
|
|
1931
2002
|
__metadata("design:paramtypes", [
|
|
1932
|
-
|
|
1933
|
-
|
|
2003
|
+
exports.ModelProvider,
|
|
2004
|
+
String
|
|
1934
2005
|
])
|
|
1935
2006
|
], AIModel);
|
|
1936
2007
|
function getDefaultParameterRuleVariableMap(name) {
|
|
1937
2008
|
/**
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2009
|
+
* Get default parameter rule for given name
|
|
2010
|
+
*
|
|
2011
|
+
* @param name - parameter name
|
|
2012
|
+
* @return parameter rule
|
|
2013
|
+
*/ const defaultParameterRule = PARAMETER_RULE_TEMPLATE[name];
|
|
1943
2014
|
if (!defaultParameterRule) {
|
|
1944
2015
|
throw new Error(`Invalid model parameter rule name ${name}`);
|
|
1945
2016
|
}
|
|
@@ -2005,17 +2076,18 @@ function _class_private_field_loose_key(name) {
|
|
|
2005
2076
|
return "__private_" + id++ + "_" + name;
|
|
2006
2077
|
}
|
|
2007
2078
|
|
|
2079
|
+
var _a;
|
|
2008
2080
|
class LLMUsage {
|
|
2009
2081
|
static emptyUsage() {
|
|
2010
2082
|
return new LLMUsage(0, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0, 0.0, 'USD', 0.0);
|
|
2011
2083
|
}
|
|
2012
2084
|
plus(other) {
|
|
2013
2085
|
/**
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2086
|
+
* Add two LLMUsage instances together.
|
|
2087
|
+
*
|
|
2088
|
+
* @param other: Another LLMUsage instance to add
|
|
2089
|
+
* @return: A new LLMUsage instance with summed values
|
|
2090
|
+
*/ if (this.totalTokens === 0) {
|
|
2019
2091
|
return other;
|
|
2020
2092
|
} else {
|
|
2021
2093
|
return new LLMUsage(this.promptTokens + other.promptTokens, other.promptUnitPrice, other.promptPriceUnit, this.promptPrice + other.promptPrice, this.completionTokens + other.completionTokens, other.completionUnitPrice, other.completionPriceUnit, this.completionPrice + other.completionPrice, this.totalTokens + other.totalTokens, this.totalPrice + other.totalPrice, other.currency, this.latency + other.latency);
|
|
@@ -2023,11 +2095,11 @@ class LLMUsage {
|
|
|
2023
2095
|
}
|
|
2024
2096
|
add(other) {
|
|
2025
2097
|
/**
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2098
|
+
* Overload the + operator to add two LLMUsage instances.
|
|
2099
|
+
*
|
|
2100
|
+
* @param other: Another LLMUsage instance to add
|
|
2101
|
+
* @return: A new LLMUsage instance with summed values
|
|
2102
|
+
*/ return this.plus(other);
|
|
2031
2103
|
}
|
|
2032
2104
|
constructor(promptTokens, promptUnitPrice, promptPriceUnit, promptPrice, completionTokens, completionUnitPrice, completionPriceUnit, completionPrice, totalTokens, totalPrice, currency, latency){
|
|
2033
2105
|
this.promptTokens = promptTokens;
|
|
@@ -2225,9 +2297,10 @@ class LargeLanguageModel extends AIModel {
|
|
|
2225
2297
|
writable: true,
|
|
2226
2298
|
value: void 0
|
|
2227
2299
|
});
|
|
2228
|
-
_class_private_field_loose_base(this, _logger)[_logger] = new common.Logger(
|
|
2300
|
+
_class_private_field_loose_base(this, _logger)[_logger] = new common.Logger(_a.name);
|
|
2229
2301
|
}
|
|
2230
2302
|
}
|
|
2303
|
+
_a = LargeLanguageModel;
|
|
2231
2304
|
function calcTokenUsage(output) {
|
|
2232
2305
|
var _output_generations;
|
|
2233
2306
|
const tokenUsage = {
|
|
@@ -2275,8 +2348,8 @@ function calcTokenUsage(output) {
|
|
|
2275
2348
|
* In this way, the reasoning process in the model output can be separated from the main content, making it easier for subsequent structured processing and display.
|
|
2276
2349
|
*/ class ChatOAICompatReasoningModel extends openai.ChatOpenAICompletions {
|
|
2277
2350
|
/**
|
|
2278
|
-
|
|
2279
|
-
|
|
2351
|
+
*
|
|
2352
|
+
*/ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2280
2353
|
delta, rawResponse, defaultRole) {
|
|
2281
2354
|
const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole);
|
|
2282
2355
|
if (delta['content'] === '<think>') {
|
|
@@ -2462,7 +2535,7 @@ function normalizeContextSize(value) {
|
|
|
2462
2535
|
return undefined;
|
|
2463
2536
|
}
|
|
2464
2537
|
|
|
2465
|
-
const COMMAND_METADATA = '__command__';
|
|
2538
|
+
const COMMAND_METADATA$1 = '__command__';
|
|
2466
2539
|
/**
|
|
2467
2540
|
* Get a Chat Model of copilot model and check it's token limitation, record the token usage
|
|
2468
2541
|
*/ class CreateModelClientCommand extends cqrs.Command {
|
|
@@ -2473,10 +2546,26 @@ const COMMAND_METADATA = '__command__';
|
|
|
2473
2546
|
}
|
|
2474
2547
|
}
|
|
2475
2548
|
CreateModelClientCommand.type = '[AI Model] Create Model Client';
|
|
2476
|
-
Reflect.defineMetadata(COMMAND_METADATA, {
|
|
2549
|
+
Reflect.defineMetadata(COMMAND_METADATA$1, {
|
|
2477
2550
|
id: CreateModelClientCommand.type
|
|
2478
2551
|
}, CreateModelClientCommand);
|
|
2479
2552
|
|
|
2553
|
+
const SKILL_SOURCE_PROVIDER = 'SKILL_SOURCE_PROVIDER';
|
|
2554
|
+
const SkillSourceProviderStrategy = (provider)=>common.applyDecorators(common.SetMetadata(SKILL_SOURCE_PROVIDER, provider), common.SetMetadata(STRATEGY_META_KEY, SKILL_SOURCE_PROVIDER));
|
|
2555
|
+
|
|
2556
|
+
exports.SkillSourceProviderRegistry = class SkillSourceProviderRegistry extends BaseStrategyRegistry {
|
|
2557
|
+
constructor(discoveryService, reflector){
|
|
2558
|
+
super(SKILL_SOURCE_PROVIDER, discoveryService, reflector);
|
|
2559
|
+
}
|
|
2560
|
+
};
|
|
2561
|
+
exports.SkillSourceProviderRegistry = __decorate([
|
|
2562
|
+
common.Injectable(),
|
|
2563
|
+
__metadata("design:paramtypes", [
|
|
2564
|
+
core.DiscoveryService,
|
|
2565
|
+
core.Reflector
|
|
2566
|
+
])
|
|
2567
|
+
], exports.SkillSourceProviderRegistry);
|
|
2568
|
+
|
|
2480
2569
|
const AGENT_MIDDLEWARE_STRATEGY = 'AGENT_MIDDLEWARE_STRATEGY';
|
|
2481
2570
|
const AgentMiddlewareStrategy = (provider)=>common.applyDecorators(common.SetMetadata(AGENT_MIDDLEWARE_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, AGENT_MIDDLEWARE_STRATEGY));
|
|
2482
2571
|
|
|
@@ -2487,10 +2576,9 @@ exports.AgentMiddlewareRegistry = class AgentMiddlewareRegistry extends BaseStra
|
|
|
2487
2576
|
};
|
|
2488
2577
|
exports.AgentMiddlewareRegistry = __decorate([
|
|
2489
2578
|
common.Injectable(),
|
|
2490
|
-
__metadata("design:type", Function),
|
|
2491
2579
|
__metadata("design:paramtypes", [
|
|
2492
|
-
|
|
2493
|
-
|
|
2580
|
+
core.DiscoveryService,
|
|
2581
|
+
core.Reflector
|
|
2494
2582
|
])
|
|
2495
2583
|
], exports.AgentMiddlewareRegistry);
|
|
2496
2584
|
|
|
@@ -2502,15 +2590,7 @@ exports.AgentMiddlewareRegistry = __decorate([
|
|
|
2502
2590
|
"end"
|
|
2503
2591
|
];
|
|
2504
2592
|
|
|
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;
|
|
2593
|
+
const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
|
|
2514
2594
|
const VERSION_PATTERN = /^v[1-9][0-9]*$/;
|
|
2515
2595
|
function assertSegment(input, name) {
|
|
2516
2596
|
if (!SEGMENT_PATTERN.test(input)) {
|
|
@@ -2576,10 +2656,9 @@ exports.HandoffProcessorRegistry = class HandoffProcessorRegistry extends BaseSt
|
|
|
2576
2656
|
};
|
|
2577
2657
|
exports.HandoffProcessorRegistry = __decorate([
|
|
2578
2658
|
common.Injectable(),
|
|
2579
|
-
__metadata("design:type", Function),
|
|
2580
2659
|
__metadata("design:paramtypes", [
|
|
2581
|
-
|
|
2582
|
-
|
|
2660
|
+
core.DiscoveryService,
|
|
2661
|
+
core.Reflector
|
|
2583
2662
|
])
|
|
2584
2663
|
], exports.HandoffProcessorRegistry);
|
|
2585
2664
|
|
|
@@ -2688,26 +2767,52 @@ exports.HandoffProcessorRegistry = __decorate([
|
|
|
2688
2767
|
* ```
|
|
2689
2768
|
*/ const ChatChannel = (type)=>common.SetMetadata(CHAT_CHANNEL, type);
|
|
2690
2769
|
|
|
2691
|
-
|
|
2770
|
+
/**
|
|
2771
|
+
* Chat Channel Registry
|
|
2772
|
+
*
|
|
2773
|
+
* Manages all registered chat channel implementations.
|
|
2774
|
+
* Channels are automatically discovered and registered via @ChatChannel decorator.
|
|
2775
|
+
*
|
|
2776
|
+
* Supports:
|
|
2777
|
+
* - Organization-scoped channels
|
|
2778
|
+
* - Global channels (fallback)
|
|
2779
|
+
* - Plugin-based registration/removal
|
|
2780
|
+
* - Dynamic channel lookup
|
|
2781
|
+
*
|
|
2782
|
+
* @example
|
|
2783
|
+
* ```typescript
|
|
2784
|
+
* // Get channel by type
|
|
2785
|
+
* const channel = registry.get('lark')
|
|
2786
|
+
*
|
|
2787
|
+
* // List all available channels for an organization
|
|
2788
|
+
* const channels = registry.list(organizationId)
|
|
2789
|
+
*
|
|
2790
|
+
* // Send message using a channel
|
|
2791
|
+
* await channel.sendText(ctx, 'Hello!')
|
|
2792
|
+
* ```
|
|
2793
|
+
*/ exports.ChatChannelRegistry = class ChatChannelRegistry extends BaseStrategyRegistry {
|
|
2692
2794
|
constructor(discoveryService, reflector){
|
|
2693
2795
|
super(CHAT_CHANNEL, discoveryService, reflector);
|
|
2694
2796
|
}
|
|
2695
2797
|
};
|
|
2696
2798
|
exports.ChatChannelRegistry = __decorate([
|
|
2697
2799
|
common.Injectable(),
|
|
2698
|
-
__metadata("design:type", Function),
|
|
2699
2800
|
__metadata("design:paramtypes", [
|
|
2700
|
-
|
|
2701
|
-
|
|
2801
|
+
core.DiscoveryService,
|
|
2802
|
+
core.Reflector
|
|
2702
2803
|
])
|
|
2703
2804
|
], exports.ChatChannelRegistry);
|
|
2704
2805
|
|
|
2806
|
+
const COMMAND_METADATA = '__command__';
|
|
2705
2807
|
class CancelConversationCommand {
|
|
2706
2808
|
constructor(input){
|
|
2707
2809
|
this.input = input;
|
|
2708
2810
|
}
|
|
2709
2811
|
}
|
|
2710
2812
|
CancelConversationCommand.type = '[Chat Conversation] Cancel';
|
|
2813
|
+
Reflect.defineMetadata(COMMAND_METADATA, {
|
|
2814
|
+
id: CancelConversationCommand.type
|
|
2815
|
+
}, CancelConversationCommand);
|
|
2711
2816
|
|
|
2712
2817
|
const FILE_STORAGE_PROVIDER = 'FILE_STORAGE_PROVIDER';
|
|
2713
2818
|
const FileStorageProvider = (provider)=>common.applyDecorators(common.SetMetadata(FILE_STORAGE_PROVIDER, provider), common.SetMetadata(STRATEGY_META_KEY, FILE_STORAGE_PROVIDER));
|
|
@@ -2719,10 +2824,9 @@ exports.FileStorageProviderRegistry = class FileStorageProviderRegistry extends
|
|
|
2719
2824
|
};
|
|
2720
2825
|
exports.FileStorageProviderRegistry = __decorate([
|
|
2721
2826
|
common.Injectable(),
|
|
2722
|
-
__metadata("design:type", Function),
|
|
2723
2827
|
__metadata("design:paramtypes", [
|
|
2724
|
-
|
|
2725
|
-
|
|
2828
|
+
core.DiscoveryService,
|
|
2829
|
+
core.Reflector
|
|
2726
2830
|
])
|
|
2727
2831
|
], exports.FileStorageProviderRegistry);
|
|
2728
2832
|
|
|
@@ -2736,10 +2840,9 @@ exports.FileUploadTargetRegistry = class FileUploadTargetRegistry extends BaseSt
|
|
|
2736
2840
|
};
|
|
2737
2841
|
exports.FileUploadTargetRegistry = __decorate([
|
|
2738
2842
|
common.Injectable(),
|
|
2739
|
-
__metadata("design:type", Function),
|
|
2740
2843
|
__metadata("design:paramtypes", [
|
|
2741
|
-
|
|
2742
|
-
|
|
2844
|
+
core.DiscoveryService,
|
|
2845
|
+
core.Reflector
|
|
2743
2846
|
])
|
|
2744
2847
|
], exports.FileUploadTargetRegistry);
|
|
2745
2848
|
|
|
@@ -2794,8 +2897,18 @@ function resolveSandboxExecutionOptions(options, defaults = DEFAULT_SANDBOX_SHEL
|
|
|
2794
2897
|
*
|
|
2795
2898
|
* @param backend - Backend instance to check
|
|
2796
2899
|
* @returns True if the backend implements SandboxBackendProtocol
|
|
2797
|
-
*/ function
|
|
2798
|
-
return typeof
|
|
2900
|
+
*/ function isObjectLike(value) {
|
|
2901
|
+
return typeof value === 'object' && value !== null;
|
|
2902
|
+
}
|
|
2903
|
+
function isSandboxBackend(backend) {
|
|
2904
|
+
return isObjectLike(backend) && typeof Reflect.get(backend, 'execute') === 'function' && typeof Reflect.get(backend, 'id') === 'string';
|
|
2905
|
+
}
|
|
2906
|
+
function resolveSandboxBackend(sandbox) {
|
|
2907
|
+
if (!isObjectLike(sandbox)) {
|
|
2908
|
+
return null;
|
|
2909
|
+
}
|
|
2910
|
+
const candidate = Reflect.has(sandbox, 'backend') ? Reflect.get(sandbox, 'backend') : sandbox;
|
|
2911
|
+
return isSandboxBackend(candidate) ? candidate : null;
|
|
2799
2912
|
}
|
|
2800
2913
|
|
|
2801
2914
|
const MAX_LINE_LENGTH = 500;
|
|
@@ -3414,10 +3527,10 @@ try {
|
|
|
3414
3527
|
* Requires Node.js 20+ on the sandbox host.
|
|
3415
3528
|
*/ class BaseSandbox {
|
|
3416
3529
|
/**
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3530
|
+
* Internal hook for file/search operations. Concrete backends can override
|
|
3531
|
+
* this to distinguish "background helper commands" from user-facing shell
|
|
3532
|
+
* execute calls.
|
|
3533
|
+
*/ executeOperation(command, options) {
|
|
3421
3534
|
return this.execute(command, options);
|
|
3422
3535
|
}
|
|
3423
3536
|
async streamExecute(command, onLine, options) {
|
|
@@ -3428,11 +3541,11 @@ try {
|
|
|
3428
3541
|
return result;
|
|
3429
3542
|
}
|
|
3430
3543
|
/**
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3544
|
+
* List files and directories in the specified directory (non-recursive).
|
|
3545
|
+
*
|
|
3546
|
+
* @param path - Absolute path to directory
|
|
3547
|
+
* @returns List of FileInfo objects for files and directories directly in the directory.
|
|
3548
|
+
*/ async lsInfo(path) {
|
|
3436
3549
|
const command = buildLsCommand(path);
|
|
3437
3550
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
|
|
3438
3551
|
if (result.exitCode !== 0) {
|
|
@@ -3456,14 +3569,14 @@ try {
|
|
|
3456
3569
|
return infos;
|
|
3457
3570
|
}
|
|
3458
3571
|
/**
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3572
|
+
* List directory contents recursively with depth control and pagination.
|
|
3573
|
+
*
|
|
3574
|
+
* @param dirPath - Absolute path to directory
|
|
3575
|
+
* @param offset - 1-indexed entry number to start from (default: 1)
|
|
3576
|
+
* @param limit - Maximum number of entries to return (default: 25)
|
|
3577
|
+
* @param depth - Maximum depth to traverse (default: 2)
|
|
3578
|
+
* @returns Human-readable directory tree with indentation
|
|
3579
|
+
*/ async listDir(dirPath, offset = 1, limit = 25, depth = 2) {
|
|
3467
3580
|
if (offset < 1) {
|
|
3468
3581
|
return 'Error: offset must be a 1-indexed entry number';
|
|
3469
3582
|
}
|
|
@@ -3481,15 +3594,15 @@ try {
|
|
|
3481
3594
|
return result.output;
|
|
3482
3595
|
}
|
|
3483
3596
|
/**
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3597
|
+
* Read file content with line numbers.
|
|
3598
|
+
*
|
|
3599
|
+
* @param filePath - Absolute file path
|
|
3600
|
+
* @param offset - Line offset to start reading from (1-indexed)
|
|
3601
|
+
* @param limit - Maximum number of lines to read
|
|
3602
|
+
* @param mode - Read mode: 'slice' (default) or 'indentation'
|
|
3603
|
+
* @param indentation - Configuration for indentation mode
|
|
3604
|
+
* @returns Formatted file content with line numbers, or error message
|
|
3605
|
+
*/ async read(filePath, offset = 1, limit = 2000, mode = 'slice', indentation) {
|
|
3493
3606
|
const command = mode === 'indentation' ? buildIndentationReadCommand(filePath, offset, limit, indentation != null ? indentation : {}) : buildSliceReadCommand(filePath, offset, limit);
|
|
3494
3607
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
|
|
3495
3608
|
if (result.exitCode !== 0) {
|
|
@@ -3498,8 +3611,8 @@ try {
|
|
|
3498
3611
|
return result.output;
|
|
3499
3612
|
}
|
|
3500
3613
|
/**
|
|
3501
|
-
|
|
3502
|
-
|
|
3614
|
+
* Structured search results or error string for invalid input.
|
|
3615
|
+
*/ async grepRaw(pattern, path = '/', include = null) {
|
|
3503
3616
|
const command = buildGrepCommand(pattern, path, include);
|
|
3504
3617
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
|
|
3505
3618
|
if (result.exitCode === 1) {
|
|
@@ -3525,8 +3638,8 @@ try {
|
|
|
3525
3638
|
return matches;
|
|
3526
3639
|
}
|
|
3527
3640
|
/**
|
|
3528
|
-
|
|
3529
|
-
|
|
3641
|
+
* Search file contents for a regex pattern, returning human-readable output.
|
|
3642
|
+
*/ async grep(pattern, path = '/', include = null) {
|
|
3530
3643
|
const result = await this.grepRaw(pattern, path, include);
|
|
3531
3644
|
if (typeof result === 'string') {
|
|
3532
3645
|
return result;
|
|
@@ -3537,8 +3650,8 @@ try {
|
|
|
3537
3650
|
return formatGrepOutput(result);
|
|
3538
3651
|
}
|
|
3539
3652
|
/**
|
|
3540
|
-
|
|
3541
|
-
|
|
3653
|
+
* Structured glob matching returning FileInfo objects.
|
|
3654
|
+
*/ async globInfo(pattern, path = '/') {
|
|
3542
3655
|
const command = buildGlobCommand(path, pattern);
|
|
3543
3656
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS);
|
|
3544
3657
|
const infos = [];
|
|
@@ -3559,8 +3672,8 @@ try {
|
|
|
3559
3672
|
return infos;
|
|
3560
3673
|
}
|
|
3561
3674
|
/**
|
|
3562
|
-
|
|
3563
|
-
|
|
3675
|
+
* Find files matching a glob pattern, returning human-readable output.
|
|
3676
|
+
*/ async glob(pattern, path = '/') {
|
|
3564
3677
|
const files = await this.globInfo(pattern, path);
|
|
3565
3678
|
if (files.length === 0) {
|
|
3566
3679
|
return 'No files found';
|
|
@@ -3568,8 +3681,8 @@ try {
|
|
|
3568
3681
|
return formatGlobOutput(files);
|
|
3569
3682
|
}
|
|
3570
3683
|
/**
|
|
3571
|
-
|
|
3572
|
-
|
|
3684
|
+
* Create a new file with content.
|
|
3685
|
+
*/ async write(filePath, content) {
|
|
3573
3686
|
const command = buildWriteCommand(filePath, content);
|
|
3574
3687
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
|
|
3575
3688
|
if (result.exitCode !== 0) {
|
|
@@ -3622,8 +3735,8 @@ try {
|
|
|
3622
3735
|
};
|
|
3623
3736
|
}
|
|
3624
3737
|
/**
|
|
3625
|
-
|
|
3626
|
-
|
|
3738
|
+
* Append content to a file. Creates the file if it doesn't exist.
|
|
3739
|
+
*/ async append(filePath, content) {
|
|
3627
3740
|
const command = buildAppendCommand(filePath, content);
|
|
3628
3741
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
|
|
3629
3742
|
if (result.exitCode !== 0) {
|
|
@@ -3638,8 +3751,8 @@ try {
|
|
|
3638
3751
|
};
|
|
3639
3752
|
}
|
|
3640
3753
|
/**
|
|
3641
|
-
|
|
3642
|
-
|
|
3754
|
+
* Edit a file by replacing string occurrences.
|
|
3755
|
+
*/ async edit(filePath, oldString, newString, replaceAll = false) {
|
|
3643
3756
|
const command = buildEditCommand(filePath, oldString, newString, replaceAll);
|
|
3644
3757
|
const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
|
|
3645
3758
|
switch(result.exitCode){
|
|
@@ -3671,10 +3784,10 @@ try {
|
|
|
3671
3784
|
}
|
|
3672
3785
|
}
|
|
3673
3786
|
/**
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3787
|
+
* Perform multiple sequential edits on a single file.
|
|
3788
|
+
* All edits are applied sequentially, with each edit operating on the result of the previous edit.
|
|
3789
|
+
* All edits must succeed for the operation to succeed (atomic).
|
|
3790
|
+
*/ async multiEdit(filePath, edits) {
|
|
3678
3791
|
if (!edits || edits.length === 0) {
|
|
3679
3792
|
return {
|
|
3680
3793
|
error: 'No edits provided'
|
|
@@ -3714,29 +3827,50 @@ exports.SandboxProviderRegistry = class SandboxProviderRegistry extends BaseStra
|
|
|
3714
3827
|
};
|
|
3715
3828
|
exports.SandboxProviderRegistry = __decorate([
|
|
3716
3829
|
common.Injectable(),
|
|
3717
|
-
__metadata("design:type", Function),
|
|
3718
3830
|
__metadata("design:paramtypes", [
|
|
3719
|
-
|
|
3720
|
-
|
|
3831
|
+
core.DiscoveryService,
|
|
3832
|
+
core.Reflector
|
|
3721
3833
|
])
|
|
3722
3834
|
], exports.SandboxProviderRegistry);
|
|
3723
3835
|
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
}
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3836
|
+
const VIEW_EXTENSION_PROVIDER = 'VIEW_EXTENSION_PROVIDER';
|
|
3837
|
+
const ViewExtensionProvider = (providerKey)=>common.applyDecorators(common.SetMetadata(VIEW_EXTENSION_PROVIDER, providerKey), common.SetMetadata(STRATEGY_META_KEY, VIEW_EXTENSION_PROVIDER));
|
|
3838
|
+
|
|
3839
|
+
exports.ViewExtensionProviderRegistry = class ViewExtensionProviderRegistry extends BaseStrategyRegistry {
|
|
3840
|
+
listEntries(organizationId) {
|
|
3841
|
+
var _this_strategies_get;
|
|
3842
|
+
const orgKey = this.resolveOrganization(organizationId);
|
|
3843
|
+
const entries = new Map();
|
|
3844
|
+
var _this_strategies_get_entries;
|
|
3845
|
+
for (const [providerKey, provider] of (_this_strategies_get_entries = (_this_strategies_get = this.strategies.get(orgKey)) == null ? void 0 : _this_strategies_get.entries()) != null ? _this_strategies_get_entries : []){
|
|
3846
|
+
entries.set(providerKey, provider);
|
|
3847
|
+
}
|
|
3848
|
+
if (orgKey !== GLOBAL_ORGANIZATION_SCOPE) {
|
|
3849
|
+
var _this_strategies_get1;
|
|
3850
|
+
var _this_strategies_get_entries1;
|
|
3851
|
+
for (const [providerKey, provider] of (_this_strategies_get_entries1 = (_this_strategies_get1 = this.strategies.get(GLOBAL_ORGANIZATION_SCOPE)) == null ? void 0 : _this_strategies_get1.entries()) != null ? _this_strategies_get_entries1 : []){
|
|
3852
|
+
if (!entries.has(providerKey)) {
|
|
3853
|
+
entries.set(providerKey, provider);
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
}
|
|
3857
|
+
return Array.from(entries.entries()).map(([providerKey, provider])=>({
|
|
3858
|
+
providerKey,
|
|
3859
|
+
provider
|
|
3860
|
+
}));
|
|
3861
|
+
}
|
|
3862
|
+
constructor(discoveryService, reflector){
|
|
3863
|
+
super(VIEW_EXTENSION_PROVIDER, discoveryService, reflector);
|
|
3864
|
+
}
|
|
3865
|
+
};
|
|
3866
|
+
exports.ViewExtensionProviderRegistry = __decorate([
|
|
3867
|
+
common.Injectable(),
|
|
3868
|
+
__metadata("design:paramtypes", [
|
|
3869
|
+
core.DiscoveryService,
|
|
3870
|
+
core.Reflector
|
|
3871
|
+
])
|
|
3872
|
+
], exports.ViewExtensionProviderRegistry);
|
|
3873
|
+
|
|
3740
3874
|
exports.AGENT_CHAT_DISPATCH_MESSAGE_TYPE = AGENT_CHAT_DISPATCH_MESSAGE_TYPE;
|
|
3741
3875
|
exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
|
|
3742
3876
|
exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
|
|
@@ -3818,8 +3952,10 @@ exports.RerankModel = RerankModel;
|
|
|
3818
3952
|
exports.RetrieverStrategy = RetrieverStrategy;
|
|
3819
3953
|
exports.SANDBOX_PROVIDER = SANDBOX_PROVIDER;
|
|
3820
3954
|
exports.SANDBOX_SHELL_TIMEOUT_LIMITS_SEC = SANDBOX_SHELL_TIMEOUT_LIMITS_SEC;
|
|
3955
|
+
exports.SKILL_SOURCE_PROVIDER = SKILL_SOURCE_PROVIDER;
|
|
3821
3956
|
exports.STRATEGY_META_KEY = STRATEGY_META_KEY;
|
|
3822
3957
|
exports.SandboxProviderStrategy = SandboxProviderStrategy;
|
|
3958
|
+
exports.SkillSourceProviderStrategy = SkillSourceProviderStrategy;
|
|
3823
3959
|
exports.Speech2TextChatModel = Speech2TextChatModel;
|
|
3824
3960
|
exports.SpeechToTextModel = SpeechToTextModel;
|
|
3825
3961
|
exports.TEXT_SPLITTER_STRATEGY = TEXT_SPLITTER_STRATEGY;
|
|
@@ -3830,7 +3966,9 @@ exports.TextToSpeechModel = TextToSpeechModel;
|
|
|
3830
3966
|
exports.ToolsetStrategy = ToolsetStrategy;
|
|
3831
3967
|
exports.USER_PERMISSION_SERVICE_TOKEN = USER_PERMISSION_SERVICE_TOKEN;
|
|
3832
3968
|
exports.VECTOR_STORE_STRATEGY = VECTOR_STORE_STRATEGY;
|
|
3969
|
+
exports.VIEW_EXTENSION_PROVIDER = VIEW_EXTENSION_PROVIDER;
|
|
3833
3970
|
exports.VectorStoreStrategy = VectorStoreStrategy;
|
|
3971
|
+
exports.ViewExtensionProvider = ViewExtensionProvider;
|
|
3834
3972
|
exports.WORKFLOW_NODE_STRATEGY = WORKFLOW_NODE_STRATEGY;
|
|
3835
3973
|
exports.WORKFLOW_TRIGGER_STRATEGY = WORKFLOW_TRIGGER_STRATEGY;
|
|
3836
3974
|
exports.WorkflowNodeStrategy = WorkflowNodeStrategy;
|
|
@@ -3864,6 +4002,7 @@ exports.loadYamlFile = loadYamlFile;
|
|
|
3864
4002
|
exports.mergeCredentials = mergeCredentials;
|
|
3865
4003
|
exports.mergeParentChildChunks = mergeParentChildChunks;
|
|
3866
4004
|
exports.normalizeContextSize = normalizeContextSize;
|
|
4005
|
+
exports.resolveSandboxBackend = resolveSandboxBackend;
|
|
3867
4006
|
exports.resolveSandboxExecutionOptions = resolveSandboxExecutionOptions;
|
|
3868
4007
|
exports.runWithRequestContext = runWithRequestContext;
|
|
3869
4008
|
exports.secondsToMilliseconds = secondsToMilliseconds;
|