@xpert-ai/plugin-sdk 3.18.2 → 3.18.4
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 +25 -0
- package/README.md +26 -1
- package/index.cjs.js +214 -28
- package/index.esm.js +210 -31
- package/model-provider.cjs.js +20 -3
- package/model-provider.esm.js +18 -4
- package/package.json +2 -2
- package/runtime-capabilities.md +49 -0
- package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +3 -0
- package/src/lib/agent/middleware/runtime.d.ts +2 -14
- package/src/lib/agent/middleware/strategy.interface.d.ts +2 -0
- package/src/lib/ai-model/types/rerank.d.ts +2 -0
- package/src/lib/connector/runtime-capability.d.ts +19 -0
- package/src/lib/core/runtime-capability.d.ts +2 -1
- package/src/lib/data/datasource/types.d.ts +7 -2
- package/src/lib/evolution/runtime-capability.d.ts +2 -1
- package/src/lib/runtime/capabilities/actor-token.d.ts +12 -0
- package/src/lib/runtime/capabilities/artifacts.d.ts +2 -0
- package/src/lib/runtime/capabilities/index.d.ts +1 -0
- package/src/lib/runtime/capabilities/knowledge-document-visual-assets.d.ts +16 -5
- package/src/lib/runtime/capabilities/knowledgebase-documents.d.ts +50 -1
- package/src/lib/runtime/capabilities/knowledgebase.d.ts +2 -1
- package/src/lib/runtime/capabilities/project-access.d.ts +30 -0
- package/src/lib/runtime/capabilities/project-provisioning.d.ts +8 -0
- package/src/lib/runtime/index.d.ts +1 -0
- package/src/lib/runtime/runtime-scope.d.ts +14 -0
- package/src/lib/tool-provider/adapters.d.ts +1 -0
- package/src/lib/tool-provider/index.d.ts +2 -0
- package/src/lib/tool-provider/prepared-result.d.ts +18 -0
- package/src/lib/tool-provider/tool-result.d.ts +16 -0
- package/src/lib/tool-provider/types.d.ts +8 -2
- package/src/lib/toolset/define-tool.d.ts +2 -1
- package/src/lib/types.d.ts +12 -1
package/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { pick } from 'lodash-es';
|
|
|
4
4
|
import { _ as _extends } from './_extends.esm.js';
|
|
5
5
|
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
6
6
|
import { Subject, filter } from 'rxjs';
|
|
7
|
-
import { LanguagesEnum, ParameterType, AiModelTypeEnum, PriceType, FetchFrom, ModelFeature, ModelPropertyKey, MCP_TOOL_RISKS, MCP_TOOL_SIDE_EFFECTS, MCP_TOOL_IDEMPOTENCY, MCP_REQUIRED_CONTEXTS, MCP_CAPABILITY_VISIBILITIES } from '@xpert-ai/contracts';
|
|
7
|
+
import { LanguagesEnum, ParameterType, AiModelTypeEnum, PriceType, FetchFrom, ModelFeature, ModelPropertyKey, MCP_CAPABILITY_APPROVAL_MODES, MCP_TOOL_RISKS, MCP_TOOL_SIDE_EFFECTS, MCP_TOOL_IDEMPOTENCY, MCP_REQUIRED_CONTEXTS, MCP_CAPABILITY_VISIBILITIES } from '@xpert-ai/contracts';
|
|
8
8
|
export { ASSISTANT_CHAT_SEND_MESSAGE_COMMAND, ASSISTANT_CONTEXT_SET_COMMAND } from '@xpert-ai/contracts';
|
|
9
9
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
10
10
|
import { ExtractJwt } from 'passport-jwt';
|
|
@@ -16,7 +16,7 @@ import fs__default from 'fs';
|
|
|
16
16
|
import http from 'http';
|
|
17
17
|
import https from 'https';
|
|
18
18
|
import { c as createRuntimeCapability, B as BuiltinToolset } from './model-provider.esm.js';
|
|
19
|
-
export { A as ActorTokenRuntimeCapability, a as
|
|
19
|
+
export { A as ActorTokenRuntimeCapability, a as ActorTokenRuntimeFactoryCapability, b as ArtifactsRuntimeCapability, d as BaseTool, e as BaseToolset, D as DefaultAgentMiddlewareRuntimeCapabilityRegistry, D as DefaultRuntimeCapabilityRegistry, K as KnowledgeDocumentVisualAssetsRuntimeCapability, f as KnowledgeDocumentVisualAssetsRuntimeFactoryCapability, g as KnowledgebaseDocumentsRuntimeCapability, h as KnowledgebaseProvisioningRuntimeCapability, i as KnowledgebaseRuntimeCapability, M as ModelProviderBuiltinToolset, P as ProjectAccessRuntimeCapability, j as ProjectProvisioningRuntimeCapability, S as SANDBOX_JOB_ERROR_CODES, k as SANDBOX_JOB_PROGRESS_PREFIX, l as SandboxJobRuntimeError, m as SandboxJobsRuntimeCapability, W as WORKSPACE_FILES_SOURCE, n as WorkspaceFilesRuntimeCapability, X as XPERT_RUNTIME_CAPABILITIES_TOKEN, o as isSandboxJobRuntimeError } from './model-provider.esm.js';
|
|
20
20
|
import fsPromises from 'fs/promises';
|
|
21
21
|
import * as path from 'path';
|
|
22
22
|
import path__default, { join } from 'path';
|
|
@@ -41,7 +41,7 @@ import { assertConnectorDefinition } from './connector.esm.js';
|
|
|
41
41
|
export { CONNECTOR_AUTHORIZATION_MODES, CONNECTOR_SCOPE_TYPES, getConnectorAuthMethods, getConnectorAuthorizationModes } from './connector.esm.js';
|
|
42
42
|
export { base64ToBytes, bytesToBase64, createCollaborationClient, createCollaborationPresenceStore, createSocketIoTransportAdapter, createYjsDocumentAdapter } from './collaboration-client.esm.js';
|
|
43
43
|
import { tool } from '@langchain/core/tools';
|
|
44
|
-
import 'zod/v3';
|
|
44
|
+
import { ZodError, z } from 'zod/v3';
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Metadata keys used in plugins for defining various aspects like entities, subscribers, and configurations.
|
|
@@ -1579,7 +1579,7 @@ class BaseSQLQueryRunner extends BaseQueryRunner {
|
|
|
1579
1579
|
return;
|
|
1580
1580
|
}
|
|
1581
1581
|
// --- MODE: UPGRADE → auto upgrade (simple implementation: only add new columns) ---
|
|
1582
|
-
// Note: This default implementation does not support modifying column types,
|
|
1582
|
+
// Note: This default implementation does not support modifying column types,
|
|
1583
1583
|
// recommend each database to implement its own version
|
|
1584
1584
|
if (exists && createMode === DBCreateTableMode.UPGRADE) {
|
|
1585
1585
|
console.warn(`[BaseSQLQueryRunner] UPGRADE mode uses basic implementation. Consider implementing tableOp for better support.`);
|
|
@@ -3579,17 +3579,11 @@ class OpenAICompatibleReranker {
|
|
|
3579
3579
|
if (!Array.isArray(output)) {
|
|
3580
3580
|
throw new Error('Invalid response format: missing results array');
|
|
3581
3581
|
}
|
|
3582
|
-
// Collect raw scores and normalize them.
|
|
3583
|
-
const scores = output.map((r)=>r.relevance_score);
|
|
3584
|
-
const minScore = Math.min(...scores);
|
|
3585
|
-
const maxScore = Math.max(...scores);
|
|
3586
|
-
const scoreRange = maxScore !== minScore ? maxScore - minScore : 1.0;
|
|
3587
3582
|
const reranked = output.map((r)=>{
|
|
3588
3583
|
const index = r.index;
|
|
3589
|
-
const normalizedScore = (r.relevance_score - minScore) / scoreRange;
|
|
3590
3584
|
const result = {
|
|
3591
3585
|
index,
|
|
3592
|
-
relevanceScore:
|
|
3586
|
+
relevanceScore: r.relevance_score
|
|
3593
3587
|
};
|
|
3594
3588
|
if (options.returnDocuments) {
|
|
3595
3589
|
var _r_document, _docs_index, _docs_index1;
|
|
@@ -4103,6 +4097,9 @@ SSOProviderRegistry = __decorate([
|
|
|
4103
4097
|
const ConnectorRuntimeCapability = createRuntimeCapability('platform.connector', {
|
|
4104
4098
|
description: 'Resolve connector credentials for agent middleware.'
|
|
4105
4099
|
});
|
|
4100
|
+
const ConnectorRuntimeFactoryCapability = createRuntimeCapability('platform.connector.factory', {
|
|
4101
|
+
description: 'Create a connector API restricted to host-granted connectors and the authorized execution identity.'
|
|
4102
|
+
});
|
|
4106
4103
|
|
|
4107
4104
|
const CONNECTOR_STRATEGY = 'CONNECTOR_STRATEGY';
|
|
4108
4105
|
const ConnectorStrategyKey = (provider)=>applyDecorators(SetMetadata(CONNECTOR_STRATEGY, provider), SetMetadata(STRATEGY_META_KEY, CONNECTOR_STRATEGY));
|
|
@@ -5866,6 +5863,9 @@ const EVOLUTION_RUNTIME_SERVICE_TOKEN = 'XPERT_EVOLUTION_RUNTIME_SERVICE';
|
|
|
5866
5863
|
const EvolutionRuntimeCapability = createRuntimeCapability('platform.agent-evolution', {
|
|
5867
5864
|
description: 'Ingest learning signals and resolve immutable capability versions for domain runtimes.'
|
|
5868
5865
|
});
|
|
5866
|
+
const EvolutionChangeRuntimeCapability = createRuntimeCapability('platform.agent-evolution.changes', {
|
|
5867
|
+
description: 'Prepare, evaluate and publish versioned changes through target-owned validators and effect providers.'
|
|
5868
|
+
});
|
|
5869
5869
|
|
|
5870
5870
|
function defineMcpApp(definition) {
|
|
5871
5871
|
return Object.freeze(definition);
|
|
@@ -6029,6 +6029,12 @@ function validateProviderOptions(options) {
|
|
|
6029
6029
|
}
|
|
6030
6030
|
function validateToolOptions(options, methodName) {
|
|
6031
6031
|
var _options_description;
|
|
6032
|
+
if (options.resultFormat && options.resultFormat !== 'dto' && options.resultFormat !== 'tool_result') {
|
|
6033
|
+
throw new Error(`Tool '${options.name}' declares an invalid resultFormat.`);
|
|
6034
|
+
}
|
|
6035
|
+
if (options.resultFormat === 'tool_result' && !options.outputSchema) {
|
|
6036
|
+
throw new Error(`Tool '${options.name}' requires outputSchema for tool_result.`);
|
|
6037
|
+
}
|
|
6032
6038
|
if (!TOOL_NAME_PATTERN.test(options.name) || options.name.length > 191) {
|
|
6033
6039
|
throw new Error(`Method '${methodName}' declares invalid Tool name '${options.name}'.`);
|
|
6034
6040
|
}
|
|
@@ -6044,6 +6050,9 @@ function validateToolOptions(options, methodName) {
|
|
|
6044
6050
|
throw new Error(`MCP Tool '${options.name}' requires at least one execution context.`);
|
|
6045
6051
|
}
|
|
6046
6052
|
if (options.mcp) {
|
|
6053
|
+
if (options.mcp.defaultApprovalMode !== undefined && !includesValue(MCP_CAPABILITY_APPROVAL_MODES, options.mcp.defaultApprovalMode)) {
|
|
6054
|
+
throw new Error(`MCP Tool '${options.name}' declares invalid defaultApprovalMode.`);
|
|
6055
|
+
}
|
|
6047
6056
|
const behavior = options.mcp.behavior;
|
|
6048
6057
|
if (!includesValue(MCP_TOOL_RISKS, behavior == null ? void 0 : behavior.risk) || !includesValue(MCP_TOOL_SIDE_EFFECTS, behavior == null ? void 0 : behavior.sideEffect) || !includesValue(MCP_TOOL_IDEMPOTENCY, behavior == null ? void 0 : behavior.idempotency)) {
|
|
6049
6058
|
throw new Error(`MCP Tool '${options.name}' requires valid behavior annotations.`);
|
|
@@ -6070,6 +6079,19 @@ function assertStrictObjectSchema(schema, toolName, role) {
|
|
|
6070
6079
|
if (!schema || typeof Reflect.get(schema, 'parseAsync') !== 'function') {
|
|
6071
6080
|
throw new Error(`Tool '${toolName}' requires a Zod ${role} schema.`);
|
|
6072
6081
|
}
|
|
6082
|
+
// Refinements preserve the strict object shape while enforcing cross-field invariants.
|
|
6083
|
+
// Plugins can load a different physical copy of Zod; use its explicit type tag.
|
|
6084
|
+
while(schema._def.typeName === 'ZodEffects'){
|
|
6085
|
+
const refinement = schema;
|
|
6086
|
+
if (refinement._def.effect.type !== 'refinement') break;
|
|
6087
|
+
schema = refinement.innerType();
|
|
6088
|
+
}
|
|
6089
|
+
if (role === 'output' && schema._def.typeName === 'ZodUnion') {
|
|
6090
|
+
// Recovery receipts may have a different shape, but every branch must reject extra fields.
|
|
6091
|
+
const union = schema;
|
|
6092
|
+
for (const option of union.options)assertStrictObjectSchema(option, toolName, role);
|
|
6093
|
+
return;
|
|
6094
|
+
}
|
|
6073
6095
|
const definition = Reflect.get(schema, '_def');
|
|
6074
6096
|
if (!definition || Reflect.get(definition, 'unknownKeys') !== 'strict') {
|
|
6075
6097
|
throw new Error(`Tool '${toolName}' ${role} schema must be a strict Zod object.`);
|
|
@@ -6143,6 +6165,141 @@ XpertToolProviderRegistry = __decorate([
|
|
|
6143
6165
|
])
|
|
6144
6166
|
], XpertToolProviderRegistry);
|
|
6145
6167
|
|
|
6168
|
+
// Invariants: recovery starts only after the business method returns successfully.
|
|
6169
|
+
// Projection and recovery callbacks must be free of business side effects.
|
|
6170
|
+
// The adapter validates normal output once and validates any fallback separately;
|
|
6171
|
+
// neither path may rerun the operation or suppress input, authorization or commit failures.
|
|
6172
|
+
// Installed plugins may resolve a different physical SDK copy from the host.
|
|
6173
|
+
const PREPARED_RESULT = Symbol.for('xpert.tool.prepared-result.v1');
|
|
6174
|
+
/** Defer output projection until the adapter can validate and recover its result. */ function prepareToolResult(project, recover) {
|
|
6175
|
+
return {
|
|
6176
|
+
[PREPARED_RESULT]: true,
|
|
6177
|
+
project,
|
|
6178
|
+
recover
|
|
6179
|
+
};
|
|
6180
|
+
}
|
|
6181
|
+
function isPrepared(value) {
|
|
6182
|
+
return typeof value === 'object' && value !== null && PREPARED_RESULT in value && value[PREPARED_RESULT] === true && 'project' in value && typeof value.project === 'function' && 'recover' in value && typeof value.recover === 'function';
|
|
6183
|
+
}
|
|
6184
|
+
async function resolveToolResult(value, validate) {
|
|
6185
|
+
if (!isPrepared(value)) return validate(value);
|
|
6186
|
+
try {
|
|
6187
|
+
return await validate(await value.project());
|
|
6188
|
+
} catch (error) {
|
|
6189
|
+
const diagnostic = {
|
|
6190
|
+
code: 'tool_output_invalid',
|
|
6191
|
+
issues: error instanceof ZodError ? error.issues.slice(0, 10).map((issue)=>({
|
|
6192
|
+
path: issue.path.join('.').slice(0, 240),
|
|
6193
|
+
code: issue.code
|
|
6194
|
+
})) : []
|
|
6195
|
+
};
|
|
6196
|
+
// A malformed fallback is a programming error too; never send unchecked data.
|
|
6197
|
+
return validate(await value.recover(diagnostic));
|
|
6198
|
+
}
|
|
6199
|
+
}
|
|
6200
|
+
|
|
6201
|
+
// Why this exists: MCP media blocks and business metadata have different contracts.
|
|
6202
|
+
// Validate metadata with the declared output schema, preserve bounded media blocks,
|
|
6203
|
+
// and include the same DTO in text for clients that hide structuredContent.
|
|
6204
|
+
const XPERT_TOOL_RESULT_FORMAT_VERSION = 1;
|
|
6205
|
+
const contentSchema = z.discriminatedUnion('type', [
|
|
6206
|
+
z.object({
|
|
6207
|
+
type: z.literal('text'),
|
|
6208
|
+
text: z.string().max(2 * 1024 * 1024)
|
|
6209
|
+
}).strict(),
|
|
6210
|
+
z.object({
|
|
6211
|
+
type: z.literal('image'),
|
|
6212
|
+
data: z.string().min(1).max(8 * 1024 * 1024),
|
|
6213
|
+
mimeType: z.enum([
|
|
6214
|
+
'image/png',
|
|
6215
|
+
'image/jpeg',
|
|
6216
|
+
'image/webp',
|
|
6217
|
+
'image/gif'
|
|
6218
|
+
])
|
|
6219
|
+
}).strict(),
|
|
6220
|
+
z.object({
|
|
6221
|
+
type: z.literal('audio'),
|
|
6222
|
+
data: z.string().min(1).max(8 * 1024 * 1024),
|
|
6223
|
+
mimeType: z.string().min(1).max(100)
|
|
6224
|
+
}).strict(),
|
|
6225
|
+
z.object({
|
|
6226
|
+
type: z.literal('resource_link'),
|
|
6227
|
+
uri: z.string().min(1).max(4096),
|
|
6228
|
+
name: z.string().max(240).optional()
|
|
6229
|
+
}).strict()
|
|
6230
|
+
]);
|
|
6231
|
+
/** Validate the envelope separately so binary content never enters the business DTO. */ async function parseDecoratedToolResult(value, outputSchema) {
|
|
6232
|
+
var _result_content;
|
|
6233
|
+
const envelope = z.object({
|
|
6234
|
+
content: z.array(contentSchema).max(32).optional(),
|
|
6235
|
+
structuredContent: outputSchema,
|
|
6236
|
+
isError: z.boolean().optional()
|
|
6237
|
+
}).strict();
|
|
6238
|
+
const result = await envelope.parseAsync(value);
|
|
6239
|
+
var _result_content_map;
|
|
6240
|
+
const content = (_result_content_map = (_result_content = result.content) == null ? void 0 : _result_content.map((item)=>{
|
|
6241
|
+
switch(item.type){
|
|
6242
|
+
case 'text':
|
|
6243
|
+
return {
|
|
6244
|
+
type: 'text',
|
|
6245
|
+
text: item.text
|
|
6246
|
+
};
|
|
6247
|
+
case 'image':
|
|
6248
|
+
return {
|
|
6249
|
+
type: 'image',
|
|
6250
|
+
data: item.data,
|
|
6251
|
+
mimeType: item.mimeType
|
|
6252
|
+
};
|
|
6253
|
+
case 'audio':
|
|
6254
|
+
return {
|
|
6255
|
+
type: 'audio',
|
|
6256
|
+
data: item.data,
|
|
6257
|
+
mimeType: item.mimeType
|
|
6258
|
+
};
|
|
6259
|
+
case 'resource_link':
|
|
6260
|
+
return _extends({
|
|
6261
|
+
type: 'resource_link',
|
|
6262
|
+
uri: item.uri
|
|
6263
|
+
}, item.name ? {
|
|
6264
|
+
name: item.name
|
|
6265
|
+
} : {});
|
|
6266
|
+
}
|
|
6267
|
+
})) != null ? _result_content_map : [];
|
|
6268
|
+
// MCP clients may expose only content to the model. Keep the validated DTO
|
|
6269
|
+
// readable there too, while retaining binary blocks and App structured data.
|
|
6270
|
+
const text = JSON.stringify(result.structuredContent);
|
|
6271
|
+
if (!content.some((item)=>item.type === 'text' && item.text === text)) content.push({
|
|
6272
|
+
type: 'text',
|
|
6273
|
+
text
|
|
6274
|
+
});
|
|
6275
|
+
return _extends({
|
|
6276
|
+
structuredContent: result.structuredContent,
|
|
6277
|
+
content
|
|
6278
|
+
}, result.isError === undefined ? {} : {
|
|
6279
|
+
isError: result.isError
|
|
6280
|
+
});
|
|
6281
|
+
}
|
|
6282
|
+
function agentContent(content) {
|
|
6283
|
+
return (content != null ? content : []).map((item)=>{
|
|
6284
|
+
if (item.type === 'image') return {
|
|
6285
|
+
type: 'image_url',
|
|
6286
|
+
image_url: {
|
|
6287
|
+
url: `data:${item.mimeType};base64,${item.data}`
|
|
6288
|
+
}
|
|
6289
|
+
};
|
|
6290
|
+
if (item.type === 'text') return item;
|
|
6291
|
+
var _item_name;
|
|
6292
|
+
if (item.type === 'resource_link') return {
|
|
6293
|
+
type: 'text',
|
|
6294
|
+
text: `${(_item_name = item.name) != null ? _item_name : 'Resource'}: ${item.uri}`
|
|
6295
|
+
};
|
|
6296
|
+
return {
|
|
6297
|
+
type: 'text',
|
|
6298
|
+
text: `Audio content (${item.mimeType}) is available through MCP.`
|
|
6299
|
+
};
|
|
6300
|
+
});
|
|
6301
|
+
}
|
|
6302
|
+
|
|
6146
6303
|
class DecoratedToolsetStrategy {
|
|
6147
6304
|
validateConfig() {
|
|
6148
6305
|
return Promise.resolve();
|
|
@@ -6183,6 +6340,9 @@ class DecoratedToolsetStrategy {
|
|
|
6183
6340
|
}
|
|
6184
6341
|
}
|
|
6185
6342
|
class DecoratedAgentMiddlewareStrategy {
|
|
6343
|
+
getToolNames() {
|
|
6344
|
+
return this.descriptor.tools.filter((item)=>item.middlewareProvider === this.provider).map((item)=>item.options.name);
|
|
6345
|
+
}
|
|
6186
6346
|
async createMiddleware(options, context) {
|
|
6187
6347
|
const tools = this.descriptor.tools.filter((item)=>item.middlewareProvider === this.provider).map((item)=>createAgentTool(this.instance, item, context, options));
|
|
6188
6348
|
const extensions = await (this.instance.getMiddlewareExtensions == null ? void 0 : this.instance.getMiddlewareExtensions.call(this.instance, this.provider, options, context));
|
|
@@ -6244,13 +6404,27 @@ function createAgentTool(instance, descriptor, middlewareContext, middlewareOpti
|
|
|
6244
6404
|
return tool(async (input, config)=>{
|
|
6245
6405
|
const parsedInput = await descriptor.options.inputSchema.parseAsync(input);
|
|
6246
6406
|
const output = await invoke(parsedInput, agentExecutionContext(middlewareContext, middlewareOptions, config));
|
|
6247
|
-
|
|
6248
|
-
|
|
6407
|
+
if (descriptor.options.resultFormat === 'tool_result' && descriptor.options.outputSchema) {
|
|
6408
|
+
const result = await resolveToolResult(output, (value)=>parseDecoratedToolResult(value, descriptor.options.outputSchema));
|
|
6409
|
+
var _result_isError;
|
|
6410
|
+
return [
|
|
6411
|
+
agentContent(result.content),
|
|
6412
|
+
{
|
|
6413
|
+
structuredContent: result.structuredContent,
|
|
6414
|
+
isError: (_result_isError = result.isError) != null ? _result_isError : false
|
|
6415
|
+
}
|
|
6416
|
+
];
|
|
6417
|
+
}
|
|
6418
|
+
return resolveToolResult(output, async (value)=>{
|
|
6419
|
+
const parsedOutput = descriptor.options.outputSchema ? await descriptor.options.outputSchema.parseAsync(value) : value;
|
|
6420
|
+
return stringifyDto(parsedOutput, descriptor.options.name);
|
|
6421
|
+
});
|
|
6249
6422
|
}, _extends({
|
|
6250
6423
|
name: descriptor.options.name,
|
|
6251
6424
|
description: descriptor.options.description,
|
|
6252
6425
|
schema: descriptor.options.inputSchema,
|
|
6253
|
-
verboseParsingErrors: true
|
|
6426
|
+
verboseParsingErrors: true,
|
|
6427
|
+
responseFormat: descriptor.options.resultFormat === 'tool_result' ? 'content_and_artifact' : 'content'
|
|
6254
6428
|
}, descriptor.options.metadata ? {
|
|
6255
6429
|
metadata: descriptor.options.metadata
|
|
6256
6430
|
} : {}));
|
|
@@ -6274,7 +6448,10 @@ function createMcpTool(instance, descriptor) {
|
|
|
6274
6448
|
eligible: true
|
|
6275
6449
|
}
|
|
6276
6450
|
},
|
|
6277
|
-
behavior: mcp.behavior
|
|
6451
|
+
behavior: mcp.behavior
|
|
6452
|
+
}, mcp.defaultApprovalMode ? {
|
|
6453
|
+
defaultApprovalMode: mcp.defaultApprovalMode
|
|
6454
|
+
} : {}, {
|
|
6278
6455
|
requiredContext: [
|
|
6279
6456
|
...mcp.requiredContext
|
|
6280
6457
|
],
|
|
@@ -6294,18 +6471,23 @@ function createMcpTool(instance, descriptor) {
|
|
|
6294
6471
|
execute: async (input, context)=>{
|
|
6295
6472
|
const parsedInput = await descriptor.options.inputSchema.parseAsync(input);
|
|
6296
6473
|
const output = await invoke(parsedInput, mcpExecutionContext(context));
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
return {
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6474
|
+
if (descriptor.options.resultFormat === 'tool_result') {
|
|
6475
|
+
return resolveToolResult(output, (value)=>parseDecoratedToolResult(value, outputSchema));
|
|
6476
|
+
}
|
|
6477
|
+
return resolveToolResult(output, async (value)=>{
|
|
6478
|
+
const parsedOutput = await outputSchema.parseAsync(value);
|
|
6479
|
+
// Serialize once so text-only clients and MCP Apps receive the same JSON-safe DTO.
|
|
6480
|
+
const text = stringifyDto(parsedOutput, descriptor.options.name);
|
|
6481
|
+
return {
|
|
6482
|
+
content: [
|
|
6483
|
+
{
|
|
6484
|
+
type: 'text',
|
|
6485
|
+
text
|
|
6486
|
+
}
|
|
6487
|
+
],
|
|
6488
|
+
structuredContent: JSON.parse(text)
|
|
6489
|
+
};
|
|
6490
|
+
});
|
|
6309
6491
|
}
|
|
6310
6492
|
});
|
|
6311
6493
|
}
|
|
@@ -6370,9 +6552,6 @@ function stringifyDto(value, toolName) {
|
|
|
6370
6552
|
if (result === undefined) throw new Error(`Tool '${toolName}' returned a non-JSON value.`);
|
|
6371
6553
|
return result;
|
|
6372
6554
|
}
|
|
6373
|
-
function jsonDto(value, toolName) {
|
|
6374
|
-
return JSON.parse(stringifyDto(value, toolName));
|
|
6375
|
-
}
|
|
6376
6555
|
function asI18n(value) {
|
|
6377
6556
|
return {
|
|
6378
6557
|
en_US: value,
|
|
@@ -6452,4 +6631,4 @@ XpertToolProviderCoordinator = __decorate([
|
|
|
6452
6631
|
])
|
|
6453
6632
|
], XpertToolProviderCoordinator);
|
|
6454
6633
|
|
|
6455
|
-
export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, 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, DecoratedAgentMiddlewareStrategy, DecoratedToolsetStrategy, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, EVOLUTION_RUNTIME_SERVICE_TOKEN, EVOLUTION_TARGET_PROVIDER, EvolutionRuntimeCapability, EvolutionTargetProviderRegistry, EvolutionTargetProviderStrategy, 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, ImageGenerationModel, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, MCP_CAPABILITY_CHANGE_EVENT_TYPES, MODEL_OUTPUT_VALIDATION_ERROR_CODE, ModelOutputValidationError, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_VERSION_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_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, 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, VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN, VIDEO_GENERATION_SERVICE_TOKEN, VIDEO_GENERATOR_FAMILIES, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, VideoGenerationModel, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XpFileSystem, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, defineMcpApp, defineMcpCapabilities, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineXpertTool, derivePluginArtifactNamespace, describeXpertToolProvider, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, isDevelopmentSandboxRuntimeEnvironment, isModelOutputValidationError, isModelUsagePricingConfig, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, pluginArtifactTableName, processAsyncAIGCManagedJob, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage };
|
|
6634
|
+
export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, 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, ConnectorRuntimeFactoryCapability, 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, DecoratedAgentMiddlewareStrategy, DecoratedToolsetStrategy, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, EVOLUTION_RUNTIME_SERVICE_TOKEN, EVOLUTION_TARGET_PROVIDER, EvolutionChangeRuntimeCapability, EvolutionRuntimeCapability, EvolutionTargetProviderRegistry, EvolutionTargetProviderStrategy, 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, ImageGenerationModel, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, MCP_CAPABILITY_CHANGE_EVENT_TYPES, MODEL_OUTPUT_VALIDATION_ERROR_CODE, ModelOutputValidationError, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_VERSION_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_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, 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, VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN, VIDEO_GENERATION_SERVICE_TOKEN, VIDEO_GENERATOR_FAMILIES, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, VideoGenerationModel, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XPERT_TOOL_RESULT_FORMAT_VERSION, XpFileSystem, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, defineMcpApp, defineMcpCapabilities, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineXpertTool, derivePluginArtifactNamespace, describeXpertToolProvider, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, isDevelopmentSandboxRuntimeEnvironment, isModelOutputValidationError, isModelUsagePricingConfig, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, pluginArtifactTableName, prepareToolResult, processAsyncAIGCManagedJob, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage };
|
package/model-provider.cjs.js
CHANGED
|
@@ -160,10 +160,13 @@ class DefaultRuntimeCapabilityRegistry {
|
|
|
160
160
|
return this;
|
|
161
161
|
}
|
|
162
162
|
has(key) {
|
|
163
|
-
|
|
163
|
+
var _this_parent;
|
|
164
|
+
return this.capabilities.has(runtimeCapabilityId(key)) || ((_this_parent = this.parent) == null ? void 0 : _this_parent.get(key)) !== undefined;
|
|
164
165
|
}
|
|
165
166
|
get(key) {
|
|
166
|
-
|
|
167
|
+
var _this_parent;
|
|
168
|
+
const id = runtimeCapabilityId(key);
|
|
169
|
+
return this.capabilities.has(id) ? this.capabilities.get(id) : (_this_parent = this.parent) == null ? void 0 : _this_parent.get(key);
|
|
167
170
|
}
|
|
168
171
|
require(key) {
|
|
169
172
|
const implementation = this.get(key);
|
|
@@ -172,8 +175,9 @@ class DefaultRuntimeCapabilityRegistry {
|
|
|
172
175
|
}
|
|
173
176
|
return implementation;
|
|
174
177
|
}
|
|
175
|
-
constructor(entries = []){
|
|
178
|
+
constructor(entries = [], parent){
|
|
176
179
|
this.capabilities = new Map();
|
|
180
|
+
this.parent = parent;
|
|
177
181
|
entries.forEach(([key, implementation])=>this.register(key, implementation));
|
|
178
182
|
}
|
|
179
183
|
}
|
|
@@ -195,10 +199,16 @@ const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platfor
|
|
|
195
199
|
const KnowledgeDocumentVisualAssetsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.visual-assets', {
|
|
196
200
|
description: 'Issue execution-scoped logical KnowledgeDocument image paths and inject validated images without exposing host storage paths.'
|
|
197
201
|
});
|
|
202
|
+
const KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = createRuntimeCapability('platform.knowledge-document.visual-assets.factory', {
|
|
203
|
+
description: 'Create a visual-assets API with an execution-local image allow-list and authorized workspace writer.'
|
|
204
|
+
});
|
|
198
205
|
|
|
199
206
|
const ActorTokenRuntimeCapability = createRuntimeCapability('platform.actor-token', {
|
|
200
207
|
description: 'Mint a short-lived host-issued actor bearer token for outbound API calls.'
|
|
201
208
|
});
|
|
209
|
+
/** Platform registry entry. The operation capability above is bound only inside a caller runtime. */ const ActorTokenRuntimeFactoryCapability = createRuntimeCapability('platform.actor-token.factory', {
|
|
210
|
+
description: 'Create an actor-token API with host-bound identity, delegation claims and an isolated token cache.'
|
|
211
|
+
});
|
|
202
212
|
|
|
203
213
|
const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts', {
|
|
204
214
|
description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
|
|
@@ -252,6 +262,10 @@ const ProjectProvisioningRuntimeCapability = createRuntimeCapability('platform.p
|
|
|
252
262
|
description: 'Idempotently provision a platform Chat Project and connect it to an Assistant.'
|
|
253
263
|
});
|
|
254
264
|
|
|
265
|
+
const ProjectAccessRuntimeCapability = createRuntimeCapability('platform.project.access', {
|
|
266
|
+
description: 'Resolve human Project membership for platform and plugin operations.'
|
|
267
|
+
});
|
|
268
|
+
|
|
255
269
|
/**
|
|
256
270
|
* Shared host-runtime plumbing for built-in tools backed by a configured model provider.
|
|
257
271
|
* Provider request/response semantics remain owned by each plugin.
|
|
@@ -367,16 +381,19 @@ function normalizeWorkspaceScope(scope) {
|
|
|
367
381
|
}
|
|
368
382
|
|
|
369
383
|
exports.ActorTokenRuntimeCapability = ActorTokenRuntimeCapability;
|
|
384
|
+
exports.ActorTokenRuntimeFactoryCapability = ActorTokenRuntimeFactoryCapability;
|
|
370
385
|
exports.ArtifactsRuntimeCapability = ArtifactsRuntimeCapability;
|
|
371
386
|
exports.BaseTool = BaseTool;
|
|
372
387
|
exports.BaseToolset = BaseToolset;
|
|
373
388
|
exports.BuiltinToolset = BuiltinToolset;
|
|
374
389
|
exports.DefaultRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
|
|
375
390
|
exports.KnowledgeDocumentVisualAssetsRuntimeCapability = KnowledgeDocumentVisualAssetsRuntimeCapability;
|
|
391
|
+
exports.KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = KnowledgeDocumentVisualAssetsRuntimeFactoryCapability;
|
|
376
392
|
exports.KnowledgebaseDocumentsRuntimeCapability = KnowledgebaseDocumentsRuntimeCapability;
|
|
377
393
|
exports.KnowledgebaseProvisioningRuntimeCapability = KnowledgebaseProvisioningRuntimeCapability;
|
|
378
394
|
exports.KnowledgebaseRuntimeCapability = KnowledgebaseRuntimeCapability;
|
|
379
395
|
exports.ModelProviderBuiltinToolset = ModelProviderBuiltinToolset;
|
|
396
|
+
exports.ProjectAccessRuntimeCapability = ProjectAccessRuntimeCapability;
|
|
380
397
|
exports.ProjectProvisioningRuntimeCapability = ProjectProvisioningRuntimeCapability;
|
|
381
398
|
exports.SANDBOX_JOB_ERROR_CODES = SANDBOX_JOB_ERROR_CODES;
|
|
382
399
|
exports.SANDBOX_JOB_PROGRESS_PREFIX = SANDBOX_JOB_PROGRESS_PREFIX;
|
package/model-provider.esm.js
CHANGED
|
@@ -158,10 +158,13 @@ class DefaultRuntimeCapabilityRegistry {
|
|
|
158
158
|
return this;
|
|
159
159
|
}
|
|
160
160
|
has(key) {
|
|
161
|
-
|
|
161
|
+
var _this_parent;
|
|
162
|
+
return this.capabilities.has(runtimeCapabilityId(key)) || ((_this_parent = this.parent) == null ? void 0 : _this_parent.get(key)) !== undefined;
|
|
162
163
|
}
|
|
163
164
|
get(key) {
|
|
164
|
-
|
|
165
|
+
var _this_parent;
|
|
166
|
+
const id = runtimeCapabilityId(key);
|
|
167
|
+
return this.capabilities.has(id) ? this.capabilities.get(id) : (_this_parent = this.parent) == null ? void 0 : _this_parent.get(key);
|
|
165
168
|
}
|
|
166
169
|
require(key) {
|
|
167
170
|
const implementation = this.get(key);
|
|
@@ -170,8 +173,9 @@ class DefaultRuntimeCapabilityRegistry {
|
|
|
170
173
|
}
|
|
171
174
|
return implementation;
|
|
172
175
|
}
|
|
173
|
-
constructor(entries = []){
|
|
176
|
+
constructor(entries = [], parent){
|
|
174
177
|
this.capabilities = new Map();
|
|
178
|
+
this.parent = parent;
|
|
175
179
|
entries.forEach(([key, implementation])=>this.register(key, implementation));
|
|
176
180
|
}
|
|
177
181
|
}
|
|
@@ -193,10 +197,16 @@ const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platfor
|
|
|
193
197
|
const KnowledgeDocumentVisualAssetsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.visual-assets', {
|
|
194
198
|
description: 'Issue execution-scoped logical KnowledgeDocument image paths and inject validated images without exposing host storage paths.'
|
|
195
199
|
});
|
|
200
|
+
const KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = createRuntimeCapability('platform.knowledge-document.visual-assets.factory', {
|
|
201
|
+
description: 'Create a visual-assets API with an execution-local image allow-list and authorized workspace writer.'
|
|
202
|
+
});
|
|
196
203
|
|
|
197
204
|
const ActorTokenRuntimeCapability = createRuntimeCapability('platform.actor-token', {
|
|
198
205
|
description: 'Mint a short-lived host-issued actor bearer token for outbound API calls.'
|
|
199
206
|
});
|
|
207
|
+
/** Platform registry entry. The operation capability above is bound only inside a caller runtime. */ const ActorTokenRuntimeFactoryCapability = createRuntimeCapability('platform.actor-token.factory', {
|
|
208
|
+
description: 'Create an actor-token API with host-bound identity, delegation claims and an isolated token cache.'
|
|
209
|
+
});
|
|
200
210
|
|
|
201
211
|
const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts', {
|
|
202
212
|
description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
|
|
@@ -250,6 +260,10 @@ const ProjectProvisioningRuntimeCapability = createRuntimeCapability('platform.p
|
|
|
250
260
|
description: 'Idempotently provision a platform Chat Project and connect it to an Assistant.'
|
|
251
261
|
});
|
|
252
262
|
|
|
263
|
+
const ProjectAccessRuntimeCapability = createRuntimeCapability('platform.project.access', {
|
|
264
|
+
description: 'Resolve human Project membership for platform and plugin operations.'
|
|
265
|
+
});
|
|
266
|
+
|
|
253
267
|
/**
|
|
254
268
|
* Shared host-runtime plumbing for built-in tools backed by a configured model provider.
|
|
255
269
|
* Provider request/response semantics remain owned by each plugin.
|
|
@@ -364,4 +378,4 @@ function normalizeWorkspaceScope(scope) {
|
|
|
364
378
|
} : {});
|
|
365
379
|
}
|
|
366
380
|
|
|
367
|
-
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, KnowledgeDocumentVisualAssetsRuntimeCapability as K, ModelProviderBuiltinToolset as M,
|
|
381
|
+
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, KnowledgeDocumentVisualAssetsRuntimeCapability as K, ModelProviderBuiltinToolset as M, ProjectAccessRuntimeCapability as P, SANDBOX_JOB_ERROR_CODES as S, WORKSPACE_FILES_SOURCE as W, XPERT_RUNTIME_CAPABILITIES_TOKEN as X, ActorTokenRuntimeFactoryCapability as a, ArtifactsRuntimeCapability as b, createRuntimeCapability as c, BaseTool as d, BaseToolset as e, KnowledgeDocumentVisualAssetsRuntimeFactoryCapability as f, KnowledgebaseDocumentsRuntimeCapability as g, KnowledgebaseProvisioningRuntimeCapability as h, KnowledgebaseRuntimeCapability as i, ProjectProvisioningRuntimeCapability as j, SANDBOX_JOB_PROGRESS_PREFIX as k, SandboxJobRuntimeError as l, SandboxJobsRuntimeCapability as m, WorkspaceFilesRuntimeCapability as n, isSandboxJobRuntimeError as o };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "3.18.
|
|
3
|
+
"version": "3.18.4",
|
|
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.18.
|
|
20
|
+
"@xpert-ai/contracts": "3.18.4",
|
|
21
21
|
"express": "^4.22.1",
|
|
22
22
|
"js-tiktoken": "^1.0.21"
|
|
23
23
|
},
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Platform capabilities and scoped factories
|
|
2
|
+
|
|
3
|
+
The platform registry is populated by `RuntimeCapabilityProvider` discovery after Nest has instantiated the application modules. Domain modules own their providers. HTTP handlers, View Actions, background jobs and Agent runtimes can consume this registry without constructing an Agent middleware runtime.
|
|
4
|
+
|
|
5
|
+
## Choose the correct registry entry
|
|
6
|
+
|
|
7
|
+
Stateless domain APIs such as ProjectProvisioning, Knowledgebase, Artifacts and File are registered directly. Their domain authorization checks still run for each operation. Agent runtimes may bind additional defaults to the same domain service, such as the conversation for File access.
|
|
8
|
+
|
|
9
|
+
Three capabilities expose a **factory** in the platform registry. The operation API has a separate key and belongs only to a caller's scoped runtime:
|
|
10
|
+
|
|
11
|
+
| Platform factory key | Scoped operation key | State owned by one API |
|
|
12
|
+
| ------------------------------------------------------- | ------------------------------------------------ | ---------------------------------------------------------- |
|
|
13
|
+
| `ConnectorRuntimeFactoryCapability` | `ConnectorRuntimeCapability` | Host-selected connector binding IDs and execution identity |
|
|
14
|
+
| `ActorTokenRuntimeFactoryCapability` | `ActorTokenRuntimeCapability` | Caller identity, fixed delegation claims and token cache |
|
|
15
|
+
| `KnowledgeDocumentVisualAssetsRuntimeFactoryCapability` | `KnowledgeDocumentVisualAssetsRuntimeCapability` | Issued image paths and execution binding |
|
|
16
|
+
|
|
17
|
+
The platform registry deliberately does not return a shared operation API for these three keys. Checking the scoped operation key on the platform registry is not a provider availability check; check the factory key there instead.
|
|
18
|
+
|
|
19
|
+
## Bind once for a caller operation
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import {
|
|
23
|
+
ActorTokenRuntimeFactoryCapability,
|
|
24
|
+
type ActorTokenRuntimeScope,
|
|
25
|
+
type RuntimeCapabilityRegistry
|
|
26
|
+
} from '@xpert-ai/plugin-sdk'
|
|
27
|
+
|
|
28
|
+
// authorizedScope comes from the host's authenticated, authorized request/job context.
|
|
29
|
+
function bindJobTokenApi(capabilities: RuntimeCapabilityRegistry, authorizedScope: ActorTokenRuntimeScope) {
|
|
30
|
+
return capabilities.require(ActorTokenRuntimeFactoryCapability).createScopedApi({
|
|
31
|
+
...authorizedScope,
|
|
32
|
+
act: { sub: 'background-task' }
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Reuse the returned API during that one operation. Create a new API for the next caller/execution. Never keep a scoped API in a singleton, or register it back into the platform registry. Factory resolution must happen after provider discovery, not in service constructors.
|
|
38
|
+
|
|
39
|
+
`RuntimeIdentityScope` carries the authorized tenant, organization, user and optional project/Assistant/conversation/execution identity. It is an in-process host contract, not an HTTP DTO or model-visible tool input. A factory does not grant access: callers must first validate request/job ownership, and operations retain their domain checks.
|
|
40
|
+
|
|
41
|
+
- Connector APIs copy the selected binding IDs. Empty selection denies access. Credential access retains identity, Assistant, project membership, personal/shared authorization and audit checks. Existing connector execution binding requirements remain in force.
|
|
42
|
+
- ActorToken APIs capture identity and host-defined `act` claims. Per-call `act` adds metadata but cannot replace fixed host claims. Cached tokens are rejected if used under a different caller identity.
|
|
43
|
+
- Visual-assets APIs require a complete authorized execution binding when used. They only read paths issued to the same API/execution and recheck document fingerprints. The caller supplies an already scoped WorkspaceFiles writer.
|
|
44
|
+
|
|
45
|
+
## Agent integration
|
|
46
|
+
|
|
47
|
+
The Agent facade resolves the platform factories when initializing a scoped runtime and registers the resulting operation APIs in that runtime's child registry. This does not change the model-visible tool list inside a tool-call loop.
|
|
48
|
+
|
|
49
|
+
Some child Agent identities are assigned after graph construction. Visual-assets factories accept an optional host-owned `resolveExecutionScope` callback for this case. The Agent integration supplies the LangGraph resolver; the domain factory has no LangGraph dependency. Platform callers that omit the callback use the fixed scope captured at API creation. Every image issuance and consumption still verifies the execution binding.
|
|
@@ -95,6 +95,8 @@ export type AgentMiddlewareCorrelatedExecution = {
|
|
|
95
95
|
};
|
|
96
96
|
export type AgentMiddlewareAssistantTaskInput = {
|
|
97
97
|
xpertId: string;
|
|
98
|
+
/** Selects the Assistant base and Primary models; child Agents retain authored models. */
|
|
99
|
+
modelId?: string;
|
|
98
100
|
agentKey?: string;
|
|
99
101
|
/** Resolve an organization-owned external Assistant from the requester's published graph. */
|
|
100
102
|
target?: AgentMiddlewareAssistantTaskTarget;
|
|
@@ -137,6 +139,7 @@ export type AgentMiddlewareAssistantTaskCancelResult = {
|
|
|
137
139
|
canceledExecutionIds: string[];
|
|
138
140
|
};
|
|
139
141
|
export interface AgentMiddlewareAssistantTaskApi {
|
|
142
|
+
getModels?(xpertId: string): Promise<import('@xpert-ai/contracts').TAssistantModelsResponse>;
|
|
140
143
|
startTask(input: AgentMiddlewareAssistantTaskInput): Promise<AgentMiddlewareAssistantTaskResult>;
|
|
141
144
|
/** Return only safe binding descriptors; internal Assistant instance IDs are intentionally omitted. */
|
|
142
145
|
listExternalAssistantBindings?(input: AgentMiddlewareListExternalAssistantBindingsInput): Promise<AgentMiddlewareExternalAssistantBinding[]>;
|