@xpert-ai/plugin-sdk 3.18.2 → 3.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +26 -1
  3. package/index.cjs.js +214 -28
  4. package/index.esm.js +210 -31
  5. package/model-provider.cjs.js +20 -3
  6. package/model-provider.esm.js +18 -4
  7. package/package.json +2 -2
  8. package/runtime-capabilities.md +49 -0
  9. package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +3 -0
  10. package/src/lib/agent/middleware/runtime.d.ts +2 -14
  11. package/src/lib/agent/middleware/strategy.interface.d.ts +2 -0
  12. package/src/lib/ai-model/types/rerank.d.ts +2 -0
  13. package/src/lib/connector/runtime-capability.d.ts +19 -0
  14. package/src/lib/core/runtime-capability.d.ts +2 -1
  15. package/src/lib/data/datasource/types.d.ts +7 -2
  16. package/src/lib/evolution/runtime-capability.d.ts +2 -1
  17. package/src/lib/runtime/capabilities/actor-token.d.ts +12 -0
  18. package/src/lib/runtime/capabilities/artifacts.d.ts +2 -0
  19. package/src/lib/runtime/capabilities/index.d.ts +1 -0
  20. package/src/lib/runtime/capabilities/knowledge-document-visual-assets.d.ts +16 -5
  21. package/src/lib/runtime/capabilities/knowledgebase-documents.d.ts +50 -1
  22. package/src/lib/runtime/capabilities/knowledgebase.d.ts +2 -1
  23. package/src/lib/runtime/capabilities/project-access.d.ts +30 -0
  24. package/src/lib/runtime/capabilities/project-provisioning.d.ts +8 -0
  25. package/src/lib/runtime/index.d.ts +1 -0
  26. package/src/lib/runtime/runtime-scope.d.ts +14 -0
  27. package/src/lib/tool-provider/adapters.d.ts +1 -0
  28. package/src/lib/tool-provider/index.d.ts +2 -0
  29. package/src/lib/tool-provider/prepared-result.d.ts +18 -0
  30. package/src/lib/tool-provider/tool-result.d.ts +16 -0
  31. package/src/lib/tool-provider/types.d.ts +8 -2
  32. package/src/lib/toolset/define-tool.d.ts +2 -1
  33. package/src/lib/types.d.ts +12 -1
@@ -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;
@@ -25,5 +25,7 @@ export interface IAgentMiddlewareContext {
25
25
  }
26
26
  export interface IAgentMiddlewareStrategy<T = unknown> {
27
27
  meta: TAgentMiddlewareMeta;
28
+ /** Static Tool names exposed by this Middleware, for capability summaries without creating a runtime instance. */
29
+ getToolNames?(options: T): readonly string[];
28
30
  createMiddleware(options: T, context: IAgentMiddlewareContext): PromiseOrValue<AgentMiddleware>;
29
31
  }
@@ -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>;
@@ -16,8 +16,9 @@ export interface RuntimeCapabilityRegistry {
16
16
  export type RuntimeCapabilityResolver = Pick<RuntimeCapabilityRegistry, 'get'>;
17
17
  export declare const XPERT_RUNTIME_CAPABILITIES_TOKEN = "XPERT_RUNTIME_CAPABILITIES";
18
18
  export declare class DefaultRuntimeCapabilityRegistry implements RuntimeCapabilityRegistry {
19
+ private readonly parent?;
19
20
  private readonly capabilities;
20
- constructor(entries?: Array<[RuntimeCapabilityKey<unknown> | string, unknown]>);
21
+ constructor(entries?: Array<[RuntimeCapabilityKey<unknown> | string, unknown]>, parent?: RuntimeCapabilityResolver);
21
22
  register<T>(key: RuntimeCapabilityKey<T> | string, implementation: T): this;
22
23
  has<T>(key: RuntimeCapabilityKey<T> | string): boolean;
23
24
  get<T>(key: RuntimeCapabilityKey<T> | string): T | undefined;
@@ -1,7 +1,7 @@
1
1
  import * as _axios from 'axios';
2
2
  import { Readable } from 'stream';
3
- import { IColumnDef, IDSSchema, IDSTable } from '@xpert-ai/contracts';
4
- export { IColumnDef, IDSSchema, IDSTable } from '@xpert-ai/contracts';
3
+ import { IColumnDef, IDataSourceCapabilityQuery, IDSSchema, IDSTable } from '@xpert-ai/contracts';
4
+ export { IColumnDef, IDataSourceCapabilityQuery, IDSSchema, IDSTable } from '@xpert-ai/contracts';
5
5
  /**
6
6
  * The base options for DB adapters
7
7
  */
@@ -82,6 +82,11 @@ export interface DBQueryRunner {
82
82
  * @param tableName
83
83
  */
84
84
  getSchema(catalog?: string, tableName?: string): Promise<IDSSchema[]>;
85
+ /**
86
+ * Runs an adapter-owned, read-only capability without exposing its domain
87
+ * contract through the host platform.
88
+ */
89
+ queryCapability?(query: IDataSourceCapabilityQuery): Promise<unknown>;
85
90
  /**
86
91
  * Describe a sql query result schema
87
92
  *
@@ -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 = {
@@ -6,3 +6,4 @@ export * from './artifacts';
6
6
  export * from './workspace-files';
7
7
  export * from './sandbox-jobs';
8
8
  export * from './project-provisioning';
9
+ export * from './project-access';
@@ -1,4 +1,5 @@
1
- import type { WorkspacePortableFileReference } from './workspace-files';
1
+ import type { RuntimeIdentityScope } from '../runtime-scope';
2
+ import type { WorkspaceFilesApi, WorkspacePortableFileReference } from './workspace-files';
2
3
  export type KnowledgeDocumentVisualCandidateReason = 'same_block' | 'same_chunk' | 'same_page' | 'adjacent_page' | 'visual_summary_match' | 'visual_only_fallback';
3
4
  export type KnowledgeDocumentVisualTextAnchor = {
4
5
  page?: number;
@@ -6,10 +7,9 @@ export type KnowledgeDocumentVisualTextAnchor = {
6
7
  sourceBlockIds?: string[];
7
8
  };
8
9
  export type KnowledgeDocumentVisualBusinessScope = {
9
- namespace: 'bom.requirement-evidence';
10
- caseId: string;
11
- baselineId: string;
12
- runId: string;
10
+ /** Plugin-owned audit namespace; document authorization remains host-owned. */
11
+ namespace: string;
12
+ attributes: Record<string, string>;
13
13
  sourceDocumentId: string;
14
14
  };
15
15
  export type KnowledgeDocumentVisualCandidateRequest = {
@@ -76,3 +76,14 @@ export interface KnowledgeDocumentVisualAssetsApi {
76
76
  discardImageBatch(batchRef: string): Promise<void>;
77
77
  }
78
78
  export declare const KnowledgeDocumentVisualAssetsRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<KnowledgeDocumentVisualAssetsApi>;
79
+ export type KnowledgeDocumentVisualAssetsRuntimeDependencies = {
80
+ /** File writer already bound to the authorized project/workspace. */
81
+ workspaceFiles: WorkspaceFilesApi;
82
+ /** Optional host resolver for child executions whose identity is assigned after graph construction. */
83
+ resolveExecutionScope?: () => RuntimeIdentityScope;
84
+ };
85
+ export interface KnowledgeDocumentVisualAssetsRuntimeFactory {
86
+ /** Every API owns a fresh allow-list; supplied scope must identify an authorized execution. */
87
+ createScopedApi(scope: RuntimeIdentityScope, dependencies: KnowledgeDocumentVisualAssetsRuntimeDependencies): KnowledgeDocumentVisualAssetsApi;
88
+ }
89
+ export declare const KnowledgeDocumentVisualAssetsRuntimeFactoryCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<KnowledgeDocumentVisualAssetsRuntimeFactory>;
@@ -1,4 +1,4 @@
1
- import { type I18nObject, JSONValue } from '@xpert-ai/contracts';
1
+ import { type I18nObject, type DocumentTextParserConfig, type DocumentSheetParserConfig, JSONValue } from '@xpert-ai/contracts';
2
2
  import type { WorkspacePortableFileReference } from './workspace-files';
3
3
  export type KnowledgebaseDocumentFile = {
4
4
  buffer: Buffer;
@@ -199,7 +199,56 @@ export type KnowledgebaseReadImageResult = {
199
199
  reference: WorkspacePortableFileReference;
200
200
  buffer: Buffer;
201
201
  };
202
+ /** Bounded, ordered source text. The host checks document read access on every page. */
203
+ export type KnowledgebaseReadTextInput = {
204
+ knowledgebaseId: string;
205
+ documentId: string;
206
+ offset?: number;
207
+ limit?: number;
208
+ };
209
+ export type KnowledgebaseReadTextResult = {
210
+ knowledgebaseId: string;
211
+ documentId: string;
212
+ version: number;
213
+ sourceHash?: string | null;
214
+ total: number;
215
+ chunks: Array<{
216
+ id: string;
217
+ text: string;
218
+ page?: number;
219
+ version: number;
220
+ }>;
221
+ };
222
+ export type KnowledgebaseProcessingOptionsInput = {
223
+ knowledgebaseId: string;
224
+ fileName: string;
225
+ /** Omit to use the Knowledge base's default for this file type. */
226
+ processor?: string;
227
+ transformerIntegration?: string;
228
+ };
229
+ export type KnowledgebaseProcessingOptionsResult = {
230
+ fileType: string;
231
+ defaultProcessor: string;
232
+ processor: string;
233
+ defaultSource: 'knowledgebase' | 'platform';
234
+ providers: Array<{
235
+ name: string;
236
+ label: I18nObject;
237
+ integrationProvider?: string;
238
+ }>;
239
+ integrations: Array<{
240
+ id: string;
241
+ name: string;
242
+ provider: string;
243
+ }>;
244
+ integrationRequired: boolean;
245
+ selectedIntegrationId?: string;
246
+ /** Server-only resolved settings. Do not expose configuration/credentials to an iframe. */
247
+ parserConfig: DocumentTextParserConfig & Partial<DocumentSheetParserConfig>;
248
+ };
202
249
  export interface KnowledgebaseDocumentsApi {
250
+ getProcessingOptions(input: KnowledgebaseProcessingOptionsInput): Promise<KnowledgebaseProcessingOptionsResult>;
251
+ readText(input: KnowledgebaseReadTextInput): Promise<KnowledgebaseReadTextResult>;
203
252
  listDocuments(input: KnowledgebaseListDocumentsInput): Promise<KnowledgebaseListDocumentsResult>;
204
253
  createFolder(input: KnowledgebaseCreateFolderInput): Promise<KnowledgebaseCreateFolderResult>;
205
254
  moveDocument(input: KnowledgebaseMoveDocumentInput): Promise<KnowledgebaseMoveDocumentResult>;
@@ -1,5 +1,5 @@
1
1
  import { JSONValue, KnowledgeFilterDiagnostics, KnowledgeFilterNode } from '@xpert-ai/contracts';
2
- export type KnowledgebaseRetrievalMode = 'vector' | 'graph' | 'hybrid';
2
+ export type KnowledgebaseRetrievalMode = 'vector' | 'keyword' | 'graph' | 'hybrid';
3
3
  export type KnowledgebaseMetadata = Record<string, JSONValue>;
4
4
  export type KnowledgebaseRetrievalSettings = {
5
5
  mode?: KnowledgebaseRetrievalMode;
@@ -15,6 +15,7 @@ export type KnowledgebaseSearchInput = {
15
15
  query: string;
16
16
  k?: number;
17
17
  score?: number;
18
+ rerankThreshold?: number;
18
19
  filter?: KnowledgeFilterNode;
19
20
  retrieval?: KnowledgebaseRetrievalSettings;
20
21
  source: string;
@@ -0,0 +1,30 @@
1
+ /** Trusted server actor. View providers derive this from host context; jobs persist that actor. */
2
+ export interface ProjectAccessActor {
3
+ tenantId: string;
4
+ organizationId?: string | null;
5
+ userId: string;
6
+ }
7
+ export interface ProjectHumanAccess {
8
+ projectId: string;
9
+ role: 'owner' | 'manager' | 'editor' | 'member';
10
+ canManage: boolean;
11
+ archived: boolean;
12
+ /** Explicit Project bindings, for plugins that choose to use assignment as business policy. */
13
+ assistantIds?: string[];
14
+ }
15
+ /** Human membership only. Assistant assignment and business authorization remain plugin-owned. */
16
+ export interface ProjectAccessApi {
17
+ listReadable(input: {
18
+ actor: ProjectAccessActor;
19
+ projectIds?: string[];
20
+ }): Promise<ProjectHumanAccess[]>;
21
+ assertEdit(input: {
22
+ actor: ProjectAccessActor;
23
+ projectId: string;
24
+ }): Promise<ProjectHumanAccess>;
25
+ assertManage(input: {
26
+ actor: ProjectAccessActor;
27
+ projectId: string;
28
+ }): Promise<ProjectHumanAccess>;
29
+ }
30
+ export declare const ProjectAccessRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ProjectAccessApi>;
@@ -37,5 +37,13 @@ export type ProjectEnsureResult = {
37
37
  export interface ProjectProvisioningApi {
38
38
  /** Create or reconcile a Chat Project without changing its caller-supplied id. */
39
39
  ensure(input: ProjectEnsureInput): Promise<ProjectEnsureResult>;
40
+ /** Owner-only physical deletion of an archived plugin-bound Project and its workspace. */
41
+ purge?(input: {
42
+ projectId: string;
43
+ xpertId: string;
44
+ }): Promise<{
45
+ projectId: string;
46
+ deleted: boolean;
47
+ }>;
40
48
  }
41
49
  export declare const ProjectProvisioningRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ProjectProvisioningApi>;
@@ -1,2 +1,3 @@
1
1
  export * from './runtime-capability';
2
+ export * from './runtime-scope';
2
3
  export * from './capabilities';
@@ -0,0 +1,14 @@
1
+ /** Host-authorized identity and execution binding; never accept this from tool arguments or HTTP bodies. */
2
+ export type RuntimeIdentityScope = {
3
+ tenantId?: string | null;
4
+ organizationId?: string | null;
5
+ userId?: string | null;
6
+ workspaceId?: string | null;
7
+ projectId?: string | null;
8
+ xpertId?: string | null;
9
+ xpertName?: string | null;
10
+ conversationId?: string | null;
11
+ threadId?: string | null;
12
+ agentKey?: string | null;
13
+ executionId?: string | null;
14
+ };
@@ -23,5 +23,6 @@ export declare class DecoratedAgentMiddlewareStrategy implements IAgentMiddlewar
23
23
  readonly provider: string;
24
24
  readonly meta: any;
25
25
  constructor(instance: XpertToolProviderInstance, descriptor: XpertToolProviderDescriptor, provider: string);
26
+ getToolNames(): readonly string[];
26
27
  createMiddleware(options: unknown, context: IAgentMiddlewareContext): Promise<AgentMiddleware>;
27
28
  }
@@ -4,3 +4,5 @@ export * from './descriptor';
4
4
  export * from './registry';
5
5
  export * from './adapters';
6
6
  export * from './coordinator';
7
+ export { XPERT_TOOL_RESULT_FORMAT_VERSION } from './tool-result';
8
+ export { prepareToolResult, type XpertPreparedToolResult, type XpertOutputDiagnostic } from './prepared-result';
@@ -0,0 +1,18 @@
1
+ import type { PromiseOrValue } from '../types';
2
+ declare const PREPARED_RESULT: unique symbol;
3
+ export interface XpertOutputDiagnostic {
4
+ code: 'tool_output_invalid';
5
+ issues: {
6
+ path: string;
7
+ code: string;
8
+ }[];
9
+ }
10
+ export interface XpertPreparedToolResult<T = unknown> {
11
+ readonly [PREPARED_RESULT]: true;
12
+ project(): PromiseOrValue<T>;
13
+ recover(diagnostic: XpertOutputDiagnostic): PromiseOrValue<T>;
14
+ }
15
+ /** Defer output projection until the adapter can validate and recover its result. */
16
+ export declare function prepareToolResult<T, TRecovery>(project: () => PromiseOrValue<T>, recover: (diagnostic: XpertOutputDiagnostic) => PromiseOrValue<TRecovery>): XpertPreparedToolResult<T | TRecovery>;
17
+ export declare function resolveToolResult<T>(value: unknown, validate: (output: unknown) => Promise<T>): Promise<T>;
18
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { ZodTypeAny } from 'zod/v3';
2
+ import type { XpertToolContent, XpertToolResult } from '../toolset/tool-result';
3
+ export declare const XPERT_TOOL_RESULT_FORMAT_VERSION = 1;
4
+ /** Validate the envelope separately so binary content never enters the business DTO. */
5
+ export declare function parseDecoratedToolResult(value: unknown, outputSchema: ZodTypeAny): Promise<XpertToolResult>;
6
+ export declare function agentContent(content: XpertToolContent[] | undefined): ({
7
+ type: string;
8
+ image_url: {
9
+ url: string;
10
+ };
11
+ text?: undefined;
12
+ } | {
13
+ type: string;
14
+ text: string;
15
+ image_url?: undefined;
16
+ })[];
@@ -1,4 +1,4 @@
1
- import type { IconDefinition, I18nObject, JsonSchemaObjectType, McpRequiredContext, McpToolBehavior, TAgentMiddlewareMeta } from '@xpert-ai/contracts';
1
+ import type { IconDefinition, I18nObject, JsonSchemaObjectType, McpRequiredContext, McpCapabilityApprovalMode, McpToolBehavior, TAgentMiddlewareMeta } from '@xpert-ai/contracts';
2
2
  import type { RunnableConfig } from '@langchain/core/runnables';
3
3
  import type { ZodTypeAny, infer as ZodInfer } from 'zod/v3';
4
4
  import type { AgentMiddleware } from '../agent/middleware/types';
@@ -6,6 +6,8 @@ import type { IAgentMiddlewareContext } from '../agent/middleware/strategy.inter
6
6
  import type { McpAppDefinition } from '../mcp/app';
7
7
  import type { ToolExecutionContext, ToolHostApi, ToolPrincipal } from '../toolset/tool-execution-context';
8
8
  import type { XpertToolAppBinding, XpertToolVisibility } from '../toolset/define-tool';
9
+ import type { XpertToolResult } from '../toolset/tool-result';
10
+ import type { XpertPreparedToolResult } from './prepared-result';
9
11
  import type { PromiseOrValue } from '../types';
10
12
  export type XpertBusinessToolSurface = 'middleware' | 'mcp';
11
13
  export interface XpertToolProviderMiddlewareDefinition {
@@ -38,6 +40,8 @@ export interface XpertToolProviderOptions {
38
40
  apps?: readonly McpAppDefinition[];
39
41
  }
40
42
  export interface XpertMcpToolOptions {
43
+ /** Default for auto-published tools; explicit administrator policy takes precedence. */
44
+ defaultApprovalMode?: McpCapabilityApprovalMode;
41
45
  behavior: McpToolBehavior;
42
46
  requiredContext: readonly McpRequiredContext[];
43
47
  visibility?: readonly XpertToolVisibility[];
@@ -50,6 +54,8 @@ export interface XpertToolOptions<TInputSchema extends ZodTypeAny = ZodTypeAny,
50
54
  description: string;
51
55
  inputSchema: TInputSchema;
52
56
  outputSchema?: TOutputSchema;
57
+ /** Opt in to standard content blocks; outputSchema validates structuredContent. */
58
+ resultFormat?: 'dto' | 'tool_result';
53
59
  /** true uses the class default, a string selects a declared group, false disables Middleware exposure. */
54
60
  middleware?: true | string | false;
55
61
  /** MCP exposure is opt-in. */
@@ -75,7 +81,7 @@ export interface XpertBusinessToolContext {
75
81
  host: ToolHostApi;
76
82
  middlewareOptions?: unknown;
77
83
  }
78
- export type XpertDecoratedToolMethod<TInputSchema extends ZodTypeAny = ZodTypeAny, TOutputSchema extends ZodTypeAny = ZodTypeAny> = (input: ZodInfer<TInputSchema>, context: XpertBusinessToolContext) => PromiseOrValue<ZodInfer<TOutputSchema>>;
84
+ export type XpertDecoratedToolMethod<TInputSchema extends ZodTypeAny = ZodTypeAny, TOutputSchema extends ZodTypeAny = ZodTypeAny> = (input: ZodInfer<TInputSchema>, context: XpertBusinessToolContext) => PromiseOrValue<ZodInfer<TOutputSchema> | XpertToolResult<ZodInfer<TOutputSchema>> | XpertPreparedToolResult>;
79
85
  export interface XpertToolProviderInstance {
80
86
  getMiddlewareExtensions?(provider: string, options: unknown, context: IAgentMiddlewareContext): PromiseOrValue<Omit<AgentMiddleware, 'name' | 'tools'>>;
81
87
  }
@@ -1,4 +1,4 @@
1
- import type { McpRequiredContext, McpToolBehavior } from '@xpert-ai/contracts';
1
+ import type { McpCapabilityApprovalMode, McpRequiredContext, McpToolBehavior } from '@xpert-ai/contracts';
2
2
  import type { ZodTypeAny, infer as ZodInfer } from 'zod/v3';
3
3
  import type { McpTaskExecutionPolicy } from '../mcp/task';
4
4
  import type { ToolExecutionContext } from './tool-execution-context';
@@ -21,6 +21,7 @@ export interface XpertToolDefinition<TInputSchema extends ZodTypeAny, TOutputSch
21
21
  outputSchema?: TOutputSchema;
22
22
  exposure: XpertToolExposure;
23
23
  behavior: McpToolBehavior;
24
+ defaultApprovalMode?: McpCapabilityApprovalMode;
24
25
  requiredContext: McpRequiredContext[];
25
26
  visibility?: XpertToolVisibility[];
26
27
  app?: XpertToolAppBinding;
@@ -51,7 +51,7 @@ export interface XpertPlugin<TConfig extends object = any> extends PluginLifecyc
51
51
  * template ids as `${pluginName}:${key}` when exposing them through the
52
52
  * xpert-template API.
53
53
  */
54
- templates?: XpertTemplateContribution[] | XpertTemplateProvider;
54
+ templates?: XpertTemplateContribution[] | XpertTemplateProvider | XpertTemplateCatalogProvider;
55
55
  /** Declares the required system-level permissions for this plugin. */
56
56
  permissions?: Permissions;
57
57
  /** Returns the DynamicModule to be mounted to the main application (can be set as global) */
@@ -78,6 +78,11 @@ export interface XpertTemplateContribution {
78
78
  startPrompts?: string[];
79
79
  promptWorkflows?: TPromptWorkflow[];
80
80
  releaseNotes?: string;
81
+ availableLocales?: string[];
82
+ defaultLocale?: string;
83
+ locale?: string;
84
+ pluginVersion?: string;
85
+ contentHash?: string;
81
86
  xpertName?: string;
82
87
  dependencies?: XpertTemplatePluginDependencies;
83
88
  [key: string]: unknown;
@@ -85,6 +90,12 @@ export interface XpertTemplateContribution {
85
90
  export interface XpertTemplateProvider {
86
91
  listTemplates(ctx: PluginContext): PromiseOrValue<XpertTemplateContribution[]>;
87
92
  }
93
+ /** Lists metadata without DSL; resolves exactly one immutable language variant on demand. */
94
+ export interface XpertTemplateCatalogProvider {
95
+ kind: 'catalog';
96
+ listTemplates(ctx: PluginContext): PromiseOrValue<XpertTemplateContribution[]>;
97
+ resolveTemplate(ctx: PluginContext, key: string, locale?: string): PromiseOrValue<XpertTemplateContribution>;
98
+ }
88
99
  export interface PluginContext<TConfig extends object = any> {
89
100
  module: ModuleRef;
90
101
  app?: INestApplicationContext;