@xpert-ai/plugin-sdk 3.15.13 → 3.15.15
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 +23 -0
- package/connector.cjs.default.js +1 -0
- package/connector.cjs.js +116 -0
- package/connector.cjs.mjs +2 -0
- package/connector.d.ts +1 -0
- package/connector.esm.js +113 -0
- package/index.cjs.js +83 -25
- package/index.esm.js +81 -26
- package/package.json +8 -2
- package/src/connector.d.ts +2 -0
- package/src/lib/agent/handoff/agent-chat.contract.d.ts +2 -0
- package/src/lib/ai-model/ai-model.d.ts +1 -1
- package/src/lib/ai-model/index.d.ts +1 -0
- package/src/lib/ai-model/pricing.d.ts +2 -0
- package/src/lib/ai-model/types/model.d.ts +1 -1
- package/src/lib/connector/strategy.interface.d.ts +131 -5
- package/src/lib/connector/strategy.registry.d.ts +7 -2
- package/src/lib/core/permissions/general.d.ts +1 -0
- package/src/lib/managed-queue/index.d.ts +3 -0
- package/src/lib/runtime/capabilities/sandbox-jobs.d.ts +10 -1
- package/src/lib/sandbox/runtime-provider.d.ts +32 -0
- package/src/lib/view-extension/provider.interface.d.ts +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @xpert-ai/plugin-sdk
|
|
2
2
|
|
|
3
|
+
## 3.15.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a26a776: Add opt-in multi-auth connector strategies, provider-neutral runtime credentials, and legacy credential mapping.
|
|
8
|
+
|
|
9
|
+
Integration-enabled plugins can also opt into inherited tenant and organization configuration reads for connector-owned OAuth apps.
|
|
10
|
+
|
|
11
|
+
Existing `ConnectorDefinition`, `ConnectorStrategy`, `ConnectorRuntimeCredential`, `ConnectorRuntimeApi.getConnector()`, and legacy registry accessors remain available unchanged. New providers can implement `ConnectorMultiAuthStrategy`, while runtime consumers can adopt `getConnectorCredential()` when the host exposes it.
|
|
12
|
+
|
|
13
|
+
- 8a0eba3: Calculate membership points proportionally, constrain tokens-per-point settings to safe presets, expose non-duplicated point usage by runtime organization in Copilot usage summaries, and support tiered model pricing.
|
|
14
|
+
- e3d3c26: Add a machine-readable stale steer callback error and close the execution-completion race before channel follow-ups are persisted.
|
|
15
|
+
- Updated dependencies [8a0eba3]
|
|
16
|
+
- Updated dependencies [5d4a308]
|
|
17
|
+
- @xpert-ai/contracts@3.15.15
|
|
18
|
+
|
|
19
|
+
## 3.15.14
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [8a46f00]
|
|
24
|
+
- @xpert-ai/contracts@3.15.14
|
|
25
|
+
|
|
3
26
|
## 3.15.13
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./connector.cjs.js').default;
|
package/connector.cjs.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function getConnectorAuthMethods(definition) {
|
|
4
|
+
var _definition_legacyAuthMethodId;
|
|
5
|
+
if ('authMethods' in definition) {
|
|
6
|
+
return definition.authMethods;
|
|
7
|
+
}
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
id: ((_definition_legacyAuthMethodId = definition.legacyAuthMethodId) == null ? void 0 : _definition_legacyAuthMethodId.trim()) || 'oauth2',
|
|
11
|
+
type: 'oauth2',
|
|
12
|
+
label: {
|
|
13
|
+
en_US: 'OAuth 2.0',
|
|
14
|
+
zh_Hans: 'OAuth 2.0'
|
|
15
|
+
},
|
|
16
|
+
appCredentials: definition.appCredentials
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
function assertConnectorDefinition(definition) {
|
|
21
|
+
if (!isObjectValue(definition)) {
|
|
22
|
+
throw new Error('Connector strategy must expose a valid connector definition');
|
|
23
|
+
}
|
|
24
|
+
const providerValue = Reflect.get(definition, 'provider');
|
|
25
|
+
const provider = typeof providerValue === 'string' ? providerValue.trim() : '';
|
|
26
|
+
if (!provider) {
|
|
27
|
+
throw new Error('Connector definition must declare a provider');
|
|
28
|
+
}
|
|
29
|
+
const label = Reflect.get(definition, 'label');
|
|
30
|
+
if (!isRuntimeI18nText(label)) {
|
|
31
|
+
throw new Error(`Connector '${provider}' must declare a label`);
|
|
32
|
+
}
|
|
33
|
+
const auth = Reflect.get(definition, 'auth');
|
|
34
|
+
const authMethods = Reflect.get(definition, 'authMethods');
|
|
35
|
+
const resolvedMethods = [];
|
|
36
|
+
const ids = new Set();
|
|
37
|
+
if (authMethods !== undefined) {
|
|
38
|
+
if (!Array.isArray(authMethods) || !authMethods.length) {
|
|
39
|
+
throw new Error(`Connector '${provider}' must declare at least one authentication method`);
|
|
40
|
+
}
|
|
41
|
+
for (const method of authMethods){
|
|
42
|
+
assertConnectorAuthMethod(method, provider);
|
|
43
|
+
const id = method.id.trim();
|
|
44
|
+
if (ids.has(id)) {
|
|
45
|
+
throw new Error(`Connector '${provider}' has duplicate authentication method id '${id}'`);
|
|
46
|
+
}
|
|
47
|
+
ids.add(id);
|
|
48
|
+
resolvedMethods.push({
|
|
49
|
+
id,
|
|
50
|
+
type: method.type
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (auth !== undefined && !isConnectorOAuthConfig(auth)) {
|
|
54
|
+
throw new Error(`Connector '${provider}' has invalid legacy OAuth metadata`);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
if (!isConnectorOAuthConfig(auth)) {
|
|
58
|
+
throw new Error(`Connector '${provider}' must declare legacy OAuth configuration or authentication methods`);
|
|
59
|
+
}
|
|
60
|
+
const legacyMethodValue = Reflect.get(definition, 'legacyAuthMethodId');
|
|
61
|
+
const legacyMethodId = typeof legacyMethodValue === 'string' && legacyMethodValue.trim() ? legacyMethodValue.trim() : 'oauth2';
|
|
62
|
+
resolvedMethods.push({
|
|
63
|
+
id: legacyMethodId,
|
|
64
|
+
type: 'oauth2'
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const legacyAuthMethodValue = Reflect.get(definition, 'legacyAuthMethodId');
|
|
68
|
+
if (legacyAuthMethodValue !== undefined && (typeof legacyAuthMethodValue !== 'string' || !legacyAuthMethodValue.trim())) {
|
|
69
|
+
throw new Error(`Connector '${provider}' has an invalid legacy authentication method id`);
|
|
70
|
+
}
|
|
71
|
+
if (typeof legacyAuthMethodValue === 'string') {
|
|
72
|
+
const legacyAuthMethodId = legacyAuthMethodValue.trim();
|
|
73
|
+
const legacyMethod = resolvedMethods.find((method)=>method.id === legacyAuthMethodId);
|
|
74
|
+
if (!legacyMethod) {
|
|
75
|
+
throw new Error(`Connector '${provider}' maps legacy credentials to unknown authentication method '${legacyAuthMethodId}'`);
|
|
76
|
+
}
|
|
77
|
+
if (legacyMethod.type !== 'oauth2') {
|
|
78
|
+
throw new Error(`Connector '${provider}' must map legacy credentials to an OAuth authentication method`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function assertConnectorAuthMethod(method, provider) {
|
|
83
|
+
if (!isObjectValue(method)) {
|
|
84
|
+
throw new Error(`Connector '${provider}' has an invalid authentication method`);
|
|
85
|
+
}
|
|
86
|
+
const idValue = Reflect.get(method, 'id');
|
|
87
|
+
if (typeof idValue !== 'string' || !idValue.trim()) {
|
|
88
|
+
throw new Error(`Connector '${provider}' has an authentication method without an id`);
|
|
89
|
+
}
|
|
90
|
+
const label = Reflect.get(method, 'label');
|
|
91
|
+
if (!isRuntimeI18nText(label)) {
|
|
92
|
+
throw new Error(`Connector '${provider}' authentication method '${idValue.trim()}' must declare a label`);
|
|
93
|
+
}
|
|
94
|
+
const type = Reflect.get(method, 'type');
|
|
95
|
+
if (type !== 'oauth2' && type !== 'api_key') {
|
|
96
|
+
throw new Error(`Connector '${provider}' has unsupported authentication method type '${String(type)}'`);
|
|
97
|
+
}
|
|
98
|
+
if (type === 'api_key' && !isObjectValue(Reflect.get(method, 'credentials'))) {
|
|
99
|
+
throw new Error(`Connector '${provider}' API key method '${idValue.trim()}' must declare credentials`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function isConnectorOAuthConfig(value) {
|
|
103
|
+
return isObjectValue(value) && Reflect.get(value, 'type') === 'oauth2';
|
|
104
|
+
}
|
|
105
|
+
function isRuntimeI18nText(value) {
|
|
106
|
+
if (typeof value === 'string') {
|
|
107
|
+
return !!value.trim();
|
|
108
|
+
}
|
|
109
|
+
return isObjectValue(value) && typeof Reflect.get(value, 'en_US') === 'string';
|
|
110
|
+
}
|
|
111
|
+
function isObjectValue(value) {
|
|
112
|
+
return typeof value === 'object' && value !== null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
exports.assertConnectorDefinition = assertConnectorDefinition;
|
|
116
|
+
exports.getConnectorAuthMethods = getConnectorAuthMethods;
|
package/connector.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/connector";
|
package/connector.esm.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
function getConnectorAuthMethods(definition) {
|
|
2
|
+
var _definition_legacyAuthMethodId;
|
|
3
|
+
if ('authMethods' in definition) {
|
|
4
|
+
return definition.authMethods;
|
|
5
|
+
}
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
id: ((_definition_legacyAuthMethodId = definition.legacyAuthMethodId) == null ? void 0 : _definition_legacyAuthMethodId.trim()) || 'oauth2',
|
|
9
|
+
type: 'oauth2',
|
|
10
|
+
label: {
|
|
11
|
+
en_US: 'OAuth 2.0',
|
|
12
|
+
zh_Hans: 'OAuth 2.0'
|
|
13
|
+
},
|
|
14
|
+
appCredentials: definition.appCredentials
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
function assertConnectorDefinition(definition) {
|
|
19
|
+
if (!isObjectValue(definition)) {
|
|
20
|
+
throw new Error('Connector strategy must expose a valid connector definition');
|
|
21
|
+
}
|
|
22
|
+
const providerValue = Reflect.get(definition, 'provider');
|
|
23
|
+
const provider = typeof providerValue === 'string' ? providerValue.trim() : '';
|
|
24
|
+
if (!provider) {
|
|
25
|
+
throw new Error('Connector definition must declare a provider');
|
|
26
|
+
}
|
|
27
|
+
const label = Reflect.get(definition, 'label');
|
|
28
|
+
if (!isRuntimeI18nText(label)) {
|
|
29
|
+
throw new Error(`Connector '${provider}' must declare a label`);
|
|
30
|
+
}
|
|
31
|
+
const auth = Reflect.get(definition, 'auth');
|
|
32
|
+
const authMethods = Reflect.get(definition, 'authMethods');
|
|
33
|
+
const resolvedMethods = [];
|
|
34
|
+
const ids = new Set();
|
|
35
|
+
if (authMethods !== undefined) {
|
|
36
|
+
if (!Array.isArray(authMethods) || !authMethods.length) {
|
|
37
|
+
throw new Error(`Connector '${provider}' must declare at least one authentication method`);
|
|
38
|
+
}
|
|
39
|
+
for (const method of authMethods){
|
|
40
|
+
assertConnectorAuthMethod(method, provider);
|
|
41
|
+
const id = method.id.trim();
|
|
42
|
+
if (ids.has(id)) {
|
|
43
|
+
throw new Error(`Connector '${provider}' has duplicate authentication method id '${id}'`);
|
|
44
|
+
}
|
|
45
|
+
ids.add(id);
|
|
46
|
+
resolvedMethods.push({
|
|
47
|
+
id,
|
|
48
|
+
type: method.type
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (auth !== undefined && !isConnectorOAuthConfig(auth)) {
|
|
52
|
+
throw new Error(`Connector '${provider}' has invalid legacy OAuth metadata`);
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
if (!isConnectorOAuthConfig(auth)) {
|
|
56
|
+
throw new Error(`Connector '${provider}' must declare legacy OAuth configuration or authentication methods`);
|
|
57
|
+
}
|
|
58
|
+
const legacyMethodValue = Reflect.get(definition, 'legacyAuthMethodId');
|
|
59
|
+
const legacyMethodId = typeof legacyMethodValue === 'string' && legacyMethodValue.trim() ? legacyMethodValue.trim() : 'oauth2';
|
|
60
|
+
resolvedMethods.push({
|
|
61
|
+
id: legacyMethodId,
|
|
62
|
+
type: 'oauth2'
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const legacyAuthMethodValue = Reflect.get(definition, 'legacyAuthMethodId');
|
|
66
|
+
if (legacyAuthMethodValue !== undefined && (typeof legacyAuthMethodValue !== 'string' || !legacyAuthMethodValue.trim())) {
|
|
67
|
+
throw new Error(`Connector '${provider}' has an invalid legacy authentication method id`);
|
|
68
|
+
}
|
|
69
|
+
if (typeof legacyAuthMethodValue === 'string') {
|
|
70
|
+
const legacyAuthMethodId = legacyAuthMethodValue.trim();
|
|
71
|
+
const legacyMethod = resolvedMethods.find((method)=>method.id === legacyAuthMethodId);
|
|
72
|
+
if (!legacyMethod) {
|
|
73
|
+
throw new Error(`Connector '${provider}' maps legacy credentials to unknown authentication method '${legacyAuthMethodId}'`);
|
|
74
|
+
}
|
|
75
|
+
if (legacyMethod.type !== 'oauth2') {
|
|
76
|
+
throw new Error(`Connector '${provider}' must map legacy credentials to an OAuth authentication method`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function assertConnectorAuthMethod(method, provider) {
|
|
81
|
+
if (!isObjectValue(method)) {
|
|
82
|
+
throw new Error(`Connector '${provider}' has an invalid authentication method`);
|
|
83
|
+
}
|
|
84
|
+
const idValue = Reflect.get(method, 'id');
|
|
85
|
+
if (typeof idValue !== 'string' || !idValue.trim()) {
|
|
86
|
+
throw new Error(`Connector '${provider}' has an authentication method without an id`);
|
|
87
|
+
}
|
|
88
|
+
const label = Reflect.get(method, 'label');
|
|
89
|
+
if (!isRuntimeI18nText(label)) {
|
|
90
|
+
throw new Error(`Connector '${provider}' authentication method '${idValue.trim()}' must declare a label`);
|
|
91
|
+
}
|
|
92
|
+
const type = Reflect.get(method, 'type');
|
|
93
|
+
if (type !== 'oauth2' && type !== 'api_key') {
|
|
94
|
+
throw new Error(`Connector '${provider}' has unsupported authentication method type '${String(type)}'`);
|
|
95
|
+
}
|
|
96
|
+
if (type === 'api_key' && !isObjectValue(Reflect.get(method, 'credentials'))) {
|
|
97
|
+
throw new Error(`Connector '${provider}' API key method '${idValue.trim()}' must declare credentials`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function isConnectorOAuthConfig(value) {
|
|
101
|
+
return isObjectValue(value) && Reflect.get(value, 'type') === 'oauth2';
|
|
102
|
+
}
|
|
103
|
+
function isRuntimeI18nText(value) {
|
|
104
|
+
if (typeof value === 'string') {
|
|
105
|
+
return !!value.trim();
|
|
106
|
+
}
|
|
107
|
+
return isObjectValue(value) && typeof Reflect.get(value, 'en_US') === 'string';
|
|
108
|
+
}
|
|
109
|
+
function isObjectValue(value) {
|
|
110
|
+
return typeof value === 'object' && value !== null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { assertConnectorDefinition, getConnectorAuthMethods };
|
package/index.cjs.js
CHANGED
|
@@ -32,6 +32,7 @@ var messages = require('@langchain/core/messages');
|
|
|
32
32
|
var env = require('@langchain/core/utils/env');
|
|
33
33
|
require('js-tiktoken');
|
|
34
34
|
var base = require('@langchain/core/language_models/base');
|
|
35
|
+
var connector = require('./connector.cjs.js');
|
|
35
36
|
|
|
36
37
|
function _interopNamespaceDefault(e) {
|
|
37
38
|
var n = Object.create(null);
|
|
@@ -2079,12 +2080,34 @@ function mergeCredentials(credentials, modelProperties) {
|
|
|
2079
2080
|
return collaborationClient._extends({}, credentials != null ? credentials : {}, modelProperties != null ? modelProperties : {});
|
|
2080
2081
|
}
|
|
2081
2082
|
|
|
2083
|
+
function calculateModelPrice(pricing, priceType, tokens, inputTokens = tokens) {
|
|
2084
|
+
var _pricing_tiered_pricing;
|
|
2085
|
+
const tier = (_pricing_tiered_pricing = pricing.tiered_pricing) == null ? void 0 : _pricing_tiered_pricing.find(({ max_tokens })=>inputTokens <= Number(max_tokens));
|
|
2086
|
+
var _tier_input, _tier_output;
|
|
2087
|
+
const configuredUnitPrice = priceType === contracts.PriceType.INPUT ? (_tier_input = tier == null ? void 0 : tier.input) != null ? _tier_input : pricing.input : (_tier_output = tier == null ? void 0 : tier.output) != null ? _tier_output : pricing.output;
|
|
2088
|
+
const unitPrice = Number(configuredUnitPrice);
|
|
2089
|
+
if (!Number.isFinite(unitPrice)) {
|
|
2090
|
+
return {
|
|
2091
|
+
unitPrice: 0,
|
|
2092
|
+
unit: 0,
|
|
2093
|
+
totalAmount: 0,
|
|
2094
|
+
currency: 'USD'
|
|
2095
|
+
};
|
|
2096
|
+
}
|
|
2097
|
+
return {
|
|
2098
|
+
unitPrice,
|
|
2099
|
+
unit: Number(pricing.unit),
|
|
2100
|
+
totalAmount: Number((tokens * unitPrice * Number(pricing.unit)).toFixed(7)),
|
|
2101
|
+
currency: pricing.currency
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2082
2105
|
var AIModel_1;
|
|
2083
2106
|
let AIModel = AIModel_1 = class AIModel {
|
|
2084
2107
|
getChatModel(copilotModel, options) {
|
|
2085
2108
|
throw new Error(`Unsupport chat model!`);
|
|
2086
2109
|
}
|
|
2087
|
-
getPrice(model, credentials, priceType, tokens) {
|
|
2110
|
+
getPrice(model, credentials, priceType, tokens, inputTokens = tokens) {
|
|
2088
2111
|
const modelSchema = this.getModelSchema(model, credentials);
|
|
2089
2112
|
if (!modelSchema || !modelSchema.pricing) {
|
|
2090
2113
|
return {
|
|
@@ -2094,23 +2117,7 @@ let AIModel = AIModel_1 = class AIModel {
|
|
|
2094
2117
|
currency: 'USD'
|
|
2095
2118
|
};
|
|
2096
2119
|
}
|
|
2097
|
-
|
|
2098
|
-
const unitPrice = priceType === contracts.PriceType.INPUT ? pricing.input : pricing.output;
|
|
2099
|
-
if (unitPrice === undefined) {
|
|
2100
|
-
return {
|
|
2101
|
-
unitPrice: 0,
|
|
2102
|
-
unit: 0,
|
|
2103
|
-
totalAmount: 0,
|
|
2104
|
-
currency: 'USD'
|
|
2105
|
-
};
|
|
2106
|
-
}
|
|
2107
|
-
const totalAmount = Number((tokens * unitPrice * pricing.unit).toFixed(7));
|
|
2108
|
-
return {
|
|
2109
|
-
unitPrice,
|
|
2110
|
-
unit: pricing.unit,
|
|
2111
|
-
totalAmount,
|
|
2112
|
-
currency: pricing.currency
|
|
2113
|
-
};
|
|
2120
|
+
return calculateModelPrice(modelSchema.pricing, priceType, tokens, inputTokens);
|
|
2114
2121
|
}
|
|
2115
2122
|
getModelPath() {
|
|
2116
2123
|
const modelType = this.modelType.toLowerCase();
|
|
@@ -2366,10 +2373,9 @@ class LargeLanguageModel extends AIModel {
|
|
|
2366
2373
|
return CommonParameterRules;
|
|
2367
2374
|
}
|
|
2368
2375
|
calcResponseUsage(model, credentials, promptTokens, completionTokens) {
|
|
2369
|
-
|
|
2370
|
-
const
|
|
2371
|
-
|
|
2372
|
-
const completionPriceInfo = this.getPrice(model, credentials, contracts.PriceType.OUTPUT, completionTokens);
|
|
2376
|
+
const promptPriceInfo = this.getPrice(model, credentials, contracts.PriceType.INPUT, promptTokens, promptTokens);
|
|
2377
|
+
const completionPriceInfo = this.getPrice(model, credentials, contracts.PriceType.OUTPUT, completionTokens, promptTokens);
|
|
2378
|
+
const totalPrice = Number((promptPriceInfo.totalAmount + completionPriceInfo.totalAmount).toFixed(7));
|
|
2373
2379
|
// Conversion usage
|
|
2374
2380
|
const usage = {
|
|
2375
2381
|
promptTokens: promptTokens,
|
|
@@ -2381,7 +2387,7 @@ class LargeLanguageModel extends AIModel {
|
|
|
2381
2387
|
completionPriceUnit: completionPriceInfo.unit,
|
|
2382
2388
|
completionPrice: completionPriceInfo.totalAmount,
|
|
2383
2389
|
totalTokens: promptTokens + completionTokens,
|
|
2384
|
-
totalPrice
|
|
2390
|
+
totalPrice,
|
|
2385
2391
|
currency: promptPriceInfo.currency,
|
|
2386
2392
|
latency: performance.now() - this.startedAt
|
|
2387
2393
|
};
|
|
@@ -2557,8 +2563,8 @@ function calcTokenUsage(output) {
|
|
|
2557
2563
|
const message = item.message;
|
|
2558
2564
|
if (message.usage_metadata) {
|
|
2559
2565
|
tokenUsage.promptTokens += message.usage_metadata.input_tokens;
|
|
2560
|
-
tokenUsage.completionTokens
|
|
2561
|
-
tokenUsage.totalTokens
|
|
2566
|
+
tokenUsage.completionTokens += message.usage_metadata.output_tokens;
|
|
2567
|
+
tokenUsage.totalTokens += message.usage_metadata.total_tokens;
|
|
2562
2568
|
}
|
|
2563
2569
|
});
|
|
2564
2570
|
});
|
|
@@ -2935,6 +2941,7 @@ function assertSegment(input, name) {
|
|
|
2935
2941
|
}
|
|
2936
2942
|
|
|
2937
2943
|
const AGENT_CHAT_DISPATCH_MESSAGE_TYPE = defineAgentMessageType('chat_dispatch', 1);
|
|
2944
|
+
const AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = 'steer_target_not_running';
|
|
2938
2945
|
|
|
2939
2946
|
/**
|
|
2940
2947
|
* Handoff Processor meta key。
|
|
@@ -3172,6 +3179,40 @@ const CONNECTOR_STRATEGY = 'CONNECTOR_STRATEGY';
|
|
|
3172
3179
|
const ConnectorStrategyKey = (provider)=>common.applyDecorators(common.SetMetadata(CONNECTOR_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, CONNECTOR_STRATEGY));
|
|
3173
3180
|
|
|
3174
3181
|
exports.ConnectorStrategyRegistry = class ConnectorStrategyRegistry extends BaseStrategyRegistry {
|
|
3182
|
+
upsert(instance) {
|
|
3183
|
+
const target = resolveStrategyMetadataTarget(instance);
|
|
3184
|
+
if (!target) {
|
|
3185
|
+
return;
|
|
3186
|
+
}
|
|
3187
|
+
const provider = this.reflector.get(CONNECTOR_STRATEGY, target);
|
|
3188
|
+
if (provider) {
|
|
3189
|
+
const definition = readConnectorDefinition(instance, target);
|
|
3190
|
+
if (definition === undefined) {
|
|
3191
|
+
throw new Error(`Connector strategy '${provider}' must expose a connector definition`);
|
|
3192
|
+
}
|
|
3193
|
+
connector.assertConnectorDefinition(definition);
|
|
3194
|
+
if (definition.provider !== provider) {
|
|
3195
|
+
throw new Error(`Connector strategy '${provider}' definition declares provider '${definition.provider}'`);
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
super.upsert(instance);
|
|
3199
|
+
}
|
|
3200
|
+
get(type, organizationId) {
|
|
3201
|
+
const strategy = super.get(type, organizationId);
|
|
3202
|
+
if (!isLegacyConnectorStrategy(strategy)) {
|
|
3203
|
+
throw new Error(`Connector strategy '${type}' does not implement the legacy OAuth contract`);
|
|
3204
|
+
}
|
|
3205
|
+
return strategy;
|
|
3206
|
+
}
|
|
3207
|
+
list(organizationId) {
|
|
3208
|
+
return super.list(organizationId).filter(isLegacyConnectorStrategy);
|
|
3209
|
+
}
|
|
3210
|
+
getRuntime(type, organizationId) {
|
|
3211
|
+
return super.get(type, organizationId);
|
|
3212
|
+
}
|
|
3213
|
+
listRuntime(organizationId) {
|
|
3214
|
+
return super.list(organizationId);
|
|
3215
|
+
}
|
|
3175
3216
|
constructor(discoveryService, reflector){
|
|
3176
3217
|
super(CONNECTOR_STRATEGY, discoveryService, reflector);
|
|
3177
3218
|
}
|
|
@@ -3183,6 +3224,19 @@ exports.ConnectorStrategyRegistry = __decorate([
|
|
|
3183
3224
|
core.Reflector
|
|
3184
3225
|
])
|
|
3185
3226
|
], exports.ConnectorStrategyRegistry);
|
|
3227
|
+
function readConnectorDefinition(instance, target) {
|
|
3228
|
+
if (isStrategyInstance(instance)) {
|
|
3229
|
+
const definition = Reflect.get(instance, 'definition');
|
|
3230
|
+
if (definition !== undefined) {
|
|
3231
|
+
return definition;
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
return Reflect.get(target, 'definition');
|
|
3235
|
+
}
|
|
3236
|
+
function isLegacyConnectorStrategy(strategy) {
|
|
3237
|
+
var _strategy_definition_auth;
|
|
3238
|
+
return 'auth' in strategy.definition && ((_strategy_definition_auth = strategy.definition.auth) == null ? void 0 : _strategy_definition_auth.type) === 'oauth2' && typeof strategy.buildAuthorizationUrl === 'function' && typeof strategy.exchangeOAuthCode === 'function';
|
|
3239
|
+
}
|
|
3186
3240
|
|
|
3187
3241
|
const SANDBOX_SHELL_TIMEOUT_LIMITS_SEC = {
|
|
3188
3242
|
min: 1,
|
|
@@ -4844,7 +4898,10 @@ Object.defineProperty(exports, "ASSISTANT_CONTEXT_SET_COMMAND", {
|
|
|
4844
4898
|
enumerable: true,
|
|
4845
4899
|
get: function () { return contracts.ASSISTANT_CONTEXT_SET_COMMAND; }
|
|
4846
4900
|
});
|
|
4901
|
+
exports.assertConnectorDefinition = connector.assertConnectorDefinition;
|
|
4902
|
+
exports.getConnectorAuthMethods = connector.getConnectorAuthMethods;
|
|
4847
4903
|
exports.ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN = ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN;
|
|
4904
|
+
exports.AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING;
|
|
4848
4905
|
exports.AGENT_CHAT_DISPATCH_MESSAGE_TYPE = AGENT_CHAT_DISPATCH_MESSAGE_TYPE;
|
|
4849
4906
|
exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
|
|
4850
4907
|
exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
|
|
@@ -4997,6 +5054,7 @@ exports.als = als;
|
|
|
4997
5054
|
exports.appendSandboxMessage = appendSandboxMessage;
|
|
4998
5055
|
exports.buildSandboxTimeoutMessage = buildSandboxTimeoutMessage;
|
|
4999
5056
|
exports.calcTokenUsage = calcTokenUsage;
|
|
5057
|
+
exports.calculateModelPrice = calculateModelPrice;
|
|
5000
5058
|
exports.chunkText = chunkText;
|
|
5001
5059
|
exports.countTokensSafe = countTokensSafe;
|
|
5002
5060
|
exports.createI18nInstance = createI18nInstance;
|
package/index.esm.js
CHANGED
|
@@ -35,6 +35,8 @@ import { AIMessage } from '@langchain/core/messages';
|
|
|
35
35
|
import { getEnvironmentVariable } from '@langchain/core/utils/env';
|
|
36
36
|
import 'js-tiktoken';
|
|
37
37
|
import { getModelContextSize as getModelContextSize$1 } from '@langchain/core/language_models/base';
|
|
38
|
+
import { assertConnectorDefinition } from './connector.esm.js';
|
|
39
|
+
export { getConnectorAuthMethods } from './connector.esm.js';
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
42
|
* Metadata keys used in plugins for defining various aspects like entities, subscribers, and configurations.
|
|
@@ -2060,12 +2062,34 @@ function mergeCredentials(credentials, modelProperties) {
|
|
|
2060
2062
|
return _extends({}, credentials != null ? credentials : {}, modelProperties != null ? modelProperties : {});
|
|
2061
2063
|
}
|
|
2062
2064
|
|
|
2065
|
+
function calculateModelPrice(pricing, priceType, tokens, inputTokens = tokens) {
|
|
2066
|
+
var _pricing_tiered_pricing;
|
|
2067
|
+
const tier = (_pricing_tiered_pricing = pricing.tiered_pricing) == null ? void 0 : _pricing_tiered_pricing.find(({ max_tokens })=>inputTokens <= Number(max_tokens));
|
|
2068
|
+
var _tier_input, _tier_output;
|
|
2069
|
+
const configuredUnitPrice = priceType === PriceType.INPUT ? (_tier_input = tier == null ? void 0 : tier.input) != null ? _tier_input : pricing.input : (_tier_output = tier == null ? void 0 : tier.output) != null ? _tier_output : pricing.output;
|
|
2070
|
+
const unitPrice = Number(configuredUnitPrice);
|
|
2071
|
+
if (!Number.isFinite(unitPrice)) {
|
|
2072
|
+
return {
|
|
2073
|
+
unitPrice: 0,
|
|
2074
|
+
unit: 0,
|
|
2075
|
+
totalAmount: 0,
|
|
2076
|
+
currency: 'USD'
|
|
2077
|
+
};
|
|
2078
|
+
}
|
|
2079
|
+
return {
|
|
2080
|
+
unitPrice,
|
|
2081
|
+
unit: Number(pricing.unit),
|
|
2082
|
+
totalAmount: Number((tokens * unitPrice * Number(pricing.unit)).toFixed(7)),
|
|
2083
|
+
currency: pricing.currency
|
|
2084
|
+
};
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2063
2087
|
var AIModel_1;
|
|
2064
2088
|
let AIModel = AIModel_1 = class AIModel {
|
|
2065
2089
|
getChatModel(copilotModel, options) {
|
|
2066
2090
|
throw new Error(`Unsupport chat model!`);
|
|
2067
2091
|
}
|
|
2068
|
-
getPrice(model, credentials, priceType, tokens) {
|
|
2092
|
+
getPrice(model, credentials, priceType, tokens, inputTokens = tokens) {
|
|
2069
2093
|
const modelSchema = this.getModelSchema(model, credentials);
|
|
2070
2094
|
if (!modelSchema || !modelSchema.pricing) {
|
|
2071
2095
|
return {
|
|
@@ -2075,23 +2099,7 @@ let AIModel = AIModel_1 = class AIModel {
|
|
|
2075
2099
|
currency: 'USD'
|
|
2076
2100
|
};
|
|
2077
2101
|
}
|
|
2078
|
-
|
|
2079
|
-
const unitPrice = priceType === PriceType.INPUT ? pricing.input : pricing.output;
|
|
2080
|
-
if (unitPrice === undefined) {
|
|
2081
|
-
return {
|
|
2082
|
-
unitPrice: 0,
|
|
2083
|
-
unit: 0,
|
|
2084
|
-
totalAmount: 0,
|
|
2085
|
-
currency: 'USD'
|
|
2086
|
-
};
|
|
2087
|
-
}
|
|
2088
|
-
const totalAmount = Number((tokens * unitPrice * pricing.unit).toFixed(7));
|
|
2089
|
-
return {
|
|
2090
|
-
unitPrice,
|
|
2091
|
-
unit: pricing.unit,
|
|
2092
|
-
totalAmount,
|
|
2093
|
-
currency: pricing.currency
|
|
2094
|
-
};
|
|
2102
|
+
return calculateModelPrice(modelSchema.pricing, priceType, tokens, inputTokens);
|
|
2095
2103
|
}
|
|
2096
2104
|
getModelPath() {
|
|
2097
2105
|
const modelType = this.modelType.toLowerCase();
|
|
@@ -2347,10 +2355,9 @@ class LargeLanguageModel extends AIModel {
|
|
|
2347
2355
|
return CommonParameterRules;
|
|
2348
2356
|
}
|
|
2349
2357
|
calcResponseUsage(model, credentials, promptTokens, completionTokens) {
|
|
2350
|
-
|
|
2351
|
-
const
|
|
2352
|
-
|
|
2353
|
-
const completionPriceInfo = this.getPrice(model, credentials, PriceType.OUTPUT, completionTokens);
|
|
2358
|
+
const promptPriceInfo = this.getPrice(model, credentials, PriceType.INPUT, promptTokens, promptTokens);
|
|
2359
|
+
const completionPriceInfo = this.getPrice(model, credentials, PriceType.OUTPUT, completionTokens, promptTokens);
|
|
2360
|
+
const totalPrice = Number((promptPriceInfo.totalAmount + completionPriceInfo.totalAmount).toFixed(7));
|
|
2354
2361
|
// Conversion usage
|
|
2355
2362
|
const usage = {
|
|
2356
2363
|
promptTokens: promptTokens,
|
|
@@ -2362,7 +2369,7 @@ class LargeLanguageModel extends AIModel {
|
|
|
2362
2369
|
completionPriceUnit: completionPriceInfo.unit,
|
|
2363
2370
|
completionPrice: completionPriceInfo.totalAmount,
|
|
2364
2371
|
totalTokens: promptTokens + completionTokens,
|
|
2365
|
-
totalPrice
|
|
2372
|
+
totalPrice,
|
|
2366
2373
|
currency: promptPriceInfo.currency,
|
|
2367
2374
|
latency: performance.now() - this.startedAt
|
|
2368
2375
|
};
|
|
@@ -2538,8 +2545,8 @@ function calcTokenUsage(output) {
|
|
|
2538
2545
|
const message = item.message;
|
|
2539
2546
|
if (message.usage_metadata) {
|
|
2540
2547
|
tokenUsage.promptTokens += message.usage_metadata.input_tokens;
|
|
2541
|
-
tokenUsage.completionTokens
|
|
2542
|
-
tokenUsage.totalTokens
|
|
2548
|
+
tokenUsage.completionTokens += message.usage_metadata.output_tokens;
|
|
2549
|
+
tokenUsage.totalTokens += message.usage_metadata.total_tokens;
|
|
2543
2550
|
}
|
|
2544
2551
|
});
|
|
2545
2552
|
});
|
|
@@ -2916,6 +2923,7 @@ function assertSegment(input, name) {
|
|
|
2916
2923
|
}
|
|
2917
2924
|
|
|
2918
2925
|
const AGENT_CHAT_DISPATCH_MESSAGE_TYPE = defineAgentMessageType('chat_dispatch', 1);
|
|
2926
|
+
const AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = 'steer_target_not_running';
|
|
2919
2927
|
|
|
2920
2928
|
/**
|
|
2921
2929
|
* Handoff Processor meta key。
|
|
@@ -3153,6 +3161,40 @@ const CONNECTOR_STRATEGY = 'CONNECTOR_STRATEGY';
|
|
|
3153
3161
|
const ConnectorStrategyKey = (provider)=>applyDecorators(SetMetadata(CONNECTOR_STRATEGY, provider), SetMetadata(STRATEGY_META_KEY, CONNECTOR_STRATEGY));
|
|
3154
3162
|
|
|
3155
3163
|
let ConnectorStrategyRegistry = class ConnectorStrategyRegistry extends BaseStrategyRegistry {
|
|
3164
|
+
upsert(instance) {
|
|
3165
|
+
const target = resolveStrategyMetadataTarget(instance);
|
|
3166
|
+
if (!target) {
|
|
3167
|
+
return;
|
|
3168
|
+
}
|
|
3169
|
+
const provider = this.reflector.get(CONNECTOR_STRATEGY, target);
|
|
3170
|
+
if (provider) {
|
|
3171
|
+
const definition = readConnectorDefinition(instance, target);
|
|
3172
|
+
if (definition === undefined) {
|
|
3173
|
+
throw new Error(`Connector strategy '${provider}' must expose a connector definition`);
|
|
3174
|
+
}
|
|
3175
|
+
assertConnectorDefinition(definition);
|
|
3176
|
+
if (definition.provider !== provider) {
|
|
3177
|
+
throw new Error(`Connector strategy '${provider}' definition declares provider '${definition.provider}'`);
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
super.upsert(instance);
|
|
3181
|
+
}
|
|
3182
|
+
get(type, organizationId) {
|
|
3183
|
+
const strategy = super.get(type, organizationId);
|
|
3184
|
+
if (!isLegacyConnectorStrategy(strategy)) {
|
|
3185
|
+
throw new Error(`Connector strategy '${type}' does not implement the legacy OAuth contract`);
|
|
3186
|
+
}
|
|
3187
|
+
return strategy;
|
|
3188
|
+
}
|
|
3189
|
+
list(organizationId) {
|
|
3190
|
+
return super.list(organizationId).filter(isLegacyConnectorStrategy);
|
|
3191
|
+
}
|
|
3192
|
+
getRuntime(type, organizationId) {
|
|
3193
|
+
return super.get(type, organizationId);
|
|
3194
|
+
}
|
|
3195
|
+
listRuntime(organizationId) {
|
|
3196
|
+
return super.list(organizationId);
|
|
3197
|
+
}
|
|
3156
3198
|
constructor(discoveryService, reflector){
|
|
3157
3199
|
super(CONNECTOR_STRATEGY, discoveryService, reflector);
|
|
3158
3200
|
}
|
|
@@ -3164,6 +3206,19 @@ ConnectorStrategyRegistry = __decorate([
|
|
|
3164
3206
|
Reflector
|
|
3165
3207
|
])
|
|
3166
3208
|
], ConnectorStrategyRegistry);
|
|
3209
|
+
function readConnectorDefinition(instance, target) {
|
|
3210
|
+
if (isStrategyInstance(instance)) {
|
|
3211
|
+
const definition = Reflect.get(instance, 'definition');
|
|
3212
|
+
if (definition !== undefined) {
|
|
3213
|
+
return definition;
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
return Reflect.get(target, 'definition');
|
|
3217
|
+
}
|
|
3218
|
+
function isLegacyConnectorStrategy(strategy) {
|
|
3219
|
+
var _strategy_definition_auth;
|
|
3220
|
+
return 'auth' in strategy.definition && ((_strategy_definition_auth = strategy.definition.auth) == null ? void 0 : _strategy_definition_auth.type) === 'oauth2' && typeof strategy.buildAuthorizationUrl === 'function' && typeof strategy.exchangeOAuthCode === 'function';
|
|
3221
|
+
}
|
|
3167
3222
|
|
|
3168
3223
|
const SANDBOX_SHELL_TIMEOUT_LIMITS_SEC = {
|
|
3169
3224
|
min: 1,
|
|
@@ -4811,4 +4866,4 @@ CollaborationDocumentProviderRegistry = __decorate([
|
|
|
4811
4866
|
])
|
|
4812
4867
|
], CollaborationDocumentProviderRegistry);
|
|
4813
4868
|
|
|
4814
|
-
export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PERMISSION_SERVICE_TOKEN, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, ArtifactsRuntimeCapability, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BaseTool, BaseToolset, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorRuntimeCapability, ConnectorStrategyKey, ConnectorStrategyRegistry, CreateModelClientCommand, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DEFAULT_EXECUTION_CONFIG, DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC, DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS, DEFAULT_SANDBOX_SHELL_TIMEOUT_MS, DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DefaultRuntimeCapabilityRegistry as DefaultAgentMiddlewareRuntimeCapabilityRegistry, DefaultRuntimeCapabilityRegistry, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseRuntimeCapability, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, PluginJobProcessor, PluginWebhookAuth, PluginWebhookAuthGuard, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_JOB_ERROR_CODES, SANDBOX_PROVIDER, SANDBOX_RUNTIME_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SANDBOX_WORKSPACE_MAPPER, SKILL_SOURCE_PROVIDER, SPEECH_TO_TEXT_PERMISSION_SERVICE_TOKEN, SPEECH_TO_TEXT_SERVICE_TOKEN, SSOProviderRegistry, SSOProviderStrategyKey, SSO_BINDING_PERMISSION_SERVICE_TOKEN, SSO_PROVIDER, STRATEGY_META_KEY, SYSTEM_GLOBAL_SCOPE, SandboxJobRuntimeError, SandboxJobsRuntimeCapability, SandboxProviderRegistry, SandboxProviderStrategy, SandboxRuntimeProviderRegistry, SandboxRuntimeProviderStrategy, SandboxWorkspaceMapperRegistry, SandboxWorkspaceMapperStrategy, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TENANT_GLOBAL_SCOPE_PREFIX, TENANT_GLOBAL_SCOPE_SUFFIX, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WORKSPACE_FILES_SOURCE, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_RUNTIME_CAPABILITIES_TOKEN, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, buildSandboxTimeoutMessage, calcTokenUsage, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, derivePluginArtifactNamespace, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, isDevelopmentSandboxRuntimeEnvironment, isRemoteFile, isSandboxBackend, isSandboxJobRuntimeError, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, pluginArtifactTableName, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage };
|
|
4869
|
+
export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PERMISSION_SERVICE_TOKEN, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, ArtifactsRuntimeCapability, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BaseTool, BaseToolset, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorRuntimeCapability, ConnectorStrategyKey, ConnectorStrategyRegistry, CreateModelClientCommand, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DEFAULT_EXECUTION_CONFIG, DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC, DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS, DEFAULT_SANDBOX_SHELL_TIMEOUT_MS, DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DefaultRuntimeCapabilityRegistry as DefaultAgentMiddlewareRuntimeCapabilityRegistry, DefaultRuntimeCapabilityRegistry, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseRuntimeCapability, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, PluginJobProcessor, PluginWebhookAuth, PluginWebhookAuthGuard, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_JOB_ERROR_CODES, SANDBOX_PROVIDER, SANDBOX_RUNTIME_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SANDBOX_WORKSPACE_MAPPER, SKILL_SOURCE_PROVIDER, SPEECH_TO_TEXT_PERMISSION_SERVICE_TOKEN, SPEECH_TO_TEXT_SERVICE_TOKEN, SSOProviderRegistry, SSOProviderStrategyKey, SSO_BINDING_PERMISSION_SERVICE_TOKEN, SSO_PROVIDER, STRATEGY_META_KEY, SYSTEM_GLOBAL_SCOPE, SandboxJobRuntimeError, SandboxJobsRuntimeCapability, SandboxProviderRegistry, SandboxProviderStrategy, SandboxRuntimeProviderRegistry, SandboxRuntimeProviderStrategy, SandboxWorkspaceMapperRegistry, SandboxWorkspaceMapperStrategy, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TENANT_GLOBAL_SCOPE_PREFIX, TENANT_GLOBAL_SCOPE_SUFFIX, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WORKSPACE_FILES_SOURCE, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_RUNTIME_CAPABILITIES_TOKEN, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateModelPrice, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, derivePluginArtifactNamespace, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, isDevelopmentSandboxRuntimeEnvironment, isRemoteFile, isSandboxBackend, isSandboxJobRuntimeError, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, pluginArtifactTableName, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.15",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@langchain/openai": "0.6.9",
|
|
20
|
-
"@xpert-ai/contracts": "3.15.
|
|
20
|
+
"@xpert-ai/contracts": "3.15.15",
|
|
21
21
|
"express": "^4.22.1",
|
|
22
22
|
"js-tiktoken": "^1.0.21"
|
|
23
23
|
},
|
|
@@ -51,6 +51,12 @@
|
|
|
51
51
|
"types": "./collaboration-client.d.ts",
|
|
52
52
|
"import": "./collaboration-client.cjs.mjs",
|
|
53
53
|
"default": "./collaboration-client.cjs.js"
|
|
54
|
+
},
|
|
55
|
+
"./connector": {
|
|
56
|
+
"module": "./connector.esm.js",
|
|
57
|
+
"types": "./connector.d.ts",
|
|
58
|
+
"import": "./connector.cjs.mjs",
|
|
59
|
+
"default": "./connector.cjs.js"
|
|
54
60
|
}
|
|
55
61
|
},
|
|
56
62
|
"types": "./index.d.ts"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TChatOptions, TChatRequest, TChatRuntimePrincipal, TChatSourceAuditOptions } from '@xpert-ai/contracts';
|
|
2
2
|
export declare const AGENT_CHAT_DISPATCH_MESSAGE_TYPE: import("./message-type").StructuredHandoffMessageType;
|
|
3
|
+
export declare const AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = "steer_target_not_running";
|
|
3
4
|
export interface AgentChatHandoffMessageCallbackTarget {
|
|
4
5
|
transport?: 'handoff-message';
|
|
5
6
|
messageType: string;
|
|
@@ -38,5 +39,6 @@ export interface AgentChatCallbackEnvelopePayload extends Record<string, unknown
|
|
|
38
39
|
sequence: number;
|
|
39
40
|
event?: unknown;
|
|
40
41
|
error?: string;
|
|
42
|
+
errorCode?: typeof AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING;
|
|
41
43
|
context?: Record<string, unknown>;
|
|
42
44
|
}
|
|
@@ -13,7 +13,7 @@ export declare abstract class AIModel implements IAIModel {
|
|
|
13
13
|
constructor(modelProvider: ModelProvider, modelType: AiModelTypeEnum);
|
|
14
14
|
abstract validateCredentials(model: string, credentials: Record<string, any>): Promise<void>;
|
|
15
15
|
getChatModel(copilotModel: ICopilotModel, options?: TChatModelOptions): BaseChatModel;
|
|
16
|
-
getPrice(model: string, credentials: Record<string, any>, priceType: PriceType, tokens: number): PriceInfo;
|
|
16
|
+
getPrice(model: string, credentials: Record<string, any>, priceType: PriceType, tokens: number, inputTokens?: number): PriceInfo;
|
|
17
17
|
protected getModelPath(): string;
|
|
18
18
|
predefinedModels(): AIModelEntity[];
|
|
19
19
|
getModelSchema(model: string, credentials?: Record<string, any>): AIModelEntity | null;
|
|
@@ -17,7 +17,7 @@ export interface IAIModel {
|
|
|
17
17
|
validateCredentials(model: string, credentials: Record<string, any>): Promise<void>;
|
|
18
18
|
getChatModel(copilotModel: ICopilotModel, options?: TChatModelOptions): BaseChatModel;
|
|
19
19
|
predefinedModels(): AIModelEntity[];
|
|
20
|
-
getPrice(model: string, credentials: Record<string, any>, priceType: PriceType, tokens: number): PriceInfo;
|
|
20
|
+
getPrice(model: string, credentials: Record<string, any>, priceType: PriceType, tokens: number, inputTokens?: number): PriceInfo;
|
|
21
21
|
}
|
|
22
22
|
export declare const CommonParameterRules: {
|
|
23
23
|
name: string;
|
|
@@ -27,6 +27,18 @@ export type ConnectorAppCredentialsConfig = {
|
|
|
27
27
|
};
|
|
28
28
|
defaultValues?: Record<string, string | number | boolean | null>;
|
|
29
29
|
};
|
|
30
|
+
export type ConnectorCredentialFormDefinition = ConnectorAppCredentialsConfig;
|
|
31
|
+
export type ConnectorAuthMethodDefinition = {
|
|
32
|
+
id: string;
|
|
33
|
+
type: 'oauth2';
|
|
34
|
+
label: RuntimeI18nText;
|
|
35
|
+
appCredentials?: ConnectorCredentialFormDefinition;
|
|
36
|
+
} | {
|
|
37
|
+
id: string;
|
|
38
|
+
type: 'api_key';
|
|
39
|
+
label: RuntimeI18nText;
|
|
40
|
+
credentials: ConnectorCredentialFormDefinition;
|
|
41
|
+
};
|
|
30
42
|
export type ConnectorPermissionDeclaration = {
|
|
31
43
|
key: string;
|
|
32
44
|
label?: RuntimeI18nText;
|
|
@@ -37,15 +49,28 @@ export type ConnectorPermissionDeclaration = {
|
|
|
37
49
|
storage?: 'platform_vault' | 'runtime_only' | 'external';
|
|
38
50
|
required?: boolean;
|
|
39
51
|
};
|
|
40
|
-
export type
|
|
52
|
+
export type ConnectorDefinitionBase = {
|
|
41
53
|
provider: string;
|
|
42
54
|
label: RuntimeI18nText;
|
|
43
55
|
description?: RuntimeI18nText;
|
|
44
56
|
icon?: RuntimeCapabilityIcon;
|
|
45
|
-
auth: ConnectorOAuthConfig;
|
|
46
57
|
permissions?: ConnectorPermissionDeclaration[];
|
|
58
|
+
/** Maps credentials stored before multi-auth support to a declared OAuth method. */
|
|
59
|
+
legacyAuthMethodId?: string;
|
|
60
|
+
};
|
|
61
|
+
export type ConnectorDefinition = ConnectorDefinitionBase & {
|
|
62
|
+
auth: ConnectorOAuthConfig;
|
|
63
|
+
appCredentials?: ConnectorAppCredentialsConfig;
|
|
64
|
+
};
|
|
65
|
+
export type ConnectorMultiAuthDefinition = ConnectorDefinitionBase & {
|
|
66
|
+
authMethods: ConnectorAuthMethodDefinition[];
|
|
67
|
+
/** Optional legacy OAuth metadata used by host compatibility adapters. */
|
|
68
|
+
auth?: ConnectorOAuthConfig;
|
|
47
69
|
appCredentials?: ConnectorAppCredentialsConfig;
|
|
48
70
|
};
|
|
71
|
+
export type ConnectorStrategyDefinition = ConnectorDefinition | ConnectorMultiAuthDefinition;
|
|
72
|
+
export declare function getConnectorAuthMethods(definition: ConnectorStrategyDefinition): ConnectorAuthMethodDefinition[];
|
|
73
|
+
export declare function assertConnectorDefinition(definition: unknown): asserts definition is ConnectorStrategyDefinition;
|
|
49
74
|
export type ConnectorProfile = {
|
|
50
75
|
openId?: string;
|
|
51
76
|
unionId?: string;
|
|
@@ -59,6 +84,7 @@ export type ConnectorInstance = {
|
|
|
59
84
|
id: string;
|
|
60
85
|
workspaceId: string;
|
|
61
86
|
provider: string;
|
|
87
|
+
authMethodId?: string | null;
|
|
62
88
|
status: ConnectorStatus;
|
|
63
89
|
profile?: ConnectorProfile | null;
|
|
64
90
|
scopes?: string[];
|
|
@@ -75,6 +101,19 @@ export type ConnectorInstance = {
|
|
|
75
101
|
export type ConnectorOAuthStartRequest = {
|
|
76
102
|
app?: ConnectorAppCredentialPayload;
|
|
77
103
|
};
|
|
104
|
+
export type ConnectorConnectRequest = {
|
|
105
|
+
authMethodId?: string;
|
|
106
|
+
values?: ConnectorAppCredentialPayload;
|
|
107
|
+
/** @deprecated Use values instead. */
|
|
108
|
+
app?: ConnectorAppCredentialPayload;
|
|
109
|
+
};
|
|
110
|
+
export type ConnectorConnectResponse = {
|
|
111
|
+
status: 'active' | 'pending';
|
|
112
|
+
connector: ConnectorInstance;
|
|
113
|
+
authorizationUrl?: string | null;
|
|
114
|
+
stateExpiresAt?: string | null;
|
|
115
|
+
pollIntervalSeconds?: number | null;
|
|
116
|
+
};
|
|
78
117
|
export type ConnectorOAuthStartResponse = {
|
|
79
118
|
connector: ConnectorInstance;
|
|
80
119
|
authorizationUrl: string;
|
|
@@ -99,6 +138,16 @@ export type ConnectorRuntimeCredential = {
|
|
|
99
138
|
scopes?: string[];
|
|
100
139
|
profile?: ConnectorProfile | null;
|
|
101
140
|
};
|
|
141
|
+
export type ConnectorRuntimeCredentialV2 = {
|
|
142
|
+
connectorId: string;
|
|
143
|
+
workspaceId: string;
|
|
144
|
+
provider: string;
|
|
145
|
+
authMethodId: string;
|
|
146
|
+
credentials: Record<string, unknown>;
|
|
147
|
+
expiresAt?: string | null;
|
|
148
|
+
scopes?: string[];
|
|
149
|
+
profile?: ConnectorProfile | null;
|
|
150
|
+
};
|
|
102
151
|
export type ConnectorRuntimeGetInput = {
|
|
103
152
|
workspaceId: string;
|
|
104
153
|
provider: string;
|
|
@@ -106,6 +155,7 @@ export type ConnectorRuntimeGetInput = {
|
|
|
106
155
|
};
|
|
107
156
|
export interface ConnectorRuntimeApi {
|
|
108
157
|
getConnector(input: ConnectorRuntimeGetInput): Promise<ConnectorRuntimeCredential>;
|
|
158
|
+
getConnectorCredential?(input: ConnectorRuntimeGetInput): Promise<ConnectorRuntimeCredentialV2>;
|
|
109
159
|
}
|
|
110
160
|
export type ConnectorSelectOption = {
|
|
111
161
|
value: string;
|
|
@@ -153,6 +203,68 @@ export type ConnectorOAuthCredential = {
|
|
|
153
203
|
scopes?: string[];
|
|
154
204
|
profile?: ConnectorProfile | null;
|
|
155
205
|
};
|
|
206
|
+
export type ConnectorCredential = {
|
|
207
|
+
data: ConnectorAppCredentialPayload;
|
|
208
|
+
expiresAt?: string | null;
|
|
209
|
+
refreshExpiresAt?: string | null;
|
|
210
|
+
scopes?: string[];
|
|
211
|
+
profile?: ConnectorProfile | null;
|
|
212
|
+
};
|
|
213
|
+
export type ConnectorConnectInput = {
|
|
214
|
+
authMethodId: string;
|
|
215
|
+
values?: ConnectorAppCredentialPayload;
|
|
216
|
+
redirectUri: string;
|
|
217
|
+
state: string;
|
|
218
|
+
scopes?: string[];
|
|
219
|
+
};
|
|
220
|
+
export type ConnectorConnectResult = {
|
|
221
|
+
status: 'pending';
|
|
222
|
+
authorizationUrl: string;
|
|
223
|
+
scopes?: string[];
|
|
224
|
+
metadata?: Record<string, unknown>;
|
|
225
|
+
pollIntervalSeconds?: number | null;
|
|
226
|
+
} | {
|
|
227
|
+
status: 'active';
|
|
228
|
+
credential: ConnectorCredential;
|
|
229
|
+
};
|
|
230
|
+
export type ConnectorAuthorizationCodeInput = {
|
|
231
|
+
authMethodId: string;
|
|
232
|
+
values?: ConnectorAppCredentialPayload;
|
|
233
|
+
metadata?: Record<string, unknown> | null;
|
|
234
|
+
code: string;
|
|
235
|
+
redirectUri: string;
|
|
236
|
+
scopes?: string[];
|
|
237
|
+
};
|
|
238
|
+
export type ConnectorConnectionPollInput = {
|
|
239
|
+
authMethodId: string;
|
|
240
|
+
values?: ConnectorAppCredentialPayload;
|
|
241
|
+
metadata?: Record<string, unknown> | null;
|
|
242
|
+
redirectUri: string;
|
|
243
|
+
scopes?: string[];
|
|
244
|
+
};
|
|
245
|
+
export type ConnectorConnectionPollResult = {
|
|
246
|
+
status: 'pending';
|
|
247
|
+
authorizationUrl?: string;
|
|
248
|
+
metadata?: Record<string, unknown>;
|
|
249
|
+
pollIntervalSeconds?: number | null;
|
|
250
|
+
message?: string;
|
|
251
|
+
} | {
|
|
252
|
+
status: 'complete';
|
|
253
|
+
credential: ConnectorCredential;
|
|
254
|
+
metadata?: Record<string, unknown>;
|
|
255
|
+
} | {
|
|
256
|
+
status: 'error';
|
|
257
|
+
error: string;
|
|
258
|
+
metadata?: Record<string, unknown>;
|
|
259
|
+
};
|
|
260
|
+
export type ConnectorCredentialRefreshInput = {
|
|
261
|
+
authMethodId: string;
|
|
262
|
+
credential: ConnectorCredential;
|
|
263
|
+
};
|
|
264
|
+
export type ConnectorRuntimeCredentialResolveInput = {
|
|
265
|
+
authMethodId: string;
|
|
266
|
+
credential: ConnectorCredential;
|
|
267
|
+
};
|
|
156
268
|
export type ConnectorOAuthCompleteRequest = {
|
|
157
269
|
state: string;
|
|
158
270
|
code: string;
|
|
@@ -177,10 +289,24 @@ export type ConnectorAuthorizationPollResult = {
|
|
|
177
289
|
error: string;
|
|
178
290
|
metadata?: Record<string, unknown>;
|
|
179
291
|
};
|
|
180
|
-
export interface
|
|
292
|
+
export interface ConnectorStrategyRuntime {
|
|
293
|
+
definition: ConnectorStrategyDefinition;
|
|
294
|
+
connect?(input: ConnectorConnectInput): Promise<ConnectorConnectResult>;
|
|
295
|
+
exchangeAuthorizationCode?(input: ConnectorAuthorizationCodeInput): Promise<ConnectorCredential>;
|
|
296
|
+
pollConnection?(input: ConnectorConnectionPollInput): Promise<ConnectorConnectionPollResult>;
|
|
297
|
+
refreshConnectionCredential?(input: ConnectorCredentialRefreshInput): Promise<ConnectorCredential>;
|
|
298
|
+
resolveRuntimeCredential?(input: ConnectorRuntimeCredentialResolveInput): Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
299
|
+
buildAuthorizationUrl?(input: ConnectorAuthorizationUrlInput): Promise<ConnectorAuthorizationUrlResult>;
|
|
300
|
+
exchangeOAuthCode?(input: ConnectorOAuthCodeInput): Promise<ConnectorOAuthCredential>;
|
|
301
|
+
refreshCredential?(input: ConnectorRefreshInput): Promise<ConnectorOAuthCredential>;
|
|
302
|
+
pollAuthorization?(input: ConnectorAuthorizationPollInput): Promise<ConnectorAuthorizationPollResult>;
|
|
303
|
+
}
|
|
304
|
+
export interface ConnectorStrategy extends ConnectorStrategyRuntime {
|
|
181
305
|
definition: ConnectorDefinition;
|
|
182
306
|
buildAuthorizationUrl(input: ConnectorAuthorizationUrlInput): Promise<ConnectorAuthorizationUrlResult>;
|
|
183
307
|
exchangeOAuthCode(input: ConnectorOAuthCodeInput): Promise<ConnectorOAuthCredential>;
|
|
184
|
-
|
|
185
|
-
|
|
308
|
+
}
|
|
309
|
+
export interface ConnectorMultiAuthStrategy extends ConnectorStrategyRuntime {
|
|
310
|
+
definition: ConnectorMultiAuthDefinition;
|
|
311
|
+
connect(input: ConnectorConnectInput): Promise<ConnectorConnectResult>;
|
|
186
312
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
2
|
import { BaseStrategyRegistry } from '../strategy';
|
|
3
|
-
import type
|
|
4
|
-
export declare class ConnectorStrategyRegistry extends BaseStrategyRegistry<
|
|
3
|
+
import { type ConnectorStrategy, type ConnectorStrategyRuntime } from './strategy.interface';
|
|
4
|
+
export declare class ConnectorStrategyRegistry extends BaseStrategyRegistry<ConnectorStrategyRuntime> {
|
|
5
5
|
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
+
upsert(instance: unknown): void;
|
|
7
|
+
get(type: string, organizationId?: string): ConnectorStrategy;
|
|
8
|
+
list(organizationId?: string): ConnectorStrategy[];
|
|
9
|
+
getRuntime(type: string, organizationId?: string): ConnectorStrategyRuntime;
|
|
10
|
+
listRuntime(organizationId?: string): ConnectorStrategyRuntime[];
|
|
6
11
|
}
|
|
@@ -70,6 +70,7 @@ export declare const INTEGRATION_PERMISSION_SERVICE_TOKEN = "XPERT_PLUGIN_INTEGR
|
|
|
70
70
|
export interface IntegrationPermissionService {
|
|
71
71
|
read<TIntegration = IIntegration>(id: string, options?: Record<string, any>): Promise<TIntegration | null>;
|
|
72
72
|
findAll<TIntegration = IIntegration>(options?: Record<string, any>): Promise<IPagination<TIntegration>>;
|
|
73
|
+
findAllWithInheritance?<TIntegration = IIntegration>(options?: Record<string, any>): Promise<IPagination<TIntegration>>;
|
|
73
74
|
ensureWebhookCredential?(id: string, options?: {
|
|
74
75
|
provider?: string | null;
|
|
75
76
|
rotateIfRevoked?: boolean;
|
|
@@ -48,6 +48,7 @@ export type ManagedQueueEnqueueInput<TPayload = unknown> = {
|
|
|
48
48
|
payload: TPayload;
|
|
49
49
|
tenantId?: string | null;
|
|
50
50
|
organizationId?: string | null;
|
|
51
|
+
/** Plugin installation scope used to route to the matching processor (for example system:global or an organization id). */
|
|
51
52
|
scopeKey?: string | null;
|
|
52
53
|
userId?: string | null;
|
|
53
54
|
jobId?: string;
|
|
@@ -88,6 +89,8 @@ export type ManagedQueueJobContext = {
|
|
|
88
89
|
};
|
|
89
90
|
export type ManagedQueueJobSnapshot<TPayload = unknown> = ManagedQueueJob<TPayload> & {
|
|
90
91
|
state?: string;
|
|
92
|
+
/** BullMQ terminal failure text, when the physical job is in the failed state. */
|
|
93
|
+
failedReason?: string;
|
|
91
94
|
timestamp?: number;
|
|
92
95
|
processedOn?: number;
|
|
93
96
|
finishedOn?: number;
|
|
@@ -13,8 +13,17 @@ export type SandboxJobFileInput = {
|
|
|
13
13
|
targetPath: string;
|
|
14
14
|
/** Expected immutable byte length checked during materialization. */
|
|
15
15
|
size: number;
|
|
16
|
-
/** Expected lowercase SHA-256
|
|
16
|
+
/** Expected immutable lowercase SHA-256; materialized inputs are re-hashed before execution. */
|
|
17
17
|
sha256: string;
|
|
18
|
+
/**
|
|
19
|
+
* Input access semantics required by the Action.
|
|
20
|
+
*
|
|
21
|
+
* `materialized` preserves the v1 behavior: Core verifies and copies the
|
|
22
|
+
* complete file into the Job workspace before execution. `read-only-seekable`
|
|
23
|
+
* asks Core to expose the exact Workspace file through a Provider-owned,
|
|
24
|
+
* Job-scoped read-only mapping so media decoders can perform on-demand reads.
|
|
25
|
+
*/
|
|
26
|
+
access?: 'materialized' | 'read-only-seekable';
|
|
18
27
|
};
|
|
19
28
|
/** Declares one output to validate and persist back into Workspace Files. */
|
|
20
29
|
export type SandboxJobOutputRequest = {
|
|
@@ -24,6 +24,30 @@ export type SandboxRuntimeFileDownloadResponse = {
|
|
|
24
24
|
content: Uint8Array | null;
|
|
25
25
|
error: SandboxRuntimeFileOperationError | null;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Core-resolved Workspace file source that a system Runtime Provider may expose
|
|
29
|
+
* read-only to one Job. These paths are never part of plugin payloads or Action
|
|
30
|
+
* manifests and must not be persisted as business data.
|
|
31
|
+
*/
|
|
32
|
+
export type SandboxRuntimeReadOnlyFileSource = {
|
|
33
|
+
/** Canonical path visible to the API process. */
|
|
34
|
+
serverPath: string;
|
|
35
|
+
/** Equivalent source path visible to the Provider engine, for example Docker. */
|
|
36
|
+
hostPath: string;
|
|
37
|
+
size: number;
|
|
38
|
+
mtimeMs: number;
|
|
39
|
+
device: number;
|
|
40
|
+
inode: number;
|
|
41
|
+
};
|
|
42
|
+
/** Exact Job-workspace alias for one authorized, seekable Workspace file. */
|
|
43
|
+
export type SandboxRuntimeReadOnlyFile = {
|
|
44
|
+
source: SandboxRuntimeReadOnlyFileSource;
|
|
45
|
+
/** Safe relative path below the Runtime workspace root. */
|
|
46
|
+
targetPath: string;
|
|
47
|
+
/** Immutable identity asserted by the system plugin that owns the Action. */
|
|
48
|
+
size: number;
|
|
49
|
+
sha256: string;
|
|
50
|
+
};
|
|
27
51
|
/** Resource policy requested by a provider-neutral Runtime Definition. */
|
|
28
52
|
export type SandboxRuntimeResources = {
|
|
29
53
|
memoryMb: number;
|
|
@@ -50,6 +74,8 @@ export type SandboxRuntimeProviderCapabilities = {
|
|
|
50
74
|
resourceLimits: boolean;
|
|
51
75
|
networkPolicy: boolean;
|
|
52
76
|
readOnlyRootFilesystem: boolean;
|
|
77
|
+
/** Supports Job-scoped, read-only, seekable Workspace file mappings. */
|
|
78
|
+
readOnlyFileMounts?: boolean;
|
|
53
79
|
};
|
|
54
80
|
/** Minimum Provider guarantees required by a Runtime Definition. */
|
|
55
81
|
export type SandboxRuntimeRequirements = SandboxRuntimeProviderCapabilities;
|
|
@@ -129,6 +155,12 @@ export type SandboxRuntimeCreateOptions = {
|
|
|
129
155
|
networkPolicy: SandboxRuntimeNetworkPolicy;
|
|
130
156
|
security: SandboxRuntimeSecurity;
|
|
131
157
|
hardDeadlineMs: number;
|
|
158
|
+
/**
|
|
159
|
+
* Core-authorized read-only inputs resolved from portable Workspace
|
|
160
|
+
* references. Providers must expose each source only at its targetPath and
|
|
161
|
+
* must not make any broader Workspace subtree visible to the Runtime.
|
|
162
|
+
*/
|
|
163
|
+
readOnlyFiles?: readonly SandboxRuntimeReadOnlyFile[];
|
|
132
164
|
};
|
|
133
165
|
/** Persisted evidence required to destroy a Runtime even after Provider reload. */
|
|
134
166
|
export type SandboxRuntimeDestroyOptions = {
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { XpertExtensionViewManifest, XpertRemoteComponentEntry, XpertRemoteComponentViewSchema, XpertResolvedViewHostContext, XpertViewActionRequest, XpertViewActionResult, XpertViewDataResult, XpertViewParameterOptionsQuery, XpertViewParameterOptionsResult, XpertViewQuery } from '@xpert-ai/contracts';
|
|
1
|
+
import { XpertExtensionViewManifest, XpertRemoteComponentEntry, XpertRemoteComponentViewSchema, XpertResolvedViewHostContext, XpertViewActionRequest, XpertViewActionResult, XpertViewDataResult, XpertViewFileAccessRequest, XpertViewParameterOptionsQuery, XpertViewParameterOptionsResult, XpertViewQuery } from '@xpert-ai/contracts';
|
|
2
|
+
import type { WorkspacePortableFileReference } from '../runtime/capabilities/workspace-files';
|
|
2
3
|
export interface XpertViewFileActionFile {
|
|
3
4
|
buffer: Buffer;
|
|
4
5
|
originalname?: string;
|
|
5
6
|
mimetype?: string;
|
|
6
7
|
size?: number;
|
|
7
8
|
}
|
|
9
|
+
export interface XpertViewFileResource {
|
|
10
|
+
reference: WorkspacePortableFileReference;
|
|
11
|
+
fileName: string;
|
|
12
|
+
mimeType: string;
|
|
13
|
+
size?: number;
|
|
14
|
+
}
|
|
8
15
|
export interface IXpertViewExtensionProvider {
|
|
9
16
|
supports(context: XpertResolvedViewHostContext): Promise<boolean> | boolean;
|
|
10
17
|
getViewManifests(context: XpertResolvedViewHostContext, slot: string): Promise<XpertExtensionViewManifest[]> | XpertExtensionViewManifest[];
|
|
11
18
|
getViewData(context: XpertResolvedViewHostContext, viewKey: string, query: XpertViewQuery): Promise<XpertViewDataResult> | XpertViewDataResult;
|
|
12
19
|
executeViewAction?(context: XpertResolvedViewHostContext, viewKey: string, actionKey: string, request: XpertViewActionRequest): Promise<XpertViewActionResult> | XpertViewActionResult;
|
|
13
20
|
executeViewFileAction?(context: XpertResolvedViewHostContext, viewKey: string, actionKey: string, request: XpertViewActionRequest, file: XpertViewFileActionFile): Promise<XpertViewActionResult> | XpertViewActionResult;
|
|
21
|
+
resolveViewFile?(context: XpertResolvedViewHostContext, viewKey: string, request: XpertViewFileAccessRequest): Promise<XpertViewFileResource> | XpertViewFileResource;
|
|
14
22
|
getViewParameterOptions?(context: XpertResolvedViewHostContext, viewKey: string, parameterKey: string, query: XpertViewParameterOptionsQuery): Promise<XpertViewParameterOptionsResult> | XpertViewParameterOptionsResult;
|
|
15
23
|
getRemoteComponentEntry?(context: XpertResolvedViewHostContext, viewKey: string, component: XpertRemoteComponentViewSchema['component']): Promise<XpertRemoteComponentEntry> | XpertRemoteComponentEntry;
|
|
16
24
|
}
|