@xpert-ai/plugin-sdk 3.6.0-beta.10 → 3.6.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.
Files changed (136) hide show
  1. package/.eslintrc.json +30 -0
  2. package/.swcrc +29 -0
  3. package/SCHEMA_SPECIFICATION.md +2 -0
  4. package/index.cjs.js +5 -649
  5. package/jest.config.ts +28 -0
  6. package/package.json +3 -3
  7. package/project.json +59 -0
  8. package/src/index.ts +11 -0
  9. package/src/lib/core/file-system.ts +113 -0
  10. package/src/lib/core/i18n.ts +31 -0
  11. package/src/lib/core/index.ts +4 -0
  12. package/src/lib/core/permissions.ts +97 -0
  13. package/src/lib/core/schema.ts +23 -0
  14. package/src/lib/integration/index.ts +3 -0
  15. package/src/lib/integration/strategy.decorator.ts +6 -0
  16. package/src/lib/integration/strategy.interface.ts +11 -0
  17. package/src/lib/integration/strategy.registry.ts +12 -0
  18. package/src/lib/logger.ts +18 -0
  19. package/src/lib/plugin-metadata.ts +20 -0
  20. package/src/lib/{plugin.hook.d.ts → plugin.hook.ts} +4 -0
  21. package/src/lib/plugin.interface.ts +67 -0
  22. package/src/lib/plugin.ts +32 -0
  23. package/src/lib/rag/image/index.ts +3 -0
  24. package/src/lib/rag/image/strategy.decorator.ts +9 -0
  25. package/src/lib/rag/image/strategy.interface.ts +37 -0
  26. package/src/lib/rag/image/strategy.registry.ts +17 -0
  27. package/src/lib/rag/index.ts +7 -0
  28. package/src/lib/rag/knowledge/index.ts +3 -0
  29. package/src/lib/rag/knowledge/knowledge-strategy.decorator.ts +6 -0
  30. package/src/lib/rag/knowledge/knowledge-strategy.interface.ts +15 -0
  31. package/src/lib/rag/knowledge/knowledge-strategy.registry.ts +12 -0
  32. package/src/lib/rag/retriever/index.ts +3 -0
  33. package/src/lib/rag/retriever/strategy.decorator.ts +9 -0
  34. package/src/lib/rag/retriever/strategy.interface.ts +32 -0
  35. package/src/lib/rag/retriever/strategy.registry.ts +12 -0
  36. package/src/lib/rag/source/index.ts +3 -0
  37. package/src/lib/rag/source/strategy.decorator.ts +9 -0
  38. package/src/lib/rag/source/strategy.interface.ts +36 -0
  39. package/src/lib/rag/source/strategy.registry.ts +17 -0
  40. package/src/lib/rag/textsplitter/index.ts +3 -0
  41. package/src/lib/rag/textsplitter/strategy.decorator.ts +6 -0
  42. package/src/lib/rag/textsplitter/strategy.interface.ts +28 -0
  43. package/src/lib/rag/textsplitter/strategy.registry.ts +17 -0
  44. package/src/lib/rag/transformer/index.ts +3 -0
  45. package/src/lib/rag/transformer/strategy.decorator.ts +9 -0
  46. package/src/lib/rag/transformer/strategy.interface.ts +34 -0
  47. package/src/lib/rag/transformer/strategy.registry.ts +14 -0
  48. package/src/lib/rag/types.ts +76 -0
  49. package/src/lib/strategy.ts +37 -0
  50. package/src/lib/toolset/builtin.ts +111 -0
  51. package/src/lib/toolset/index.ts +5 -0
  52. package/src/lib/toolset/strategy.decorator.ts +9 -0
  53. package/src/lib/toolset/strategy.interface.ts +32 -0
  54. package/src/lib/toolset/strategy.registry.ts +17 -0
  55. package/src/lib/toolset/toolset.ts +76 -0
  56. package/src/lib/types.ts +47 -0
  57. package/src/lib/vectorstore/index.ts +3 -0
  58. package/src/lib/vectorstore/strategy.decorator.ts +6 -0
  59. package/src/lib/vectorstore/strategy.interface.ts +25 -0
  60. package/src/lib/vectorstore/strategy.registry.ts +17 -0
  61. package/src/lib/workflow/index.ts +2 -0
  62. package/src/lib/workflow/node/index.ts +3 -0
  63. package/src/lib/workflow/node/strategy.decorator.ts +9 -0
  64. package/src/lib/workflow/node/strategy.interface.ts +51 -0
  65. package/src/lib/workflow/node/strategy.registry.ts +18 -0
  66. package/src/lib/workflow/trigger/index.ts +3 -0
  67. package/src/lib/workflow/trigger/strategy.decorator.ts +6 -0
  68. package/src/lib/workflow/trigger/strategy.interface.ts +27 -0
  69. package/src/lib/workflow/trigger/strategy.registry.ts +17 -0
  70. package/tsconfig.json +22 -0
  71. package/tsconfig.lib.json +10 -0
  72. package/tsconfig.spec.json +9 -0
  73. package/index.cjs.d.ts +0 -1
  74. package/index.esm.d.ts +0 -1
  75. package/index.esm.js +0 -616
  76. package/src/index.d.ts +0 -12
  77. package/src/lib/core/file-system.d.ts +0 -42
  78. package/src/lib/core/i18n.d.ts +0 -2
  79. package/src/lib/core/index.d.ts +0 -4
  80. package/src/lib/core/permissions.d.ts +0 -74
  81. package/src/lib/core/schema.d.ts +0 -22
  82. package/src/lib/integration/index.d.ts +0 -3
  83. package/src/lib/integration/strategy.decorator.d.ts +0 -2
  84. package/src/lib/integration/strategy.interface.d.ts +0 -9
  85. package/src/lib/integration/strategy.registry.d.ts +0 -6
  86. package/src/lib/knowledge/index.d.ts +0 -3
  87. package/src/lib/knowledge/knowledge-strategy.decorator.d.ts +0 -2
  88. package/src/lib/knowledge/knowledge-strategy.interface.d.ts +0 -15
  89. package/src/lib/knowledge/knowledge-strategy.registry.d.ts +0 -12
  90. package/src/lib/logger.d.ts +0 -2
  91. package/src/lib/plugin-metadata.d.ts +0 -17
  92. package/src/lib/plugin.d.ts +0 -8
  93. package/src/lib/plugin.interface.d.ts +0 -59
  94. package/src/lib/rag/image/index.d.ts +0 -3
  95. package/src/lib/rag/image/strategy.decorator.d.ts +0 -5
  96. package/src/lib/rag/image/strategy.interface.d.ts +0 -32
  97. package/src/lib/rag/image/strategy.registry.d.ts +0 -6
  98. package/src/lib/rag/index.d.ts +0 -6
  99. package/src/lib/rag/retriever/index.d.ts +0 -3
  100. package/src/lib/rag/retriever/strategy.decorator.d.ts +0 -5
  101. package/src/lib/rag/retriever/strategy.interface.d.ts +0 -30
  102. package/src/lib/rag/retriever/strategy.registry.d.ts +0 -6
  103. package/src/lib/rag/source/index.d.ts +0 -3
  104. package/src/lib/rag/source/strategy.decorator.d.ts +0 -5
  105. package/src/lib/rag/source/strategy.interface.d.ts +0 -36
  106. package/src/lib/rag/source/strategy.registry.d.ts +0 -6
  107. package/src/lib/rag/textsplitter/index.d.ts +0 -3
  108. package/src/lib/rag/textsplitter/strategy.decorator.d.ts +0 -2
  109. package/src/lib/rag/textsplitter/strategy.interface.d.ts +0 -24
  110. package/src/lib/rag/textsplitter/strategy.registry.d.ts +0 -6
  111. package/src/lib/rag/transformer/index.d.ts +0 -3
  112. package/src/lib/rag/transformer/strategy.decorator.d.ts +0 -5
  113. package/src/lib/rag/transformer/strategy.interface.d.ts +0 -26
  114. package/src/lib/rag/transformer/strategy.registry.d.ts +0 -6
  115. package/src/lib/rag/types.d.ts +0 -37
  116. package/src/lib/strategy.d.ts +0 -12
  117. package/src/lib/toolset/builtin.d.ts +0 -54
  118. package/src/lib/toolset/index.d.ts +0 -5
  119. package/src/lib/toolset/strategy.decorator.d.ts +0 -5
  120. package/src/lib/toolset/strategy.interface.d.ts +0 -28
  121. package/src/lib/toolset/strategy.registry.d.ts +0 -6
  122. package/src/lib/toolset/toolset.d.ts +0 -53
  123. package/src/lib/types.d.ts +0 -47
  124. package/src/lib/vectorstore/index.d.ts +0 -3
  125. package/src/lib/vectorstore/strategy.decorator.d.ts +0 -2
  126. package/src/lib/vectorstore/strategy.interface.d.ts +0 -24
  127. package/src/lib/vectorstore/strategy.registry.d.ts +0 -6
  128. package/src/lib/workflow/index.d.ts +0 -2
  129. package/src/lib/workflow/node/index.d.ts +0 -3
  130. package/src/lib/workflow/node/strategy.decorator.d.ts +0 -5
  131. package/src/lib/workflow/node/strategy.interface.d.ts +0 -40
  132. package/src/lib/workflow/node/strategy.registry.d.ts +0 -9
  133. package/src/lib/workflow/trigger/index.d.ts +0 -3
  134. package/src/lib/workflow/trigger/strategy.decorator.d.ts +0 -2
  135. package/src/lib/workflow/trigger/strategy.interface.d.ts +0 -22
  136. package/src/lib/workflow/trigger/strategy.registry.d.ts +0 -6
@@ -1,74 +0,0 @@
1
- /**
2
- * ===============================
3
- * Unified Permissions Definition
4
- * ===============================
5
- * Used by Agent / Plugin developers to declare required capabilities.
6
- * Core system will check and inject allowed resources accordingly.
7
- */
8
- /**
9
- * Base Permission type
10
- */
11
- export interface BasePermission {
12
- type: string;
13
- description?: string;
14
- }
15
- /**
16
- * 1. LLM Permission
17
- * Example: { type: 'llm', provider: 'openai', capability: 'vision' }
18
- */
19
- export interface LLMPermission extends BasePermission {
20
- type: 'llm';
21
- provider?: string;
22
- capability: 'text' | 'chat' | 'vision' | 'embedding';
23
- scope?: string[];
24
- maxTokens?: number;
25
- rateLimit?: {
26
- rps: number;
27
- };
28
- }
29
- /**
30
- * 2. Vector Store Permission
31
- * Example: { type: 'vectorstore', provider: 'pinecone', operations: ['insert', 'query'] }
32
- */
33
- export interface VectorStorePermission extends BasePermission {
34
- type: 'vectorstore';
35
- provider: string;
36
- operations: Array<'insert' | 'query' | 'delete'>;
37
- scope?: string[];
38
- }
39
- /**
40
- * 3. Knowledge Base Permission
41
- * Example: { type: 'knowledge', operations: ['read', 'write'], scope: ['kb_123'] }
42
- */
43
- export interface KnowledgePermission extends BasePermission {
44
- type: 'knowledge';
45
- operations: Array<'read' | 'write' | 'update' | 'delete'>;
46
- scope?: string[];
47
- }
48
- /**
49
- * 4. File System Permission
50
- * Example: { type: 'filesystem', operations: ['read', 'write'], scope: ['/documents', '/images'] }
51
- */
52
- export interface FileSystemPermission extends BasePermission {
53
- type: 'filesystem';
54
- operations: Array<'read' | 'write' | 'delete' | 'list'>;
55
- scope?: string[];
56
- }
57
- /**
58
- * 5. Integration Permission
59
- * Example: { type: 'integration', service: 'feishu', operations: ['read', 'write'] }
60
- */
61
- export interface IntegrationPermission extends BasePermission {
62
- type: 'integration';
63
- service: string;
64
- operations?: Array<'read' | 'write' | 'update' | 'delete'>;
65
- scope?: string[];
66
- }
67
- /**
68
- * Union type for all permissions
69
- */
70
- export type Permission = LLMPermission | VectorStorePermission | KnowledgePermission | FileSystemPermission | IntegrationPermission;
71
- /**
72
- * Permissions array type
73
- */
74
- export type Permissions = Permission[];
@@ -1,22 +0,0 @@
1
- /**
2
- * Common UI Schema field definitions
3
- */
4
- export interface ISchemaUIBase {
5
- component: string;
6
- label?: string;
7
- description?: string;
8
- placeholder?: string;
9
- order?: number;
10
- required?: boolean;
11
- visibleWhen?: Record<string, any>;
12
- enabledWhen?: Record<string, any>;
13
- }
14
- /**
15
- * Secret field extensions
16
- */
17
- export interface ISchemaSecretField extends ISchemaUIBase {
18
- component: 'secretInput';
19
- revealable?: boolean;
20
- maskSymbol?: string;
21
- persist?: boolean;
22
- }
@@ -1,3 +0,0 @@
1
- export * from './strategy.decorator';
2
- export * from './strategy.interface';
3
- export * from './strategy.registry';
@@ -1,2 +0,0 @@
1
- export declare const INTEGRATION_STRATEGY = "INTEGRATION_STRATEGY";
2
- export declare const IntegrationStrategyKey: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
@@ -1,9 +0,0 @@
1
- import { IIntegration, TIntegrationProvider } from '@metad/contracts';
2
- export type TIntegrationStrategyParams = {
3
- query: string;
4
- };
5
- export interface IntegrationStrategy<T = unknown> {
6
- meta: TIntegrationProvider;
7
- execute(integration: IIntegration<T>, payload: TIntegrationStrategyParams): Promise<any>;
8
- validateConfig?(config: T): Promise<void>;
9
- }
@@ -1,6 +0,0 @@
1
- import { DiscoveryService, Reflector } from '@nestjs/core';
2
- import { BaseStrategyRegistry } from '../strategy';
3
- import { IntegrationStrategy } from './strategy.interface';
4
- export declare class IntegrationStrategyRegistry extends BaseStrategyRegistry<IntegrationStrategy> {
5
- constructor(discoveryService: DiscoveryService, reflector: Reflector);
6
- }
@@ -1,3 +0,0 @@
1
- export * from './knowledge-strategy.decorator';
2
- export * from './knowledge-strategy.interface';
3
- export * from './knowledge-strategy.registry';
@@ -1,2 +0,0 @@
1
- export declare const KNOWLEDGE_STRATEGY = "KNOWLEDGE_STRATEGY";
2
- export declare const KnowledgeStrategyKey: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
@@ -1,15 +0,0 @@
1
- import { IIntegration } from '@metad/contracts';
2
- import { Document } from '@langchain/core/documents';
3
- export type TKnowledgeStrategyParams = {
4
- query: string;
5
- k: number;
6
- filter: Record<string, any>;
7
- options: {
8
- knowledgebaseId: string;
9
- };
10
- };
11
- export interface KnowledgeStrategy {
12
- execute(integration: IIntegration, payload: TKnowledgeStrategyParams): Promise<{
13
- chunks: [Document, number][];
14
- }>;
15
- }
@@ -1,12 +0,0 @@
1
- import { KnowledgeProviderEnum } from '@metad/contracts';
2
- import { OnModuleInit } from '@nestjs/common';
3
- import { DiscoveryService, Reflector } from '@nestjs/core';
4
- import { KnowledgeStrategy } from './knowledge-strategy.interface';
5
- export declare class KnowledgeStrategyRegistry implements OnModuleInit {
6
- private discoveryService;
7
- private reflector;
8
- private strategies;
9
- constructor(discoveryService: DiscoveryService, reflector: Reflector);
10
- onModuleInit(): void;
11
- get(type: KnowledgeProviderEnum): KnowledgeStrategy;
12
- }
@@ -1,2 +0,0 @@
1
- import type { PluginLogger } from './types';
2
- export declare function createPluginLogger(scope: string, baseMeta?: Record<string, any>): PluginLogger;
@@ -1,17 +0,0 @@
1
- /**
2
- * Metadata keys used in plugins for defining various aspects like entities, subscribers, and configurations.
3
- */
4
- export declare const PLUGIN_METADATA: {
5
- /**
6
- * Key representing the entities registered within the plugin.
7
- */
8
- readonly ENTITIES: "entities";
9
- /**
10
- * Key representing event subscribers within the plugin.
11
- */
12
- readonly SUBSCRIBERS: "subscribers";
13
- };
14
- /**
15
- * Type definition for valid plugin metadata keys.
16
- */
17
- export type PluginMetadataKey = (typeof PLUGIN_METADATA)[keyof typeof PLUGIN_METADATA];
@@ -1,8 +0,0 @@
1
- import { PluginMetadata } from './plugin.interface';
2
- /**
3
- * Decorator function for extending NestJS features with additional metadata.
4
- *
5
- * @param pluginMetadata Metadata to be applied to the target class.
6
- * @returns Class decorator function.
7
- */
8
- export declare function XpertServerPlugin(pluginMetadata: PluginMetadata): ClassDecorator;
@@ -1,59 +0,0 @@
1
- import { ModuleMetadata, Type } from '@nestjs/common';
2
- /**
3
- * Metadata definition for a plugin in NestJS.
4
- */
5
- export interface PluginMetadata extends ModuleMetadata {
6
- /**
7
- * List of entities injected by the plugin.
8
- */
9
- entities?: Array<Type<any>> | (() => Array<Type<any>>);
10
- /**
11
- * List of subscribers injected by the plugin.
12
- */
13
- subscribers?: Array<Type<any>> | (() => Array<Type<any>>);
14
- }
15
- /**
16
- * Interface for plugins with a bootstrap lifecycle method.
17
- */
18
- export interface IOnPluginBootstrap {
19
- /**
20
- * Called when the plugin is being initialized.
21
- * @returns A void or a Promise representing the completion of the operation.
22
- */
23
- onPluginBootstrap(): void | Promise<void>;
24
- }
25
- /**
26
- * Interface for plugins with a destroy lifecycle method.
27
- */
28
- export interface IOnPluginDestroy {
29
- /**
30
- * Called when the plugin is being destroyed.
31
- * @returns A void or a Promise representing the completion of the operation.
32
- */
33
- onPluginDestroy(): void | Promise<void>;
34
- }
35
- /**
36
- * Interface for plugins supporting various seed operations.
37
- */
38
- export interface IOnPluginSeedable {
39
- /**
40
- * Invoked when seeding basic plugin data.
41
- * @returns A void or a Promise representing the completion of the operation.
42
- */
43
- onPluginBasicSeed?(): void | Promise<void>;
44
- /**
45
- * Invoked when seeding default plugin data.
46
- * @returns A void or a Promise representing the completion of the operation.
47
- */
48
- onPluginDefaultSeed?(): void | Promise<void>;
49
- /**
50
- * Invoked when seeding random plugin data.
51
- * @returns A void or a Promise representing the completion of the operation.
52
- */
53
- onPluginRandomSeed?(): void | Promise<void>;
54
- }
55
- /**
56
- * Represents the combined lifecycle methods for a plugin.
57
- * This type combines interfaces for initializing and destroying a plugin.
58
- */
59
- export type PluginLifecycleMethods = IOnPluginBootstrap & IOnPluginDestroy & IOnPluginSeedable;
@@ -1,3 +0,0 @@
1
- export * from './strategy.decorator';
2
- export * from './strategy.interface';
3
- export * from './strategy.registry';
@@ -1,5 +0,0 @@
1
- export declare const IMAGE_UNDERSTANDING_STRATEGY = "IMAGE_UNDERSTANDING_STRATEGY";
2
- /**
3
- * Decorator to mark a provider as an Image Understanding Strategy
4
- */
5
- export declare const ImageUnderstandingStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
@@ -1,32 +0,0 @@
1
- import { Document } from '@langchain/core/documents';
2
- import { BaseChatModel } from '@langchain/core/language_models/chat_models';
3
- import { IDocumentUnderstandingProvider, IKnowledgeDocument } from '@metad/contracts';
4
- import { Permissions, XpFileSystem } from '../../core/index';
5
- import { ChunkMetadata } from '../types';
6
- export type TImageUnderstandingConfig = {
7
- stage: 'test' | 'prod';
8
- visionModel: BaseChatModel;
9
- permissions?: {
10
- fileSystem?: XpFileSystem;
11
- };
12
- };
13
- export type TImageUnderstandingResult = {
14
- chunks: Document<Partial<ChunkMetadata>>[];
15
- pages?: Document<Partial<ChunkMetadata>>[];
16
- metadata: any;
17
- };
18
- export interface IImageUnderstandingStrategy<TConfig extends TImageUnderstandingConfig = TImageUnderstandingConfig> {
19
- readonly permissions: Permissions;
20
- /**
21
- * Metadata about this strategy
22
- */
23
- readonly meta: IDocumentUnderstandingProvider;
24
- /**
25
- * Validate the configuration
26
- */
27
- validateConfig(config: TConfig): Promise<void>;
28
- /**
29
- * Understand image files (e.g., OCR, VLM, Chart Parsing)
30
- */
31
- understandImages(doc: IKnowledgeDocument<ChunkMetadata>, config: TConfig): Promise<TImageUnderstandingResult>;
32
- }
@@ -1,6 +0,0 @@
1
- import { DiscoveryService, Reflector } from '@nestjs/core';
2
- import { BaseStrategyRegistry } from '../../strategy';
3
- import { IImageUnderstandingStrategy, TImageUnderstandingConfig } from './strategy.interface';
4
- export declare class ImageUnderstandingRegistry<TConfig extends TImageUnderstandingConfig = TImageUnderstandingConfig> extends BaseStrategyRegistry<IImageUnderstandingStrategy<TConfig>> {
5
- constructor(discoveryService: DiscoveryService, reflector: Reflector);
6
- }
@@ -1,6 +0,0 @@
1
- export * from './textsplitter/index';
2
- export * from './source/index';
3
- export * from './transformer/index';
4
- export * from './retriever/index';
5
- export * from './types';
6
- export * from './image/index';
@@ -1,3 +0,0 @@
1
- export * from './strategy.decorator';
2
- export * from './strategy.interface';
3
- export * from './strategy.registry';
@@ -1,5 +0,0 @@
1
- export declare const RETRIEVER_STRATEGY = "RETRIEVER_STRATEGY";
2
- /**
3
- * Decorator to mark a provider as a Retriever Strategy
4
- */
5
- export declare const RetrieverStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
@@ -1,30 +0,0 @@
1
- import { VectorStore } from '@langchain/core/vectorstores';
2
- import { I18nObject } from '@metad/contracts';
3
- import { Document } from '@langchain/core/documents';
4
- export type TRetrieverConfig = {
5
- vectorStore: VectorStore;
6
- };
7
- export interface IRetrieverStrategy<TConfig extends TRetrieverConfig = TRetrieverConfig> {
8
- /**
9
- * Metadata about this retriever
10
- */
11
- readonly meta: {
12
- name: string;
13
- label: I18nObject;
14
- configSchema: any;
15
- icon: {
16
- svg?: string;
17
- color?: string;
18
- };
19
- };
20
- /**
21
- * Validate the configuration
22
- */
23
- validateConfig(config: TConfig): Promise<void>;
24
- /**
25
- * Retrieve relevant documents for a given query
26
- */
27
- retrieve(query: string, options?: TConfig): Promise<{
28
- documents: Document[];
29
- }>;
30
- }
@@ -1,6 +0,0 @@
1
- import { DiscoveryService, Reflector } from '@nestjs/core';
2
- import { BaseStrategyRegistry } from '../../strategy';
3
- import { IRetrieverStrategy } from './strategy.interface';
4
- export declare class RetrieverRegistry extends BaseStrategyRegistry<IRetrieverStrategy> {
5
- constructor(discoveryService: DiscoveryService, reflector: Reflector);
6
- }
@@ -1,3 +0,0 @@
1
- export * from './strategy.decorator';
2
- export * from './strategy.interface';
3
- export * from './strategy.registry';
@@ -1,5 +0,0 @@
1
- export declare const DOCUMENT_SOURCE_STRATEGY = "DOCUMENT_SOURCE_STRATEGY";
2
- /**
3
- * Decorator to mark a provider as a Document Source Strategy
4
- */
5
- export declare const DocumentSourceStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
@@ -1,36 +0,0 @@
1
- import { IDocumentSourceProvider, IIntegration } from '@metad/contracts';
2
- import { Document } from '@langchain/core/documents';
3
- import { Permissions } from '../../core';
4
- export interface IDocumentSourceStrategy<TConfig = any> {
5
- readonly permissions: Permissions;
6
- /**
7
- * Metadata about this document source
8
- */
9
- readonly meta: IDocumentSourceProvider;
10
- /**
11
- * Validate the configuration
12
- */
13
- validateConfig(config: TConfig): Promise<void>;
14
- /**
15
- * Test the connection to the source
16
- *
17
- * @param config
18
- */
19
- test(config: TConfig): Promise<any>;
20
- /**
21
- * Load documents from the source
22
- */
23
- loadDocuments(config: TConfig, context?: {
24
- integration?: IIntegration;
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>;
36
- }
@@ -1,6 +0,0 @@
1
- import { DiscoveryService, Reflector } from '@nestjs/core';
2
- import { BaseStrategyRegistry } from '../../strategy';
3
- import { IDocumentSourceStrategy } from './strategy.interface';
4
- export declare class DocumentSourceRegistry<TConfig = any> extends BaseStrategyRegistry<IDocumentSourceStrategy<TConfig>> {
5
- constructor(discoveryService: DiscoveryService, reflector: Reflector);
6
- }
@@ -1,3 +0,0 @@
1
- export * from './strategy.decorator';
2
- export * from './strategy.interface';
3
- export * from './strategy.registry';
@@ -1,2 +0,0 @@
1
- export declare const TEXT_SPLITTER_STRATEGY = "TEXT_SPLITTER_STRATEGY";
2
- export declare const TextSplitterStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
@@ -1,24 +0,0 @@
1
- import { IDocumentChunkerProvider, KnowledgeStructureEnum } from '@metad/contracts';
2
- import { Document } from '@langchain/core/documents';
3
- import { ChunkMetadata } from '../types';
4
- /**
5
- * Split text content into chunks for embedding and retrieval
6
- */
7
- export interface ITextSplitterStrategy<TConfig = any> {
8
- /**
9
- * Metadata about this splitter
10
- */
11
- readonly meta: IDocumentChunkerProvider;
12
- readonly structure: KnowledgeStructureEnum;
13
- /**
14
- * Validate the configuration
15
- */
16
- validateConfig(config: TConfig): Promise<void>;
17
- /**
18
- * Split a text into chunks and pages (if applicable)
19
- */
20
- splitDocuments(documents: Document[], options?: TConfig): Promise<{
21
- chunks: Document<ChunkMetadata>[];
22
- pages?: Document<ChunkMetadata>[];
23
- }>;
24
- }
@@ -1,6 +0,0 @@
1
- import { DiscoveryService, Reflector } from '@nestjs/core';
2
- import { BaseStrategyRegistry } from '../../strategy';
3
- import { ITextSplitterStrategy } from './strategy.interface';
4
- export declare class TextSplitterRegistry<TConfig = any> extends BaseStrategyRegistry<ITextSplitterStrategy<TConfig>> {
5
- constructor(discoveryService: DiscoveryService, reflector: Reflector);
6
- }
@@ -1,3 +0,0 @@
1
- export * from './strategy.decorator';
2
- export * from './strategy.interface';
3
- export * from './strategy.registry';
@@ -1,5 +0,0 @@
1
- export declare const DOCUMENT_TRANSFORMER_STRATEGY = "DOCUMENT_TRANSFORMER_STRATEGY";
2
- /**
3
- * Decorator to mark a provider as a Document Transformer Strategy
4
- */
5
- export declare const DocumentTransformerStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
@@ -1,26 +0,0 @@
1
- import { IDocumentProcessorProvider, IIntegration, IKnowledgeDocument } from '@metad/contracts';
2
- import { Permissions, XpFileSystem } from '../../core/index';
3
- import { ChunkMetadata } from '../types';
4
- export type TDocumentTransformerConfig = {
5
- stage: 'test' | 'prod';
6
- tempDir?: string;
7
- permissions?: {
8
- fileSystem?: XpFileSystem;
9
- integration?: IIntegration;
10
- };
11
- };
12
- export interface IDocumentTransformerStrategy<TConfig extends TDocumentTransformerConfig = TDocumentTransformerConfig> {
13
- /**
14
- * Metadata about this transformer
15
- */
16
- readonly meta: IDocumentProcessorProvider;
17
- readonly permissions: Permissions;
18
- /**
19
- * Validate the configuration
20
- */
21
- validateConfig(config: TConfig): Promise<void>;
22
- /**
23
- * Transform documents (e.g., extract, OCR, normalize, enrich metadata)
24
- */
25
- transformDocuments(files: Partial<IKnowledgeDocument>[], config: TConfig): Promise<Partial<IKnowledgeDocument<ChunkMetadata>>[]>;
26
- }
@@ -1,6 +0,0 @@
1
- import { DiscoveryService, Reflector } from '@nestjs/core';
2
- import { BaseStrategyRegistry } from '../../strategy';
3
- import { IDocumentTransformerStrategy, TDocumentTransformerConfig } from './strategy.interface';
4
- export declare class DocumentTransformerRegistry<TConfig extends TDocumentTransformerConfig = TDocumentTransformerConfig> extends BaseStrategyRegistry<IDocumentTransformerStrategy<TConfig>> {
5
- constructor(discoveryService: DiscoveryService, reflector: Reflector);
6
- }
@@ -1,37 +0,0 @@
1
- import { DocumentInterface } from '@langchain/core/documents';
2
- export type TDocumentAsset = {
3
- type: 'image' | 'video' | 'audio' | 'file';
4
- url: string;
5
- filePath: string;
6
- };
7
- export interface ChunkMetadata {
8
- documentId?: string;
9
- pageId?: string;
10
- chunkId: string;
11
- parentId?: string;
12
- chunkIndex?: number;
13
- startOffset?: number;
14
- endOffset?: number;
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';
21
- children?: DocumentInterface<ChunkMetadata>[];
22
- /**
23
- * Associated assets like images, videos, etc.
24
- */
25
- assets?: TDocumentAsset[];
26
- [key: string]: any;
27
- }
28
- /**
29
- * Merge parent chunks with their child chunks based on metadata (parentId and chunkId)
30
- * @param chunks
31
- * @param children
32
- * @returns
33
- */
34
- export declare function mergeParentChildChunks(chunks: DocumentInterface<ChunkMetadata>[], // Parent chunks
35
- children: DocumentInterface<ChunkMetadata>[]): DocumentInterface<ChunkMetadata>[];
36
- export declare function isRemoteFile(path: string): boolean;
37
- export declare function downloadRemoteFile(url: string, dest: string): Promise<string>;
@@ -1,12 +0,0 @@
1
- import { OnModuleInit } from "@nestjs/common";
2
- import { DiscoveryService, Reflector } from "@nestjs/core";
3
- export declare class BaseStrategyRegistry<S> implements OnModuleInit {
4
- protected readonly strategyKey: string;
5
- protected discoveryService: DiscoveryService;
6
- protected reflector: Reflector;
7
- protected strategies: Map<string, S>;
8
- constructor(strategyKey: string, discoveryService: DiscoveryService, reflector: Reflector);
9
- onModuleInit(): void;
10
- get(type: string): S;
11
- list(): S[];
12
- }
@@ -1,54 +0,0 @@
1
- import { StructuredToolInterface } from '@langchain/core/tools';
2
- import { BaseStore } from '@langchain/langgraph';
3
- import { I18nObject, IXpertToolset, ToolProviderCredentials, TToolCredentials, TToolsetParams, XpertToolsetCategoryEnum } from '@metad/contracts';
4
- import { Logger } from '@nestjs/common';
5
- import { CommandBus, QueryBus } from '@nestjs/cqrs';
6
- import { BaseToolset } from './toolset';
7
- /**
8
- * The context params of creating toolset
9
- */
10
- export type TBuiltinToolsetParams = TToolsetParams & {
11
- commandBus: CommandBus;
12
- queryBus: QueryBus;
13
- store?: BaseStore;
14
- };
15
- export interface IBuiltinToolset {
16
- validateCredentials(credentials: TToolCredentials): Promise<void>;
17
- }
18
- export declare abstract class BuiltinToolset<T extends StructuredToolInterface = StructuredToolInterface, C = TToolCredentials> extends BaseToolset<T> implements IBuiltinToolset {
19
- providerName: string;
20
- protected toolset?: IXpertToolset;
21
- protected params?: TBuiltinToolsetParams;
22
- static provider: string;
23
- protected logger: Logger;
24
- providerType: XpertToolsetCategoryEnum.BUILTIN;
25
- credentialsSchema?: {
26
- [key: string]: ToolProviderCredentials;
27
- };
28
- get tenantId(): string;
29
- get organizationId(): string;
30
- get commandBus(): CommandBus<import("@nestjs/cqrs").ICommand>;
31
- get queryBus(): QueryBus<import("@nestjs/cqrs").IQuery>;
32
- get xpertId(): string;
33
- constructor(providerName: string, toolset?: IXpertToolset, params?: TBuiltinToolsetParams);
34
- validateCredentials(credentials: C): Promise<void>;
35
- _validateCredentials(credentials: C): Promise<void>;
36
- getId(): string;
37
- getCredentials(): C;
38
- getToolTitle(name: string): string | I18nObject;
39
- /**
40
- * Get credentials schema
41
- *
42
- * @returns Credentials schema
43
- */
44
- getCredentialsSchema(): {
45
- [key: string]: ToolProviderCredentials;
46
- };
47
- /**
48
- * Get toolset entity
49
- *
50
- * @returns XpertToolset
51
- */
52
- getToolset(): IXpertToolset;
53
- getName(): string;
54
- }
@@ -1,5 +0,0 @@
1
- export * from './strategy.decorator';
2
- export * from './strategy.interface';
3
- export * from './strategy.registry';
4
- export * from './builtin';
5
- export * from './toolset';
@@ -1,5 +0,0 @@
1
- export declare const TOOLSET_STRATEGY = "TOOLSET_STRATEGY";
2
- /**
3
- * Decorator to mark a provider as a Toolset Strategy
4
- */
5
- export declare const ToolsetStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;