@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.
- package/.eslintrc.json +30 -0
- package/.swcrc +29 -0
- package/SCHEMA_SPECIFICATION.md +2 -0
- package/index.cjs.js +5 -649
- package/jest.config.ts +28 -0
- package/package.json +3 -3
- package/project.json +59 -0
- package/src/index.ts +11 -0
- package/src/lib/core/file-system.ts +113 -0
- package/src/lib/core/i18n.ts +31 -0
- package/src/lib/core/index.ts +4 -0
- package/src/lib/core/permissions.ts +97 -0
- package/src/lib/core/schema.ts +23 -0
- package/src/lib/integration/index.ts +3 -0
- package/src/lib/integration/strategy.decorator.ts +6 -0
- package/src/lib/integration/strategy.interface.ts +11 -0
- package/src/lib/integration/strategy.registry.ts +12 -0
- package/src/lib/logger.ts +18 -0
- package/src/lib/plugin-metadata.ts +20 -0
- package/src/lib/{plugin.hook.d.ts → plugin.hook.ts} +4 -0
- package/src/lib/plugin.interface.ts +67 -0
- package/src/lib/plugin.ts +32 -0
- package/src/lib/rag/image/index.ts +3 -0
- package/src/lib/rag/image/strategy.decorator.ts +9 -0
- package/src/lib/rag/image/strategy.interface.ts +37 -0
- package/src/lib/rag/image/strategy.registry.ts +17 -0
- package/src/lib/rag/index.ts +7 -0
- package/src/lib/rag/knowledge/index.ts +3 -0
- package/src/lib/rag/knowledge/knowledge-strategy.decorator.ts +6 -0
- package/src/lib/rag/knowledge/knowledge-strategy.interface.ts +15 -0
- package/src/lib/rag/knowledge/knowledge-strategy.registry.ts +12 -0
- package/src/lib/rag/retriever/index.ts +3 -0
- package/src/lib/rag/retriever/strategy.decorator.ts +9 -0
- package/src/lib/rag/retriever/strategy.interface.ts +32 -0
- package/src/lib/rag/retriever/strategy.registry.ts +12 -0
- package/src/lib/rag/source/index.ts +3 -0
- package/src/lib/rag/source/strategy.decorator.ts +9 -0
- package/src/lib/rag/source/strategy.interface.ts +36 -0
- package/src/lib/rag/source/strategy.registry.ts +17 -0
- package/src/lib/rag/textsplitter/index.ts +3 -0
- package/src/lib/rag/textsplitter/strategy.decorator.ts +6 -0
- package/src/lib/rag/textsplitter/strategy.interface.ts +28 -0
- package/src/lib/rag/textsplitter/strategy.registry.ts +17 -0
- package/src/lib/rag/transformer/index.ts +3 -0
- package/src/lib/rag/transformer/strategy.decorator.ts +9 -0
- package/src/lib/rag/transformer/strategy.interface.ts +34 -0
- package/src/lib/rag/transformer/strategy.registry.ts +14 -0
- package/src/lib/rag/types.ts +76 -0
- package/src/lib/strategy.ts +37 -0
- package/src/lib/toolset/builtin.ts +111 -0
- package/src/lib/toolset/index.ts +5 -0
- package/src/lib/toolset/strategy.decorator.ts +9 -0
- package/src/lib/toolset/strategy.interface.ts +32 -0
- package/src/lib/toolset/strategy.registry.ts +17 -0
- package/src/lib/toolset/toolset.ts +76 -0
- package/src/lib/types.ts +47 -0
- package/src/lib/vectorstore/index.ts +3 -0
- package/src/lib/vectorstore/strategy.decorator.ts +6 -0
- package/src/lib/vectorstore/strategy.interface.ts +25 -0
- package/src/lib/vectorstore/strategy.registry.ts +17 -0
- package/src/lib/workflow/index.ts +2 -0
- package/src/lib/workflow/node/index.ts +3 -0
- package/src/lib/workflow/node/strategy.decorator.ts +9 -0
- package/src/lib/workflow/node/strategy.interface.ts +51 -0
- package/src/lib/workflow/node/strategy.registry.ts +18 -0
- package/src/lib/workflow/trigger/index.ts +3 -0
- package/src/lib/workflow/trigger/strategy.decorator.ts +6 -0
- package/src/lib/workflow/trigger/strategy.interface.ts +27 -0
- package/src/lib/workflow/trigger/strategy.registry.ts +17 -0
- package/tsconfig.json +22 -0
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +9 -0
- package/index.cjs.d.ts +0 -1
- package/index.esm.d.ts +0 -1
- package/index.esm.js +0 -616
- package/src/index.d.ts +0 -12
- package/src/lib/core/file-system.d.ts +0 -42
- package/src/lib/core/i18n.d.ts +0 -2
- package/src/lib/core/index.d.ts +0 -4
- package/src/lib/core/permissions.d.ts +0 -74
- package/src/lib/core/schema.d.ts +0 -22
- package/src/lib/integration/index.d.ts +0 -3
- package/src/lib/integration/strategy.decorator.d.ts +0 -2
- package/src/lib/integration/strategy.interface.d.ts +0 -9
- package/src/lib/integration/strategy.registry.d.ts +0 -6
- package/src/lib/knowledge/index.d.ts +0 -3
- package/src/lib/knowledge/knowledge-strategy.decorator.d.ts +0 -2
- package/src/lib/knowledge/knowledge-strategy.interface.d.ts +0 -15
- package/src/lib/knowledge/knowledge-strategy.registry.d.ts +0 -12
- package/src/lib/logger.d.ts +0 -2
- package/src/lib/plugin-metadata.d.ts +0 -17
- package/src/lib/plugin.d.ts +0 -8
- package/src/lib/plugin.interface.d.ts +0 -59
- package/src/lib/rag/image/index.d.ts +0 -3
- package/src/lib/rag/image/strategy.decorator.d.ts +0 -5
- package/src/lib/rag/image/strategy.interface.d.ts +0 -32
- package/src/lib/rag/image/strategy.registry.d.ts +0 -6
- package/src/lib/rag/index.d.ts +0 -6
- package/src/lib/rag/retriever/index.d.ts +0 -3
- package/src/lib/rag/retriever/strategy.decorator.d.ts +0 -5
- package/src/lib/rag/retriever/strategy.interface.d.ts +0 -30
- package/src/lib/rag/retriever/strategy.registry.d.ts +0 -6
- package/src/lib/rag/source/index.d.ts +0 -3
- package/src/lib/rag/source/strategy.decorator.d.ts +0 -5
- package/src/lib/rag/source/strategy.interface.d.ts +0 -36
- package/src/lib/rag/source/strategy.registry.d.ts +0 -6
- package/src/lib/rag/textsplitter/index.d.ts +0 -3
- package/src/lib/rag/textsplitter/strategy.decorator.d.ts +0 -2
- package/src/lib/rag/textsplitter/strategy.interface.d.ts +0 -24
- package/src/lib/rag/textsplitter/strategy.registry.d.ts +0 -6
- package/src/lib/rag/transformer/index.d.ts +0 -3
- package/src/lib/rag/transformer/strategy.decorator.d.ts +0 -5
- package/src/lib/rag/transformer/strategy.interface.d.ts +0 -26
- package/src/lib/rag/transformer/strategy.registry.d.ts +0 -6
- package/src/lib/rag/types.d.ts +0 -37
- package/src/lib/strategy.d.ts +0 -12
- package/src/lib/toolset/builtin.d.ts +0 -54
- package/src/lib/toolset/index.d.ts +0 -5
- package/src/lib/toolset/strategy.decorator.d.ts +0 -5
- package/src/lib/toolset/strategy.interface.d.ts +0 -28
- package/src/lib/toolset/strategy.registry.d.ts +0 -6
- package/src/lib/toolset/toolset.d.ts +0 -53
- package/src/lib/types.d.ts +0 -47
- package/src/lib/vectorstore/index.d.ts +0 -3
- package/src/lib/vectorstore/strategy.decorator.d.ts +0 -2
- package/src/lib/vectorstore/strategy.interface.d.ts +0 -24
- package/src/lib/vectorstore/strategy.registry.d.ts +0 -6
- package/src/lib/workflow/index.d.ts +0 -2
- package/src/lib/workflow/node/index.d.ts +0 -3
- package/src/lib/workflow/node/strategy.decorator.d.ts +0 -5
- package/src/lib/workflow/node/strategy.interface.d.ts +0 -40
- package/src/lib/workflow/node/strategy.registry.d.ts +0 -9
- package/src/lib/workflow/trigger/index.d.ts +0 -3
- package/src/lib/workflow/trigger/strategy.decorator.d.ts +0 -2
- package/src/lib/workflow/trigger/strategy.interface.d.ts +0 -22
- package/src/lib/workflow/trigger/strategy.registry.d.ts +0 -6
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
2
|
-
import { I18nObject } from '@metad/contracts';
|
|
3
|
-
import { ZodSchema } from 'zod';
|
|
4
|
-
import { BuiltinToolset } from './builtin';
|
|
5
|
-
export interface IToolsetStrategy<TConfig = any> {
|
|
6
|
-
/**
|
|
7
|
-
* Metadata about this toolset
|
|
8
|
-
*/
|
|
9
|
-
readonly meta: {
|
|
10
|
-
author: string;
|
|
11
|
-
tags: string[];
|
|
12
|
-
name: string;
|
|
13
|
-
label: I18nObject;
|
|
14
|
-
description?: I18nObject;
|
|
15
|
-
configSchema: any;
|
|
16
|
-
icon?: {
|
|
17
|
-
svg?: string;
|
|
18
|
-
png?: string;
|
|
19
|
-
color?: string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Validate the configuration
|
|
24
|
-
*/
|
|
25
|
-
validateConfig(config: TConfig): Promise<void>;
|
|
26
|
-
create(config: TConfig): Promise<BuiltinToolset>;
|
|
27
|
-
createTools(): DynamicStructuredTool<ZodSchema>[];
|
|
28
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
-
import { IToolsetStrategy } from './strategy.interface';
|
|
3
|
-
import { BaseStrategyRegistry } from '../strategy';
|
|
4
|
-
export declare class ToolsetRegistry<TConfig = any> extends BaseStrategyRegistry<IToolsetStrategy<TConfig>> {
|
|
5
|
-
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { BaseToolkit, StructuredTool, StructuredToolInterface } from "@langchain/core/tools";
|
|
2
|
-
import { I18nObject, TStateVariable, TToolsetParams } from "@metad/contracts";
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
type ZodObjectAny = z.ZodObject<any, any, any, any>;
|
|
5
|
-
/**
|
|
6
|
-
* Base ability for all toolsets
|
|
7
|
-
*/
|
|
8
|
-
export declare abstract class BaseToolset<T extends StructuredToolInterface = StructuredToolInterface> extends BaseToolkit {
|
|
9
|
-
protected params?: TToolsetParams;
|
|
10
|
-
abstract providerName: string;
|
|
11
|
-
tools: T[];
|
|
12
|
-
stateVariables: TStateVariable[];
|
|
13
|
-
constructor(params?: TToolsetParams);
|
|
14
|
-
/**
|
|
15
|
-
* Async init tools
|
|
16
|
-
*
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
initTools(): Promise<T[]>;
|
|
20
|
-
/**
|
|
21
|
-
* Get ID of the toolset
|
|
22
|
-
*/
|
|
23
|
-
abstract getId(): string;
|
|
24
|
-
/**
|
|
25
|
-
* Get name of the toolset
|
|
26
|
-
*/
|
|
27
|
-
abstract getName(): string;
|
|
28
|
-
/**
|
|
29
|
-
* Get one tool
|
|
30
|
-
*
|
|
31
|
-
* @param toolName
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
getTool(toolName: string): StructuredToolInterface<import("@langchain/core/tools").ToolSchemaBase, any, any>;
|
|
35
|
-
/**
|
|
36
|
-
* Get state variables config
|
|
37
|
-
*
|
|
38
|
-
* @returns State variables
|
|
39
|
-
*/
|
|
40
|
-
getVariables(): Promise<TStateVariable[]>;
|
|
41
|
-
/**
|
|
42
|
-
* Get title of tool
|
|
43
|
-
*/
|
|
44
|
-
abstract getToolTitle(name: string): string | I18nObject;
|
|
45
|
-
/**
|
|
46
|
-
* Close all (connections).
|
|
47
|
-
*/
|
|
48
|
-
close(): Promise<void>;
|
|
49
|
-
}
|
|
50
|
-
export declare abstract class BaseTool<T extends ZodObjectAny = ZodObjectAny> extends StructuredTool<T> {
|
|
51
|
-
schema: any;
|
|
52
|
-
}
|
|
53
|
-
export {};
|
package/src/lib/types.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { PluginMeta } from '@metad/contracts';
|
|
2
|
-
import type { DynamicModule, INestApplicationContext } from '@nestjs/common';
|
|
3
|
-
import type { ZodSchema } from 'zod';
|
|
4
|
-
export interface PluginLifecycle {
|
|
5
|
-
/** Called after module registration but before application startup */
|
|
6
|
-
onInit?(ctx: PluginContext): Promise<void> | void;
|
|
7
|
-
/** Called after application startup (can start serving externally) */
|
|
8
|
-
onStart?(ctx: PluginContext): Promise<void> | void;
|
|
9
|
-
/** Called during graceful shutdown */
|
|
10
|
-
onStop?(ctx: PluginContext): Promise<void> | void;
|
|
11
|
-
}
|
|
12
|
-
export interface PluginHealth {
|
|
13
|
-
/** Returns health status and optional dependency check details */
|
|
14
|
-
checkHealth?(ctx: PluginContext): Promise<{
|
|
15
|
-
status: 'up' | 'down';
|
|
16
|
-
details?: any;
|
|
17
|
-
}> | {
|
|
18
|
-
status: 'up' | 'down';
|
|
19
|
-
details?: any;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export interface PluginConfigSpec<T extends object = any> {
|
|
23
|
-
/** Zod validation schema for plugin-level config (optional) */
|
|
24
|
-
schema?: ZodSchema<T>;
|
|
25
|
-
/** Default configuration */
|
|
26
|
-
defaults?: Partial<T>;
|
|
27
|
-
}
|
|
28
|
-
export interface XpertPlugin<TConfig extends object = any> extends PluginLifecycle, PluginHealth {
|
|
29
|
-
meta: PluginMeta;
|
|
30
|
-
config?: PluginConfigSpec<TConfig>;
|
|
31
|
-
/** Returns the DynamicModule to be mounted to the main application (can be set as global) */
|
|
32
|
-
register(ctx: PluginContext<TConfig>): DynamicModule;
|
|
33
|
-
}
|
|
34
|
-
export interface PluginContext<TConfig extends object = any> {
|
|
35
|
-
app: INestApplicationContext;
|
|
36
|
-
logger: PluginLogger;
|
|
37
|
-
config: TConfig;
|
|
38
|
-
/** Helper method to access other Providers in the container */
|
|
39
|
-
resolve<TInput = any, TResult = TInput>(token: any): TResult;
|
|
40
|
-
}
|
|
41
|
-
export interface PluginLogger {
|
|
42
|
-
child(meta: Record<string, any>): PluginLogger;
|
|
43
|
-
debug(msg: string, meta?: any): void;
|
|
44
|
-
log(msg: string, meta?: any): void;
|
|
45
|
-
warn(msg: string, meta?: any): void;
|
|
46
|
-
error(msg: string, meta?: any): void;
|
|
47
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { EmbeddingsInterface } from '@langchain/core/embeddings';
|
|
2
|
-
import { VectorStore } from '@langchain/core/vectorstores';
|
|
3
|
-
/**
|
|
4
|
-
* Interface for VectorStore strategy。
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export interface IVectorStoreStrategy<TConfig extends {
|
|
9
|
-
collectionName?: string;
|
|
10
|
-
}> {
|
|
11
|
-
/**
|
|
12
|
-
* Metadata about the strategy
|
|
13
|
-
*/
|
|
14
|
-
readonly name: string;
|
|
15
|
-
readonly description?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Validate configuration for VectorStore
|
|
18
|
-
*/
|
|
19
|
-
validateConfig(config: TConfig): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Create a VectorStore with given config
|
|
22
|
-
*/
|
|
23
|
-
createStore(embeddings: EmbeddingsInterface, config: TConfig): Promise<VectorStore>;
|
|
24
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
-
import { BaseStrategyRegistry } from '../strategy';
|
|
3
|
-
import { IVectorStoreStrategy } from './strategy.interface';
|
|
4
|
-
export declare class VectorStoreRegistry<TConfig = any> extends BaseStrategyRegistry<IVectorStoreStrategy<TConfig>> {
|
|
5
|
-
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Runnable } from '@langchain/core/runnables';
|
|
2
|
-
import { BaseChannel } from '@langchain/langgraph';
|
|
3
|
-
import { IEnvironment, IWorkflowNode, TWorkflowNodeMeta, TXpertGraph, TXpertParameter, TXpertTeamNode } from '@metad/contracts';
|
|
4
|
-
export type TWorkflowNodeParams<TConfig = any> = {
|
|
5
|
-
xpertId: string;
|
|
6
|
-
agentKey?: string;
|
|
7
|
-
node: TXpertTeamNode;
|
|
8
|
-
config: TConfig;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Workflow Node Strategy interface
|
|
12
|
-
*/
|
|
13
|
-
export interface IWorkflowNodeStrategy<TConfig = any, TResult = any> {
|
|
14
|
-
/**
|
|
15
|
-
* Metadata describing the node (type, label, description, config schema, etc.)
|
|
16
|
-
*/
|
|
17
|
-
meta: TWorkflowNodeMeta;
|
|
18
|
-
/**
|
|
19
|
-
* Create the node subgraph
|
|
20
|
-
*/
|
|
21
|
-
create(payload: {
|
|
22
|
-
graph: TXpertGraph;
|
|
23
|
-
node: TXpertTeamNode & {
|
|
24
|
-
type: 'workflow';
|
|
25
|
-
};
|
|
26
|
-
xpertId: string;
|
|
27
|
-
environment: IEnvironment;
|
|
28
|
-
isDraft: boolean;
|
|
29
|
-
}): {
|
|
30
|
-
name?: string;
|
|
31
|
-
graph: Runnable;
|
|
32
|
-
ends: string[];
|
|
33
|
-
channel: {
|
|
34
|
-
name: string;
|
|
35
|
-
annotation: BaseChannel;
|
|
36
|
-
};
|
|
37
|
-
navigator?: (state: any, config: any) => Promise<any>;
|
|
38
|
-
};
|
|
39
|
-
outputVariables(entity: IWorkflowNode): TXpertParameter[];
|
|
40
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
-
import { BaseStrategyRegistry } from '../../strategy';
|
|
3
|
-
import { IWorkflowNodeStrategy } from './strategy.interface';
|
|
4
|
-
/**
|
|
5
|
-
* Registry for Workflow Node Strategies
|
|
6
|
-
*/
|
|
7
|
-
export declare class WorkflowNodeRegistry<TConfig = any, TResult = any> extends BaseStrategyRegistry<IWorkflowNodeStrategy<TConfig, TResult>> {
|
|
8
|
-
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
9
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { TWorkflowTriggerMeta, TXpertTeamNode } from '@metad/contracts';
|
|
2
|
-
export type TWorkflowTriggerParams<T> = {
|
|
3
|
-
xpertId: string;
|
|
4
|
-
agentKey?: string;
|
|
5
|
-
node?: TXpertTeamNode;
|
|
6
|
-
config: T;
|
|
7
|
-
};
|
|
8
|
-
export interface IWorkflowTriggerStrategy<T> {
|
|
9
|
-
meta: TWorkflowTriggerMeta;
|
|
10
|
-
validate(payload: TWorkflowTriggerParams<T>): Promise<any[]>;
|
|
11
|
-
/**
|
|
12
|
-
* Initialize the trigger when publish xpert workflow
|
|
13
|
-
*
|
|
14
|
-
* @param payload
|
|
15
|
-
* @param callback
|
|
16
|
-
*/
|
|
17
|
-
publish(payload: TWorkflowTriggerParams<T>, callback: (payload: any) => void): Promise<any> | void;
|
|
18
|
-
/**
|
|
19
|
-
* Stop the trigger
|
|
20
|
-
*/
|
|
21
|
-
stop(payload: TWorkflowTriggerParams<T>): void;
|
|
22
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
-
import { BaseStrategyRegistry } from '../../strategy';
|
|
3
|
-
import { IWorkflowTriggerStrategy } from './strategy.interface';
|
|
4
|
-
export declare class WorkflowTriggerRegistry<T = any> extends BaseStrategyRegistry<IWorkflowTriggerStrategy<T>> {
|
|
5
|
-
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
-
}
|