@xpert-ai/plugin-sdk 3.18.7 → 3.19.0
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 +19 -0
- package/MIDDLEWARE_APPS.md +71 -0
- package/README.md +2 -0
- package/index.cjs.js +132 -56
- package/index.esm.js +120 -57
- package/package.json +2 -2
- package/runtime-capabilities.md +35 -0
- package/src/index.d.ts +3 -0
- package/src/lib/agent/index.d.ts +1 -0
- package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +55 -20
- package/src/lib/agent/middleware/types.d.ts +13 -3
- package/src/lib/agent/runtime/capability.d.ts +29 -0
- package/src/lib/agent/runtime/index.d.ts +3 -0
- package/src/lib/agent/runtime/strategy.d.ts +50 -0
- package/src/lib/agent/runtime/types.d.ts +132 -0
- package/src/lib/assistant-capability/index.d.ts +42 -0
- package/src/lib/connector/runtime-capability.d.ts +2 -0
- package/src/lib/connector/strategy.interface.d.ts +8 -0
- package/src/lib/core/context/request-context.d.ts +6 -0
- package/src/lib/core/strategy-bus.d.ts +0 -3
- package/src/lib/evolution/runtime-capability.d.ts +2 -1
- package/src/lib/integration/strategy.interface.d.ts +22 -0
- package/src/lib/mcp/app.d.ts +10 -0
- package/src/lib/project-task/index.d.ts +59 -0
- package/src/lib/project-type/index.d.ts +64 -0
- package/src/lib/runtime/capabilities/knowledge-graph.d.ts +59 -0
- package/src/lib/runtime/capabilities/knowledgebase-documents.d.ts +21 -0
- package/src/lib/runtime/capabilities/knowledgebase.d.ts +8 -3
- package/src/lib/runtime/capabilities/project-access.d.ts +2 -1
- package/src/lib/runtime/capabilities/project-provisioning.d.ts +3 -0
- package/src/lib/runtime/runtime-scope.d.ts +7 -1
- package/src/lib/sandbox/execution-environment.d.ts +10 -0
- package/src/lib/sandbox/execution.d.ts +3 -0
- package/src/lib/sandbox/index.d.ts +1 -0
- package/src/lib/sandbox/protocol.d.ts +2 -0
- package/src/lib/tool-provider/types.d.ts +6 -0
- package/src/lib/types.d.ts +2 -1
- package/src/lib/workflow/trigger/strategy.interface.d.ts +2 -1
package/index.esm.js
CHANGED
|
@@ -8,7 +8,6 @@ import { LanguagesEnum, ParameterType, AiModelTypeEnum, PriceType, FetchFrom, Mo
|
|
|
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';
|
|
11
|
-
import { verify, JsonWebTokenError } from 'jsonwebtoken';
|
|
12
11
|
import { randomUUID, createHash } from 'node:crypto';
|
|
13
12
|
import { Command } from '@nestjs/cqrs';
|
|
14
13
|
import * as fs from 'fs';
|
|
@@ -332,22 +331,15 @@ class RequestContext {
|
|
|
332
331
|
}
|
|
333
332
|
return scope.organizationId;
|
|
334
333
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (found.length === findPermissions.length) {
|
|
345
|
-
return true;
|
|
346
|
-
}
|
|
347
|
-
} else {
|
|
348
|
-
return false;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
334
|
+
/**
|
|
335
|
+
* Check the authenticated principal's enabled role permissions, matching the
|
|
336
|
+
* server RequestContext. Authentication guards resolve JWTs, API keys and
|
|
337
|
+
* ChatKit client secrets before this check; the bearer is not always a JWT.
|
|
338
|
+
*/ static hasPermissions(findPermissions, throwError) {
|
|
339
|
+
const permissions = this.currentPermissions();
|
|
340
|
+
if (permissions.length > 0) {
|
|
341
|
+
const found = permissions.filter((value)=>findPermissions.indexOf(value) >= 0);
|
|
342
|
+
if (found.length === findPermissions.length) return true;
|
|
351
343
|
}
|
|
352
344
|
if (throwError) {
|
|
353
345
|
throw new HttpException('Unauthorized', HttpStatus.UNAUTHORIZED);
|
|
@@ -355,17 +347,9 @@ class RequestContext {
|
|
|
355
347
|
return false;
|
|
356
348
|
}
|
|
357
349
|
static hasAnyPermission(findPermissions, throwError) {
|
|
358
|
-
const
|
|
359
|
-
if (
|
|
360
|
-
|
|
361
|
-
const token = ExtractJwt.fromAuthHeaderAsBearerToken()(requestContext.request);
|
|
362
|
-
if (token) {
|
|
363
|
-
const { permissions } = verify(token, process.env['JWT_SECRET']);
|
|
364
|
-
const found = permissions.filter((value)=>findPermissions.indexOf(value) >= 0);
|
|
365
|
-
if (found.length > 0) {
|
|
366
|
-
return true;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
350
|
+
const permissions = this.currentPermissions();
|
|
351
|
+
if (permissions.some((value)=>findPermissions.includes(value))) {
|
|
352
|
+
return true;
|
|
369
353
|
}
|
|
370
354
|
if (throwError) {
|
|
371
355
|
throw new HttpException('Unauthorized', HttpStatus.UNAUTHORIZED);
|
|
@@ -403,20 +387,6 @@ class RequestContext {
|
|
|
403
387
|
const context = RequestContext.currentRequestContext();
|
|
404
388
|
if (context) {
|
|
405
389
|
var _this_currentUser_role, _this_currentUser;
|
|
406
|
-
// tslint:disable-next-line
|
|
407
|
-
const token = this.currentToken();
|
|
408
|
-
if (token) {
|
|
409
|
-
try {
|
|
410
|
-
const { role } = verify(token, process.env['JWT_SECRET']);
|
|
411
|
-
if (role) {
|
|
412
|
-
return roles.includes(role);
|
|
413
|
-
}
|
|
414
|
-
} catch (error) {
|
|
415
|
-
if (!(error instanceof JsonWebTokenError)) {
|
|
416
|
-
throw error;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
390
|
const role = (_this_currentUser = this.currentUser()) == null ? void 0 : (_this_currentUser_role = _this_currentUser.role) == null ? void 0 : _this_currentUser_role.name;
|
|
421
391
|
if (role) {
|
|
422
392
|
return roles.includes(role);
|
|
@@ -427,6 +397,11 @@ class RequestContext {
|
|
|
427
397
|
}
|
|
428
398
|
return false;
|
|
429
399
|
}
|
|
400
|
+
static currentPermissions() {
|
|
401
|
+
var _this_currentUser_role, _this_currentUser;
|
|
402
|
+
var _this_currentUser_role_rolePermissions;
|
|
403
|
+
return ((_this_currentUser_role_rolePermissions = (_this_currentUser = this.currentUser()) == null ? void 0 : (_this_currentUser_role = _this_currentUser.role) == null ? void 0 : _this_currentUser_role.rolePermissions) != null ? _this_currentUser_role_rolePermissions : []).filter((rolePermission)=>rolePermission == null ? void 0 : rolePermission.enabled).map((rolePermission)=>rolePermission == null ? void 0 : rolePermission.permission).filter((permission)=>!!permission);
|
|
404
|
+
}
|
|
430
405
|
constructor(request, response, reqId, userId, extras = {}){
|
|
431
406
|
this.request = request;
|
|
432
407
|
this.response = response;
|
|
@@ -497,15 +472,6 @@ function runWithRequestContext(req, res, next) {
|
|
|
497
472
|
}
|
|
498
473
|
|
|
499
474
|
let StrategyBus = class StrategyBus {
|
|
500
|
-
registerRemovalGuard(guard) {
|
|
501
|
-
this.removalGuards.add(guard);
|
|
502
|
-
return ()=>{
|
|
503
|
-
this.removalGuards.delete(guard);
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
async assertCanRemove(scopeKey, pluginNames) {
|
|
507
|
-
for (const guard of this.removalGuards)await guard(scopeKey, pluginNames);
|
|
508
|
-
}
|
|
509
475
|
upsert(strategyType, entry) {
|
|
510
476
|
this.subject.next({
|
|
511
477
|
type: 'UPSERT',
|
|
@@ -523,7 +489,6 @@ let StrategyBus = class StrategyBus {
|
|
|
523
489
|
} : {}));
|
|
524
490
|
}
|
|
525
491
|
constructor(){
|
|
526
|
-
this.removalGuards = new Set();
|
|
527
492
|
this.subject = new Subject();
|
|
528
493
|
this.events$ = this.subject.asObservable();
|
|
529
494
|
}
|
|
@@ -3864,7 +3829,7 @@ AgentMiddlewareRegistry = __decorate([
|
|
|
3864
3829
|
'end'
|
|
3865
3830
|
];
|
|
3866
3831
|
|
|
3867
|
-
const AssistantTaskRuntimeCapability = createRuntimeCapability('platform.assistant_task', {
|
|
3832
|
+
/** Scoped runtime capability for platform Assistant tasks. */ const AssistantTaskRuntimeCapability = createRuntimeCapability('platform.assistant_task', {
|
|
3868
3833
|
description: 'Start asynchronous tasks on the current platform assistant.'
|
|
3869
3834
|
});
|
|
3870
3835
|
|
|
@@ -3987,6 +3952,52 @@ HandoffProcessorRegistry = __decorate([
|
|
|
3987
3952
|
runTtlMs: 10 * 60 * 1000
|
|
3988
3953
|
};
|
|
3989
3954
|
|
|
3955
|
+
/** Checks confirmed completion; unknown remains non-terminal. */ function isAgentInvocationTerminal(status) {
|
|
3956
|
+
return status === 'succeeded' || status === 'failed' || status === 'cancelled';
|
|
3957
|
+
}
|
|
3958
|
+
|
|
3959
|
+
/** Nest discovery metadata key for runtime strategies. */ const AGENT_RUNTIME_STRATEGY = 'AGENT_RUNTIME_STRATEGY';
|
|
3960
|
+
/** Associate a stable provider key with an adapter. Also declare @Injectable() and register the provider. */ const AgentRuntimeStrategy = (provider)=>applyDecorators(SetMetadata(AGENT_RUNTIME_STRATEGY, provider), SetMetadata(STRATEGY_META_KEY, AGENT_RUNTIME_STRATEGY));
|
|
3961
|
+
/** Scoped strategy registry with pinned provider/version lookup for continuation. */ let AgentRuntimeRegistry = class AgentRuntimeRegistry extends BaseStrategyRegistry {
|
|
3962
|
+
/** Find the exact original scope/plugin/version, without fallback. Returns undefined if unavailable. */ getPinned(provider, source) {
|
|
3963
|
+
var _this_strategies_get;
|
|
3964
|
+
const strategy = (_this_strategies_get = this.strategies.get(source.scopeKey)) == null ? void 0 : _this_strategies_get.get(provider);
|
|
3965
|
+
if (!strategy) return undefined;
|
|
3966
|
+
const actual = this.getSource(strategy);
|
|
3967
|
+
return actual.kind === source.kind && actual.scopeKey === source.scopeKey && (actual.kind !== 'plugin' || source.kind !== 'plugin' || actual.pluginName === source.pluginName && actual.pluginVersion === source.pluginVersion) ? strategy : undefined;
|
|
3968
|
+
}
|
|
3969
|
+
constructor(discoveryService, reflector){
|
|
3970
|
+
super(AGENT_RUNTIME_STRATEGY, discoveryService, reflector);
|
|
3971
|
+
}
|
|
3972
|
+
};
|
|
3973
|
+
AgentRuntimeRegistry = __decorate([
|
|
3974
|
+
Injectable(),
|
|
3975
|
+
__metadata("design:paramtypes", [
|
|
3976
|
+
DiscoveryService,
|
|
3977
|
+
Reflector
|
|
3978
|
+
])
|
|
3979
|
+
], AgentRuntimeRegistry);
|
|
3980
|
+
|
|
3981
|
+
/** Caller-scoped API obtained through runtime.capabilities.require(...). */ const AgentInvocationRuntimeCapability = createRuntimeCapability('platform.agent_invocation', {
|
|
3982
|
+
description: 'Scoped, versioned Agent invocation and lifecycle control'
|
|
3983
|
+
});
|
|
3984
|
+
/** Platform factory capability. The wire key is stable across SDK naming changes. */ const AgentRuntimeFactoryCapability = createRuntimeCapability('platform.agent_invocation.factory');
|
|
3985
|
+
|
|
3986
|
+
const ASSISTANT_CAPABILITY_PROVIDER = 'ASSISTANT_CAPABILITY_PROVIDER';
|
|
3987
|
+
const AssistantCapabilityProvider = (key)=>applyDecorators(SetMetadata(ASSISTANT_CAPABILITY_PROVIDER, key), SetMetadata(STRATEGY_META_KEY, ASSISTANT_CAPABILITY_PROVIDER));
|
|
3988
|
+
let AssistantCapabilityProviderRegistry = class AssistantCapabilityProviderRegistry extends BaseStrategyRegistry {
|
|
3989
|
+
constructor(discovery, reflector){
|
|
3990
|
+
super(ASSISTANT_CAPABILITY_PROVIDER, discovery, reflector);
|
|
3991
|
+
}
|
|
3992
|
+
};
|
|
3993
|
+
AssistantCapabilityProviderRegistry = __decorate([
|
|
3994
|
+
Injectable(),
|
|
3995
|
+
__metadata("design:paramtypes", [
|
|
3996
|
+
DiscoveryService,
|
|
3997
|
+
Reflector
|
|
3998
|
+
])
|
|
3999
|
+
], AssistantCapabilityProviderRegistry);
|
|
4000
|
+
|
|
3990
4001
|
/**
|
|
3991
4002
|
* Common platform message length limits
|
|
3992
4003
|
*/ const CHAT_CHANNEL_TEXT_LIMITS = {
|
|
@@ -4281,10 +4292,12 @@ function appendSandboxMessage(output, message) {
|
|
|
4281
4292
|
function resolveSandboxExecutionOptions(options, defaults = DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS) {
|
|
4282
4293
|
const timeoutMs = typeof (options == null ? void 0 : options.timeoutMs) === 'number' && Number.isFinite(options.timeoutMs) && options.timeoutMs > 0 ? Math.trunc(options.timeoutMs) : typeof defaults.timeoutMs === 'number' && Number.isFinite(defaults.timeoutMs) && defaults.timeoutMs > 0 ? Math.trunc(defaults.timeoutMs) : DEFAULT_SANDBOX_SHELL_TIMEOUT_MS;
|
|
4283
4294
|
const maxOutputBytes = typeof (options == null ? void 0 : options.maxOutputBytes) === 'number' && Number.isFinite(options.maxOutputBytes) && options.maxOutputBytes > 0 ? Math.trunc(options.maxOutputBytes) : typeof defaults.maxOutputBytes === 'number' && Number.isFinite(defaults.maxOutputBytes) && defaults.maxOutputBytes > 0 ? Math.trunc(defaults.maxOutputBytes) : DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES;
|
|
4284
|
-
return {
|
|
4295
|
+
return _extends({
|
|
4285
4296
|
timeoutMs,
|
|
4286
4297
|
maxOutputBytes
|
|
4287
|
-
}
|
|
4298
|
+
}, (options == null ? void 0 : options.signal) ? {
|
|
4299
|
+
signal: options.signal
|
|
4300
|
+
} : {});
|
|
4288
4301
|
}
|
|
4289
4302
|
|
|
4290
4303
|
function isObjectLike$2(value) {
|
|
@@ -5937,6 +5950,9 @@ EvolutionTargetProviderRegistry = __decorate([
|
|
|
5937
5950
|
], EvolutionTargetProviderRegistry);
|
|
5938
5951
|
|
|
5939
5952
|
const EVOLUTION_RUNTIME_SERVICE_TOKEN = 'XPERT_EVOLUTION_RUNTIME_SERVICE';
|
|
5953
|
+
const EvolutionBaselineRuntimeCapability = createRuntimeCapability('platform.agent-evolution.baselines', {
|
|
5954
|
+
description: 'Inspect and initialize organization rule baselines with administrator authorization and revision checks.'
|
|
5955
|
+
});
|
|
5940
5956
|
const EvolutionRuntimeCapability = createRuntimeCapability('platform.agent-evolution', {
|
|
5941
5957
|
description: 'Ingest learning signals and resolve immutable capability versions for domain runtimes.'
|
|
5942
5958
|
});
|
|
@@ -6177,6 +6193,11 @@ function describeXpertToolProvider(instance) {
|
|
|
6177
6193
|
if (middlewareProvider && !middlewareProviders.has(middlewareProvider)) {
|
|
6178
6194
|
throw new Error(`Tool '${toolOptions.name}' references undeclared Middleware provider '${middlewareProvider}'.`);
|
|
6179
6195
|
}
|
|
6196
|
+
if (toolOptions.app) {
|
|
6197
|
+
if (!middlewareProvider || !toolOptions.app.visibility.length || toolOptions.app.visibility.some((item)=>item !== 'model' && item !== 'app') || toolOptions.app.resourceKey && (!appKeys.has(toolOptions.app.resourceKey) || !toolOptions.app.visibility.includes('app'))) {
|
|
6198
|
+
throw new Error(`Tool '${toolOptions.name}' has an invalid middleware App binding.`);
|
|
6199
|
+
}
|
|
6200
|
+
}
|
|
6180
6201
|
const appKey = toolOptions.mcp && ((_toolOptions_mcp_app = toolOptions.mcp.app) == null ? void 0 : _toolOptions_mcp_app.resourceKey);
|
|
6181
6202
|
if (appKey && !appKeys.has(appKey)) {
|
|
6182
6203
|
throw new Error(`MCP Tool '${toolOptions.name}' references undeclared App '${appKey}'.`);
|
|
@@ -6574,12 +6595,21 @@ class DecoratedAgentMiddlewareStrategy {
|
|
|
6574
6595
|
return this.descriptor.tools.filter((item)=>item.middlewareProvider === this.provider).map((item)=>item.options.name);
|
|
6575
6596
|
}
|
|
6576
6597
|
async createMiddleware(options, context) {
|
|
6598
|
+
var _this_descriptor_options_apps;
|
|
6577
6599
|
const tools = this.descriptor.tools.filter((item)=>item.middlewareProvider === this.provider).map((item)=>createAgentTool(this.instance, item, context, options));
|
|
6578
6600
|
const extensions = await (this.instance.getMiddlewareExtensions == null ? void 0 : this.instance.getMiddlewareExtensions.call(this.instance, this.provider, options, context));
|
|
6579
6601
|
return _extends({}, extensions != null ? extensions : {}, {
|
|
6580
6602
|
name: this.provider,
|
|
6581
6603
|
tools
|
|
6582
|
-
})
|
|
6604
|
+
}, ((_this_descriptor_options_apps = this.descriptor.options.apps) == null ? void 0 : _this_descriptor_options_apps.length) ? {
|
|
6605
|
+
apps: {
|
|
6606
|
+
definitions: this.descriptor.options.apps,
|
|
6607
|
+
tools: Object.fromEntries(this.descriptor.tools.filter((item)=>item.middlewareProvider === this.provider && item.options.app).map((item)=>[
|
|
6608
|
+
item.options.name,
|
|
6609
|
+
item.options.app
|
|
6610
|
+
]))
|
|
6611
|
+
}
|
|
6612
|
+
} : {});
|
|
6583
6613
|
}
|
|
6584
6614
|
constructor(instance, descriptor, provider){
|
|
6585
6615
|
var _descriptor_options_middlewares;
|
|
@@ -9739,4 +9769,37 @@ function stableJson(value) {
|
|
|
9739
9769
|
return `{${entries.map(([key, item])=>`${JSON.stringify(key)}:${stableJson(item)}`).join(',')}}`;
|
|
9740
9770
|
}
|
|
9741
9771
|
|
|
9742
|
-
|
|
9772
|
+
const PROJECT_TYPE_PROVIDER = 'PROJECT_TYPE_PROVIDER';
|
|
9773
|
+
/** Register the stable provider key used by entity-backed App project type declarations. */ const ProjectTypeProvider = (key)=>applyDecorators(SetMetadata(PROJECT_TYPE_PROVIDER, key), SetMetadata(STRATEGY_META_KEY, PROJECT_TYPE_PROVIDER));
|
|
9774
|
+
let ProjectTypeProviderRegistry = class ProjectTypeProviderRegistry extends BaseStrategyRegistry {
|
|
9775
|
+
constructor(discovery, reflector){
|
|
9776
|
+
super(PROJECT_TYPE_PROVIDER, discovery, reflector);
|
|
9777
|
+
}
|
|
9778
|
+
};
|
|
9779
|
+
ProjectTypeProviderRegistry = __decorate([
|
|
9780
|
+
Injectable(),
|
|
9781
|
+
__metadata("design:paramtypes", [
|
|
9782
|
+
DiscoveryService,
|
|
9783
|
+
Reflector
|
|
9784
|
+
])
|
|
9785
|
+
], ProjectTypeProviderRegistry);
|
|
9786
|
+
|
|
9787
|
+
const PROJECT_TASK_PROVIDER = 'PROJECT_TASK_PROVIDER';
|
|
9788
|
+
const ProjectTaskProvider = (key)=>applyDecorators(SetMetadata(PROJECT_TASK_PROVIDER, key), SetMetadata(STRATEGY_META_KEY, PROJECT_TASK_PROVIDER));
|
|
9789
|
+
let ProjectTaskProviderRegistry = class ProjectTaskProviderRegistry extends BaseStrategyRegistry {
|
|
9790
|
+
constructor(discovery, reflector){
|
|
9791
|
+
super(PROJECT_TASK_PROVIDER, discovery, reflector);
|
|
9792
|
+
}
|
|
9793
|
+
};
|
|
9794
|
+
ProjectTaskProviderRegistry = __decorate([
|
|
9795
|
+
Injectable(),
|
|
9796
|
+
__metadata("design:paramtypes", [
|
|
9797
|
+
DiscoveryService,
|
|
9798
|
+
Reflector
|
|
9799
|
+
])
|
|
9800
|
+
], ProjectTaskProviderRegistry);
|
|
9801
|
+
const ProjectTasksRuntimeCapability = createRuntimeCapability('platform.project.tasks', {
|
|
9802
|
+
description: 'Read project task graphs, manage schedules, and resolve exact execution conversations.'
|
|
9803
|
+
});
|
|
9804
|
+
|
|
9805
|
+
export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AGENT_RUNTIME_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ASSISTANT_CAPABILITY_PROVIDER, AdapterDataSourceStrategy, AgentInvocationRuntimeCapability, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AgentRuntimeFactoryCapability, AgentRuntimeRegistry, AgentRuntimeStrategy, AiModelNotFoundException, AssistantCapabilityProvider, AssistantCapabilityProviderRegistry, 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, EvolutionBaselineRuntimeCapability, 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, KEYWORD_ANALYZER_STRATEGY, KNOWLEDGE_STRATEGY, KeywordAnalyzerRegistry, KeywordAnalyzerStrategy, 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, PROJECT_TASK_PROVIDER, PROJECT_TYPE_PROVIDER, 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, ProjectTaskProvider, ProjectTaskProviderRegistry, ProjectTasksRuntimeCapability, ProjectTypeProvider, ProjectTypeProviderRegistry, 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, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XPERT_TOOL_RESULT_FORMAT_VERSION, XpFileSystem, XpertPrompt, XpertResource, XpertResourceTemplate, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, chunkText, countTextTokens, 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, isAgentInvocationTerminal, 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, resolveXpertMcpExtensions, runWithRequestContext, runtimeToolProviderComponent, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage, textTokenBoundaries };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@langchain/openai": "0.6.9",
|
|
59
|
-
"@xpert-ai/contracts": "3.
|
|
59
|
+
"@xpert-ai/contracts": "3.19.0",
|
|
60
60
|
"express": "^4.22.1",
|
|
61
61
|
"js-tiktoken": "^1.0.21"
|
|
62
62
|
},
|
package/runtime-capabilities.md
CHANGED
|
@@ -47,3 +47,38 @@ Reuse the returned API during that one operation. Create a new API for the next
|
|
|
47
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
48
|
|
|
49
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.
|
|
50
|
+
|
|
51
|
+
## Agent invocation
|
|
52
|
+
|
|
53
|
+
Agent runtime extension contracts live under `src/lib/agent/runtime` and are
|
|
54
|
+
exported from `@xpert-ai/plugin-sdk`. `AgentRuntimeFactory`, strategies and the
|
|
55
|
+
registry describe the execution mechanism; `AgentInvocation*` types describe an
|
|
56
|
+
individual call. Renaming the factory does not change capability identifiers.
|
|
57
|
+
|
|
58
|
+
`AgentInvocationRuntimeCapability` is the scoped consumer API for invoking an
|
|
59
|
+
approved Agent binding. Resolve the binding immediately before starting a call;
|
|
60
|
+
provide the host tool-call/operation ID for idempotency. The API captures identity
|
|
61
|
+
and rechecks workspace grants, target revision and provider provenance. Tools
|
|
62
|
+
cannot supply user/organization identity or arbitrary runner configuration.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
const api = context.runtime.capabilities.require(AgentInvocationRuntimeCapability)
|
|
66
|
+
const target = await api.resolve(bindingId)
|
|
67
|
+
const invocation = await api.start({ target, callId: toolCallId, input: { prompt } })
|
|
68
|
+
// wait mode uses the host checkpoint adapter; background mode returns the ID.
|
|
69
|
+
const completed = await api.awaitResult(invocation.id)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`inspect`, `cancel` and `respond` operate on the same invocation. A cancelling or
|
|
73
|
+
unknown state is not proof of termination. Caller jobs may use
|
|
74
|
+
`AgentRuntimeFactoryCapability` with a host-authorized identity;
|
|
75
|
+
never accept that identity from model arguments.
|
|
76
|
+
|
|
77
|
+
Providers implement `IAgentRuntimeStrategy` and use `@AgentRuntimeStrategy(key)`.
|
|
78
|
+
Persist a receipt with `context.checkpoint` before waiting for external work.
|
|
79
|
+
Declare checkpoint/session/no recovery accurately; reattachment must not send an
|
|
80
|
+
ambiguous prompt again. The strategy contract contains no graph types. The host
|
|
81
|
+
owns binding authorization, persistence, idempotency, waiting and audit history.
|
|
82
|
+
The native Xpert graph and native background Task transports are separate
|
|
83
|
+
strategies behind that same boundary. Providers must not call the Task facade
|
|
84
|
+
back from their own executor.
|
package/src/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './lib/data/index';
|
|
|
14
14
|
export * from './lib/ai-model/index';
|
|
15
15
|
export * from './lib/runtime/index';
|
|
16
16
|
export * from './lib/agent/index';
|
|
17
|
+
export * from './lib/assistant-capability/index';
|
|
17
18
|
export * from './lib/channel/index';
|
|
18
19
|
export * from './lib/file/index';
|
|
19
20
|
export * from './lib/strategy';
|
|
@@ -27,3 +28,5 @@ export * from './lib/collaboration/index';
|
|
|
27
28
|
export * from './lib/evolution/index';
|
|
28
29
|
export * from './lib/mcp/index';
|
|
29
30
|
export * from './lib/tool-provider/index';
|
|
31
|
+
export * from './lib/project-type/index';
|
|
32
|
+
export * from './lib/project-task/index';
|
package/src/lib/agent/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { JSONValue, TAvatar } from '@xpert-ai/contracts';
|
|
2
|
+
/** Task lifecycle snapshot. interrupted means paused; unknown does not confirm failure. */
|
|
2
3
|
export type AgentMiddlewareAssistantTaskStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'interrupted' | 'unknown';
|
|
4
|
+
/** Existing platform file reference; access remains subject to host authorization. */
|
|
3
5
|
export type AgentMiddlewareAssistantTaskFile = {
|
|
4
6
|
id?: string;
|
|
5
7
|
fileId?: string;
|
|
@@ -13,33 +15,27 @@ export type AgentMiddlewareAssistantTaskFile = {
|
|
|
13
15
|
role?: string;
|
|
14
16
|
};
|
|
15
17
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* Plugin-owned callers must not persist workspace-local SkillPackage UUIDs.
|
|
19
|
-
* The host resolves this portable identity to the installed package and verifies
|
|
20
|
-
* that the target Agent is directly connected to the owning Skills Middleware.
|
|
18
|
+
* Portable plugin skill identity, resolved through the target Agent's connected Skills Middleware.
|
|
19
|
+
* Do not persist workspace-local SkillPackage UUIDs in plugin configuration.
|
|
21
20
|
*/
|
|
22
21
|
export type AgentMiddlewareAssistantTaskSkillRef = {
|
|
23
22
|
pluginName: string;
|
|
24
23
|
componentKey: string;
|
|
25
24
|
};
|
|
26
|
-
/**
|
|
27
|
-
* Portable role identity used to resolve an organization-owned Assistant.
|
|
28
|
-
* Instance UUIDs stay out of plugin contracts so the same workflow is deployable across organizations.
|
|
29
|
-
*/
|
|
25
|
+
/** Portable plugin/template/Agent identity used to resolve a deployed Assistant. */
|
|
30
26
|
export type AgentMiddlewareExternalAssistantExpectation = {
|
|
31
27
|
pluginName: string;
|
|
32
28
|
templateKey: string;
|
|
33
29
|
agentKey: string;
|
|
34
30
|
};
|
|
35
|
-
/** Resolve the executor from the requester's required, direct external-
|
|
31
|
+
/** Resolve the executor from the requester's required, direct published external-Assistant connections. */
|
|
36
32
|
export type AgentMiddlewareAssistantTaskTarget = {
|
|
37
33
|
kind: 'external_assistant';
|
|
38
34
|
requesterXpertId: string;
|
|
39
35
|
requesterAgentKey: string;
|
|
40
36
|
expectation: AgentMiddlewareExternalAssistantExpectation;
|
|
41
37
|
};
|
|
42
|
-
/**
|
|
38
|
+
/** Plugin-owned operation identity for reconciling executions with a domain subject. */
|
|
43
39
|
export type AgentMiddlewareExecutionCorrelation = {
|
|
44
40
|
namespace: string;
|
|
45
41
|
operationId: string;
|
|
@@ -48,7 +44,7 @@ export type AgentMiddlewareExecutionCorrelation = {
|
|
|
48
44
|
};
|
|
49
45
|
/** Availability of a resolved external Assistant binding. */
|
|
50
46
|
export type AgentMiddlewareExternalAssistantBindingStatus = 'available' | 'incompatible' | 'unpublished' | 'cross_organization';
|
|
51
|
-
/**
|
|
47
|
+
/** Binding display metadata; intentionally omits the deployed Assistant instance ID. */
|
|
52
48
|
export type AgentMiddlewareExternalAssistantBinding = {
|
|
53
49
|
title: string;
|
|
54
50
|
name: string;
|
|
@@ -63,12 +59,12 @@ export type AgentMiddlewareExternalAssistantBinding = {
|
|
|
63
59
|
publishedVersion?: string;
|
|
64
60
|
status: AgentMiddlewareExternalAssistantBindingStatus;
|
|
65
61
|
};
|
|
66
|
-
/**
|
|
62
|
+
/** Requester whose required direct external-Assistant bindings should be listed. */
|
|
67
63
|
export type AgentMiddlewareListExternalAssistantBindingsInput = {
|
|
68
64
|
requesterXpertId: string;
|
|
69
65
|
requesterAgentKey: string;
|
|
70
66
|
};
|
|
71
|
-
/**
|
|
67
|
+
/** Requester-scoped execution lookup for a plugin namespace and domain subject. */
|
|
72
68
|
export type AgentMiddlewareListCorrelatedExecutionsInput = {
|
|
73
69
|
requesterXpertId: string;
|
|
74
70
|
requesterAgentKey: string;
|
|
@@ -76,7 +72,7 @@ export type AgentMiddlewareListCorrelatedExecutionsInput = {
|
|
|
76
72
|
subjectId: string;
|
|
77
73
|
limit?: number;
|
|
78
74
|
};
|
|
79
|
-
/**
|
|
75
|
+
/** Execution receipt for domain reconciliation; executor fields identify the resolved published Assistant. */
|
|
80
76
|
export type AgentMiddlewareCorrelatedExecution = {
|
|
81
77
|
operationId: string;
|
|
82
78
|
subjectId: string;
|
|
@@ -93,27 +89,32 @@ export type AgentMiddlewareCorrelatedExecution = {
|
|
|
93
89
|
startedAt?: string;
|
|
94
90
|
updatedAt?: string;
|
|
95
91
|
};
|
|
92
|
+
/** Start an asynchronous task on the current Assistant or a resolved external Assistant. */
|
|
96
93
|
export type AgentMiddlewareAssistantTaskInput = {
|
|
94
|
+
/** Current/requesting Assistant ID; must match target.requesterXpertId when target is supplied. */
|
|
97
95
|
xpertId: string;
|
|
98
|
-
/** Selects the
|
|
96
|
+
/** Selects the base/Primary model; child Agents retain authored models. */
|
|
99
97
|
modelId?: string;
|
|
98
|
+
/** Entry Agent for the current Assistant; external targets use their resolved primary Agent. */
|
|
100
99
|
agentKey?: string;
|
|
101
|
-
/**
|
|
100
|
+
/** Optional external executor resolved from the requester's published graph. */
|
|
102
101
|
target?: AgentMiddlewareAssistantTaskTarget;
|
|
103
102
|
conversationId?: string | null;
|
|
104
103
|
executionId?: string | null;
|
|
105
104
|
projectId?: string | null;
|
|
106
105
|
taskId?: string;
|
|
106
|
+
/** Per-run idempotency key. Otherwise correlation.operationId or executionId is used; taskId alone is insufficient. */
|
|
107
107
|
clientMessageId?: string;
|
|
108
108
|
prompt: string;
|
|
109
109
|
files?: AgentMiddlewareAssistantTaskFile[];
|
|
110
|
-
/** Skills
|
|
110
|
+
/** Skills expected to load through the target Agent's connected Skills Middleware. */
|
|
111
111
|
selectedSkillRefs?: AgentMiddlewareAssistantTaskSkillRef[];
|
|
112
|
-
/** Additional bounded
|
|
112
|
+
/** Additional bounded runtime input; does not override the task prompt or files. */
|
|
113
113
|
humanInput?: Record<string, JSONValue>;
|
|
114
114
|
context?: Record<string, unknown>;
|
|
115
115
|
correlation?: AgentMiddlewareExecutionCorrelation;
|
|
116
116
|
};
|
|
117
|
+
/** Task receipt, not necessarily a completed result. Use status and execution identifiers to follow progress. */
|
|
117
118
|
export type AgentMiddlewareAssistantTaskResult = {
|
|
118
119
|
status: AgentMiddlewareAssistantTaskStatus;
|
|
119
120
|
taskId?: string;
|
|
@@ -127,6 +128,7 @@ export type AgentMiddlewareAssistantTaskResult = {
|
|
|
127
128
|
executorAssistantTitle?: string;
|
|
128
129
|
executorPublishedVersion?: string;
|
|
129
130
|
};
|
|
131
|
+
/** Host task/execution identifiers for lookup. Cancellation requires an execution, conversation or thread ID. */
|
|
130
132
|
export type AgentMiddlewareAssistantTaskStatusInput = {
|
|
131
133
|
taskId?: string;
|
|
132
134
|
executionId?: string;
|
|
@@ -135,17 +137,50 @@ export type AgentMiddlewareAssistantTaskStatusInput = {
|
|
|
135
137
|
clientMessageId?: string;
|
|
136
138
|
xpertId?: string;
|
|
137
139
|
};
|
|
140
|
+
/** Platform executions affected by the cancellation request. */
|
|
138
141
|
export type AgentMiddlewareAssistantTaskCancelResult = {
|
|
139
142
|
canceledExecutionIds: string[];
|
|
140
143
|
};
|
|
144
|
+
/** Host Assistant Task API. Feature-detect optional methods before calling them. */
|
|
141
145
|
export interface AgentMiddlewareAssistantTaskApi {
|
|
146
|
+
/**
|
|
147
|
+
* Verify that a running native delegate is the requester's bound external role.
|
|
148
|
+
*
|
|
149
|
+
* Re-resolves the requester's direct, required external-Assistant connections on
|
|
150
|
+
* every call. Exactly one candidate must match the plugin, template and primary
|
|
151
|
+
* Agent identity, be published and active in the same organization, and have
|
|
152
|
+
* the same instance ID as the actual executor. This only validates a binding;
|
|
153
|
+
* it does not create a task, invoke an Assistant or authorize domain artifacts.
|
|
154
|
+
*
|
|
155
|
+
* @param input - Requester identity, actual runtime executor and expected role.
|
|
156
|
+
* @param input.requesterXpertId - Assistant that owns the external connection.
|
|
157
|
+
* @param input.requesterAgentKey - The requesting Assistant's primary Agent key.
|
|
158
|
+
* @param input.executorXpertId - Actual executor ID from the trusted runtime context.
|
|
159
|
+
* @param input.expectation - Portable plugin, template and primary Agent identity.
|
|
160
|
+
* @returns Validated binding metadata with instance and workspace IDs omitted.
|
|
161
|
+
* @throws If the binding is missing, ambiguous, unpublished, incompatible, or
|
|
162
|
+
* the resolved instance differs from the runtime executor.
|
|
163
|
+
*/
|
|
164
|
+
assertExternalAssistantBinding?(input: {
|
|
165
|
+
requesterXpertId: string;
|
|
166
|
+
requesterAgentKey: string;
|
|
167
|
+
executorXpertId: string;
|
|
168
|
+
expectation: {
|
|
169
|
+
pluginName: string;
|
|
170
|
+
templateKey: string;
|
|
171
|
+
agentKey: string;
|
|
172
|
+
};
|
|
173
|
+
}): Promise<AgentMiddlewareExternalAssistantBinding>;
|
|
142
174
|
getModels?(xpertId: string): Promise<import('@xpert-ai/contracts').TAssistantModelsResponse>;
|
|
175
|
+
/** Submit once and retain the receipt; use getTaskStatus to follow asynchronous progress. */
|
|
143
176
|
startTask(input: AgentMiddlewareAssistantTaskInput): Promise<AgentMiddlewareAssistantTaskResult>;
|
|
144
|
-
/**
|
|
177
|
+
/** List safe binding descriptors without deployed Assistant instance IDs. */
|
|
145
178
|
listExternalAssistantBindings?(input: AgentMiddlewareListExternalAssistantBindingsInput): Promise<AgentMiddlewareExternalAssistantBinding[]>;
|
|
146
179
|
/** Read executions owned by the requester and its currently bound external Assistants. */
|
|
147
180
|
listCorrelatedExecutions?(input: AgentMiddlewareListCorrelatedExecutionsInput): Promise<AgentMiddlewareCorrelatedExecution[]>;
|
|
181
|
+
/** Return the current receipt, or null if no matching task is found. */
|
|
148
182
|
getTaskStatus?(input: AgentMiddlewareAssistantTaskStatusInput): Promise<AgentMiddlewareAssistantTaskResult | null>;
|
|
149
183
|
cancelTask?(input: AgentMiddlewareAssistantTaskStatusInput): Promise<AgentMiddlewareAssistantTaskCancelResult>;
|
|
150
184
|
}
|
|
185
|
+
/** Scoped runtime capability for platform Assistant tasks. */
|
|
151
186
|
export declare const AssistantTaskRuntimeCapability: import("../../../core/runtime-capability").RuntimeCapabilityKey<AgentMiddlewareAssistantTaskApi>;
|
|
@@ -107,7 +107,10 @@ export type AfterAgentHook<TSchema extends InteropZodObject | undefined = undefi
|
|
|
107
107
|
*/
|
|
108
108
|
export interface ModelRequest<TState extends Record<string, unknown> = Record<string, unknown>, TContext = unknown> {
|
|
109
109
|
/**
|
|
110
|
-
* The model to use for this step.
|
|
110
|
+
* The unbound model to use for this step. Middleware may replace it before
|
|
111
|
+
* the host binds the final tool selection or structured output schema.
|
|
112
|
+
* Replacements must expose bindTools/withStructuredOutput when those features
|
|
113
|
+
* are used. A plain Runnable is supported for calls without either feature.
|
|
111
114
|
*/
|
|
112
115
|
model: LanguageModelLike;
|
|
113
116
|
/**
|
|
@@ -116,7 +119,8 @@ export interface ModelRequest<TState extends Record<string, unknown> = Record<st
|
|
|
116
119
|
messages: BaseMessage[];
|
|
117
120
|
systemMessage?: SystemMessage;
|
|
118
121
|
/**
|
|
119
|
-
*
|
|
122
|
+
* Portable tool choice configuration, applied by the host after selection.
|
|
123
|
+
* A named tool must remain selected; "required" needs a non-empty selection.
|
|
120
124
|
* Can be one of:
|
|
121
125
|
* - `"auto"`: means the model can pick between generating a message or calling one or more tools.
|
|
122
126
|
* - `"none"`: means the model will not call any tool and instead generates a message.
|
|
@@ -130,7 +134,11 @@ export interface ModelRequest<TState extends Record<string, unknown> = Record<st
|
|
|
130
134
|
};
|
|
131
135
|
};
|
|
132
136
|
/**
|
|
133
|
-
* The tools to make available for this step.
|
|
137
|
+
* The registered tools to make available for this step. Return a subset of
|
|
138
|
+
* these instances (or an empty array) to change the model's available tools.
|
|
139
|
+
* New definitions, cloned tools and schema replacements require separate
|
|
140
|
+
* runtime registration so that every advertised tool has an execution route.
|
|
141
|
+
* Selection does not replace authorization at the tool execution boundary.
|
|
134
142
|
*/
|
|
135
143
|
tools: (ServerTool | ClientTool)[];
|
|
136
144
|
/**
|
|
@@ -225,6 +233,8 @@ export interface AgentMiddleware<TSchema extends InteropZodObject | undefined =
|
|
|
225
233
|
*/
|
|
226
234
|
contextSchema?: TContextSchema;
|
|
227
235
|
tools?: DynamicStructuredTool[];
|
|
236
|
+
/** Resource-backed MCP Apps and explicit model/App tool visibility. */
|
|
237
|
+
apps?: import('../../mcp/app').MiddlewareMcpApps;
|
|
228
238
|
beforeAgent?: BeforeAgentHook<TSchema, TFullContext>;
|
|
229
239
|
beforeModel?: BeforeModelHook<TSchema, TFullContext>;
|
|
230
240
|
afterModel?: AfterModelHook<TSchema, TFullContext>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AgentInvocation, AgentInvocationRequest, AgentJson, AgentTarget } from './types';
|
|
2
|
+
import type { RuntimeIdentityScope } from '../../runtime/runtime-scope';
|
|
3
|
+
/** Invocation API bound to one authorized caller/execution. Each operation revalidates access. */
|
|
4
|
+
export interface AgentInvocationApi {
|
|
5
|
+
/** Resolve a binding to a pinned target. Optional on hosts with pre-resolved native targets. */
|
|
6
|
+
resolve?(bindingId: string): Promise<AgentTarget>;
|
|
7
|
+
/** Start or recover an idempotent request. The returned snapshot may still be running. */
|
|
8
|
+
start(request: AgentInvocationRequest): Promise<AgentInvocation>;
|
|
9
|
+
/** Refresh an existing invocation, possibly persisting provider observations. Never relaunches work. */
|
|
10
|
+
inspect(invocationId: string): Promise<AgentInvocation>;
|
|
11
|
+
/** Request supported cancellation; cancelling does not confirm termination. */
|
|
12
|
+
cancel(invocationId: string): Promise<AgentInvocation>;
|
|
13
|
+
/** Answer the current interaction using its exact ID and provider-defined response schema. */
|
|
14
|
+
respond(invocationId: string, interactionId: string, response: AgentJson): Promise<AgentInvocation>;
|
|
15
|
+
/**
|
|
16
|
+
* Optional checkpoint-aware wait; returns a terminal or unknown observation.
|
|
17
|
+
* Allow host suspension to propagate instead of treating it as a tool failure.
|
|
18
|
+
*/
|
|
19
|
+
awaitResult?(invocationId: string): Promise<AgentInvocation>;
|
|
20
|
+
}
|
|
21
|
+
/** Caller-scoped API obtained through runtime.capabilities.require(...). */
|
|
22
|
+
export declare const AgentInvocationRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<AgentInvocationApi>;
|
|
23
|
+
/** Trusted host factory; scope must come from authenticated context, not model arguments. */
|
|
24
|
+
export interface AgentRuntimeFactory {
|
|
25
|
+
/** Create an API per caller/execution. Do not cache it as a global singleton. */
|
|
26
|
+
createScopedApi(scope: RuntimeIdentityScope): AgentInvocationApi;
|
|
27
|
+
}
|
|
28
|
+
/** Platform factory capability. The wire key is stable across SDK naming changes. */
|
|
29
|
+
export declare const AgentRuntimeFactoryCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<AgentRuntimeFactory>;
|