@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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
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
|
|
10
|
-
|
|
11
|
-
|
|
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>;
|
|
@@ -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
|
+
};
|
|
@@ -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;
|
package/src/lib/types.d.ts
CHANGED
|
@@ -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;
|