@xpert-ai/plugin-sdk 3.16.1 → 3.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -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 +500 -285
- package/index.esm.js +444 -247
- 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 +11 -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);
|
|
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');
|
|
2459
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.
|
|
@@ -2704,7 +2911,7 @@ function isValidTokenCount(value) {
|
|
|
2704
2911
|
// Some compatible providers also omit the role on non-stream responses.
|
|
2705
2912
|
// Normalize that response before LangChain falls back to a generic
|
|
2706
2913
|
// message with role `unknown`.
|
|
2707
|
-
const normalizedMessage =
|
|
2914
|
+
const normalizedMessage = _extends._extends({}, message, {
|
|
2708
2915
|
role: (_message_role = message.role) != null ? _message_role : 'assistant'
|
|
2709
2916
|
});
|
|
2710
2917
|
const langChainMessage = super._convertCompletionsMessageToBaseMessage(normalizedMessage, rawResponse);
|
|
@@ -2819,7 +3026,7 @@ class Speech2TextChatModel extends chat_models.BaseChatModel {
|
|
|
2819
3026
|
if (!apiKey) {
|
|
2820
3027
|
throw new Error(`Tongyi API key not found. Please set the DASHSCOPE_API_KEY environment variable or pass the key into "apiKey" field.`);
|
|
2821
3028
|
}
|
|
2822
|
-
super(
|
|
3029
|
+
super(_extends._extends({}, fields));
|
|
2823
3030
|
this.fields = fields;
|
|
2824
3031
|
this.apiKey = apiKey;
|
|
2825
3032
|
}
|
|
@@ -2852,10 +3059,10 @@ function getModelContextSize(input) {
|
|
|
2852
3059
|
return (_input_profile_maxInputTokens = input.profile.maxInputTokens) != null ? _input_profile_maxInputTokens : undefined;
|
|
2853
3060
|
}
|
|
2854
3061
|
if ("model" in input && typeof input.model === "string") {
|
|
2855
|
-
return base.getModelContextSize(input.model);
|
|
3062
|
+
return base$1.getModelContextSize(input.model);
|
|
2856
3063
|
}
|
|
2857
3064
|
if ("modelName" in input && typeof input.modelName === "string") {
|
|
2858
|
-
return base.getModelContextSize(input.modelName);
|
|
3065
|
+
return base$1.getModelContextSize(input.modelName);
|
|
2859
3066
|
}
|
|
2860
3067
|
return undefined;
|
|
2861
3068
|
}
|
|
@@ -2892,66 +3099,6 @@ Reflect.defineMetadata(COMMAND_METADATA$1, {
|
|
|
2892
3099
|
id: CreateModelClientCommand.type
|
|
2893
3100
|
}, CreateModelClientCommand);
|
|
2894
3101
|
|
|
2895
|
-
const KnowledgebaseRuntimeCapability = createRuntimeCapability('platform.knowledgebase', {
|
|
2896
|
-
description: 'List, search, and write chunks in platform knowledgebases.'
|
|
2897
|
-
});
|
|
2898
|
-
|
|
2899
|
-
const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.documents', {
|
|
2900
|
-
description: 'Upload, import, create, process, inspect, and delete persistent knowledgebase documents.'
|
|
2901
|
-
});
|
|
2902
|
-
|
|
2903
|
-
const ActorTokenRuntimeCapability = createRuntimeCapability('platform.actor-token', {
|
|
2904
|
-
description: 'Mint a short-lived host-issued actor bearer token for outbound API calls.'
|
|
2905
|
-
});
|
|
2906
|
-
|
|
2907
|
-
const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts', {
|
|
2908
|
-
description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
|
|
2909
|
-
});
|
|
2910
|
-
|
|
2911
|
-
/** Stable source identifier for portable workspace file references. */ const WORKSPACE_FILES_SOURCE = 'platform.workspace.files';
|
|
2912
|
-
const WorkspaceFilesRuntimeCapability = createRuntimeCapability('platform.workspace.files', {
|
|
2913
|
-
description: 'Upload, understand, resolve, read, and delete raw files in Xpert workspace volumes.'
|
|
2914
|
-
});
|
|
2915
|
-
|
|
2916
|
-
/** Stable machine-readable failures emitted by the Sandbox Jobs capability. */ const SANDBOX_JOB_ERROR_CODES = [
|
|
2917
|
-
'SANDBOX_ACTION_UNAVAILABLE',
|
|
2918
|
-
'SANDBOX_ACTION_INVALID',
|
|
2919
|
-
'SANDBOX_PROFILE_UNAVAILABLE',
|
|
2920
|
-
'SANDBOX_RUNTIME_UNAVAILABLE',
|
|
2921
|
-
'SANDBOX_VERSION_MISMATCH',
|
|
2922
|
-
'SANDBOX_CAPACITY_UNAVAILABLE',
|
|
2923
|
-
'SANDBOX_START_FAILED',
|
|
2924
|
-
'BROWSER_LAUNCH_FAILED',
|
|
2925
|
-
'EXPORT_TIMEOUT',
|
|
2926
|
-
'EXPORT_OOM',
|
|
2927
|
-
'EXPORT_MEDIA_FAILED',
|
|
2928
|
-
'EXPORT_INPUT_INVALID',
|
|
2929
|
-
'EXPORT_OUTPUT_INVALID',
|
|
2930
|
-
'SANDBOX_CANCELLED'
|
|
2931
|
-
];
|
|
2932
|
-
/** Line prefix used by trusted Actions to report structured, provider-neutral progress. */ const SANDBOX_JOB_PROGRESS_PREFIX = 'XPERT_SANDBOX_PROGRESS ';
|
|
2933
|
-
/** Error carrying retry policy and Job identity across plugin queue handlers. */ class SandboxJobRuntimeError extends Error {
|
|
2934
|
-
constructor(code, message, retryable, jobId){
|
|
2935
|
-
super(message);
|
|
2936
|
-
this.code = code;
|
|
2937
|
-
this.retryable = retryable;
|
|
2938
|
-
this.jobId = jobId;
|
|
2939
|
-
this.name = 'SandboxJobRuntimeError';
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
const SANDBOX_JOB_ERROR_CODE_SET = new Set(SANDBOX_JOB_ERROR_CODES);
|
|
2943
|
-
/** Narrows an unknown failure to the structured Sandbox Jobs runtime error contract. */ function isSandboxJobRuntimeError(error) {
|
|
2944
|
-
if (error instanceof SandboxJobRuntimeError) return true;
|
|
2945
|
-
if (typeof error !== 'object' || error === null) return false;
|
|
2946
|
-
// Dynamically loaded plugins may resolve another Plugin SDK module instance,
|
|
2947
|
-
// so class identity is not a reliable runtime boundary. Validate the stable shape.
|
|
2948
|
-
const candidate = error;
|
|
2949
|
-
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');
|
|
2950
|
-
}
|
|
2951
|
-
/** Runtime capability key used to resolve SandboxJobsApi from the platform registry. */ const SandboxJobsRuntimeCapability = createRuntimeCapability('platform.sandbox.jobs', {
|
|
2952
|
-
description: 'Run registered plugin actions in isolated, short-lived Sandbox Runtime jobs.'
|
|
2953
|
-
});
|
|
2954
|
-
|
|
2955
3102
|
const SKILL_SOURCE_PROVIDER = 'SKILL_SOURCE_PROVIDER';
|
|
2956
3103
|
const SkillSourceProviderStrategy = (provider)=>common.applyDecorators(common.SetMetadata(SKILL_SOURCE_PROVIDER, provider), common.SetMetadata(STRATEGY_META_KEY, SKILL_SOURCE_PROVIDER));
|
|
2957
3104
|
|
|
@@ -2992,14 +3139,40 @@ exports.AgentMiddlewareRegistry = __decorate([
|
|
|
2992
3139
|
'end'
|
|
2993
3140
|
];
|
|
2994
3141
|
|
|
2995
|
-
const AssistantTaskRuntimeCapability = createRuntimeCapability('platform.assistant_task', {
|
|
3142
|
+
const AssistantTaskRuntimeCapability = modelProvider.createRuntimeCapability('platform.assistant_task', {
|
|
2996
3143
|
description: 'Start asynchronous tasks on the current platform assistant.'
|
|
2997
3144
|
});
|
|
2998
3145
|
|
|
2999
|
-
const FileRuntimeCapability = createRuntimeCapability('platform.file', {
|
|
3146
|
+
const FileRuntimeCapability = modelProvider.createRuntimeCapability('platform.file', {
|
|
3000
3147
|
description: 'Resolve platform file handles into previewable file URLs.'
|
|
3001
3148
|
});
|
|
3002
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
|
+
|
|
3003
3176
|
const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
|
|
3004
3177
|
const VERSION_PATTERN = /^v[1-9][0-9]*$/;
|
|
3005
3178
|
function assertSegment(input, name) {
|
|
@@ -3273,7 +3446,7 @@ exports.SSOProviderRegistry = __decorate([
|
|
|
3273
3446
|
])
|
|
3274
3447
|
], exports.SSOProviderRegistry);
|
|
3275
3448
|
|
|
3276
|
-
const ConnectorRuntimeCapability = createRuntimeCapability('platform.connector', {
|
|
3449
|
+
const ConnectorRuntimeCapability = modelProvider.createRuntimeCapability('platform.connector', {
|
|
3277
3450
|
description: 'Resolve connector credentials for agent middleware.'
|
|
3278
3451
|
});
|
|
3279
3452
|
|
|
@@ -4472,7 +4645,7 @@ function normalizePluginJobProcessorMetadata(options) {
|
|
|
4472
4645
|
if (concurrency !== undefined && (!Number.isFinite(concurrency) || concurrency <= 0)) {
|
|
4473
4646
|
throw new Error('PluginJobProcessor concurrency must be a positive number');
|
|
4474
4647
|
}
|
|
4475
|
-
return
|
|
4648
|
+
return _extends._extends({
|
|
4476
4649
|
pluginName,
|
|
4477
4650
|
queueName,
|
|
4478
4651
|
jobName
|
|
@@ -4996,7 +5169,7 @@ function escapeInlineScript(value) {
|
|
|
4996
5169
|
|
|
4997
5170
|
const VIEW_EXTENSION_CACHE_SERVICE_TOKEN = 'XPERT_PLUGIN_VIEW_EXTENSION_CACHE_SERVICE';
|
|
4998
5171
|
|
|
4999
|
-
/** 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', {
|
|
5000
5173
|
description: 'Create, synchronize, persist, authorize, and observe platform-managed real-time collaboration documents.'
|
|
5001
5174
|
});
|
|
5002
5175
|
|
|
@@ -5016,12 +5189,30 @@ exports.CollaborationDocumentProviderRegistry = __decorate([
|
|
|
5016
5189
|
])
|
|
5017
5190
|
], exports.CollaborationDocumentProviderRegistry);
|
|
5018
5191
|
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
exports.
|
|
5023
|
-
|
|
5024
|
-
|
|
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
|
+
|
|
5025
5216
|
Object.defineProperty(exports, "ASSISTANT_CHAT_SEND_MESSAGE_COMMAND", {
|
|
5026
5217
|
enumerable: true,
|
|
5027
5218
|
get: function () { return contracts.ASSISTANT_CHAT_SEND_MESSAGE_COMMAND; }
|
|
@@ -5030,8 +5221,36 @@ Object.defineProperty(exports, "ASSISTANT_CONTEXT_SET_COMMAND", {
|
|
|
5030
5221
|
enumerable: true,
|
|
5031
5222
|
get: function () { return contracts.ASSISTANT_CONTEXT_SET_COMMAND; }
|
|
5032
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;
|
|
5033
5246
|
exports.assertConnectorDefinition = connector.assertConnectorDefinition;
|
|
5034
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;
|
|
5035
5254
|
exports.ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN = ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN;
|
|
5036
5255
|
exports.AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING;
|
|
5037
5256
|
exports.AGENT_CHAT_DISPATCH_MESSAGE_TYPE = AGENT_CHAT_DISPATCH_MESSAGE_TYPE;
|
|
@@ -5039,11 +5258,9 @@ exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
|
|
|
5039
5258
|
exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
|
|
5040
5259
|
exports.AIModelProviderStrategy = AIModelProviderStrategy;
|
|
5041
5260
|
exports.AI_MODEL_PROVIDER = AI_MODEL_PROVIDER;
|
|
5042
|
-
exports.ActorTokenRuntimeCapability = ActorTokenRuntimeCapability;
|
|
5043
5261
|
exports.AdapterDataSourceStrategy = AdapterDataSourceStrategy;
|
|
5044
5262
|
exports.AgentMiddlewareStrategy = AgentMiddlewareStrategy;
|
|
5045
5263
|
exports.AiModelNotFoundException = AiModelNotFoundException;
|
|
5046
|
-
exports.ArtifactsRuntimeCapability = ArtifactsRuntimeCapability;
|
|
5047
5264
|
exports.AssistantTaskRuntimeCapability = AssistantTaskRuntimeCapability;
|
|
5048
5265
|
exports.BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN = BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN;
|
|
5049
5266
|
exports.BUILTIN_GLOBAL_SCOPE = BUILTIN_GLOBAL_SCOPE;
|
|
@@ -5052,9 +5269,6 @@ exports.BaseQueryRunner = BaseQueryRunner;
|
|
|
5052
5269
|
exports.BaseSQLQueryRunner = BaseSQLQueryRunner;
|
|
5053
5270
|
exports.BaseSandbox = BaseSandbox;
|
|
5054
5271
|
exports.BaseStrategyRegistry = BaseStrategyRegistry;
|
|
5055
|
-
exports.BaseTool = BaseTool;
|
|
5056
|
-
exports.BaseToolset = BaseToolset;
|
|
5057
|
-
exports.BuiltinToolset = BuiltinToolset;
|
|
5058
5272
|
exports.CHAT_CHANNEL = CHAT_CHANNEL;
|
|
5059
5273
|
exports.CHAT_CHANNEL_TEXT_LIMITS = CHAT_CHANNEL_TEXT_LIMITS;
|
|
5060
5274
|
exports.COLLABORATION_DOCUMENT_PROVIDER = COLLABORATION_DOCUMENT_PROVIDER;
|
|
@@ -5085,10 +5299,12 @@ exports.DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC = DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC;
|
|
|
5085
5299
|
exports.DOCUMENT_SOURCE_STRATEGY = DOCUMENT_SOURCE_STRATEGY;
|
|
5086
5300
|
exports.DOCUMENT_TRANSFORMER_STRATEGY = DOCUMENT_TRANSFORMER_STRATEGY;
|
|
5087
5301
|
exports.DataSourceStrategy = DataSourceStrategy;
|
|
5088
|
-
exports.DefaultAgentMiddlewareRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
|
|
5089
|
-
exports.DefaultRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
|
|
5090
5302
|
exports.DocumentSourceStrategy = DocumentSourceStrategy;
|
|
5091
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;
|
|
5092
5308
|
exports.FILE_STORAGE_PROVIDER = FILE_STORAGE_PROVIDER;
|
|
5093
5309
|
exports.FILE_UPLOAD_TARGET_STRATEGY = FILE_UPLOAD_TARGET_STRATEGY;
|
|
5094
5310
|
exports.FileRuntimeCapability = FileRuntimeCapability;
|
|
@@ -5102,19 +5318,20 @@ exports.HandoffProcessorStrategy = HandoffProcessorStrategy;
|
|
|
5102
5318
|
exports.IMAGE_UNDERSTANDING_STRATEGY = IMAGE_UNDERSTANDING_STRATEGY;
|
|
5103
5319
|
exports.INTEGRATION_PERMISSION_SERVICE_TOKEN = INTEGRATION_PERMISSION_SERVICE_TOKEN;
|
|
5104
5320
|
exports.INTEGRATION_STRATEGY = INTEGRATION_STRATEGY;
|
|
5321
|
+
exports.ImageGenerationModel = ImageGenerationModel;
|
|
5105
5322
|
exports.ImageUnderstandingStrategy = ImageUnderstandingStrategy;
|
|
5106
5323
|
exports.IntegrationStrategyKey = IntegrationStrategyKey;
|
|
5107
5324
|
exports.JUMP_TO_TARGETS = JUMP_TO_TARGETS;
|
|
5108
5325
|
exports.JsonSchemaValidator = JsonSchemaValidator;
|
|
5109
5326
|
exports.KNOWLEDGE_STRATEGY = KNOWLEDGE_STRATEGY;
|
|
5110
5327
|
exports.KnowledgeStrategyKey = KnowledgeStrategyKey;
|
|
5111
|
-
exports.KnowledgebaseDocumentsRuntimeCapability = KnowledgebaseDocumentsRuntimeCapability;
|
|
5112
|
-
exports.KnowledgebaseRuntimeCapability = KnowledgebaseRuntimeCapability;
|
|
5113
5328
|
exports.LLMUsage = LLMUsage;
|
|
5114
5329
|
exports.LargeLanguageModel = LargeLanguageModel;
|
|
5115
5330
|
exports.MANAGED_CONNECTION_REGISTRY_TOKEN = MANAGED_CONNECTION_REGISTRY_TOKEN;
|
|
5116
5331
|
exports.MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN = MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN;
|
|
5117
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;
|
|
5118
5335
|
exports.ORGANIZATION_METADATA_KEY = ORGANIZATION_METADATA_KEY;
|
|
5119
5336
|
exports.OpenAICompatibleReranker = OpenAICompatibleReranker;
|
|
5120
5337
|
exports.PERMISSION_OPERATION_METADATA_KEY = PERMISSION_OPERATION_METADATA_KEY;
|
|
@@ -5137,8 +5354,6 @@ exports.RequestContext = RequestContext;
|
|
|
5137
5354
|
exports.RequirePermissionOperation = RequirePermissionOperation;
|
|
5138
5355
|
exports.RerankModel = RerankModel;
|
|
5139
5356
|
exports.RetrieverStrategy = RetrieverStrategy;
|
|
5140
|
-
exports.SANDBOX_JOB_ERROR_CODES = SANDBOX_JOB_ERROR_CODES;
|
|
5141
|
-
exports.SANDBOX_JOB_PROGRESS_PREFIX = SANDBOX_JOB_PROGRESS_PREFIX;
|
|
5142
5357
|
exports.SANDBOX_PROVIDER = SANDBOX_PROVIDER;
|
|
5143
5358
|
exports.SANDBOX_RUNTIME_PROVIDER = SANDBOX_RUNTIME_PROVIDER;
|
|
5144
5359
|
exports.SANDBOX_SHELL_TIMEOUT_LIMITS_SEC = SANDBOX_SHELL_TIMEOUT_LIMITS_SEC;
|
|
@@ -5151,8 +5366,6 @@ exports.SSO_BINDING_PERMISSION_SERVICE_TOKEN = SSO_BINDING_PERMISSION_SERVICE_TO
|
|
|
5151
5366
|
exports.SSO_PROVIDER = SSO_PROVIDER;
|
|
5152
5367
|
exports.STRATEGY_META_KEY = STRATEGY_META_KEY;
|
|
5153
5368
|
exports.SYSTEM_GLOBAL_SCOPE = SYSTEM_GLOBAL_SCOPE;
|
|
5154
|
-
exports.SandboxJobRuntimeError = SandboxJobRuntimeError;
|
|
5155
|
-
exports.SandboxJobsRuntimeCapability = SandboxJobsRuntimeCapability;
|
|
5156
5369
|
exports.SandboxProviderStrategy = SandboxProviderStrategy;
|
|
5157
5370
|
exports.SandboxRuntimeProviderStrategy = SandboxRuntimeProviderStrategy;
|
|
5158
5371
|
exports.SandboxWorkspaceMapperStrategy = SandboxWorkspaceMapperStrategy;
|
|
@@ -5175,15 +5388,14 @@ exports.VIDEO_GENERATOR_FAMILIES = VIDEO_GENERATOR_FAMILIES;
|
|
|
5175
5388
|
exports.VIEW_EXTENSION_CACHE_SERVICE_TOKEN = VIEW_EXTENSION_CACHE_SERVICE_TOKEN;
|
|
5176
5389
|
exports.VIEW_EXTENSION_PROVIDER = VIEW_EXTENSION_PROVIDER;
|
|
5177
5390
|
exports.VectorStoreStrategy = VectorStoreStrategy;
|
|
5391
|
+
exports.VideoGenerationModel = VideoGenerationModel;
|
|
5178
5392
|
exports.ViewExtensionProvider = ViewExtensionProvider;
|
|
5179
5393
|
exports.WORKFLOW_NODE_STRATEGY = WORKFLOW_NODE_STRATEGY;
|
|
5180
5394
|
exports.WORKFLOW_TRIGGER_STRATEGY = WORKFLOW_TRIGGER_STRATEGY;
|
|
5181
|
-
exports.WORKSPACE_FILES_SOURCE = WORKSPACE_FILES_SOURCE;
|
|
5182
5395
|
exports.WorkflowNodeStrategy = WorkflowNodeStrategy;
|
|
5183
5396
|
exports.WorkflowTriggerStrategy = WorkflowTriggerStrategy;
|
|
5184
|
-
exports.WorkspaceFilesRuntimeCapability = WorkspaceFilesRuntimeCapability;
|
|
5185
5397
|
exports.WrapWorkflowNodeExecutionCommand = WrapWorkflowNodeExecutionCommand;
|
|
5186
|
-
exports.
|
|
5398
|
+
exports.XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN = XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN;
|
|
5187
5399
|
exports.XpFileSystem = XpFileSystem;
|
|
5188
5400
|
exports.XpertServerPlugin = XpertServerPlugin;
|
|
5189
5401
|
exports.als = als;
|
|
@@ -5191,11 +5403,11 @@ exports.appendSandboxMessage = appendSandboxMessage;
|
|
|
5191
5403
|
exports.buildSandboxTimeoutMessage = buildSandboxTimeoutMessage;
|
|
5192
5404
|
exports.calcTokenUsage = calcTokenUsage;
|
|
5193
5405
|
exports.calculateModelPrice = calculateModelPrice;
|
|
5406
|
+
exports.calculateModelUsageCharge = calculateModelUsageCharge;
|
|
5194
5407
|
exports.chunkText = chunkText;
|
|
5195
5408
|
exports.countTokensSafe = countTokensSafe;
|
|
5196
5409
|
exports.createI18nInstance = createI18nInstance;
|
|
5197
5410
|
exports.createPluginLogger = createPluginLogger;
|
|
5198
|
-
exports.createRuntimeCapability = createRuntimeCapability;
|
|
5199
5411
|
exports.defineAgentMessageType = defineAgentMessageType;
|
|
5200
5412
|
exports.defineChannelMessageType = defineChannelMessageType;
|
|
5201
5413
|
exports.derivePluginArtifactNamespace = derivePluginArtifactNamespace;
|
|
@@ -5211,9 +5423,10 @@ exports.getRequestContext = getRequestContext;
|
|
|
5211
5423
|
exports.getRequiredPermissionOperation = getRequiredPermissionOperation;
|
|
5212
5424
|
exports.getTenantGlobalScopeKey = getTenantGlobalScopeKey;
|
|
5213
5425
|
exports.isDevelopmentSandboxRuntimeEnvironment = isDevelopmentSandboxRuntimeEnvironment;
|
|
5426
|
+
exports.isModelOutputValidationError = isModelOutputValidationError;
|
|
5427
|
+
exports.isModelUsagePricingConfig = isModelUsagePricingConfig;
|
|
5214
5428
|
exports.isRemoteFile = isRemoteFile;
|
|
5215
5429
|
exports.isSandboxBackend = isSandboxBackend;
|
|
5216
|
-
exports.isSandboxJobRuntimeError = isSandboxJobRuntimeError;
|
|
5217
5430
|
exports.isSandboxManagedServiceAdapter = isSandboxManagedServiceAdapter;
|
|
5218
5431
|
exports.isSandboxServiceProxyAdapter = isSandboxServiceProxyAdapter;
|
|
5219
5432
|
exports.isSandboxTerminalAdapter = isSandboxTerminalAdapter;
|
|
@@ -5225,9 +5438,11 @@ exports.mergeCredentials = mergeCredentials;
|
|
|
5225
5438
|
exports.mergeParentChildChunks = mergeParentChildChunks;
|
|
5226
5439
|
exports.normalizeContextSize = normalizeContextSize;
|
|
5227
5440
|
exports.pluginArtifactTableName = pluginArtifactTableName;
|
|
5441
|
+
exports.processAsyncAIGCManagedJob = processAsyncAIGCManagedJob;
|
|
5228
5442
|
exports.renderRemoteModuleIframeHtml = renderRemoteModuleIframeHtml;
|
|
5229
5443
|
exports.renderRemoteReactIframeHtml = renderRemoteReactIframeHtml;
|
|
5230
5444
|
exports.renderRemoteVueIframeHtml = renderRemoteVueIframeHtml;
|
|
5445
|
+
exports.resolveModelUsagePricingSnapshot = resolveModelUsagePricingSnapshot;
|
|
5231
5446
|
exports.resolveSandboxBackend = resolveSandboxBackend;
|
|
5232
5447
|
exports.resolveSandboxExecutionOptions = resolveSandboxExecutionOptions;
|
|
5233
5448
|
exports.resolveSandboxManagedServiceAdapter = resolveSandboxManagedServiceAdapter;
|