@xpert-ai/plugin-sdk 3.18.3 → 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 +17 -0
- package/README.md +26 -1
- package/index.cjs.js +209 -27
- package/index.esm.js +206 -30
- package/model-provider.cjs.js +8 -0
- package/model-provider.esm.js +7 -1
- 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/ai-model/types/rerank.d.ts +2 -0
- package/src/lib/connector/runtime-capability.d.ts +19 -0
- 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/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 +1 -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/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.
|
|
@@ -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();
|
|
@@ -6247,13 +6404,27 @@ function createAgentTool(instance, descriptor, middlewareContext, middlewareOpti
|
|
|
6247
6404
|
return tool(async (input, config)=>{
|
|
6248
6405
|
const parsedInput = await descriptor.options.inputSchema.parseAsync(input);
|
|
6249
6406
|
const output = await invoke(parsedInput, agentExecutionContext(middlewareContext, middlewareOptions, config));
|
|
6250
|
-
|
|
6251
|
-
|
|
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
|
+
});
|
|
6252
6422
|
}, _extends({
|
|
6253
6423
|
name: descriptor.options.name,
|
|
6254
6424
|
description: descriptor.options.description,
|
|
6255
6425
|
schema: descriptor.options.inputSchema,
|
|
6256
|
-
verboseParsingErrors: true
|
|
6426
|
+
verboseParsingErrors: true,
|
|
6427
|
+
responseFormat: descriptor.options.resultFormat === 'tool_result' ? 'content_and_artifact' : 'content'
|
|
6257
6428
|
}, descriptor.options.metadata ? {
|
|
6258
6429
|
metadata: descriptor.options.metadata
|
|
6259
6430
|
} : {}));
|
|
@@ -6277,7 +6448,10 @@ function createMcpTool(instance, descriptor) {
|
|
|
6277
6448
|
eligible: true
|
|
6278
6449
|
}
|
|
6279
6450
|
},
|
|
6280
|
-
behavior: mcp.behavior
|
|
6451
|
+
behavior: mcp.behavior
|
|
6452
|
+
}, mcp.defaultApprovalMode ? {
|
|
6453
|
+
defaultApprovalMode: mcp.defaultApprovalMode
|
|
6454
|
+
} : {}, {
|
|
6281
6455
|
requiredContext: [
|
|
6282
6456
|
...mcp.requiredContext
|
|
6283
6457
|
],
|
|
@@ -6297,18 +6471,23 @@ function createMcpTool(instance, descriptor) {
|
|
|
6297
6471
|
execute: async (input, context)=>{
|
|
6298
6472
|
const parsedInput = await descriptor.options.inputSchema.parseAsync(input);
|
|
6299
6473
|
const output = await invoke(parsedInput, mcpExecutionContext(context));
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
return {
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
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
|
+
});
|
|
6312
6491
|
}
|
|
6313
6492
|
});
|
|
6314
6493
|
}
|
|
@@ -6373,9 +6552,6 @@ function stringifyDto(value, toolName) {
|
|
|
6373
6552
|
if (result === undefined) throw new Error(`Tool '${toolName}' returned a non-JSON value.`);
|
|
6374
6553
|
return result;
|
|
6375
6554
|
}
|
|
6376
|
-
function jsonDto(value, toolName) {
|
|
6377
|
-
return JSON.parse(stringifyDto(value, toolName));
|
|
6378
|
-
}
|
|
6379
6555
|
function asI18n(value) {
|
|
6380
6556
|
return {
|
|
6381
6557
|
en_US: value,
|
|
@@ -6455,4 +6631,4 @@ XpertToolProviderCoordinator = __decorate([
|
|
|
6455
6631
|
])
|
|
6456
6632
|
], XpertToolProviderCoordinator);
|
|
6457
6633
|
|
|
6458
|
-
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
|
@@ -199,10 +199,16 @@ const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platfor
|
|
|
199
199
|
const KnowledgeDocumentVisualAssetsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.visual-assets', {
|
|
200
200
|
description: 'Issue execution-scoped logical KnowledgeDocument image paths and inject validated images without exposing host storage paths.'
|
|
201
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
|
+
});
|
|
202
205
|
|
|
203
206
|
const ActorTokenRuntimeCapability = createRuntimeCapability('platform.actor-token', {
|
|
204
207
|
description: 'Mint a short-lived host-issued actor bearer token for outbound API calls.'
|
|
205
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
|
+
});
|
|
206
212
|
|
|
207
213
|
const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts', {
|
|
208
214
|
description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
|
|
@@ -375,12 +381,14 @@ function normalizeWorkspaceScope(scope) {
|
|
|
375
381
|
}
|
|
376
382
|
|
|
377
383
|
exports.ActorTokenRuntimeCapability = ActorTokenRuntimeCapability;
|
|
384
|
+
exports.ActorTokenRuntimeFactoryCapability = ActorTokenRuntimeFactoryCapability;
|
|
378
385
|
exports.ArtifactsRuntimeCapability = ArtifactsRuntimeCapability;
|
|
379
386
|
exports.BaseTool = BaseTool;
|
|
380
387
|
exports.BaseToolset = BaseToolset;
|
|
381
388
|
exports.BuiltinToolset = BuiltinToolset;
|
|
382
389
|
exports.DefaultRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
|
|
383
390
|
exports.KnowledgeDocumentVisualAssetsRuntimeCapability = KnowledgeDocumentVisualAssetsRuntimeCapability;
|
|
391
|
+
exports.KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = KnowledgeDocumentVisualAssetsRuntimeFactoryCapability;
|
|
384
392
|
exports.KnowledgebaseDocumentsRuntimeCapability = KnowledgebaseDocumentsRuntimeCapability;
|
|
385
393
|
exports.KnowledgebaseProvisioningRuntimeCapability = KnowledgebaseProvisioningRuntimeCapability;
|
|
386
394
|
exports.KnowledgebaseRuntimeCapability = KnowledgebaseRuntimeCapability;
|
package/model-provider.esm.js
CHANGED
|
@@ -197,10 +197,16 @@ const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platfor
|
|
|
197
197
|
const KnowledgeDocumentVisualAssetsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.visual-assets', {
|
|
198
198
|
description: 'Issue execution-scoped logical KnowledgeDocument image paths and inject validated images without exposing host storage paths.'
|
|
199
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
|
+
});
|
|
200
203
|
|
|
201
204
|
const ActorTokenRuntimeCapability = createRuntimeCapability('platform.actor-token', {
|
|
202
205
|
description: 'Mint a short-lived host-issued actor bearer token for outbound API calls.'
|
|
203
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
|
+
});
|
|
204
210
|
|
|
205
211
|
const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts', {
|
|
206
212
|
description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
|
|
@@ -372,4 +378,4 @@ function normalizeWorkspaceScope(scope) {
|
|
|
372
378
|
} : {});
|
|
373
379
|
}
|
|
374
380
|
|
|
375
|
-
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,
|
|
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[]>;
|
|
@@ -7,6 +7,7 @@ import { ICopilotModel, IModelAccessResolution, IXpertAgentExecution, JSONValue,
|
|
|
7
7
|
import { Subscriber } from 'rxjs';
|
|
8
8
|
import { AIGCModelClient, AsyncAIGCModelClient, IRerank, TLLMUsage } from '../../ai-model/types';
|
|
9
9
|
import type { RuntimeCapabilityRegistry } from '../../core';
|
|
10
|
+
import type { ConnectorRuntimeScope } from '../../connector/runtime-capability';
|
|
10
11
|
import type { WorkspaceFileCatalog } from '../../runtime/capabilities/workspace-files';
|
|
11
12
|
export * from './runtime-capability';
|
|
12
13
|
export * from './capabilities';
|
|
@@ -92,27 +93,14 @@ export type AgentMiddlewareModelProviderConnection = {
|
|
|
92
93
|
/** Persist final authoritative usage and calculate its charge exactly once. */
|
|
93
94
|
reportUsage(report: ModelUsageReport, modelAccess?: IModelAccessResolution): Promise<ModelUsageReportResult>;
|
|
94
95
|
};
|
|
95
|
-
export type AgentMiddlewareRuntimeScope = {
|
|
96
|
-
tenantId?: string | null;
|
|
97
|
-
organizationId?: string | null;
|
|
96
|
+
export type AgentMiddlewareRuntimeScope = ConnectorRuntimeScope & {
|
|
98
97
|
providerScopeId?: string | null;
|
|
99
|
-
userId?: string | null;
|
|
100
|
-
workspaceId?: string | null;
|
|
101
|
-
projectId?: string | null;
|
|
102
|
-
xpertId?: string | null;
|
|
103
98
|
/** Authoritative Volume catalog for runtime workspace files. */
|
|
104
99
|
catalog?: WorkspaceFileCatalog | null;
|
|
105
100
|
/** Authoritative catalog identity for portable workspace references. */
|
|
106
101
|
scopeId?: string | null;
|
|
107
102
|
/** Legacy xperts catalog compatibility flag; new runtimes use user-xperts instead. */
|
|
108
103
|
isolateByUser?: boolean | null;
|
|
109
|
-
xpertName?: string | null;
|
|
110
|
-
conversationId?: string | null;
|
|
111
|
-
threadId?: string | null;
|
|
112
|
-
agentKey?: string | null;
|
|
113
|
-
executionId?: string | null;
|
|
114
|
-
/** Connector bindings selected for this conversation. An empty list denies connector resolution. */
|
|
115
|
-
connectorBindingIds?: string[] | null;
|
|
116
104
|
usageCallback?: (usage: TLLMUsage) => void | Promise<void>;
|
|
117
105
|
workspaceRoot?: string | null;
|
|
118
106
|
workspacePath?: string | null;
|
|
@@ -4,6 +4,7 @@ import { AIModel } from '../ai-model';
|
|
|
4
4
|
import { TChatModelOptions } from './model';
|
|
5
5
|
export type RerankResult = {
|
|
6
6
|
index: number;
|
|
7
|
+
/** Relevance score reported by the rerank provider. Higher values are more relevant. */
|
|
7
8
|
relevanceScore: number;
|
|
8
9
|
document?: Document<Record<string, any>>;
|
|
9
10
|
};
|
|
@@ -14,6 +15,7 @@ export declare abstract class RerankModel extends AIModel {
|
|
|
14
15
|
export interface IRerank {
|
|
15
16
|
rerank(docs: Document<Record<string, any>>[], query: string, options: {
|
|
16
17
|
topN?: number;
|
|
18
|
+
/** Minimum relevanceScore, applied before the Top N limit. */
|
|
17
19
|
scoreThreshold?: number;
|
|
18
20
|
model?: string;
|
|
19
21
|
}): Promise<RerankResult[]>;
|
|
@@ -1,2 +1,21 @@
|
|
|
1
|
+
import type { RuntimeIdentityScope } from '../runtime/runtime-scope';
|
|
1
2
|
import type { ConnectorRuntimeApi } from './strategy.interface';
|
|
2
3
|
export declare const ConnectorRuntimeCapability: import("../core").RuntimeCapabilityKey<ConnectorRuntimeApi>;
|
|
4
|
+
/** No binding or provider grants means no connector access. */
|
|
5
|
+
export type ConnectorRuntimeScope = RuntimeIdentityScope & {
|
|
6
|
+
/** Host-selected bindings, including IDs pinned by enabled graph Connector nodes. */
|
|
7
|
+
connectorBindingIds?: string[] | null;
|
|
8
|
+
/** Providers configured by enabled graph Connector nodes without a pinned ID. */
|
|
9
|
+
connectorProviders?: string[] | null;
|
|
10
|
+
};
|
|
11
|
+
export type SelectedRuntimeConnectorBinding = {
|
|
12
|
+
bindingId: string;
|
|
13
|
+
provider: string;
|
|
14
|
+
};
|
|
15
|
+
export interface ConnectorRuntimeFactory {
|
|
16
|
+
/** Snapshot the authorized identity and connector grants for this runtime. */
|
|
17
|
+
createScopedApi(scope: ConnectorRuntimeScope): ConnectorRuntimeApi;
|
|
18
|
+
/** Preflight selected bindings through the same identity, project and credential checks. */
|
|
19
|
+
resolveSelectedRuntimeBindings(bindingIds: string[] | null | undefined, scope: ConnectorRuntimeScope): Promise<SelectedRuntimeConnectorBinding[]>;
|
|
20
|
+
}
|
|
21
|
+
export declare const ConnectorRuntimeFactoryCapability: import("../core").RuntimeCapabilityKey<ConnectorRuntimeFactory>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { EvolutionRuntimeApi } from '@xpert-ai/contracts';
|
|
1
|
+
import type { EvolutionRuntimeApi, EvolutionChangeRuntimeApi } from '@xpert-ai/contracts';
|
|
2
2
|
export declare const EVOLUTION_RUNTIME_SERVICE_TOKEN = "XPERT_EVOLUTION_RUNTIME_SERVICE";
|
|
3
3
|
export declare const EvolutionRuntimeCapability: import("../core").RuntimeCapabilityKey<EvolutionRuntimeApi>;
|
|
4
|
+
export declare const EvolutionChangeRuntimeCapability: import("../core").RuntimeCapabilityKey<EvolutionChangeRuntimeApi>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { RuntimeIdentityScope } from '../runtime-scope';
|
|
1
2
|
export type ActorTokenAct = Record<string, string | number | boolean | null | undefined>;
|
|
2
3
|
export interface ActorTokenRequest {
|
|
3
4
|
audience?: string | string[];
|
|
4
5
|
ttlSeconds?: number;
|
|
6
|
+
/** Extra delegation metadata; cannot replace claims fixed by the host when creating the API. */
|
|
5
7
|
act?: ActorTokenAct;
|
|
6
8
|
}
|
|
7
9
|
export interface ActorTokenResult {
|
|
@@ -13,3 +15,13 @@ export interface ActorTokenApi {
|
|
|
13
15
|
getToken(input?: ActorTokenRequest): Promise<ActorTokenResult>;
|
|
14
16
|
}
|
|
15
17
|
export declare const ActorTokenRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ActorTokenApi>;
|
|
18
|
+
/** Host-defined delegation claims are fixed when the API is created. */
|
|
19
|
+
export type ActorTokenRuntimeScope = RuntimeIdentityScope & {
|
|
20
|
+
act?: ActorTokenAct;
|
|
21
|
+
};
|
|
22
|
+
export interface ActorTokenRuntimeFactory {
|
|
23
|
+
/** Create one independent token cache for a host-authorized caller/execution. */
|
|
24
|
+
createScopedApi(scope: ActorTokenRuntimeScope): ActorTokenApi;
|
|
25
|
+
}
|
|
26
|
+
/** Platform registry entry. The operation capability above is bound only inside a caller runtime. */
|
|
27
|
+
export declare const ActorTokenRuntimeFactoryCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ActorTokenRuntimeFactory>;
|
|
@@ -54,6 +54,8 @@ export type ArtifactLinkAccessInput = {
|
|
|
54
54
|
expiresAt?: string | Date | null;
|
|
55
55
|
ttlSeconds?: number | null;
|
|
56
56
|
userConfirmedPublicLink?: boolean | null;
|
|
57
|
+
/** Trusted application authorization; must never be populated from untrusted tool arguments. */
|
|
58
|
+
publicLinkAuthorization?: 'application_policy';
|
|
57
59
|
};
|
|
58
60
|
/** Browser response hints and HTML safety profile for an Artifact link. */
|
|
59
61
|
export type ArtifactLinkPresentationInput = {
|