@xpert-ai/plugin-sdk 3.16.0 → 3.17.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/CHANGELOG.md +19 -0
- package/_extends.cjs.js +14 -0
- package/_extends.esm.js +12 -0
- package/collaboration-client.cjs.js +392 -8
- package/collaboration-client.esm.js +389 -1
- package/index.cjs.js +513 -286
- package/index.esm.js +458 -249
- package/model-provider-http-client.cjs.default.js +1 -0
- package/model-provider-http-client.cjs.js +118 -0
- package/model-provider-http-client.cjs.mjs +2 -0
- package/model-provider-http-client.d.ts +1 -0
- package/model-provider-http-client.esm.js +115 -0
- package/model-provider-toolset.cjs.default.js +1 -0
- package/model-provider-toolset.cjs.js +12 -0
- package/model-provider-toolset.cjs.mjs +2 -0
- package/model-provider-toolset.d.ts +1 -0
- package/model-provider-toolset.esm.js +6 -0
- package/model-provider.cjs.js +348 -0
- package/model-provider.esm.js +328 -0
- package/package.json +14 -2
- package/src/index.d.ts +1 -0
- package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +3 -0
- package/src/lib/agent/middleware/index.d.ts +1 -0
- package/src/lib/agent/middleware/model-output-validation-error.d.ts +27 -0
- package/src/lib/agent/middleware/runtime.d.ts +43 -4
- package/src/lib/ai-model/abstract-provider.d.ts +2 -2
- package/src/lib/ai-model/ai-model-provider.interface.d.ts +3 -3
- package/src/lib/ai-model/ai-model.d.ts +4 -1
- package/src/lib/ai-model/index.d.ts +2 -0
- package/src/lib/ai-model/llm.d.ts +49 -3
- package/src/lib/ai-model/managed-aigc-job.d.ts +37 -0
- package/src/lib/ai-model/model-provider-http-client.d.ts +51 -0
- package/src/lib/ai-model/pricing.d.ts +13 -1
- package/src/lib/ai-model/types/aigc.d.ts +39 -0
- package/src/lib/ai-model/types/index.d.ts +1 -0
- package/src/lib/ai-model/types/model.d.ts +10 -4
- package/src/lib/core/runtime-capability.d.ts +2 -0
- package/src/lib/evolution/index.d.ts +4 -0
- package/src/lib/evolution/provider.decorator.d.ts +2 -0
- package/src/lib/evolution/provider.registry.d.ts +7 -0
- package/src/lib/evolution/runtime-capability.d.ts +3 -0
- package/src/lib/managed-queue/index.d.ts +3 -1
- package/src/lib/runtime/capabilities/knowledgebase-documents.d.ts +59 -1
- package/src/lib/runtime/capabilities/knowledgebase.d.ts +95 -3
- package/src/lib/runtime/capabilities/workspace-files.d.ts +5 -0
- package/src/lib/toolset/builtin.d.ts +28 -0
- package/src/lib/toolset/index.d.ts +1 -0
- package/src/lib/toolset/model-provider.d.ts +31 -0
- package/src/lib/vectorstore/strategy.interface.d.ts +3 -0
- package/src/model-provider-http-client.d.ts +1 -0
- package/src/model-provider-toolset.d.ts +1 -0
- package/collaboration-client.cjs2.js +0 -406
- package/collaboration-client.esm2.js +0 -398
package/index.cjs.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var common = require('@nestjs/common');
|
|
4
4
|
var constants = require('@nestjs/common/constants');
|
|
5
5
|
var lodashEs = require('lodash-es');
|
|
6
|
-
var
|
|
6
|
+
var _extends = require('./_extends.cjs.js');
|
|
7
7
|
var core = require('@nestjs/core');
|
|
8
8
|
var rxjs = require('rxjs');
|
|
9
9
|
var contracts = require('@xpert-ai/contracts');
|
|
@@ -15,8 +15,7 @@ var cqrs = require('@nestjs/cqrs');
|
|
|
15
15
|
var fs = require('fs');
|
|
16
16
|
var http = require('http');
|
|
17
17
|
var https = require('https');
|
|
18
|
-
var
|
|
19
|
-
var zod = require('zod');
|
|
18
|
+
var modelProvider = require('./model-provider.cjs.js');
|
|
20
19
|
var fsPromises = require('fs/promises');
|
|
21
20
|
var path = require('path');
|
|
22
21
|
var i18next = require('i18next');
|
|
@@ -25,14 +24,20 @@ var yaml = require('yaml');
|
|
|
25
24
|
var Ajv = require('ajv');
|
|
26
25
|
var schemaDraft04 = require('ajv/dist/refs/json-schema-draft-06.json');
|
|
27
26
|
var _axios = require('axios');
|
|
27
|
+
var base = require('@langchain/core/callbacks/base');
|
|
28
|
+
var outputs = require('@langchain/core/outputs');
|
|
29
|
+
var messages = require('@langchain/core/messages');
|
|
28
30
|
var openai = require('@langchain/openai');
|
|
29
31
|
var documents = require('@langchain/core/documents');
|
|
30
32
|
var chat_models = require('@langchain/core/language_models/chat_models');
|
|
31
|
-
var messages = require('@langchain/core/messages');
|
|
32
33
|
var env = require('@langchain/core/utils/env');
|
|
34
|
+
var modelProviderHttpClient = require('./model-provider-http-client.cjs.js');
|
|
33
35
|
require('js-tiktoken');
|
|
34
|
-
var base = require('@langchain/core/language_models/base');
|
|
36
|
+
var base$1 = require('@langchain/core/language_models/base');
|
|
35
37
|
var connector = require('./connector.cjs.js');
|
|
38
|
+
var collaborationClient = require('./collaboration-client.cjs.js');
|
|
39
|
+
require('@langchain/core/tools');
|
|
40
|
+
require('zod');
|
|
36
41
|
|
|
37
42
|
function _interopNamespaceDefault(e) {
|
|
38
43
|
var n = Object.create(null);
|
|
@@ -158,12 +163,12 @@ function createPluginLogger(scope, baseMeta = {}) {
|
|
|
158
163
|
const wrap = (level, msg, meta)=>{
|
|
159
164
|
var // Maintain alignment with the Nest Logger interface
|
|
160
165
|
_nestLogger_level;
|
|
161
|
-
const payload = meta ?
|
|
166
|
+
const payload = meta ? _extends._extends({}, baseMeta, meta) : baseMeta;
|
|
162
167
|
(_nestLogger_level = nestLogger[level]) == null ? void 0 : _nestLogger_level.call(nestLogger, msg + (Object.keys(payload).length ? ` ${JSON.stringify(payload)}` : ''));
|
|
163
168
|
};
|
|
164
169
|
return {
|
|
165
170
|
child (meta) {
|
|
166
|
-
return createPluginLogger(scope,
|
|
171
|
+
return createPluginLogger(scope, _extends._extends({}, baseMeta, meta));
|
|
167
172
|
},
|
|
168
173
|
debug: (msg, meta)=>wrap('debug', msg, meta),
|
|
169
174
|
log: (msg, meta)=>wrap('log', msg, meta),
|
|
@@ -962,123 +967,6 @@ exports.ToolsetRegistry = __decorate([
|
|
|
962
967
|
])
|
|
963
968
|
], exports.ToolsetRegistry);
|
|
964
969
|
|
|
965
|
-
/**
|
|
966
|
-
* Base ability for all toolsets
|
|
967
|
-
*/ class BaseToolset extends tools.BaseToolkit {
|
|
968
|
-
/**
|
|
969
|
-
* Async init tools
|
|
970
|
-
*
|
|
971
|
-
* @returns
|
|
972
|
-
*/ async initTools() {
|
|
973
|
-
return this.tools;
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Get one tool
|
|
977
|
-
*
|
|
978
|
-
* @param toolName
|
|
979
|
-
* @returns
|
|
980
|
-
*/ getTool(toolName) {
|
|
981
|
-
var _this_getTools;
|
|
982
|
-
return (_this_getTools = this.getTools()) == null ? void 0 : _this_getTools.find((tool)=>tool.name === toolName);
|
|
983
|
-
}
|
|
984
|
-
/**
|
|
985
|
-
* Get state variables config
|
|
986
|
-
*
|
|
987
|
-
* @returns State variables
|
|
988
|
-
*/ async getVariables() {
|
|
989
|
-
return null;
|
|
990
|
-
}
|
|
991
|
-
/**
|
|
992
|
-
* Close all (connections).
|
|
993
|
-
*/ async close() {
|
|
994
|
-
//
|
|
995
|
-
}
|
|
996
|
-
constructor(params){
|
|
997
|
-
super();
|
|
998
|
-
this.params = params;
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
class BaseTool extends tools.StructuredTool {
|
|
1002
|
-
constructor(...args){
|
|
1003
|
-
super(...args);
|
|
1004
|
-
this.schema = zod.z.object({
|
|
1005
|
-
input: zod.z.string().optional()
|
|
1006
|
-
}).transform((obj)=>obj.input);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
class BuiltinToolset extends BaseToolset {
|
|
1011
|
-
get tenantId() {
|
|
1012
|
-
var _this_params;
|
|
1013
|
-
return (_this_params = this.params) == null ? void 0 : _this_params.tenantId;
|
|
1014
|
-
}
|
|
1015
|
-
get organizationId() {
|
|
1016
|
-
var _this_params;
|
|
1017
|
-
return (_this_params = this.params) == null ? void 0 : _this_params.organizationId;
|
|
1018
|
-
}
|
|
1019
|
-
get commandBus() {
|
|
1020
|
-
var _this_params;
|
|
1021
|
-
return (_this_params = this.params) == null ? void 0 : _this_params.commandBus;
|
|
1022
|
-
}
|
|
1023
|
-
get queryBus() {
|
|
1024
|
-
var _this_params;
|
|
1025
|
-
return (_this_params = this.params) == null ? void 0 : _this_params.queryBus;
|
|
1026
|
-
}
|
|
1027
|
-
get xpertId() {
|
|
1028
|
-
var _this_params;
|
|
1029
|
-
return (_this_params = this.params) == null ? void 0 : _this_params.xpertId;
|
|
1030
|
-
}
|
|
1031
|
-
async validateCredentials(credentials) {
|
|
1032
|
-
await this._validateCredentials(credentials);
|
|
1033
|
-
}
|
|
1034
|
-
async _validateCredentials(credentials) {
|
|
1035
|
-
throw new Error('Method not implemented.');
|
|
1036
|
-
}
|
|
1037
|
-
getId() {
|
|
1038
|
-
var _this_toolset;
|
|
1039
|
-
return (_this_toolset = this.toolset) == null ? void 0 : _this_toolset.id;
|
|
1040
|
-
}
|
|
1041
|
-
getCredentials() {
|
|
1042
|
-
var _this_toolset;
|
|
1043
|
-
return (_this_toolset = this.toolset) == null ? void 0 : _this_toolset.credentials;
|
|
1044
|
-
}
|
|
1045
|
-
getToolTitle(name) {
|
|
1046
|
-
var _this_toolset_tools, _this_toolset, _tool_schema;
|
|
1047
|
-
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);
|
|
1048
|
-
const identity = tool == null ? void 0 : (_tool_schema = tool.schema) == null ? void 0 : _tool_schema.identity;
|
|
1049
|
-
if (identity) {
|
|
1050
|
-
return identity.label;
|
|
1051
|
-
}
|
|
1052
|
-
return null;
|
|
1053
|
-
}
|
|
1054
|
-
/**
|
|
1055
|
-
* Get credentials schema
|
|
1056
|
-
*
|
|
1057
|
-
* @returns Credentials schema
|
|
1058
|
-
*/ getCredentialsSchema() {
|
|
1059
|
-
return collaborationClient._extends({}, this.credentialsSchema);
|
|
1060
|
-
}
|
|
1061
|
-
/**
|
|
1062
|
-
* Get toolset entity
|
|
1063
|
-
*
|
|
1064
|
-
* @returns XpertToolset
|
|
1065
|
-
*/ getToolset() {
|
|
1066
|
-
return this.toolset;
|
|
1067
|
-
}
|
|
1068
|
-
getName() {
|
|
1069
|
-
var _this_getToolset;
|
|
1070
|
-
return (_this_getToolset = this.getToolset()) == null ? void 0 : _this_getToolset.name;
|
|
1071
|
-
}
|
|
1072
|
-
constructor(providerName, toolset, params){
|
|
1073
|
-
super(params);
|
|
1074
|
-
this.logger = new common.Logger(this.constructor.name);
|
|
1075
|
-
this.providerName = providerName;
|
|
1076
|
-
this.toolset = toolset;
|
|
1077
|
-
this.params = params;
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
BuiltinToolset.provider = '';
|
|
1081
|
-
|
|
1082
970
|
/**
|
|
1083
971
|
* Restricted FileSystem based on granted permissions
|
|
1084
972
|
*/ class XpFileSystem {
|
|
@@ -1373,7 +1261,7 @@ class JsonSchemaValidator {
|
|
|
1373
1261
|
const PLUGIN_WEBHOOK_AUTH_METADATA_KEY = 'xpert:plugin:webhook-auth';
|
|
1374
1262
|
const PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN = 'XPERT_PLUGIN_WEBHOOK_AUTH_SERVICE';
|
|
1375
1263
|
function PluginWebhookAuth(metadata = {}) {
|
|
1376
|
-
return common.SetMetadata(PLUGIN_WEBHOOK_AUTH_METADATA_KEY,
|
|
1264
|
+
return common.SetMetadata(PLUGIN_WEBHOOK_AUTH_METADATA_KEY, _extends._extends({
|
|
1377
1265
|
integrationParam: 'id',
|
|
1378
1266
|
secretQueryParam: 'secret'
|
|
1379
1267
|
}, metadata));
|
|
@@ -1407,7 +1295,7 @@ exports.PluginWebhookAuthGuard = class PluginWebhookAuthGuard {
|
|
|
1407
1295
|
}
|
|
1408
1296
|
request.user = principalContext.user;
|
|
1409
1297
|
var _request_headers;
|
|
1410
|
-
request.headers =
|
|
1298
|
+
request.headers = _extends._extends({}, (_request_headers = request.headers) != null ? _request_headers : {}, principalContext.headers);
|
|
1411
1299
|
return true;
|
|
1412
1300
|
}
|
|
1413
1301
|
resolveMetadata(context) {
|
|
@@ -1433,40 +1321,6 @@ exports.PluginWebhookAuthGuard = __decorate([
|
|
|
1433
1321
|
])
|
|
1434
1322
|
], exports.PluginWebhookAuthGuard);
|
|
1435
1323
|
|
|
1436
|
-
function createRuntimeCapability(id, options = {}) {
|
|
1437
|
-
return Object.freeze({
|
|
1438
|
-
id,
|
|
1439
|
-
description: options.description
|
|
1440
|
-
});
|
|
1441
|
-
}
|
|
1442
|
-
const XPERT_RUNTIME_CAPABILITIES_TOKEN = 'XPERT_RUNTIME_CAPABILITIES';
|
|
1443
|
-
class DefaultRuntimeCapabilityRegistry {
|
|
1444
|
-
register(key, implementation) {
|
|
1445
|
-
this.capabilities.set(runtimeCapabilityId(key), implementation);
|
|
1446
|
-
return this;
|
|
1447
|
-
}
|
|
1448
|
-
has(key) {
|
|
1449
|
-
return this.capabilities.has(runtimeCapabilityId(key));
|
|
1450
|
-
}
|
|
1451
|
-
get(key) {
|
|
1452
|
-
return this.capabilities.get(runtimeCapabilityId(key));
|
|
1453
|
-
}
|
|
1454
|
-
require(key) {
|
|
1455
|
-
const implementation = this.get(key);
|
|
1456
|
-
if (!implementation) {
|
|
1457
|
-
throw new Error(`Runtime capability '${runtimeCapabilityId(key)}' is not available`);
|
|
1458
|
-
}
|
|
1459
|
-
return implementation;
|
|
1460
|
-
}
|
|
1461
|
-
constructor(entries = []){
|
|
1462
|
-
this.capabilities = new Map();
|
|
1463
|
-
entries.forEach(([key, implementation])=>this.register(key, implementation));
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
function runtimeCapabilityId(key) {
|
|
1467
|
-
return typeof key === 'string' ? key : key.id;
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
1324
|
const DATASOURCE_STRATEGY = 'DATASOURCE_STRATEGY';
|
|
1471
1325
|
const DataSourceStrategy = (provider)=>common.applyDecorators(common.SetMetadata(DATASOURCE_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, DATASOURCE_STRATEGY));
|
|
1472
1326
|
|
|
@@ -1852,10 +1706,15 @@ exports.ModelProvider = ModelProvider_1 = class ModelProvider {
|
|
|
1852
1706
|
}
|
|
1853
1707
|
async getModels(modelType) {
|
|
1854
1708
|
const providerSchema = this.getProviderSchema();
|
|
1855
|
-
|
|
1709
|
+
const supported = providerSchema.supported_model_types.includes(modelType) || modelType === contracts.AiModelTypeEnum.IMAGE && providerSchema.supported_model_types.includes(contracts.AiModelTypeEnum.TEXT2IMG);
|
|
1710
|
+
if (!supported) {
|
|
1856
1711
|
return [];
|
|
1857
1712
|
}
|
|
1858
|
-
|
|
1713
|
+
var _this_modelManagers_get;
|
|
1714
|
+
const modelInstance = modelType === contracts.AiModelTypeEnum.IMAGE ? (_this_modelManagers_get = this.modelManagers.get(contracts.AiModelTypeEnum.IMAGE)) != null ? _this_modelManagers_get : this.modelManagers.get(contracts.AiModelTypeEnum.TEXT2IMG) : this.modelManagers.get(modelType);
|
|
1715
|
+
if (!modelInstance) {
|
|
1716
|
+
throw new AiModelNotFoundException(`Missing AIModel instance for model type ${modelType}`);
|
|
1717
|
+
}
|
|
1859
1718
|
return modelInstance.predefinedModels();
|
|
1860
1719
|
}
|
|
1861
1720
|
registerAIModelInstance(modelType, modelInstance) {
|
|
@@ -1887,7 +1746,8 @@ exports.ModelProvider = ModelProvider_1 = class ModelProvider {
|
|
|
1887
1746
|
getSystemProviderModels(modelTypes) {
|
|
1888
1747
|
const models = [];
|
|
1889
1748
|
modelTypes == null ? void 0 : modelTypes.forEach((modelType)=>{
|
|
1890
|
-
|
|
1749
|
+
var _this_modelManagers_get;
|
|
1750
|
+
const modelManager = modelType === contracts.AiModelTypeEnum.IMAGE ? (_this_modelManagers_get = this.modelManagers.get(contracts.AiModelTypeEnum.IMAGE)) != null ? _this_modelManagers_get : this.modelManagers.get(contracts.AiModelTypeEnum.TEXT2IMG) : this.modelManagers.get(modelType);
|
|
1891
1751
|
if (modelManager) {
|
|
1892
1752
|
models.push(...modelManager.predefinedModels());
|
|
1893
1753
|
}
|
|
@@ -1921,6 +1781,14 @@ exports.ModelProvider = ModelProvider_1 = class ModelProvider {
|
|
|
1921
1781
|
case contracts.AiModelTypeEnum.RERANK:
|
|
1922
1782
|
var _this_getModelManager4;
|
|
1923
1783
|
return (_this_getModelManager4 = this.getModelManager(type)) == null ? void 0 : _this_getModelManager4.getReranker(copilotModel, options);
|
|
1784
|
+
case contracts.AiModelTypeEnum.IMAGE:
|
|
1785
|
+
var _this;
|
|
1786
|
+
var _this_modelManagers_get;
|
|
1787
|
+
return (_this = (_this_modelManagers_get = this.modelManagers.get(contracts.AiModelTypeEnum.IMAGE)) != null ? _this_modelManagers_get : this.modelManagers.get(contracts.AiModelTypeEnum.TEXT2IMG)) == null ? void 0 : _this.getAIGCModel(copilotModel, options);
|
|
1788
|
+
case contracts.AiModelTypeEnum.TEXT2IMG:
|
|
1789
|
+
case contracts.AiModelTypeEnum.VIDEO:
|
|
1790
|
+
var _this_getModelManager5;
|
|
1791
|
+
return (_this_getModelManager5 = this.getModelManager(type)) == null ? void 0 : _this_getModelManager5.getAIGCModel(copilotModel, options);
|
|
1924
1792
|
}
|
|
1925
1793
|
return null;
|
|
1926
1794
|
}
|
|
@@ -2122,7 +1990,7 @@ const CommonParameterRules = [
|
|
|
2122
1990
|
}
|
|
2123
1991
|
];
|
|
2124
1992
|
function mergeCredentials(credentials, modelProperties) {
|
|
2125
|
-
return
|
|
1993
|
+
return _extends._extends({}, credentials != null ? credentials : {}, modelProperties != null ? modelProperties : {});
|
|
2126
1994
|
}
|
|
2127
1995
|
|
|
2128
1996
|
function calculateModelPrice(pricing, priceType, tokens, inputTokens = tokens) {
|
|
@@ -2146,15 +2014,137 @@ function calculateModelPrice(pricing, priceType, tokens, inputTokens = tokens) {
|
|
|
2146
2014
|
currency: pricing.currency
|
|
2147
2015
|
};
|
|
2148
2016
|
}
|
|
2017
|
+
function resolveModelUsagePricingSnapshot(pricing, context) {
|
|
2018
|
+
var _normalizeDate;
|
|
2019
|
+
var _normalizeDate_toISOString;
|
|
2020
|
+
const capturedAt = (_normalizeDate_toISOString = (_normalizeDate = normalizeDate(context.startedAt)) == null ? void 0 : _normalizeDate.toISOString()) != null ? _normalizeDate_toISOString : new Date().toISOString();
|
|
2021
|
+
if (!isModelUsagePricingConfig(pricing)) {
|
|
2022
|
+
return {
|
|
2023
|
+
capturedAt,
|
|
2024
|
+
rules: []
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
const at = new Date(capturedAt);
|
|
2028
|
+
const rules = pricing.rules.filter((rule)=>matchesUsagePriceRule(rule, context, at));
|
|
2029
|
+
const units = new Set();
|
|
2030
|
+
for (const rule of rules){
|
|
2031
|
+
validateUsagePriceRule(rule);
|
|
2032
|
+
if (units.has(rule.unit)) {
|
|
2033
|
+
throw new Error(`Ambiguous usage pricing rules for unit '${rule.unit}'`);
|
|
2034
|
+
}
|
|
2035
|
+
units.add(rule.unit);
|
|
2036
|
+
}
|
|
2037
|
+
return {
|
|
2038
|
+
capturedAt,
|
|
2039
|
+
rules
|
|
2040
|
+
};
|
|
2041
|
+
}
|
|
2042
|
+
function calculateModelUsageCharge(snapshot, metric) {
|
|
2043
|
+
const rule = snapshot == null ? void 0 : snapshot.rules.find((candidate)=>candidate.unit === metric.unit);
|
|
2044
|
+
const fallbackQuantity = metricQuantity(metric);
|
|
2045
|
+
if (!rule) {
|
|
2046
|
+
return {
|
|
2047
|
+
pricingStatus: 'unpriced',
|
|
2048
|
+
quantity: fallbackQuantity
|
|
2049
|
+
};
|
|
2050
|
+
}
|
|
2051
|
+
const quantity = rule.unit === 'token' ? tokenQuantity(metric, rule.token_type) : fallbackQuantity;
|
|
2052
|
+
if (rule.charge_type === 'free') {
|
|
2053
|
+
return _extends._extends({
|
|
2054
|
+
pricingStatus: 'free',
|
|
2055
|
+
pricingRule: rule,
|
|
2056
|
+
quantity,
|
|
2057
|
+
unitSize: rule.unit_size,
|
|
2058
|
+
unitPrice: 0
|
|
2059
|
+
}, rule.currency ? {
|
|
2060
|
+
currency: rule.currency
|
|
2061
|
+
} : {}, {
|
|
2062
|
+
amount: 0
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
const unitPrice = Number(rule.unit_price);
|
|
2066
|
+
const unitSize = Number(rule.unit_size);
|
|
2067
|
+
return {
|
|
2068
|
+
pricingStatus: 'priced',
|
|
2069
|
+
pricingRule: rule,
|
|
2070
|
+
quantity,
|
|
2071
|
+
unitSize,
|
|
2072
|
+
unitPrice,
|
|
2073
|
+
currency: rule.currency,
|
|
2074
|
+
amount: roundCharge(quantity / unitSize * unitPrice)
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
2077
|
+
function isModelUsagePricingConfig(pricing) {
|
|
2078
|
+
return pricing !== undefined && 'type' in pricing && pricing.type === 'usage' && Array.isArray(pricing.rules);
|
|
2079
|
+
}
|
|
2080
|
+
function matchesUsagePriceRule(rule, context, at) {
|
|
2081
|
+
var _rule_operations;
|
|
2082
|
+
const effectiveFrom = normalizeDate(rule.effective_from);
|
|
2083
|
+
const effectiveTo = normalizeDate(rule.effective_to);
|
|
2084
|
+
if (!effectiveFrom || effectiveFrom > at || effectiveTo && effectiveTo <= at) return false;
|
|
2085
|
+
if (((_rule_operations = rule.operations) == null ? void 0 : _rule_operations.length) && !rule.operations.includes(context.operation)) return false;
|
|
2086
|
+
var _context_pricingDimensions;
|
|
2087
|
+
const dimensions = (_context_pricingDimensions = context.pricingDimensions) != null ? _context_pricingDimensions : {};
|
|
2088
|
+
var _rule_dimensions;
|
|
2089
|
+
return Object.entries((_rule_dimensions = rule.dimensions) != null ? _rule_dimensions : {}).every(([key, value])=>{
|
|
2090
|
+
if (key === 'resolution') return dimensions.resolution === value;
|
|
2091
|
+
if (key === 'audio') return dimensions.audio === value;
|
|
2092
|
+
if (key === 'videoInput') return dimensions.videoInput === value;
|
|
2093
|
+
if (key === 'mode') return dimensions.mode === value;
|
|
2094
|
+
return false;
|
|
2095
|
+
});
|
|
2096
|
+
}
|
|
2097
|
+
function validateUsagePriceRule(rule) {
|
|
2098
|
+
var _rule_id, _rule_version;
|
|
2099
|
+
if (!((_rule_id = rule.id) == null ? void 0 : _rule_id.trim()) || !((_rule_version = rule.version) == null ? void 0 : _rule_version.trim())) throw new Error('Usage pricing rules require id and version');
|
|
2100
|
+
if (!Number.isFinite(Number(rule.unit_size)) || Number(rule.unit_size) <= 0) {
|
|
2101
|
+
throw new Error(`Usage pricing rule '${rule.id}' requires a positive unit_size`);
|
|
2102
|
+
}
|
|
2103
|
+
if (rule.unit !== 'token' && rule.token_type) {
|
|
2104
|
+
throw new Error(`Usage pricing rule '${rule.id}' can only use token_type with token pricing`);
|
|
2105
|
+
}
|
|
2106
|
+
if (rule.charge_type === 'paid') {
|
|
2107
|
+
var _rule_currency;
|
|
2108
|
+
if (!Number.isFinite(Number(rule.unit_price)) || Number(rule.unit_price) <= 0 || !((_rule_currency = rule.currency) == null ? void 0 : _rule_currency.trim())) {
|
|
2109
|
+
throw new Error(`Paid usage pricing rule '${rule.id}' requires unit_price and currency`);
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
function metricQuantity(metric) {
|
|
2114
|
+
if (metric.unit !== 'token') return finiteQuantity(metric.quantity);
|
|
2115
|
+
var _metric_totalTokens, _ref;
|
|
2116
|
+
return finiteQuantity((_ref = (_metric_totalTokens = metric.totalTokens) != null ? _metric_totalTokens : metric.promptTokens) != null ? _ref : metric.completionTokens);
|
|
2117
|
+
}
|
|
2118
|
+
function tokenQuantity(metric, tokenType) {
|
|
2119
|
+
if (metric.unit !== 'token') return 0;
|
|
2120
|
+
if (tokenType === 'prompt') return finiteQuantity(metric.promptTokens);
|
|
2121
|
+
if (tokenType === 'completion') return finiteQuantity(metric.completionTokens);
|
|
2122
|
+
return finiteQuantity(metric.totalTokens);
|
|
2123
|
+
}
|
|
2124
|
+
function finiteQuantity(value) {
|
|
2125
|
+
const quantity = Number(value);
|
|
2126
|
+
return Number.isFinite(quantity) && quantity > 0 ? quantity : 0;
|
|
2127
|
+
}
|
|
2128
|
+
function normalizeDate(value) {
|
|
2129
|
+
if (!value) return undefined;
|
|
2130
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
2131
|
+
return Number.isNaN(date.getTime()) ? undefined : date;
|
|
2132
|
+
}
|
|
2133
|
+
function roundCharge(value) {
|
|
2134
|
+
return Number(value.toFixed(10));
|
|
2135
|
+
}
|
|
2149
2136
|
|
|
2150
2137
|
var AIModel_1;
|
|
2151
2138
|
let AIModel = AIModel_1 = class AIModel {
|
|
2152
2139
|
getChatModel(copilotModel, options) {
|
|
2153
2140
|
throw new Error(`Unsupport chat model!`);
|
|
2154
2141
|
}
|
|
2142
|
+
getAIGCModel(copilotModel, options) {
|
|
2143
|
+
throw new Error(`Unsupported AIGC model!`);
|
|
2144
|
+
}
|
|
2155
2145
|
getPrice(model, credentials, priceType, tokens, inputTokens = tokens) {
|
|
2156
2146
|
const modelSchema = this.getModelSchema(model, credentials);
|
|
2157
|
-
if (!modelSchema || !modelSchema.pricing) {
|
|
2147
|
+
if (!modelSchema || !modelSchema.pricing || isModelUsagePricingConfig(modelSchema.pricing)) {
|
|
2158
2148
|
return {
|
|
2159
2149
|
unitPrice: 0,
|
|
2160
2150
|
unit: 0,
|
|
@@ -2164,6 +2154,10 @@ let AIModel = AIModel_1 = class AIModel {
|
|
|
2164
2154
|
}
|
|
2165
2155
|
return calculateModelPrice(modelSchema.pricing, priceType, tokens, inputTokens);
|
|
2166
2156
|
}
|
|
2157
|
+
getUsagePricingSnapshot(model, credentials, context) {
|
|
2158
|
+
var _this_getModelSchema;
|
|
2159
|
+
return resolveModelUsagePricingSnapshot((_this_getModelSchema = this.getModelSchema(model, credentials)) == null ? void 0 : _this_getModelSchema.pricing, context);
|
|
2160
|
+
}
|
|
2167
2161
|
getModelPath() {
|
|
2168
2162
|
const modelType = this.modelType.toLowerCase();
|
|
2169
2163
|
return path__namespace.join(this.modelProvider.getProviderServerPath(), modelType);
|
|
@@ -2224,7 +2218,7 @@ let AIModel = AIModel_1 = class AIModel {
|
|
|
2224
2218
|
try {
|
|
2225
2219
|
const defaultParameterName = valueOf(DefaultParameterName, parameterRule.use_template);
|
|
2226
2220
|
const defaultParameterRule = getDefaultParameterRuleVariableMap(defaultParameterName);
|
|
2227
|
-
const copyDefaultParameterRule =
|
|
2221
|
+
const copyDefaultParameterRule = _extends._extends({}, defaultParameterRule, parameterRule);
|
|
2228
2222
|
parameterRule = copyDefaultParameterRule;
|
|
2229
2223
|
} catch (error) {
|
|
2230
2224
|
// Handle error if necessary
|
|
@@ -2353,6 +2347,11 @@ class TextToSpeechModel extends AIModel {
|
|
|
2353
2347
|
}
|
|
2354
2348
|
}
|
|
2355
2349
|
|
|
2350
|
+
class ImageGenerationModel extends AIModel {
|
|
2351
|
+
}
|
|
2352
|
+
class VideoGenerationModel extends AIModel {
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2356
2355
|
const PROVIDE_AI_MODEL_LLM = 'provide_ai_model_llm';
|
|
2357
2356
|
const PROVIDE_AI_MODEL_MODERATION = 'provide_ai_model_moderation';
|
|
2358
2357
|
const PROVIDE_AI_MODEL_SPEECH2TEXT = 'provide_ai_model_speech2text';
|
|
@@ -2417,7 +2416,7 @@ class LargeLanguageModel extends AIModel {
|
|
|
2417
2416
|
_commonParameterRules(model) {
|
|
2418
2417
|
return CommonParameterRules;
|
|
2419
2418
|
}
|
|
2420
|
-
calcResponseUsage(model, credentials, promptTokens, completionTokens) {
|
|
2419
|
+
calcResponseUsage(model, credentials, promptTokens, completionTokens, startedAt = this.startedAt) {
|
|
2421
2420
|
const promptPriceInfo = this.getPrice(model, credentials, contracts.PriceType.INPUT, promptTokens, promptTokens);
|
|
2422
2421
|
const completionPriceInfo = this.getPrice(model, credentials, contracts.PriceType.OUTPUT, completionTokens, promptTokens);
|
|
2423
2422
|
const totalPrice = Number((promptPriceInfo.totalAmount + completionPriceInfo.totalAmount).toFixed(7));
|
|
@@ -2434,30 +2433,68 @@ class LargeLanguageModel extends AIModel {
|
|
|
2434
2433
|
totalTokens: promptTokens + completionTokens,
|
|
2435
2434
|
totalPrice,
|
|
2436
2435
|
currency: promptPriceInfo.currency,
|
|
2437
|
-
latency: performance.now() -
|
|
2436
|
+
latency: performance.now() - startedAt
|
|
2438
2437
|
};
|
|
2439
2438
|
return usage;
|
|
2440
2439
|
}
|
|
2441
2440
|
createHandleUsageCallbacks(copilot, model, credentials, handleLLMTokens) {
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2441
|
+
const runs = new Map();
|
|
2442
|
+
const reportUsage = async (requestId, tokenUsage, startedAt, type)=>{
|
|
2443
|
+
if (!handleLLMTokens || tokenUsage.totalTokens <= 0) {
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
const usage = _extends._extends({}, this.calcResponseUsage(model, credentials, tokenUsage.promptTokens, tokenUsage.completionTokens, startedAt), type ? {
|
|
2447
|
+
type
|
|
2448
|
+
} : {});
|
|
2449
|
+
usage.totalTokens = tokenUsage.totalTokens;
|
|
2450
|
+
await handleLLMTokens({
|
|
2451
|
+
copilot,
|
|
2452
|
+
model,
|
|
2453
|
+
requestId,
|
|
2454
|
+
usage,
|
|
2455
|
+
tokenUsed: tokenUsage.totalTokens
|
|
2456
|
+
});
|
|
2457
|
+
};
|
|
2458
|
+
const callback = base.BaseCallbackHandler.fromMethods({
|
|
2459
|
+
handleLLMStart: (_llm, prompts, runId)=>{
|
|
2460
|
+
runs.set(runId, {
|
|
2461
|
+
startedAt: performance.now(),
|
|
2462
|
+
prompts,
|
|
2463
|
+
completion: ''
|
|
2464
|
+
});
|
|
2465
|
+
},
|
|
2466
|
+
handleLLMNewToken: (token, _idx, runId, _parentRunId, _tags, fields)=>{
|
|
2467
|
+
const run = runs.get(runId);
|
|
2468
|
+
if (run) {
|
|
2469
|
+
run.completion += token + readToolCallChunkText(fields == null ? void 0 : fields.chunk);
|
|
2459
2470
|
}
|
|
2471
|
+
},
|
|
2472
|
+
handleLLMEnd: async (output, runId)=>{
|
|
2473
|
+
const run = runs.get(runId);
|
|
2474
|
+
runs.delete(runId);
|
|
2475
|
+
const resolved = resolveTokenUsageWithAuthority(output);
|
|
2476
|
+
if (resolved.usage.totalTokens > 0) {
|
|
2477
|
+
var _run_startedAt;
|
|
2478
|
+
await reportUsage(runId, resolved.usage, (_run_startedAt = run == null ? void 0 : run.startedAt) != null ? _run_startedAt : performance.now(), resolved.type);
|
|
2479
|
+
} else {
|
|
2480
|
+
var _run_startedAt1;
|
|
2481
|
+
await reportUsage(runId, estimateFallbackUsage(run == null ? void 0 : run.prompts, (run == null ? void 0 : run.completion) || readCompletionText(output)), (_run_startedAt1 = run == null ? void 0 : run.startedAt) != null ? _run_startedAt1 : performance.now(), 'estimated');
|
|
2482
|
+
}
|
|
2483
|
+
},
|
|
2484
|
+
handleLLMError: async (error, runId)=>{
|
|
2485
|
+
const run = runs.get(runId);
|
|
2486
|
+
runs.delete(runId);
|
|
2487
|
+
if (!(run == null ? void 0 : run.completion) && !isAbortError(error)) {
|
|
2488
|
+
return;
|
|
2489
|
+
}
|
|
2490
|
+
var _run_startedAt;
|
|
2491
|
+
await reportUsage(runId, estimateFallbackUsage(run == null ? void 0 : run.prompts, run == null ? void 0 : run.completion), (_run_startedAt = run == null ? void 0 : run.startedAt) != null ? _run_startedAt : performance.now(), 'estimated');
|
|
2460
2492
|
}
|
|
2493
|
+
});
|
|
2494
|
+
callback.awaitHandlers = true;
|
|
2495
|
+
callback.raiseError = true;
|
|
2496
|
+
return [
|
|
2497
|
+
callback
|
|
2461
2498
|
];
|
|
2462
2499
|
}
|
|
2463
2500
|
createHandleLLMErrorCallbacks(fields, logger) {
|
|
@@ -2594,6 +2631,55 @@ class LargeLanguageModel extends AIModel {
|
|
|
2594
2631
|
}
|
|
2595
2632
|
}
|
|
2596
2633
|
_a = LargeLanguageModel;
|
|
2634
|
+
function estimateFallbackUsage(prompts, completion) {
|
|
2635
|
+
if (!prompts) {
|
|
2636
|
+
return {
|
|
2637
|
+
promptTokens: 0,
|
|
2638
|
+
completionTokens: 0,
|
|
2639
|
+
totalTokens: 0
|
|
2640
|
+
};
|
|
2641
|
+
}
|
|
2642
|
+
const promptTokens = estimateTokens(prompts.join('\n'));
|
|
2643
|
+
const completionTokens = estimateTokens(completion != null ? completion : '');
|
|
2644
|
+
return {
|
|
2645
|
+
promptTokens,
|
|
2646
|
+
completionTokens,
|
|
2647
|
+
totalTokens: promptTokens + completionTokens
|
|
2648
|
+
};
|
|
2649
|
+
}
|
|
2650
|
+
function readCompletionText(output) {
|
|
2651
|
+
var _output_generations;
|
|
2652
|
+
return (_output_generations = output.generations) == null ? void 0 : _output_generations.flat().map((generation)=>generation.text).filter(Boolean).join('\n');
|
|
2653
|
+
}
|
|
2654
|
+
function estimateTokens(text) {
|
|
2655
|
+
const estimatedText = text.replace(/data:image\/[a-zA-Z0-9.+-]+;base64,[a-zA-Z0-9+/_=-]+/g, '[image]');
|
|
2656
|
+
let cjkCharacters = 0;
|
|
2657
|
+
let otherCharacters = 0;
|
|
2658
|
+
for (const character of estimatedText){
|
|
2659
|
+
if (RegExp("\\p{Script=Han}", "u").test(character)) {
|
|
2660
|
+
cjkCharacters++;
|
|
2661
|
+
} else {
|
|
2662
|
+
otherCharacters++;
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
return Math.ceil(cjkCharacters / 1.5 + otherCharacters / 4);
|
|
2666
|
+
}
|
|
2667
|
+
function readToolCallChunkText(chunk) {
|
|
2668
|
+
if (!(chunk instanceof outputs.ChatGenerationChunk) || !messages.isAIMessageChunk(chunk.message)) {
|
|
2669
|
+
return '';
|
|
2670
|
+
}
|
|
2671
|
+
var _chunk_message_tool_call_chunks;
|
|
2672
|
+
return ((_chunk_message_tool_call_chunks = chunk.message.tool_call_chunks) != null ? _chunk_message_tool_call_chunks : []).map((toolCall)=>{
|
|
2673
|
+
var _toolCall_name, _toolCall_args;
|
|
2674
|
+
return `${(_toolCall_name = toolCall.name) != null ? _toolCall_name : ''}${(_toolCall_args = toolCall.args) != null ? _toolCall_args : ''}`;
|
|
2675
|
+
}).join('');
|
|
2676
|
+
}
|
|
2677
|
+
function isAbortError(error) {
|
|
2678
|
+
if (!(error instanceof Error)) {
|
|
2679
|
+
return false;
|
|
2680
|
+
}
|
|
2681
|
+
return error.name === 'AbortError' || /\babort(?:ed)?\b/i.test(error.message);
|
|
2682
|
+
}
|
|
2597
2683
|
function calcTokenUsage(output) {
|
|
2598
2684
|
var _output_generations;
|
|
2599
2685
|
const tokenUsage = {
|
|
@@ -2614,14 +2700,32 @@ function calcTokenUsage(output) {
|
|
|
2614
2700
|
return tokenUsage;
|
|
2615
2701
|
}
|
|
2616
2702
|
function resolveTokenUsage(output) {
|
|
2703
|
+
return resolveTokenUsageWithAuthority(output).usage;
|
|
2704
|
+
}
|
|
2705
|
+
function resolveTokenUsageWithAuthority(output) {
|
|
2617
2706
|
var _output_llmOutput, _output_llmOutput1, _output_llmOutput2;
|
|
2618
|
-
var _normalizeTokenUsage, _ref
|
|
2619
|
-
|
|
2620
|
-
totalTokens: (
|
|
2621
|
-
})
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2707
|
+
var _normalizeTokenUsage, _ref;
|
|
2708
|
+
const actualUsage = (_ref = (_normalizeTokenUsage = normalizeTokenUsage(calcTokenUsage(output))) != null ? _normalizeTokenUsage : normalizeTokenUsage((_output_llmOutput = output.llmOutput) == null ? void 0 : _output_llmOutput['tokenUsage'])) != null ? _ref : normalizeTokenUsage({
|
|
2709
|
+
totalTokens: (_output_llmOutput1 = output.llmOutput) == null ? void 0 : _output_llmOutput1['totalTokens']
|
|
2710
|
+
});
|
|
2711
|
+
if (actualUsage) {
|
|
2712
|
+
return {
|
|
2713
|
+
usage: actualUsage
|
|
2714
|
+
};
|
|
2715
|
+
}
|
|
2716
|
+
const estimatedUsage = normalizeTokenUsage((_output_llmOutput2 = output.llmOutput) == null ? void 0 : _output_llmOutput2['estimatedTokenUsage']);
|
|
2717
|
+
if (estimatedUsage) {
|
|
2718
|
+
return {
|
|
2719
|
+
usage: estimatedUsage,
|
|
2720
|
+
type: 'estimated'
|
|
2721
|
+
};
|
|
2722
|
+
}
|
|
2723
|
+
return {
|
|
2724
|
+
usage: {
|
|
2725
|
+
promptTokens: 0,
|
|
2726
|
+
completionTokens: 0,
|
|
2727
|
+
totalTokens: 0
|
|
2728
|
+
}
|
|
2625
2729
|
};
|
|
2626
2730
|
}
|
|
2627
2731
|
function normalizeTokenUsage(candidate) {
|
|
@@ -2664,6 +2768,109 @@ function isValidTokenCount(value) {
|
|
|
2664
2768
|
return tokenUsed;
|
|
2665
2769
|
}
|
|
2666
2770
|
|
|
2771
|
+
/**
|
|
2772
|
+
* Runs one asynchronous provider request inside a Managed Queue job.
|
|
2773
|
+
* Provider acceptance, terminal usage reporting, and result delivery are checkpointed so a queue retry resumes
|
|
2774
|
+
* from the last durable provider request instead of intentionally submitting a second request.
|
|
2775
|
+
*/ async function processAsyncAIGCManagedJob(job, options) {
|
|
2776
|
+
let payload = job.data;
|
|
2777
|
+
if (payload.phase === 'succeeded' && payload.result !== undefined) return payload.result;
|
|
2778
|
+
if (payload.phase === 'failed') throw new Error(payload.errorCode || 'Provider generation task failed');
|
|
2779
|
+
if (!payload.pricingSnapshot) {
|
|
2780
|
+
const pricingSnapshot = options.provider.resolvePricingSnapshot ? await options.provider.resolvePricingSnapshot({
|
|
2781
|
+
model: payload.model,
|
|
2782
|
+
operation: payload.operation,
|
|
2783
|
+
modality: payload.modality,
|
|
2784
|
+
pricingDimensions: payload.pricingDimensions,
|
|
2785
|
+
startedAt: payload.startedAt
|
|
2786
|
+
}) : {
|
|
2787
|
+
capturedAt: new Date().toISOString(),
|
|
2788
|
+
rules: []
|
|
2789
|
+
};
|
|
2790
|
+
payload = await checkpoint(job, _extends._extends({}, payload, {
|
|
2791
|
+
pricingSnapshot
|
|
2792
|
+
}));
|
|
2793
|
+
}
|
|
2794
|
+
if (!payload.providerRequestId) {
|
|
2795
|
+
const submission = await options.client.submit(payload.input);
|
|
2796
|
+
payload = await checkpoint(job, _extends._extends({}, payload, {
|
|
2797
|
+
providerRequestId: submission.providerRequestId,
|
|
2798
|
+
phase: 'submitted',
|
|
2799
|
+
providerState: 'submitted'
|
|
2800
|
+
}));
|
|
2801
|
+
}
|
|
2802
|
+
const providerRequestId = payload.providerRequestId;
|
|
2803
|
+
var _options_sleep;
|
|
2804
|
+
const sleep = (_options_sleep = options.sleep) != null ? _options_sleep : delay;
|
|
2805
|
+
const pollIntervalMs = normalizePollInterval(options.pollIntervalMs);
|
|
2806
|
+
while(true){
|
|
2807
|
+
const query = await options.client.query(providerRequestId, {
|
|
2808
|
+
operation: payload.operation,
|
|
2809
|
+
pricingDimensions: payload.pricingDimensions
|
|
2810
|
+
});
|
|
2811
|
+
const observation = query.observation;
|
|
2812
|
+
payload = await checkpoint(job, _extends._extends({}, payload, {
|
|
2813
|
+
providerState: observation.state,
|
|
2814
|
+
phase: toJobPhase(observation.state)
|
|
2815
|
+
}, observation.errorCode ? {
|
|
2816
|
+
errorCode: observation.errorCode
|
|
2817
|
+
} : {}));
|
|
2818
|
+
if (observation.state === 'succeeded') {
|
|
2819
|
+
payload = await reportTerminalUsage(job, payload, observation.metrics, options.provider);
|
|
2820
|
+
const result = await options.finalize(query.data);
|
|
2821
|
+
payload = await checkpoint(job, _extends._extends({}, payload, {
|
|
2822
|
+
phase: 'succeeded',
|
|
2823
|
+
result
|
|
2824
|
+
}));
|
|
2825
|
+
return result;
|
|
2826
|
+
}
|
|
2827
|
+
if (observation.state === 'failed' || observation.state === 'cancelled') {
|
|
2828
|
+
payload = await reportTerminalUsage(job, payload, observation.metrics, options.provider);
|
|
2829
|
+
var _options_failureMessage, _ref;
|
|
2830
|
+
const message = (_ref = (_options_failureMessage = options.failureMessage == null ? void 0 : options.failureMessage.call(options, query.data, observation)) != null ? _options_failureMessage : observation.errorCode) != null ? _ref : `Provider generation task ${providerRequestId} ${observation.state}`;
|
|
2831
|
+
await checkpoint(job, _extends._extends({}, payload, {
|
|
2832
|
+
phase: 'failed',
|
|
2833
|
+
errorCode: message
|
|
2834
|
+
}));
|
|
2835
|
+
throw new Error(message);
|
|
2836
|
+
}
|
|
2837
|
+
await sleep(pollIntervalMs);
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
async function reportTerminalUsage(job, payload, metrics, provider) {
|
|
2841
|
+
if (payload.usageReported || !(metrics == null ? void 0 : metrics.length)) return payload;
|
|
2842
|
+
await provider.reportUsage({
|
|
2843
|
+
requestId: payload.requestId,
|
|
2844
|
+
model: payload.model,
|
|
2845
|
+
modelType: payload.modality === 'image' ? contracts.AiModelTypeEnum.IMAGE : contracts.AiModelTypeEnum.VIDEO,
|
|
2846
|
+
toolName: payload.toolName,
|
|
2847
|
+
operation: payload.operation,
|
|
2848
|
+
modality: payload.modality,
|
|
2849
|
+
pricingDimensions: payload.pricingDimensions,
|
|
2850
|
+
pricingSnapshot: payload.pricingSnapshot,
|
|
2851
|
+
metrics,
|
|
2852
|
+
recordedAt: new Date().toISOString()
|
|
2853
|
+
});
|
|
2854
|
+
return checkpoint(job, _extends._extends({}, payload, {
|
|
2855
|
+
usageReported: true
|
|
2856
|
+
}));
|
|
2857
|
+
}
|
|
2858
|
+
async function checkpoint(job, payload) {
|
|
2859
|
+
await job.updateData(payload);
|
|
2860
|
+
return payload;
|
|
2861
|
+
}
|
|
2862
|
+
function toJobPhase(state) {
|
|
2863
|
+
if (state === 'succeeded') return 'succeeded';
|
|
2864
|
+
if (state === 'failed' || state === 'cancelled') return 'failed';
|
|
2865
|
+
return state === 'submitted' ? 'submitted' : 'processing';
|
|
2866
|
+
}
|
|
2867
|
+
function normalizePollInterval(value) {
|
|
2868
|
+
return Number.isFinite(value) && Number(value) > 0 ? Math.trunc(Number(value)) : 5000;
|
|
2869
|
+
}
|
|
2870
|
+
function delay(milliseconds) {
|
|
2871
|
+
return new Promise((resolve)=>setTimeout(resolve, milliseconds));
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2667
2874
|
/**
|
|
2668
2875
|
* A model extended from ChatOpenAICompletions, compatible with OpenAI-style chat completions,
|
|
2669
2876
|
* and supports structuring content within `<think>` reasoning tags into the `reasoning_content` field.
|
|
@@ -2679,7 +2886,12 @@ function isValidTokenCount(value) {
|
|
|
2679
2886
|
*
|
|
2680
2887
|
*/ _convertCompletionsDeltaToBaseMessageChunk(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2681
2888
|
delta, rawResponse, defaultRole) {
|
|
2682
|
-
|
|
2889
|
+
// Some OpenAI-compatible providers omit `delta.role` on the final usage
|
|
2890
|
+
// chunk. Without a role, LangChain creates a generic ChatMessageChunk;
|
|
2891
|
+
// persisting that chunk makes the next request contain `role: undefined`.
|
|
2892
|
+
// Treat role-less completion deltas as assistant output so they remain
|
|
2893
|
+
// valid both in the current stream and when the conversation is resumed.
|
|
2894
|
+
const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(delta, rawResponse, defaultRole != null ? defaultRole : 'assistant');
|
|
2683
2895
|
if (delta['content'] === '<think>') {
|
|
2684
2896
|
this.thinking = true;
|
|
2685
2897
|
messageChunk.content = '';
|
|
@@ -2695,7 +2907,14 @@ function isValidTokenCount(value) {
|
|
|
2695
2907
|
return messageChunk;
|
|
2696
2908
|
}
|
|
2697
2909
|
_convertCompletionsMessageToBaseMessage(message, rawResponse) {
|
|
2698
|
-
|
|
2910
|
+
var _message_role;
|
|
2911
|
+
// Some compatible providers also omit the role on non-stream responses.
|
|
2912
|
+
// Normalize that response before LangChain falls back to a generic
|
|
2913
|
+
// message with role `unknown`.
|
|
2914
|
+
const normalizedMessage = _extends._extends({}, message, {
|
|
2915
|
+
role: (_message_role = message.role) != null ? _message_role : 'assistant'
|
|
2916
|
+
});
|
|
2917
|
+
const langChainMessage = super._convertCompletionsMessageToBaseMessage(normalizedMessage, rawResponse);
|
|
2699
2918
|
console.log(langChainMessage.content);
|
|
2700
2919
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2701
2920
|
if (message.reasoning_content) {
|
|
@@ -2807,7 +3026,7 @@ class Speech2TextChatModel extends chat_models.BaseChatModel {
|
|
|
2807
3026
|
if (!apiKey) {
|
|
2808
3027
|
throw new Error(`Tongyi API key not found. Please set the DASHSCOPE_API_KEY environment variable or pass the key into "apiKey" field.`);
|
|
2809
3028
|
}
|
|
2810
|
-
super(
|
|
3029
|
+
super(_extends._extends({}, fields));
|
|
2811
3030
|
this.fields = fields;
|
|
2812
3031
|
this.apiKey = apiKey;
|
|
2813
3032
|
}
|
|
@@ -2840,10 +3059,10 @@ function getModelContextSize(input) {
|
|
|
2840
3059
|
return (_input_profile_maxInputTokens = input.profile.maxInputTokens) != null ? _input_profile_maxInputTokens : undefined;
|
|
2841
3060
|
}
|
|
2842
3061
|
if ("model" in input && typeof input.model === "string") {
|
|
2843
|
-
return base.getModelContextSize(input.model);
|
|
3062
|
+
return base$1.getModelContextSize(input.model);
|
|
2844
3063
|
}
|
|
2845
3064
|
if ("modelName" in input && typeof input.modelName === "string") {
|
|
2846
|
-
return base.getModelContextSize(input.modelName);
|
|
3065
|
+
return base$1.getModelContextSize(input.modelName);
|
|
2847
3066
|
}
|
|
2848
3067
|
return undefined;
|
|
2849
3068
|
}
|
|
@@ -2880,66 +3099,6 @@ Reflect.defineMetadata(COMMAND_METADATA$1, {
|
|
|
2880
3099
|
id: CreateModelClientCommand.type
|
|
2881
3100
|
}, CreateModelClientCommand);
|
|
2882
3101
|
|
|
2883
|
-
const KnowledgebaseRuntimeCapability = createRuntimeCapability('platform.knowledgebase', {
|
|
2884
|
-
description: 'List, search, and write chunks in platform knowledgebases.'
|
|
2885
|
-
});
|
|
2886
|
-
|
|
2887
|
-
const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.documents', {
|
|
2888
|
-
description: 'Upload, import, create, process, inspect, and delete persistent knowledgebase documents.'
|
|
2889
|
-
});
|
|
2890
|
-
|
|
2891
|
-
const ActorTokenRuntimeCapability = createRuntimeCapability('platform.actor-token', {
|
|
2892
|
-
description: 'Mint a short-lived host-issued actor bearer token for outbound API calls.'
|
|
2893
|
-
});
|
|
2894
|
-
|
|
2895
|
-
const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts', {
|
|
2896
|
-
description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
|
|
2897
|
-
});
|
|
2898
|
-
|
|
2899
|
-
/** Stable source identifier for portable workspace file references. */ const WORKSPACE_FILES_SOURCE = 'platform.workspace.files';
|
|
2900
|
-
const WorkspaceFilesRuntimeCapability = createRuntimeCapability('platform.workspace.files', {
|
|
2901
|
-
description: 'Upload, understand, resolve, read, and delete raw files in Xpert workspace volumes.'
|
|
2902
|
-
});
|
|
2903
|
-
|
|
2904
|
-
/** Stable machine-readable failures emitted by the Sandbox Jobs capability. */ const SANDBOX_JOB_ERROR_CODES = [
|
|
2905
|
-
'SANDBOX_ACTION_UNAVAILABLE',
|
|
2906
|
-
'SANDBOX_ACTION_INVALID',
|
|
2907
|
-
'SANDBOX_PROFILE_UNAVAILABLE',
|
|
2908
|
-
'SANDBOX_RUNTIME_UNAVAILABLE',
|
|
2909
|
-
'SANDBOX_VERSION_MISMATCH',
|
|
2910
|
-
'SANDBOX_CAPACITY_UNAVAILABLE',
|
|
2911
|
-
'SANDBOX_START_FAILED',
|
|
2912
|
-
'BROWSER_LAUNCH_FAILED',
|
|
2913
|
-
'EXPORT_TIMEOUT',
|
|
2914
|
-
'EXPORT_OOM',
|
|
2915
|
-
'EXPORT_MEDIA_FAILED',
|
|
2916
|
-
'EXPORT_INPUT_INVALID',
|
|
2917
|
-
'EXPORT_OUTPUT_INVALID',
|
|
2918
|
-
'SANDBOX_CANCELLED'
|
|
2919
|
-
];
|
|
2920
|
-
/** Line prefix used by trusted Actions to report structured, provider-neutral progress. */ const SANDBOX_JOB_PROGRESS_PREFIX = 'XPERT_SANDBOX_PROGRESS ';
|
|
2921
|
-
/** Error carrying retry policy and Job identity across plugin queue handlers. */ class SandboxJobRuntimeError extends Error {
|
|
2922
|
-
constructor(code, message, retryable, jobId){
|
|
2923
|
-
super(message);
|
|
2924
|
-
this.code = code;
|
|
2925
|
-
this.retryable = retryable;
|
|
2926
|
-
this.jobId = jobId;
|
|
2927
|
-
this.name = 'SandboxJobRuntimeError';
|
|
2928
|
-
}
|
|
2929
|
-
}
|
|
2930
|
-
const SANDBOX_JOB_ERROR_CODE_SET = new Set(SANDBOX_JOB_ERROR_CODES);
|
|
2931
|
-
/** Narrows an unknown failure to the structured Sandbox Jobs runtime error contract. */ function isSandboxJobRuntimeError(error) {
|
|
2932
|
-
if (error instanceof SandboxJobRuntimeError) return true;
|
|
2933
|
-
if (typeof error !== 'object' || error === null) return false;
|
|
2934
|
-
// Dynamically loaded plugins may resolve another Plugin SDK module instance,
|
|
2935
|
-
// so class identity is not a reliable runtime boundary. Validate the stable shape.
|
|
2936
|
-
const candidate = error;
|
|
2937
|
-
return candidate.name === 'SandboxJobRuntimeError' && typeof candidate.message === 'string' && typeof candidate.code === 'string' && SANDBOX_JOB_ERROR_CODE_SET.has(candidate.code) && typeof candidate.retryable === 'boolean' && (candidate.jobId === undefined || typeof candidate.jobId === 'string');
|
|
2938
|
-
}
|
|
2939
|
-
/** Runtime capability key used to resolve SandboxJobsApi from the platform registry. */ const SandboxJobsRuntimeCapability = createRuntimeCapability('platform.sandbox.jobs', {
|
|
2940
|
-
description: 'Run registered plugin actions in isolated, short-lived Sandbox Runtime jobs.'
|
|
2941
|
-
});
|
|
2942
|
-
|
|
2943
3102
|
const SKILL_SOURCE_PROVIDER = 'SKILL_SOURCE_PROVIDER';
|
|
2944
3103
|
const SkillSourceProviderStrategy = (provider)=>common.applyDecorators(common.SetMetadata(SKILL_SOURCE_PROVIDER, provider), common.SetMetadata(STRATEGY_META_KEY, SKILL_SOURCE_PROVIDER));
|
|
2945
3104
|
|
|
@@ -2980,14 +3139,40 @@ exports.AgentMiddlewareRegistry = __decorate([
|
|
|
2980
3139
|
'end'
|
|
2981
3140
|
];
|
|
2982
3141
|
|
|
2983
|
-
const AssistantTaskRuntimeCapability = createRuntimeCapability('platform.assistant_task', {
|
|
3142
|
+
const AssistantTaskRuntimeCapability = modelProvider.createRuntimeCapability('platform.assistant_task', {
|
|
2984
3143
|
description: 'Start asynchronous tasks on the current platform assistant.'
|
|
2985
3144
|
});
|
|
2986
3145
|
|
|
2987
|
-
const FileRuntimeCapability = createRuntimeCapability('platform.file', {
|
|
3146
|
+
const FileRuntimeCapability = modelProvider.createRuntimeCapability('platform.file', {
|
|
2988
3147
|
description: 'Resolve platform file handles into previewable file URLs.'
|
|
2989
3148
|
});
|
|
2990
3149
|
|
|
3150
|
+
const XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN = 'XPERT_AGENT_MIDDLEWARE_RUNTIME';
|
|
3151
|
+
|
|
3152
|
+
const MODEL_OUTPUT_VALIDATION_ERROR_CODE = 'MODEL_OUTPUT_VALIDATION_ERROR';
|
|
3153
|
+
/**
|
|
3154
|
+
* Signals that the provider returned a model response which could not be
|
|
3155
|
+
* accepted, but can be regenerated safely because no tool was executed.
|
|
3156
|
+
*
|
|
3157
|
+
* Keep `repairContext` compact and free of raw tool arguments. Model
|
|
3158
|
+
* middleware may use it as retry-local feedback, so it must never contain
|
|
3159
|
+
* credentials, complete documents, or other unbounded model output.
|
|
3160
|
+
*/ class ModelOutputValidationError extends Error {
|
|
3161
|
+
constructor(message, repairContext){
|
|
3162
|
+
super(message);
|
|
3163
|
+
this.code = MODEL_OUTPUT_VALIDATION_ERROR_CODE;
|
|
3164
|
+
this.retryable = true;
|
|
3165
|
+
this.repairContext = repairContext;
|
|
3166
|
+
this.name = 'ModelOutputValidationError';
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
function isModelOutputValidationError(error) {
|
|
3170
|
+
var _candidate_repairContext;
|
|
3171
|
+
if (!error || typeof error !== 'object') return false;
|
|
3172
|
+
const candidate = error;
|
|
3173
|
+
return candidate.code === MODEL_OUTPUT_VALIDATION_ERROR_CODE && candidate.retryable === true && ((_candidate_repairContext = candidate.repairContext) == null ? void 0 : _candidate_repairContext.kind) === 'invalid_tool_calls' && Array.isArray(candidate.repairContext.issues);
|
|
3174
|
+
}
|
|
3175
|
+
|
|
2991
3176
|
const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
|
|
2992
3177
|
const VERSION_PATTERN = /^v[1-9][0-9]*$/;
|
|
2993
3178
|
function assertSegment(input, name) {
|
|
@@ -3261,7 +3446,7 @@ exports.SSOProviderRegistry = __decorate([
|
|
|
3261
3446
|
])
|
|
3262
3447
|
], exports.SSOProviderRegistry);
|
|
3263
3448
|
|
|
3264
|
-
const ConnectorRuntimeCapability = createRuntimeCapability('platform.connector', {
|
|
3449
|
+
const ConnectorRuntimeCapability = modelProvider.createRuntimeCapability('platform.connector', {
|
|
3265
3450
|
description: 'Resolve connector credentials for agent middleware.'
|
|
3266
3451
|
});
|
|
3267
3452
|
|
|
@@ -4460,7 +4645,7 @@ function normalizePluginJobProcessorMetadata(options) {
|
|
|
4460
4645
|
if (concurrency !== undefined && (!Number.isFinite(concurrency) || concurrency <= 0)) {
|
|
4461
4646
|
throw new Error('PluginJobProcessor concurrency must be a positive number');
|
|
4462
4647
|
}
|
|
4463
|
-
return
|
|
4648
|
+
return _extends._extends({
|
|
4464
4649
|
pluginName,
|
|
4465
4650
|
queueName,
|
|
4466
4651
|
jobName
|
|
@@ -4984,7 +5169,7 @@ function escapeInlineScript(value) {
|
|
|
4984
5169
|
|
|
4985
5170
|
const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
|
|
4986
5171
|
|
|
4987
|
-
/** Platform-owned real-time collaboration capability available to scoped plugin runtimes. */ const CollaborationRuntimeCapability = createRuntimeCapability('platform.collaboration', {
|
|
5172
|
+
/** Platform-owned real-time collaboration capability available to scoped plugin runtimes. */ const CollaborationRuntimeCapability = modelProvider.createRuntimeCapability('platform.collaboration', {
|
|
4988
5173
|
description: 'Create, synchronize, persist, authorize, and observe platform-managed real-time collaboration documents.'
|
|
4989
5174
|
});
|
|
4990
5175
|
|
|
@@ -5004,12 +5189,30 @@ exports.CollaborationDocumentProviderRegistry = __decorate([
|
|
|
5004
5189
|
])
|
|
5005
5190
|
], exports.CollaborationDocumentProviderRegistry);
|
|
5006
5191
|
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
exports.
|
|
5011
|
-
|
|
5012
|
-
|
|
5192
|
+
const EVOLUTION_TARGET_PROVIDER = 'EVOLUTION_TARGET_PROVIDER';
|
|
5193
|
+
const EvolutionTargetProviderStrategy = (providerKey)=>common.applyDecorators(common.SetMetadata(EVOLUTION_TARGET_PROVIDER, providerKey), common.SetMetadata(STRATEGY_META_KEY, EVOLUTION_TARGET_PROVIDER));
|
|
5194
|
+
|
|
5195
|
+
exports.EvolutionTargetProviderRegistry = class EvolutionTargetProviderRegistry extends BaseStrategyRegistry {
|
|
5196
|
+
listDescriptors(organizationId) {
|
|
5197
|
+
return this.list(organizationId).map((provider)=>provider.descriptor);
|
|
5198
|
+
}
|
|
5199
|
+
constructor(discoveryService, reflector){
|
|
5200
|
+
super(EVOLUTION_TARGET_PROVIDER, discoveryService, reflector);
|
|
5201
|
+
}
|
|
5202
|
+
};
|
|
5203
|
+
exports.EvolutionTargetProviderRegistry = __decorate([
|
|
5204
|
+
common.Injectable(),
|
|
5205
|
+
__metadata("design:paramtypes", [
|
|
5206
|
+
core.DiscoveryService,
|
|
5207
|
+
core.Reflector
|
|
5208
|
+
])
|
|
5209
|
+
], exports.EvolutionTargetProviderRegistry);
|
|
5210
|
+
|
|
5211
|
+
const EVOLUTION_RUNTIME_SERVICE_TOKEN = 'XPERT_EVOLUTION_RUNTIME_SERVICE';
|
|
5212
|
+
const EvolutionRuntimeCapability = modelProvider.createRuntimeCapability('platform.agent-evolution', {
|
|
5213
|
+
description: 'Ingest learning signals and resolve immutable capability versions for domain runtimes.'
|
|
5214
|
+
});
|
|
5215
|
+
|
|
5013
5216
|
Object.defineProperty(exports, "ASSISTANT_CHAT_SEND_MESSAGE_COMMAND", {
|
|
5014
5217
|
enumerable: true,
|
|
5015
5218
|
get: function () { return contracts.ASSISTANT_CHAT_SEND_MESSAGE_COMMAND; }
|
|
@@ -5018,8 +5221,36 @@ Object.defineProperty(exports, "ASSISTANT_CONTEXT_SET_COMMAND", {
|
|
|
5018
5221
|
enumerable: true,
|
|
5019
5222
|
get: function () { return contracts.ASSISTANT_CONTEXT_SET_COMMAND; }
|
|
5020
5223
|
});
|
|
5224
|
+
exports.ActorTokenRuntimeCapability = modelProvider.ActorTokenRuntimeCapability;
|
|
5225
|
+
exports.ArtifactsRuntimeCapability = modelProvider.ArtifactsRuntimeCapability;
|
|
5226
|
+
exports.BaseTool = modelProvider.BaseTool;
|
|
5227
|
+
exports.BaseToolset = modelProvider.BaseToolset;
|
|
5228
|
+
exports.BuiltinToolset = modelProvider.BuiltinToolset;
|
|
5229
|
+
exports.DefaultAgentMiddlewareRuntimeCapabilityRegistry = modelProvider.DefaultRuntimeCapabilityRegistry;
|
|
5230
|
+
exports.DefaultRuntimeCapabilityRegistry = modelProvider.DefaultRuntimeCapabilityRegistry;
|
|
5231
|
+
exports.KnowledgebaseDocumentsRuntimeCapability = modelProvider.KnowledgebaseDocumentsRuntimeCapability;
|
|
5232
|
+
exports.KnowledgebaseProvisioningRuntimeCapability = modelProvider.KnowledgebaseProvisioningRuntimeCapability;
|
|
5233
|
+
exports.KnowledgebaseRuntimeCapability = modelProvider.KnowledgebaseRuntimeCapability;
|
|
5234
|
+
exports.ModelProviderBuiltinToolset = modelProvider.ModelProviderBuiltinToolset;
|
|
5235
|
+
exports.SANDBOX_JOB_ERROR_CODES = modelProvider.SANDBOX_JOB_ERROR_CODES;
|
|
5236
|
+
exports.SANDBOX_JOB_PROGRESS_PREFIX = modelProvider.SANDBOX_JOB_PROGRESS_PREFIX;
|
|
5237
|
+
exports.SandboxJobRuntimeError = modelProvider.SandboxJobRuntimeError;
|
|
5238
|
+
exports.SandboxJobsRuntimeCapability = modelProvider.SandboxJobsRuntimeCapability;
|
|
5239
|
+
exports.WORKSPACE_FILES_SOURCE = modelProvider.WORKSPACE_FILES_SOURCE;
|
|
5240
|
+
exports.WorkspaceFilesRuntimeCapability = modelProvider.WorkspaceFilesRuntimeCapability;
|
|
5241
|
+
exports.XPERT_RUNTIME_CAPABILITIES_TOKEN = modelProvider.XPERT_RUNTIME_CAPABILITIES_TOKEN;
|
|
5242
|
+
exports.createRuntimeCapability = modelProvider.createRuntimeCapability;
|
|
5243
|
+
exports.isSandboxJobRuntimeError = modelProvider.isSandboxJobRuntimeError;
|
|
5244
|
+
exports.ModelProviderHttpClient = modelProviderHttpClient.ModelProviderHttpClient;
|
|
5245
|
+
exports.ModelProviderHttpError = modelProviderHttpClient.ModelProviderHttpError;
|
|
5021
5246
|
exports.assertConnectorDefinition = connector.assertConnectorDefinition;
|
|
5022
5247
|
exports.getConnectorAuthMethods = connector.getConnectorAuthMethods;
|
|
5248
|
+
exports.base64ToBytes = collaborationClient.base64ToBytes;
|
|
5249
|
+
exports.bytesToBase64 = collaborationClient.bytesToBase64;
|
|
5250
|
+
exports.createCollaborationClient = collaborationClient.createCollaborationClient;
|
|
5251
|
+
exports.createCollaborationPresenceStore = collaborationClient.createCollaborationPresenceStore;
|
|
5252
|
+
exports.createSocketIoTransportAdapter = collaborationClient.createSocketIoTransportAdapter;
|
|
5253
|
+
exports.createYjsDocumentAdapter = collaborationClient.createYjsDocumentAdapter;
|
|
5023
5254
|
exports.ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN = ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN;
|
|
5024
5255
|
exports.AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING;
|
|
5025
5256
|
exports.AGENT_CHAT_DISPATCH_MESSAGE_TYPE = AGENT_CHAT_DISPATCH_MESSAGE_TYPE;
|
|
@@ -5027,11 +5258,9 @@ exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
|
|
|
5027
5258
|
exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
|
|
5028
5259
|
exports.AIModelProviderStrategy = AIModelProviderStrategy;
|
|
5029
5260
|
exports.AI_MODEL_PROVIDER = AI_MODEL_PROVIDER;
|
|
5030
|
-
exports.ActorTokenRuntimeCapability = ActorTokenRuntimeCapability;
|
|
5031
5261
|
exports.AdapterDataSourceStrategy = AdapterDataSourceStrategy;
|
|
5032
5262
|
exports.AgentMiddlewareStrategy = AgentMiddlewareStrategy;
|
|
5033
5263
|
exports.AiModelNotFoundException = AiModelNotFoundException;
|
|
5034
|
-
exports.ArtifactsRuntimeCapability = ArtifactsRuntimeCapability;
|
|
5035
5264
|
exports.AssistantTaskRuntimeCapability = AssistantTaskRuntimeCapability;
|
|
5036
5265
|
exports.BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN = BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN;
|
|
5037
5266
|
exports.BUILTIN_GLOBAL_SCOPE = BUILTIN_GLOBAL_SCOPE;
|
|
@@ -5040,9 +5269,6 @@ exports.BaseQueryRunner = BaseQueryRunner;
|
|
|
5040
5269
|
exports.BaseSQLQueryRunner = BaseSQLQueryRunner;
|
|
5041
5270
|
exports.BaseSandbox = BaseSandbox;
|
|
5042
5271
|
exports.BaseStrategyRegistry = BaseStrategyRegistry;
|
|
5043
|
-
exports.BaseTool = BaseTool;
|
|
5044
|
-
exports.BaseToolset = BaseToolset;
|
|
5045
|
-
exports.BuiltinToolset = BuiltinToolset;
|
|
5046
5272
|
exports.CHAT_CHANNEL = CHAT_CHANNEL;
|
|
5047
5273
|
exports.CHAT_CHANNEL_TEXT_LIMITS = CHAT_CHANNEL_TEXT_LIMITS;
|
|
5048
5274
|
exports.COLLABORATION_DOCUMENT_PROVIDER = COLLABORATION_DOCUMENT_PROVIDER;
|
|
@@ -5073,10 +5299,12 @@ exports.DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC = DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC;
|
|
|
5073
5299
|
exports.DOCUMENT_SOURCE_STRATEGY = DOCUMENT_SOURCE_STRATEGY;
|
|
5074
5300
|
exports.DOCUMENT_TRANSFORMER_STRATEGY = DOCUMENT_TRANSFORMER_STRATEGY;
|
|
5075
5301
|
exports.DataSourceStrategy = DataSourceStrategy;
|
|
5076
|
-
exports.DefaultAgentMiddlewareRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
|
|
5077
|
-
exports.DefaultRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
|
|
5078
5302
|
exports.DocumentSourceStrategy = DocumentSourceStrategy;
|
|
5079
5303
|
exports.DocumentTransformerStrategy = DocumentTransformerStrategy;
|
|
5304
|
+
exports.EVOLUTION_RUNTIME_SERVICE_TOKEN = EVOLUTION_RUNTIME_SERVICE_TOKEN;
|
|
5305
|
+
exports.EVOLUTION_TARGET_PROVIDER = EVOLUTION_TARGET_PROVIDER;
|
|
5306
|
+
exports.EvolutionRuntimeCapability = EvolutionRuntimeCapability;
|
|
5307
|
+
exports.EvolutionTargetProviderStrategy = EvolutionTargetProviderStrategy;
|
|
5080
5308
|
exports.FILE_STORAGE_PROVIDER = FILE_STORAGE_PROVIDER;
|
|
5081
5309
|
exports.FILE_UPLOAD_TARGET_STRATEGY = FILE_UPLOAD_TARGET_STRATEGY;
|
|
5082
5310
|
exports.FileRuntimeCapability = FileRuntimeCapability;
|
|
@@ -5090,19 +5318,20 @@ exports.HandoffProcessorStrategy = HandoffProcessorStrategy;
|
|
|
5090
5318
|
exports.IMAGE_UNDERSTANDING_STRATEGY = IMAGE_UNDERSTANDING_STRATEGY;
|
|
5091
5319
|
exports.INTEGRATION_PERMISSION_SERVICE_TOKEN = INTEGRATION_PERMISSION_SERVICE_TOKEN;
|
|
5092
5320
|
exports.INTEGRATION_STRATEGY = INTEGRATION_STRATEGY;
|
|
5321
|
+
exports.ImageGenerationModel = ImageGenerationModel;
|
|
5093
5322
|
exports.ImageUnderstandingStrategy = ImageUnderstandingStrategy;
|
|
5094
5323
|
exports.IntegrationStrategyKey = IntegrationStrategyKey;
|
|
5095
5324
|
exports.JUMP_TO_TARGETS = JUMP_TO_TARGETS;
|
|
5096
5325
|
exports.JsonSchemaValidator = JsonSchemaValidator;
|
|
5097
5326
|
exports.KNOWLEDGE_STRATEGY = KNOWLEDGE_STRATEGY;
|
|
5098
5327
|
exports.KnowledgeStrategyKey = KnowledgeStrategyKey;
|
|
5099
|
-
exports.KnowledgebaseDocumentsRuntimeCapability = KnowledgebaseDocumentsRuntimeCapability;
|
|
5100
|
-
exports.KnowledgebaseRuntimeCapability = KnowledgebaseRuntimeCapability;
|
|
5101
5328
|
exports.LLMUsage = LLMUsage;
|
|
5102
5329
|
exports.LargeLanguageModel = LargeLanguageModel;
|
|
5103
5330
|
exports.MANAGED_CONNECTION_REGISTRY_TOKEN = MANAGED_CONNECTION_REGISTRY_TOKEN;
|
|
5104
5331
|
exports.MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN;
|
|
5105
5332
|
exports.MANAGED_QUEUE_SERVICE_TOKEN = MANAGED_QUEUE_SERVICE_TOKEN;
|
|
5333
|
+
exports.MODEL_OUTPUT_VALIDATION_ERROR_CODE = MODEL_OUTPUT_VALIDATION_ERROR_CODE;
|
|
5334
|
+
exports.ModelOutputValidationError = ModelOutputValidationError;
|
|
5106
5335
|
exports.ORGANIZATION_METADATA_KEY = ORGANIZATION_METADATA_KEY;
|
|
5107
5336
|
exports.OpenAICompatibleReranker = OpenAICompatibleReranker;
|
|
5108
5337
|
exports.PERMISSION_OPERATION_METADATA_KEY = PERMISSION_OPERATION_METADATA_KEY;
|
|
@@ -5125,8 +5354,6 @@ exports.RequestContext = RequestContext;
|
|
|
5125
5354
|
exports.RequirePermissionOperation = RequirePermissionOperation;
|
|
5126
5355
|
exports.RerankModel = RerankModel;
|
|
5127
5356
|
exports.RetrieverStrategy = RetrieverStrategy;
|
|
5128
|
-
exports.SANDBOX_JOB_ERROR_CODES = SANDBOX_JOB_ERROR_CODES;
|
|
5129
|
-
exports.SANDBOX_JOB_PROGRESS_PREFIX = SANDBOX_JOB_PROGRESS_PREFIX;
|
|
5130
5357
|
exports.SANDBOX_PROVIDER = SANDBOX_PROVIDER;
|
|
5131
5358
|
exports.SANDBOX_RUNTIME_PROVIDER = SANDBOX_RUNTIME_PROVIDER;
|
|
5132
5359
|
exports.SANDBOX_SHELL_TIMEOUT_LIMITS_SEC = SANDBOX_SHELL_TIMEOUT_LIMITS_SEC;
|
|
@@ -5139,8 +5366,6 @@ exports.SSO_BINDING_PERMISSION_SERVICE_TOKEN = SSO_BINDING_PERMISSION_SERVICE_TO
|
|
|
5139
5366
|
exports.SSO_PROVIDER = SSO_PROVIDER;
|
|
5140
5367
|
exports.STRATEGY_META_KEY = STRATEGY_META_KEY;
|
|
5141
5368
|
exports.SYSTEM_GLOBAL_SCOPE = SYSTEM_GLOBAL_SCOPE;
|
|
5142
|
-
exports.SandboxJobRuntimeError = SandboxJobRuntimeError;
|
|
5143
|
-
exports.SandboxJobsRuntimeCapability = SandboxJobsRuntimeCapability;
|
|
5144
5369
|
exports.SandboxProviderStrategy = SandboxProviderStrategy;
|
|
5145
5370
|
exports.SandboxRuntimeProviderStrategy = SandboxRuntimeProviderStrategy;
|
|
5146
5371
|
exports.SandboxWorkspaceMapperStrategy = SandboxWorkspaceMapperStrategy;
|
|
@@ -5163,15 +5388,14 @@ exports.VIDEO_GENERATOR_FAMILIES = VIDEO_GENERATOR_FAMILIES;
|
|
|
5163
5388
|
exports.VIEW_EXTENSION_CACHE_SERVICE_TOKEN = VIEW_EXTENSION_CACHE_SERVICE_TOKEN;
|
|
5164
5389
|
exports.VIEW_EXTENSION_PROVIDER = VIEW_EXTENSION_PROVIDER;
|
|
5165
5390
|
exports.VectorStoreStrategy = VectorStoreStrategy;
|
|
5391
|
+
exports.VideoGenerationModel = VideoGenerationModel;
|
|
5166
5392
|
exports.ViewExtensionProvider = ViewExtensionProvider;
|
|
5167
5393
|
exports.WORKFLOW_NODE_STRATEGY = WORKFLOW_NODE_STRATEGY;
|
|
5168
5394
|
exports.WORKFLOW_TRIGGER_STRATEGY = WORKFLOW_TRIGGER_STRATEGY;
|
|
5169
|
-
exports.WORKSPACE_FILES_SOURCE = WORKSPACE_FILES_SOURCE;
|
|
5170
5395
|
exports.WorkflowNodeStrategy = WorkflowNodeStrategy;
|
|
5171
5396
|
exports.WorkflowTriggerStrategy = WorkflowTriggerStrategy;
|
|
5172
|
-
exports.WorkspaceFilesRuntimeCapability = WorkspaceFilesRuntimeCapability;
|
|
5173
5397
|
exports.WrapWorkflowNodeExecutionCommand = WrapWorkflowNodeExecutionCommand;
|
|
5174
|
-
exports.
|
|
5398
|
+
exports.XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN = XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN;
|
|
5175
5399
|
exports.XpFileSystem = XpFileSystem;
|
|
5176
5400
|
exports.XpertServerPlugin = XpertServerPlugin;
|
|
5177
5401
|
exports.als = als;
|
|
@@ -5179,11 +5403,11 @@ exports.appendSandboxMessage = appendSandboxMessage;
|
|
|
5179
5403
|
exports.buildSandboxTimeoutMessage = buildSandboxTimeoutMessage;
|
|
5180
5404
|
exports.calcTokenUsage = calcTokenUsage;
|
|
5181
5405
|
exports.calculateModelPrice = calculateModelPrice;
|
|
5406
|
+
exports.calculateModelUsageCharge = calculateModelUsageCharge;
|
|
5182
5407
|
exports.chunkText = chunkText;
|
|
5183
5408
|
exports.countTokensSafe = countTokensSafe;
|
|
5184
5409
|
exports.createI18nInstance = createI18nInstance;
|
|
5185
5410
|
exports.createPluginLogger = createPluginLogger;
|
|
5186
|
-
exports.createRuntimeCapability = createRuntimeCapability;
|
|
5187
5411
|
exports.defineAgentMessageType = defineAgentMessageType;
|
|
5188
5412
|
exports.defineChannelMessageType = defineChannelMessageType;
|
|
5189
5413
|
exports.derivePluginArtifactNamespace = derivePluginArtifactNamespace;
|
|
@@ -5199,9 +5423,10 @@ exports.getRequestContext = getRequestContext;
|
|
|
5199
5423
|
exports.getRequiredPermissionOperation = getRequiredPermissionOperation;
|
|
5200
5424
|
exports.getTenantGlobalScopeKey = getTenantGlobalScopeKey;
|
|
5201
5425
|
exports.isDevelopmentSandboxRuntimeEnvironment = isDevelopmentSandboxRuntimeEnvironment;
|
|
5426
|
+
exports.isModelOutputValidationError = isModelOutputValidationError;
|
|
5427
|
+
exports.isModelUsagePricingConfig = isModelUsagePricingConfig;
|
|
5202
5428
|
exports.isRemoteFile = isRemoteFile;
|
|
5203
5429
|
exports.isSandboxBackend = isSandboxBackend;
|
|
5204
|
-
exports.isSandboxJobRuntimeError = isSandboxJobRuntimeError;
|
|
5205
5430
|
exports.isSandboxManagedServiceAdapter = isSandboxManagedServiceAdapter;
|
|
5206
5431
|
exports.isSandboxServiceProxyAdapter = isSandboxServiceProxyAdapter;
|
|
5207
5432
|
exports.isSandboxTerminalAdapter = isSandboxTerminalAdapter;
|
|
@@ -5213,9 +5438,11 @@ exports.mergeCredentials = mergeCredentials;
|
|
|
5213
5438
|
exports.mergeParentChildChunks = mergeParentChildChunks;
|
|
5214
5439
|
exports.normalizeContextSize = normalizeContextSize;
|
|
5215
5440
|
exports.pluginArtifactTableName = pluginArtifactTableName;
|
|
5441
|
+
exports.processAsyncAIGCManagedJob = processAsyncAIGCManagedJob;
|
|
5216
5442
|
exports.renderRemoteModuleIframeHtml = renderRemoteModuleIframeHtml;
|
|
5217
5443
|
exports.renderRemoteReactIframeHtml = renderRemoteReactIframeHtml;
|
|
5218
5444
|
exports.renderRemoteVueIframeHtml = renderRemoteVueIframeHtml;
|
|
5445
|
+
exports.resolveModelUsagePricingSnapshot = resolveModelUsagePricingSnapshot;
|
|
5219
5446
|
exports.resolveSandboxBackend = resolveSandboxBackend;
|
|
5220
5447
|
exports.resolveSandboxExecutionOptions = resolveSandboxExecutionOptions;
|
|
5221
5448
|
exports.resolveSandboxManagedServiceAdapter = resolveSandboxManagedServiceAdapter;
|