@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @xpert-ai/plugin-sdk
|
|
2
2
|
|
|
3
|
+
## 3.18.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3f72082: Add opt-in lazy template catalogs, summary pagination, explicit prompt locales and source revision tracking. Existing eager template providers remain compatible.
|
|
8
|
+
|
|
9
|
+
Restore role skill bindings when switching templates and preserve localized skill names during installation and selection.
|
|
10
|
+
|
|
11
|
+
- 4be390b: Release Xpert 3.18.4 with aligned contracts, plugin-sdk, and Web application versions.
|
|
12
|
+
|
|
13
|
+
- 63cd444: Allow host-enabled graph Connector providers in scoped runtime credentials while preserving explicit binding checks. Existing Connector APIs remain compatible.
|
|
14
|
+
- Updated dependencies [3f72082]
|
|
15
|
+
- Updated dependencies [7b97fee]
|
|
16
|
+
- Updated dependencies [4be390b]
|
|
17
|
+
- Updated dependencies [4e8c7ed]
|
|
18
|
+
- @xpert-ai/contracts@3.18.4
|
|
19
|
+
|
|
3
20
|
## 3.18.3
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Plugin SDK
|
|
2
2
|
|
|
3
|
+
## Runtime capabilities
|
|
4
|
+
|
|
5
|
+
See [platform capabilities and scoped factories](./runtime-capabilities.md) for domain registration, execution-scoped APIs and usage outside Agent middleware.
|
|
6
|
+
|
|
3
7
|
## Building
|
|
4
8
|
|
|
5
9
|
Run `nx build plugin-sdk` to build the library.
|
|
@@ -61,7 +65,9 @@ export class OrderOperationsTools {
|
|
|
61
65
|
}
|
|
62
66
|
```
|
|
63
67
|
|
|
64
|
-
MCP exposure is explicit. Provide strict Zod input/output schemas and return an allowlisted DTO; the host validates the output and maps it to `structuredContent
|
|
68
|
+
MCP exposure is explicit. Provide strict Zod input/output schemas and return an allowlisted DTO; the host validates the output and maps it to `structuredContent` and a JSON `TextContent` block so clients that only expose text can still read the result. With `resultFormat: 'tool_result'`, image and other content blocks are preserved and the validated structured metadata also receives a JSON text fallback. Invocation context is constructed for every call and must never be cached on the Provider singleton. `getMiddlewareExtensions()` may add Agent-only hooks such as `wrapToolCall`, but business-critical behavior belongs in the method or shared service.
|
|
69
|
+
|
|
70
|
+
For completed operations, `prepareToolResult(() => project(result), () => minimalReceipt)` defers output mapping to the adapter. The normal path maps and validates once; projection, validation or JSON serialization failures recover a bounded receipt without executing the business method again. Declare `outputSchema: z.union([normalSchema, receiptSchema])`, with strict objects in every branch. The fallback is validated too. Business exceptions thrown before the method returns remain errors. With `tool_result`, both callbacks return the content envelope and the union describes its structured metadata. The MCP protocol still validates the published JSON Schema; custom Zod refinements remain enforced by the SDK. Do not put side effects inside either callback.
|
|
65
71
|
|
|
66
72
|
For a host-native MCP App, declare each static HTML bundle once in the Provider's `apps` array, then bind a Tool with `mcp.app.resourceKey` and include `app` visibility. The App key must exist in the same Provider and its entry must be a relative `.html` path inside the packaged plugin. The host publishes the bundle as a `ui://` resource; plugins must not create a stdio server or put CSP/credentials in Tool results.
|
|
67
73
|
|
|
@@ -85,3 +91,22 @@ import {
|
|
|
85
91
|
```
|
|
86
92
|
|
|
87
93
|
This entry point excludes the NestJS and Node.js dependencies used by the server SDK.
|
|
94
|
+
|
|
95
|
+
### Native MCP invocation defaults
|
|
96
|
+
|
|
97
|
+
A decorated tool can declare `mcp.defaultApprovalMode: 'allow' | 'confirm' | 'deny'`.
|
|
98
|
+
The native capability descriptor carries this default through auto-publication and
|
|
99
|
+
provider synchronization. Explicit Publication administrator policies take
|
|
100
|
+
precedence. Omitting the field retains the existing risk defaults: reads allow,
|
|
101
|
+
writes confirm, and dangerous tools deny. A dangerous tool can run directly only
|
|
102
|
+
when its owner explicitly declares `allow`; risk annotations remain unchanged.
|
|
103
|
+
Manual Publications review changes to this declaration before adopting them.
|
|
104
|
+
|
|
105
|
+
For public Artifact links authorized by trusted application policy, runtime callers
|
|
106
|
+
may pass `access.publicLinkAuthorization: 'application_policy'` instead of
|
|
107
|
+
asserting `userConfirmedPublicLink`. This field must be derived by trusted plugin
|
|
108
|
+
code, never exposed as a tool argument. Existing user-confirmation calls retain
|
|
109
|
+
their behavior; user identity and Artifact scope checks still apply.
|
|
110
|
+
|
|
111
|
+
These additions require matching host contracts/runtime support and an SDK build
|
|
112
|
+
containing these interfaces. They are not part of the published SDK 3.18.3 baseline.
|
package/index.cjs.js
CHANGED
|
@@ -37,7 +37,7 @@ var base$1 = require('@langchain/core/language_models/base');
|
|
|
37
37
|
var connector = require('./connector.cjs.js');
|
|
38
38
|
var collaborationClient = require('./collaboration-client.cjs.js');
|
|
39
39
|
var tools = require('@langchain/core/tools');
|
|
40
|
-
require('zod/v3');
|
|
40
|
+
var v3 = require('zod/v3');
|
|
41
41
|
|
|
42
42
|
function _interopNamespaceDefault(e) {
|
|
43
43
|
var n = Object.create(null);
|
|
@@ -3597,17 +3597,11 @@ class OpenAICompatibleReranker {
|
|
|
3597
3597
|
if (!Array.isArray(output)) {
|
|
3598
3598
|
throw new Error('Invalid response format: missing results array');
|
|
3599
3599
|
}
|
|
3600
|
-
// Collect raw scores and normalize them.
|
|
3601
|
-
const scores = output.map((r)=>r.relevance_score);
|
|
3602
|
-
const minScore = Math.min(...scores);
|
|
3603
|
-
const maxScore = Math.max(...scores);
|
|
3604
|
-
const scoreRange = maxScore !== minScore ? maxScore - minScore : 1.0;
|
|
3605
3600
|
const reranked = output.map((r)=>{
|
|
3606
3601
|
const index = r.index;
|
|
3607
|
-
const normalizedScore = (r.relevance_score - minScore) / scoreRange;
|
|
3608
3602
|
const result = {
|
|
3609
3603
|
index,
|
|
3610
|
-
relevanceScore:
|
|
3604
|
+
relevanceScore: r.relevance_score
|
|
3611
3605
|
};
|
|
3612
3606
|
if (options.returnDocuments) {
|
|
3613
3607
|
var _r_document, _docs_index, _docs_index1;
|
|
@@ -4121,6 +4115,9 @@ exports.SSOProviderRegistry = __decorate([
|
|
|
4121
4115
|
const ConnectorRuntimeCapability = modelProvider.createRuntimeCapability('platform.connector', {
|
|
4122
4116
|
description: 'Resolve connector credentials for agent middleware.'
|
|
4123
4117
|
});
|
|
4118
|
+
const ConnectorRuntimeFactoryCapability = modelProvider.createRuntimeCapability('platform.connector.factory', {
|
|
4119
|
+
description: 'Create a connector API restricted to host-granted connectors and the authorized execution identity.'
|
|
4120
|
+
});
|
|
4124
4121
|
|
|
4125
4122
|
const CONNECTOR_STRATEGY = 'CONNECTOR_STRATEGY';
|
|
4126
4123
|
const ConnectorStrategyKey = (provider)=>common.applyDecorators(common.SetMetadata(CONNECTOR_STRATEGY, provider), common.SetMetadata(STRATEGY_META_KEY, CONNECTOR_STRATEGY));
|
|
@@ -5884,6 +5881,9 @@ const EVOLUTION_RUNTIME_SERVICE_TOKEN = 'XPERT_EVOLUTION_RUNTIME_SERVICE';
|
|
|
5884
5881
|
const EvolutionRuntimeCapability = modelProvider.createRuntimeCapability('platform.agent-evolution', {
|
|
5885
5882
|
description: 'Ingest learning signals and resolve immutable capability versions for domain runtimes.'
|
|
5886
5883
|
});
|
|
5884
|
+
const EvolutionChangeRuntimeCapability = modelProvider.createRuntimeCapability('platform.agent-evolution.changes', {
|
|
5885
|
+
description: 'Prepare, evaluate and publish versioned changes through target-owned validators and effect providers.'
|
|
5886
|
+
});
|
|
5887
5887
|
|
|
5888
5888
|
function defineMcpApp(definition) {
|
|
5889
5889
|
return Object.freeze(definition);
|
|
@@ -6047,6 +6047,12 @@ function validateProviderOptions(options) {
|
|
|
6047
6047
|
}
|
|
6048
6048
|
function validateToolOptions(options, methodName) {
|
|
6049
6049
|
var _options_description;
|
|
6050
|
+
if (options.resultFormat && options.resultFormat !== 'dto' && options.resultFormat !== 'tool_result') {
|
|
6051
|
+
throw new Error(`Tool '${options.name}' declares an invalid resultFormat.`);
|
|
6052
|
+
}
|
|
6053
|
+
if (options.resultFormat === 'tool_result' && !options.outputSchema) {
|
|
6054
|
+
throw new Error(`Tool '${options.name}' requires outputSchema for tool_result.`);
|
|
6055
|
+
}
|
|
6050
6056
|
if (!TOOL_NAME_PATTERN.test(options.name) || options.name.length > 191) {
|
|
6051
6057
|
throw new Error(`Method '${methodName}' declares invalid Tool name '${options.name}'.`);
|
|
6052
6058
|
}
|
|
@@ -6062,6 +6068,9 @@ function validateToolOptions(options, methodName) {
|
|
|
6062
6068
|
throw new Error(`MCP Tool '${options.name}' requires at least one execution context.`);
|
|
6063
6069
|
}
|
|
6064
6070
|
if (options.mcp) {
|
|
6071
|
+
if (options.mcp.defaultApprovalMode !== undefined && !includesValue(contracts.MCP_CAPABILITY_APPROVAL_MODES, options.mcp.defaultApprovalMode)) {
|
|
6072
|
+
throw new Error(`MCP Tool '${options.name}' declares invalid defaultApprovalMode.`);
|
|
6073
|
+
}
|
|
6065
6074
|
const behavior = options.mcp.behavior;
|
|
6066
6075
|
if (!includesValue(contracts.MCP_TOOL_RISKS, behavior == null ? void 0 : behavior.risk) || !includesValue(contracts.MCP_TOOL_SIDE_EFFECTS, behavior == null ? void 0 : behavior.sideEffect) || !includesValue(contracts.MCP_TOOL_IDEMPOTENCY, behavior == null ? void 0 : behavior.idempotency)) {
|
|
6067
6076
|
throw new Error(`MCP Tool '${options.name}' requires valid behavior annotations.`);
|
|
@@ -6088,6 +6097,19 @@ function assertStrictObjectSchema(schema, toolName, role) {
|
|
|
6088
6097
|
if (!schema || typeof Reflect.get(schema, 'parseAsync') !== 'function') {
|
|
6089
6098
|
throw new Error(`Tool '${toolName}' requires a Zod ${role} schema.`);
|
|
6090
6099
|
}
|
|
6100
|
+
// Refinements preserve the strict object shape while enforcing cross-field invariants.
|
|
6101
|
+
// Plugins can load a different physical copy of Zod; use its explicit type tag.
|
|
6102
|
+
while(schema._def.typeName === 'ZodEffects'){
|
|
6103
|
+
const refinement = schema;
|
|
6104
|
+
if (refinement._def.effect.type !== 'refinement') break;
|
|
6105
|
+
schema = refinement.innerType();
|
|
6106
|
+
}
|
|
6107
|
+
if (role === 'output' && schema._def.typeName === 'ZodUnion') {
|
|
6108
|
+
// Recovery receipts may have a different shape, but every branch must reject extra fields.
|
|
6109
|
+
const union = schema;
|
|
6110
|
+
for (const option of union.options)assertStrictObjectSchema(option, toolName, role);
|
|
6111
|
+
return;
|
|
6112
|
+
}
|
|
6091
6113
|
const definition = Reflect.get(schema, '_def');
|
|
6092
6114
|
if (!definition || Reflect.get(definition, 'unknownKeys') !== 'strict') {
|
|
6093
6115
|
throw new Error(`Tool '${toolName}' ${role} schema must be a strict Zod object.`);
|
|
@@ -6161,6 +6183,141 @@ exports.XpertToolProviderRegistry = __decorate([
|
|
|
6161
6183
|
])
|
|
6162
6184
|
], exports.XpertToolProviderRegistry);
|
|
6163
6185
|
|
|
6186
|
+
// Invariants: recovery starts only after the business method returns successfully.
|
|
6187
|
+
// Projection and recovery callbacks must be free of business side effects.
|
|
6188
|
+
// The adapter validates normal output once and validates any fallback separately;
|
|
6189
|
+
// neither path may rerun the operation or suppress input, authorization or commit failures.
|
|
6190
|
+
// Installed plugins may resolve a different physical SDK copy from the host.
|
|
6191
|
+
const PREPARED_RESULT = Symbol.for('xpert.tool.prepared-result.v1');
|
|
6192
|
+
/** Defer output projection until the adapter can validate and recover its result. */ function prepareToolResult(project, recover) {
|
|
6193
|
+
return {
|
|
6194
|
+
[PREPARED_RESULT]: true,
|
|
6195
|
+
project,
|
|
6196
|
+
recover
|
|
6197
|
+
};
|
|
6198
|
+
}
|
|
6199
|
+
function isPrepared(value) {
|
|
6200
|
+
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';
|
|
6201
|
+
}
|
|
6202
|
+
async function resolveToolResult(value, validate) {
|
|
6203
|
+
if (!isPrepared(value)) return validate(value);
|
|
6204
|
+
try {
|
|
6205
|
+
return await validate(await value.project());
|
|
6206
|
+
} catch (error) {
|
|
6207
|
+
const diagnostic = {
|
|
6208
|
+
code: 'tool_output_invalid',
|
|
6209
|
+
issues: error instanceof v3.ZodError ? error.issues.slice(0, 10).map((issue)=>({
|
|
6210
|
+
path: issue.path.join('.').slice(0, 240),
|
|
6211
|
+
code: issue.code
|
|
6212
|
+
})) : []
|
|
6213
|
+
};
|
|
6214
|
+
// A malformed fallback is a programming error too; never send unchecked data.
|
|
6215
|
+
return validate(await value.recover(diagnostic));
|
|
6216
|
+
}
|
|
6217
|
+
}
|
|
6218
|
+
|
|
6219
|
+
// Why this exists: MCP media blocks and business metadata have different contracts.
|
|
6220
|
+
// Validate metadata with the declared output schema, preserve bounded media blocks,
|
|
6221
|
+
// and include the same DTO in text for clients that hide structuredContent.
|
|
6222
|
+
const XPERT_TOOL_RESULT_FORMAT_VERSION = 1;
|
|
6223
|
+
const contentSchema = v3.z.discriminatedUnion('type', [
|
|
6224
|
+
v3.z.object({
|
|
6225
|
+
type: v3.z.literal('text'),
|
|
6226
|
+
text: v3.z.string().max(2 * 1024 * 1024)
|
|
6227
|
+
}).strict(),
|
|
6228
|
+
v3.z.object({
|
|
6229
|
+
type: v3.z.literal('image'),
|
|
6230
|
+
data: v3.z.string().min(1).max(8 * 1024 * 1024),
|
|
6231
|
+
mimeType: v3.z.enum([
|
|
6232
|
+
'image/png',
|
|
6233
|
+
'image/jpeg',
|
|
6234
|
+
'image/webp',
|
|
6235
|
+
'image/gif'
|
|
6236
|
+
])
|
|
6237
|
+
}).strict(),
|
|
6238
|
+
v3.z.object({
|
|
6239
|
+
type: v3.z.literal('audio'),
|
|
6240
|
+
data: v3.z.string().min(1).max(8 * 1024 * 1024),
|
|
6241
|
+
mimeType: v3.z.string().min(1).max(100)
|
|
6242
|
+
}).strict(),
|
|
6243
|
+
v3.z.object({
|
|
6244
|
+
type: v3.z.literal('resource_link'),
|
|
6245
|
+
uri: v3.z.string().min(1).max(4096),
|
|
6246
|
+
name: v3.z.string().max(240).optional()
|
|
6247
|
+
}).strict()
|
|
6248
|
+
]);
|
|
6249
|
+
/** Validate the envelope separately so binary content never enters the business DTO. */ async function parseDecoratedToolResult(value, outputSchema) {
|
|
6250
|
+
var _result_content;
|
|
6251
|
+
const envelope = v3.z.object({
|
|
6252
|
+
content: v3.z.array(contentSchema).max(32).optional(),
|
|
6253
|
+
structuredContent: outputSchema,
|
|
6254
|
+
isError: v3.z.boolean().optional()
|
|
6255
|
+
}).strict();
|
|
6256
|
+
const result = await envelope.parseAsync(value);
|
|
6257
|
+
var _result_content_map;
|
|
6258
|
+
const content = (_result_content_map = (_result_content = result.content) == null ? void 0 : _result_content.map((item)=>{
|
|
6259
|
+
switch(item.type){
|
|
6260
|
+
case 'text':
|
|
6261
|
+
return {
|
|
6262
|
+
type: 'text',
|
|
6263
|
+
text: item.text
|
|
6264
|
+
};
|
|
6265
|
+
case 'image':
|
|
6266
|
+
return {
|
|
6267
|
+
type: 'image',
|
|
6268
|
+
data: item.data,
|
|
6269
|
+
mimeType: item.mimeType
|
|
6270
|
+
};
|
|
6271
|
+
case 'audio':
|
|
6272
|
+
return {
|
|
6273
|
+
type: 'audio',
|
|
6274
|
+
data: item.data,
|
|
6275
|
+
mimeType: item.mimeType
|
|
6276
|
+
};
|
|
6277
|
+
case 'resource_link':
|
|
6278
|
+
return _extends._extends({
|
|
6279
|
+
type: 'resource_link',
|
|
6280
|
+
uri: item.uri
|
|
6281
|
+
}, item.name ? {
|
|
6282
|
+
name: item.name
|
|
6283
|
+
} : {});
|
|
6284
|
+
}
|
|
6285
|
+
})) != null ? _result_content_map : [];
|
|
6286
|
+
// MCP clients may expose only content to the model. Keep the validated DTO
|
|
6287
|
+
// readable there too, while retaining binary blocks and App structured data.
|
|
6288
|
+
const text = JSON.stringify(result.structuredContent);
|
|
6289
|
+
if (!content.some((item)=>item.type === 'text' && item.text === text)) content.push({
|
|
6290
|
+
type: 'text',
|
|
6291
|
+
text
|
|
6292
|
+
});
|
|
6293
|
+
return _extends._extends({
|
|
6294
|
+
structuredContent: result.structuredContent,
|
|
6295
|
+
content
|
|
6296
|
+
}, result.isError === undefined ? {} : {
|
|
6297
|
+
isError: result.isError
|
|
6298
|
+
});
|
|
6299
|
+
}
|
|
6300
|
+
function agentContent(content) {
|
|
6301
|
+
return (content != null ? content : []).map((item)=>{
|
|
6302
|
+
if (item.type === 'image') return {
|
|
6303
|
+
type: 'image_url',
|
|
6304
|
+
image_url: {
|
|
6305
|
+
url: `data:${item.mimeType};base64,${item.data}`
|
|
6306
|
+
}
|
|
6307
|
+
};
|
|
6308
|
+
if (item.type === 'text') return item;
|
|
6309
|
+
var _item_name;
|
|
6310
|
+
if (item.type === 'resource_link') return {
|
|
6311
|
+
type: 'text',
|
|
6312
|
+
text: `${(_item_name = item.name) != null ? _item_name : 'Resource'}: ${item.uri}`
|
|
6313
|
+
};
|
|
6314
|
+
return {
|
|
6315
|
+
type: 'text',
|
|
6316
|
+
text: `Audio content (${item.mimeType}) is available through MCP.`
|
|
6317
|
+
};
|
|
6318
|
+
});
|
|
6319
|
+
}
|
|
6320
|
+
|
|
6164
6321
|
class DecoratedToolsetStrategy {
|
|
6165
6322
|
validateConfig() {
|
|
6166
6323
|
return Promise.resolve();
|
|
@@ -6265,13 +6422,27 @@ function createAgentTool(instance, descriptor, middlewareContext, middlewareOpti
|
|
|
6265
6422
|
return tools.tool(async (input, config)=>{
|
|
6266
6423
|
const parsedInput = await descriptor.options.inputSchema.parseAsync(input);
|
|
6267
6424
|
const output = await invoke(parsedInput, agentExecutionContext(middlewareContext, middlewareOptions, config));
|
|
6268
|
-
|
|
6269
|
-
|
|
6425
|
+
if (descriptor.options.resultFormat === 'tool_result' && descriptor.options.outputSchema) {
|
|
6426
|
+
const result = await resolveToolResult(output, (value)=>parseDecoratedToolResult(value, descriptor.options.outputSchema));
|
|
6427
|
+
var _result_isError;
|
|
6428
|
+
return [
|
|
6429
|
+
agentContent(result.content),
|
|
6430
|
+
{
|
|
6431
|
+
structuredContent: result.structuredContent,
|
|
6432
|
+
isError: (_result_isError = result.isError) != null ? _result_isError : false
|
|
6433
|
+
}
|
|
6434
|
+
];
|
|
6435
|
+
}
|
|
6436
|
+
return resolveToolResult(output, async (value)=>{
|
|
6437
|
+
const parsedOutput = descriptor.options.outputSchema ? await descriptor.options.outputSchema.parseAsync(value) : value;
|
|
6438
|
+
return stringifyDto(parsedOutput, descriptor.options.name);
|
|
6439
|
+
});
|
|
6270
6440
|
}, _extends._extends({
|
|
6271
6441
|
name: descriptor.options.name,
|
|
6272
6442
|
description: descriptor.options.description,
|
|
6273
6443
|
schema: descriptor.options.inputSchema,
|
|
6274
|
-
verboseParsingErrors: true
|
|
6444
|
+
verboseParsingErrors: true,
|
|
6445
|
+
responseFormat: descriptor.options.resultFormat === 'tool_result' ? 'content_and_artifact' : 'content'
|
|
6275
6446
|
}, descriptor.options.metadata ? {
|
|
6276
6447
|
metadata: descriptor.options.metadata
|
|
6277
6448
|
} : {}));
|
|
@@ -6295,7 +6466,10 @@ function createMcpTool(instance, descriptor) {
|
|
|
6295
6466
|
eligible: true
|
|
6296
6467
|
}
|
|
6297
6468
|
},
|
|
6298
|
-
behavior: mcp.behavior
|
|
6469
|
+
behavior: mcp.behavior
|
|
6470
|
+
}, mcp.defaultApprovalMode ? {
|
|
6471
|
+
defaultApprovalMode: mcp.defaultApprovalMode
|
|
6472
|
+
} : {}, {
|
|
6299
6473
|
requiredContext: [
|
|
6300
6474
|
...mcp.requiredContext
|
|
6301
6475
|
],
|
|
@@ -6315,18 +6489,23 @@ function createMcpTool(instance, descriptor) {
|
|
|
6315
6489
|
execute: async (input, context)=>{
|
|
6316
6490
|
const parsedInput = await descriptor.options.inputSchema.parseAsync(input);
|
|
6317
6491
|
const output = await invoke(parsedInput, mcpExecutionContext(context));
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
return {
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6492
|
+
if (descriptor.options.resultFormat === 'tool_result') {
|
|
6493
|
+
return resolveToolResult(output, (value)=>parseDecoratedToolResult(value, outputSchema));
|
|
6494
|
+
}
|
|
6495
|
+
return resolveToolResult(output, async (value)=>{
|
|
6496
|
+
const parsedOutput = await outputSchema.parseAsync(value);
|
|
6497
|
+
// Serialize once so text-only clients and MCP Apps receive the same JSON-safe DTO.
|
|
6498
|
+
const text = stringifyDto(parsedOutput, descriptor.options.name);
|
|
6499
|
+
return {
|
|
6500
|
+
content: [
|
|
6501
|
+
{
|
|
6502
|
+
type: 'text',
|
|
6503
|
+
text
|
|
6504
|
+
}
|
|
6505
|
+
],
|
|
6506
|
+
structuredContent: JSON.parse(text)
|
|
6507
|
+
};
|
|
6508
|
+
});
|
|
6330
6509
|
}
|
|
6331
6510
|
});
|
|
6332
6511
|
}
|
|
@@ -6391,9 +6570,6 @@ function stringifyDto(value, toolName) {
|
|
|
6391
6570
|
if (result === undefined) throw new Error(`Tool '${toolName}' returned a non-JSON value.`);
|
|
6392
6571
|
return result;
|
|
6393
6572
|
}
|
|
6394
|
-
function jsonDto(value, toolName) {
|
|
6395
|
-
return JSON.parse(stringifyDto(value, toolName));
|
|
6396
|
-
}
|
|
6397
6573
|
function asI18n(value) {
|
|
6398
6574
|
return {
|
|
6399
6575
|
en_US: value,
|
|
@@ -6482,6 +6658,7 @@ Object.defineProperty(exports, "ASSISTANT_CONTEXT_SET_COMMAND", {
|
|
|
6482
6658
|
get: function () { return contracts.ASSISTANT_CONTEXT_SET_COMMAND; }
|
|
6483
6659
|
});
|
|
6484
6660
|
exports.ActorTokenRuntimeCapability = modelProvider.ActorTokenRuntimeCapability;
|
|
6661
|
+
exports.ActorTokenRuntimeFactoryCapability = modelProvider.ActorTokenRuntimeFactoryCapability;
|
|
6485
6662
|
exports.ArtifactsRuntimeCapability = modelProvider.ArtifactsRuntimeCapability;
|
|
6486
6663
|
exports.BaseTool = modelProvider.BaseTool;
|
|
6487
6664
|
exports.BaseToolset = modelProvider.BaseToolset;
|
|
@@ -6489,6 +6666,7 @@ exports.BuiltinToolset = modelProvider.BuiltinToolset;
|
|
|
6489
6666
|
exports.DefaultAgentMiddlewareRuntimeCapabilityRegistry = modelProvider.DefaultRuntimeCapabilityRegistry;
|
|
6490
6667
|
exports.DefaultRuntimeCapabilityRegistry = modelProvider.DefaultRuntimeCapabilityRegistry;
|
|
6491
6668
|
exports.KnowledgeDocumentVisualAssetsRuntimeCapability = modelProvider.KnowledgeDocumentVisualAssetsRuntimeCapability;
|
|
6669
|
+
exports.KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = modelProvider.KnowledgeDocumentVisualAssetsRuntimeFactoryCapability;
|
|
6492
6670
|
exports.KnowledgebaseDocumentsRuntimeCapability = modelProvider.KnowledgebaseDocumentsRuntimeCapability;
|
|
6493
6671
|
exports.KnowledgebaseProvisioningRuntimeCapability = modelProvider.KnowledgebaseProvisioningRuntimeCapability;
|
|
6494
6672
|
exports.KnowledgebaseRuntimeCapability = modelProvider.KnowledgebaseRuntimeCapability;
|
|
@@ -6547,6 +6725,7 @@ exports.CollaborationDocumentProvider = CollaborationDocumentProvider;
|
|
|
6547
6725
|
exports.CollaborationRuntimeCapability = CollaborationRuntimeCapability;
|
|
6548
6726
|
exports.CommonParameterRules = CommonParameterRules;
|
|
6549
6727
|
exports.ConnectorRuntimeCapability = ConnectorRuntimeCapability;
|
|
6728
|
+
exports.ConnectorRuntimeFactoryCapability = ConnectorRuntimeFactoryCapability;
|
|
6550
6729
|
exports.ConnectorStrategyKey = ConnectorStrategyKey;
|
|
6551
6730
|
exports.CreateModelClientCommand = CreateModelClientCommand;
|
|
6552
6731
|
exports.CredentialsValidateFailedError = CredentialsValidateFailedError;
|
|
@@ -6571,6 +6750,7 @@ exports.DocumentSourceStrategy = DocumentSourceStrategy;
|
|
|
6571
6750
|
exports.DocumentTransformerStrategy = DocumentTransformerStrategy;
|
|
6572
6751
|
exports.EVOLUTION_RUNTIME_SERVICE_TOKEN = EVOLUTION_RUNTIME_SERVICE_TOKEN;
|
|
6573
6752
|
exports.EVOLUTION_TARGET_PROVIDER = EVOLUTION_TARGET_PROVIDER;
|
|
6753
|
+
exports.EvolutionChangeRuntimeCapability = EvolutionChangeRuntimeCapability;
|
|
6574
6754
|
exports.EvolutionRuntimeCapability = EvolutionRuntimeCapability;
|
|
6575
6755
|
exports.EvolutionTargetProviderStrategy = EvolutionTargetProviderStrategy;
|
|
6576
6756
|
exports.FILE_STORAGE_PROVIDER = FILE_STORAGE_PROVIDER;
|
|
@@ -6669,6 +6849,7 @@ exports.XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN = XPERT_AGENT_MIDDLEWARE_RUNTIME_TO
|
|
|
6669
6849
|
exports.XPERT_TOOL_METHOD_METADATA = XPERT_TOOL_METHOD_METADATA;
|
|
6670
6850
|
exports.XPERT_TOOL_PROVIDER = XPERT_TOOL_PROVIDER;
|
|
6671
6851
|
exports.XPERT_TOOL_PROVIDER_METADATA = XPERT_TOOL_PROVIDER_METADATA;
|
|
6852
|
+
exports.XPERT_TOOL_RESULT_FORMAT_VERSION = XPERT_TOOL_RESULT_FORMAT_VERSION;
|
|
6672
6853
|
exports.XpFileSystem = XpFileSystem;
|
|
6673
6854
|
exports.XpertServerPlugin = XpertServerPlugin;
|
|
6674
6855
|
exports.XpertTool = XpertTool;
|
|
@@ -6722,6 +6903,7 @@ exports.mergeCredentials = mergeCredentials;
|
|
|
6722
6903
|
exports.mergeParentChildChunks = mergeParentChildChunks;
|
|
6723
6904
|
exports.normalizeContextSize = normalizeContextSize;
|
|
6724
6905
|
exports.pluginArtifactTableName = pluginArtifactTableName;
|
|
6906
|
+
exports.prepareToolResult = prepareToolResult;
|
|
6725
6907
|
exports.processAsyncAIGCManagedJob = processAsyncAIGCManagedJob;
|
|
6726
6908
|
exports.renderRemoteModuleIframeHtml = renderRemoteModuleIframeHtml;
|
|
6727
6909
|
exports.renderRemoteReactIframeHtml = renderRemoteReactIframeHtml;
|