@xpert-ai/plugin-sdk 0.0.3-0 → 3.6.0-beta.10
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/README.md +0 -1
- package/index.cjs.js +355 -56098
- package/index.esm.js +344 -56088
- package/package.json +14 -1
- package/src/lib/core/i18n.d.ts +2 -0
- package/src/lib/core/index.d.ts +1 -0
- package/src/lib/core/schema.d.ts +2 -2
- package/src/lib/integration/strategy.interface.d.ts +1 -0
- package/src/lib/knowledge/knowledge-strategy.interface.d.ts +1 -1
- package/src/lib/rag/image/strategy.interface.d.ts +4 -8
- package/src/lib/rag/retriever/strategy.interface.d.ts +1 -1
- package/src/lib/rag/source/strategy.interface.d.ts +11 -1
- package/src/lib/rag/textsplitter/strategy.interface.d.ts +1 -1
- package/src/lib/rag/transformer/strategy.interface.d.ts +3 -17
- package/src/lib/rag/types.d.ts +8 -0
- package/src/lib/types.d.ts +8 -8
package/package.json
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.6.0-beta.10",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"dependencies": {},
|
|
6
6
|
"main": "./index.cjs.js",
|
|
7
7
|
"module": "./index.esm.js",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@langchain/core": "*",
|
|
13
|
+
"@metad/contracts": "*",
|
|
14
|
+
"@nestjs/common": "*",
|
|
15
|
+
"@nestjs/core": "*",
|
|
16
|
+
"@nestjs/microservices": "*",
|
|
17
|
+
"lodash-es": "*",
|
|
18
|
+
"i18next-fs-backend": "*",
|
|
19
|
+
"i18next": "*",
|
|
20
|
+
"zod": "*",
|
|
21
|
+
"fs": "*",
|
|
22
|
+
"path": "*"
|
|
10
23
|
}
|
|
11
24
|
}
|
package/src/lib/core/index.d.ts
CHANGED
package/src/lib/core/schema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Common UI Schema field definitions
|
|
3
3
|
*/
|
|
4
4
|
export interface ISchemaUIBase {
|
|
5
5
|
component: string;
|
|
@@ -12,7 +12,7 @@ export interface ISchemaUIBase {
|
|
|
12
12
|
enabledWhen?: Record<string, any>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Secret
|
|
15
|
+
* Secret field extensions
|
|
16
16
|
*/
|
|
17
17
|
export interface ISchemaSecretField extends ISchemaUIBase {
|
|
18
18
|
component: 'secretInput';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Document } from '@langchain/core/documents';
|
|
1
2
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
2
|
-
import { IDocumentUnderstandingProvider } from '@metad/contracts';
|
|
3
|
-
import { Document } from 'langchain/document';
|
|
3
|
+
import { IDocumentUnderstandingProvider, IKnowledgeDocument } from '@metad/contracts';
|
|
4
4
|
import { Permissions, XpFileSystem } from '../../core/index';
|
|
5
|
-
import { ChunkMetadata
|
|
5
|
+
import { ChunkMetadata } from '../types';
|
|
6
6
|
export type TImageUnderstandingConfig = {
|
|
7
7
|
stage: 'test' | 'prod';
|
|
8
8
|
visionModel: BaseChatModel;
|
|
@@ -10,10 +10,6 @@ export type TImageUnderstandingConfig = {
|
|
|
10
10
|
fileSystem?: XpFileSystem;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export type TImageUnderstandingInput = {
|
|
14
|
-
chunks: Document<ChunkMetadata>[];
|
|
15
|
-
files: TDocumentAsset[];
|
|
16
|
-
};
|
|
17
13
|
export type TImageUnderstandingResult = {
|
|
18
14
|
chunks: Document<Partial<ChunkMetadata>>[];
|
|
19
15
|
pages?: Document<Partial<ChunkMetadata>>[];
|
|
@@ -32,5 +28,5 @@ export interface IImageUnderstandingStrategy<TConfig extends TImageUnderstanding
|
|
|
32
28
|
/**
|
|
33
29
|
* Understand image files (e.g., OCR, VLM, Chart Parsing)
|
|
34
30
|
*/
|
|
35
|
-
understandImages(
|
|
31
|
+
understandImages(doc: IKnowledgeDocument<ChunkMetadata>, config: TConfig): Promise<TImageUnderstandingResult>;
|
|
36
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VectorStore } from '@langchain/core/vectorstores';
|
|
2
2
|
import { I18nObject } from '@metad/contracts';
|
|
3
|
-
import { Document } from 'langchain/
|
|
3
|
+
import { Document } from '@langchain/core/documents';
|
|
4
4
|
export type TRetrieverConfig = {
|
|
5
5
|
vectorStore: VectorStore;
|
|
6
6
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDocumentSourceProvider, IIntegration } from '@metad/contracts';
|
|
2
|
-
import { Document } from 'langchain/
|
|
2
|
+
import { Document } from '@langchain/core/documents';
|
|
3
3
|
import { Permissions } from '../../core';
|
|
4
4
|
export interface IDocumentSourceStrategy<TConfig = any> {
|
|
5
5
|
readonly permissions: Permissions;
|
|
@@ -23,4 +23,14 @@ export interface IDocumentSourceStrategy<TConfig = any> {
|
|
|
23
23
|
loadDocuments(config: TConfig, context?: {
|
|
24
24
|
integration?: IIntegration;
|
|
25
25
|
}): Promise<Document[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Load a single document by its ID
|
|
28
|
+
*
|
|
29
|
+
* @deprecated Planning
|
|
30
|
+
* @param documentId
|
|
31
|
+
* @param context
|
|
32
|
+
*/
|
|
33
|
+
loadDocument?(document: Document, context: {
|
|
34
|
+
integration?: IIntegration;
|
|
35
|
+
}): Promise<Document>;
|
|
26
36
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDocumentChunkerProvider, KnowledgeStructureEnum } from '@metad/contracts';
|
|
2
|
-
import { Document } from 'langchain/
|
|
2
|
+
import { Document } from '@langchain/core/documents';
|
|
3
3
|
import { ChunkMetadata } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Split text content into chunks for embedding and retrieval
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _TFile, IDocumentProcessorProvider, IIntegration } from '@metad/contracts';
|
|
1
|
+
import { IDocumentProcessorProvider, IIntegration, IKnowledgeDocument } from '@metad/contracts';
|
|
3
2
|
import { Permissions, XpFileSystem } from '../../core/index';
|
|
4
|
-
import { ChunkMetadata
|
|
3
|
+
import { ChunkMetadata } from '../types';
|
|
5
4
|
export type TDocumentTransformerConfig = {
|
|
6
5
|
stage: 'test' | 'prod';
|
|
7
6
|
tempDir?: string;
|
|
@@ -10,19 +9,6 @@ export type TDocumentTransformerConfig = {
|
|
|
10
9
|
integration?: IIntegration;
|
|
11
10
|
};
|
|
12
11
|
};
|
|
13
|
-
export type TDocumentTransformerFile = _TFile & {
|
|
14
|
-
id?: string;
|
|
15
|
-
filename: string;
|
|
16
|
-
extension: string | undefined;
|
|
17
|
-
};
|
|
18
|
-
export type TDocumentTransformerInput = TDocumentTransformerFile[] | string | string[];
|
|
19
|
-
export type TDocumentTransformerResult = {
|
|
20
|
-
id?: string;
|
|
21
|
-
chunks: DocumentInterface<ChunkMetadata>[];
|
|
22
|
-
metadata: {
|
|
23
|
-
assets?: TDocumentAsset[];
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
12
|
export interface IDocumentTransformerStrategy<TConfig extends TDocumentTransformerConfig = TDocumentTransformerConfig> {
|
|
27
13
|
/**
|
|
28
14
|
* Metadata about this transformer
|
|
@@ -36,5 +22,5 @@ export interface IDocumentTransformerStrategy<TConfig extends TDocumentTransform
|
|
|
36
22
|
/**
|
|
37
23
|
* Transform documents (e.g., extract, OCR, normalize, enrich metadata)
|
|
38
24
|
*/
|
|
39
|
-
transformDocuments(files:
|
|
25
|
+
transformDocuments(files: Partial<IKnowledgeDocument>[], config: TConfig): Promise<Partial<IKnowledgeDocument<ChunkMetadata>>[]>;
|
|
40
26
|
}
|
package/src/lib/rag/types.d.ts
CHANGED
|
@@ -13,7 +13,15 @@ export interface ChunkMetadata {
|
|
|
13
13
|
startOffset?: number;
|
|
14
14
|
endOffset?: number;
|
|
15
15
|
type?: 'parent' | 'child';
|
|
16
|
+
/**
|
|
17
|
+
* Default to 'text'. Indicates the original media type of the chunk.
|
|
18
|
+
* @default text
|
|
19
|
+
*/
|
|
20
|
+
mediaType?: 'text' | 'image' | 'video' | 'audio';
|
|
16
21
|
children?: DocumentInterface<ChunkMetadata>[];
|
|
22
|
+
/**
|
|
23
|
+
* Associated assets like images, videos, etc.
|
|
24
|
+
*/
|
|
17
25
|
assets?: TDocumentAsset[];
|
|
18
26
|
[key: string]: any;
|
|
19
27
|
}
|
package/src/lib/types.d.ts
CHANGED
|
@@ -2,15 +2,15 @@ import { PluginMeta } from '@metad/contracts';
|
|
|
2
2
|
import type { DynamicModule, INestApplicationContext } from '@nestjs/common';
|
|
3
3
|
import type { ZodSchema } from 'zod';
|
|
4
4
|
export interface PluginLifecycle {
|
|
5
|
-
/**
|
|
5
|
+
/** Called after module registration but before application startup */
|
|
6
6
|
onInit?(ctx: PluginContext): Promise<void> | void;
|
|
7
|
-
/**
|
|
7
|
+
/** Called after application startup (can start serving externally) */
|
|
8
8
|
onStart?(ctx: PluginContext): Promise<void> | void;
|
|
9
|
-
/**
|
|
9
|
+
/** Called during graceful shutdown */
|
|
10
10
|
onStop?(ctx: PluginContext): Promise<void> | void;
|
|
11
11
|
}
|
|
12
12
|
export interface PluginHealth {
|
|
13
|
-
/**
|
|
13
|
+
/** Returns health status and optional dependency check details */
|
|
14
14
|
checkHealth?(ctx: PluginContext): Promise<{
|
|
15
15
|
status: 'up' | 'down';
|
|
16
16
|
details?: any;
|
|
@@ -20,22 +20,22 @@ export interface PluginHealth {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
export interface PluginConfigSpec<T extends object = any> {
|
|
23
|
-
/**
|
|
23
|
+
/** Zod validation schema for plugin-level config (optional) */
|
|
24
24
|
schema?: ZodSchema<T>;
|
|
25
|
-
/**
|
|
25
|
+
/** Default configuration */
|
|
26
26
|
defaults?: Partial<T>;
|
|
27
27
|
}
|
|
28
28
|
export interface XpertPlugin<TConfig extends object = any> extends PluginLifecycle, PluginHealth {
|
|
29
29
|
meta: PluginMeta;
|
|
30
30
|
config?: PluginConfigSpec<TConfig>;
|
|
31
|
-
/**
|
|
31
|
+
/** Returns the DynamicModule to be mounted to the main application (can be set as global) */
|
|
32
32
|
register(ctx: PluginContext<TConfig>): DynamicModule;
|
|
33
33
|
}
|
|
34
34
|
export interface PluginContext<TConfig extends object = any> {
|
|
35
35
|
app: INestApplicationContext;
|
|
36
36
|
logger: PluginLogger;
|
|
37
37
|
config: TConfig;
|
|
38
|
-
/**
|
|
38
|
+
/** Helper method to access other Providers in the container */
|
|
39
39
|
resolve<TInput = any, TResult = TInput>(token: any): TResult;
|
|
40
40
|
}
|
|
41
41
|
export interface PluginLogger {
|