@xpert-ai/plugin-sdk 3.6.7 → 3.7.1

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 (43) hide show
  1. package/SCHEMA_SPECIFICATION.md +2 -1
  2. package/index.cjs.js +1278 -241
  3. package/index.esm.js +1270 -243
  4. package/package.json +2 -1
  5. package/src/index.d.ts +2 -0
  6. package/src/lib/agent/index.d.ts +1 -0
  7. package/src/lib/agent/middleware/index.d.ts +5 -0
  8. package/src/lib/agent/middleware/runtime.d.ts +57 -0
  9. package/src/lib/agent/middleware/strategy.decorator.d.ts +2 -0
  10. package/src/lib/agent/middleware/strategy.interface.d.ts +16 -0
  11. package/src/lib/agent/middleware/strategy.registry.d.ts +6 -0
  12. package/src/lib/agent/middleware/types.d.ts +251 -0
  13. package/src/lib/agent/skill/index.d.ts +3 -0
  14. package/src/lib/agent/skill/skill-source-provider.decorator.d.ts +2 -0
  15. package/src/lib/agent/skill/skill-source-provider.interface.d.ts +23 -0
  16. package/src/lib/agent/skill/skill-source-provider.registry.d.ts +6 -0
  17. package/src/lib/ai-model/commands/create-model-client.command.d.ts +21 -0
  18. package/src/lib/ai-model/commands/index.d.ts +1 -0
  19. package/src/lib/ai-model/index.d.ts +1 -0
  20. package/src/lib/ai-model/types/index.d.ts +1 -0
  21. package/src/lib/ai-model/types/model.d.ts +2 -1
  22. package/src/lib/ai-model/types/profile.d.ts +172 -0
  23. package/src/lib/core/index.d.ts +2 -0
  24. package/src/lib/core/strategy-bus.d.ts +17 -0
  25. package/src/lib/core/types.d.ts +16 -0
  26. package/src/lib/data/datasource/strategy.decorator.d.ts +1 -1
  27. package/src/lib/data/datasource/types.d.ts +29 -1
  28. package/src/lib/integration/strategy.decorator.d.ts +1 -1
  29. package/src/lib/rag/image/strategy.decorator.d.ts +1 -1
  30. package/src/lib/rag/knowledge/knowledge-strategy.decorator.d.ts +1 -1
  31. package/src/lib/rag/retriever/strategy.decorator.d.ts +1 -1
  32. package/src/lib/rag/source/strategy.decorator.d.ts +1 -1
  33. package/src/lib/rag/textsplitter/strategy.decorator.d.ts +1 -1
  34. package/src/lib/rag/transformer/strategy.decorator.d.ts +1 -1
  35. package/src/lib/strategy.d.ts +29 -3
  36. package/src/lib/toolset/strategy.decorator.d.ts +1 -1
  37. package/src/lib/types.d.ts +4 -0
  38. package/src/lib/vectorstore/strategy.decorator.d.ts +1 -1
  39. package/src/lib/workflow/commands/index.d.ts +1 -0
  40. package/src/lib/workflow/commands/wrap-workflow-node-execution.command.d.ts +26 -0
  41. package/src/lib/workflow/index.d.ts +1 -0
  42. package/src/lib/workflow/node/strategy.decorator.d.ts +1 -1
  43. package/src/lib/workflow/trigger/strategy.decorator.d.ts +1 -1
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Who provided this strategy instance:
3
+ * - "core": main app providers
4
+ * - "plugin": runtime loaded plugin providers
5
+ */
6
+ export type StrategySourceKind = 'core' | 'plugin';
7
+ export interface StrategyEntry<S> {
8
+ instance: S;
9
+ /**
10
+ * Unique id for conflict detection & removal.
11
+ * For core providers you can use wrapper.id or class name.
12
+ * For plugin providers use `${org}:${pluginId}@${version}:${className}`
13
+ */
14
+ sourceId: string;
15
+ sourceKind: StrategySourceKind;
16
+ }
@@ -1,2 +1,2 @@
1
1
  export declare const DATASOURCE_STRATEGY = "DATASOURCE_STRATEGY";
2
- export declare const DataSourceStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
2
+ export declare const DataSourceStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -155,9 +155,21 @@ export interface ColumnDef {
155
155
  */
156
156
  isKey: boolean;
157
157
  /**
158
- * Is required column
158
+ * Is required column (NOT NULL)
159
159
  */
160
160
  required?: boolean;
161
+ /**
162
+ * Is unique column
163
+ */
164
+ unique?: boolean;
165
+ /**
166
+ * Auto increment (for number type)
167
+ */
168
+ autoIncrement?: boolean;
169
+ /**
170
+ * Default value
171
+ */
172
+ defaultValue?: string;
161
173
  /**
162
174
  * length of type for column: varchar, decimal ...
163
175
  */
@@ -166,6 +178,14 @@ export interface ColumnDef {
166
178
  * fraction of type for decimal
167
179
  */
168
180
  fraction?: number;
181
+ /**
182
+ * Enum values (for ENUM type)
183
+ */
184
+ enumValues?: string[];
185
+ /**
186
+ * Set values (for SET type)
187
+ */
188
+ setValues?: string[];
169
189
  }
170
190
  export interface CreationTable {
171
191
  catalog?: string;
@@ -242,6 +262,14 @@ export declare abstract class BaseSQLQueryRunner<T extends SQLAdapterOptions = S
242
262
  get port(): string | number;
243
263
  abstract createCatalog?(catalog: string): Promise<void>;
244
264
  ping(): Promise<void>;
265
+ /**
266
+ * Default implementation for table operations
267
+ */
268
+ tableOp(action: DBTableAction, params: DBTableOperationParams, options?: QueryOptions): Promise<any>;
269
+ /**
270
+ * Generic type mapping (subclasses can override)
271
+ */
272
+ protected mapColumnType(type: string, isKey: boolean, length?: number): string;
245
273
  }
246
274
  export interface File {
247
275
  /** Name of the form field associated with this file. */
@@ -1,2 +1,2 @@
1
1
  export declare const INTEGRATION_STRATEGY = "INTEGRATION_STRATEGY";
2
- export declare const IntegrationStrategyKey: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
2
+ export declare const IntegrationStrategyKey: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -2,4 +2,4 @@ export declare const IMAGE_UNDERSTANDING_STRATEGY = "IMAGE_UNDERSTANDING_STRATEG
2
2
  /**
3
3
  * Decorator to mark a provider as an Image Understanding Strategy
4
4
  */
5
- export declare const ImageUnderstandingStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
5
+ export declare const ImageUnderstandingStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1,2 +1,2 @@
1
1
  export declare const KNOWLEDGE_STRATEGY = "KNOWLEDGE_STRATEGY";
2
- export declare const KnowledgeStrategyKey: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
2
+ export declare const KnowledgeStrategyKey: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -2,4 +2,4 @@ export declare const RETRIEVER_STRATEGY = "RETRIEVER_STRATEGY";
2
2
  /**
3
3
  * Decorator to mark a provider as a Retriever Strategy
4
4
  */
5
- export declare const RetrieverStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
5
+ export declare const RetrieverStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -2,4 +2,4 @@ export declare const DOCUMENT_SOURCE_STRATEGY = "DOCUMENT_SOURCE_STRATEGY";
2
2
  /**
3
3
  * Decorator to mark a provider as a Document Source Strategy
4
4
  */
5
- export declare const DocumentSourceStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
5
+ export declare const DocumentSourceStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1,2 +1,2 @@
1
1
  export declare const TEXT_SPLITTER_STRATEGY = "TEXT_SPLITTER_STRATEGY";
2
- export declare const TextSplitterStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
2
+ export declare const TextSplitterStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -2,4 +2,4 @@ export declare const DOCUMENT_TRANSFORMER_STRATEGY = "DOCUMENT_TRANSFORMER_STRAT
2
2
  /**
3
3
  * Decorator to mark a provider as a Document Transformer Strategy
4
4
  */
5
- export declare const DocumentTransformerStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
5
+ export declare const DocumentTransformerStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1,12 +1,38 @@
1
1
  import { OnModuleInit } from "@nestjs/common";
2
2
  import { DiscoveryService, Reflector } from "@nestjs/core";
3
+ import { StrategyBus } from "./core/strategy-bus";
3
4
  export declare class BaseStrategyRegistry<S> implements OnModuleInit {
4
5
  protected readonly strategyKey: string;
5
6
  protected discoveryService: DiscoveryService;
6
7
  protected reflector: Reflector;
7
- protected strategies: Map<string, S>;
8
+ private readonly logger;
9
+ protected readonly bus: StrategyBus;
10
+ protected strategies: Map<string, Map<string, S>>;
11
+ protected pluginStrategies: Map<string, Set<string>>;
8
12
  constructor(strategyKey: string, discoveryService: DiscoveryService, reflector: Reflector);
9
13
  onModuleInit(): void;
10
- get(type: string): S;
11
- list(): S[];
14
+ upsert(instance: any): void;
15
+ /**
16
+ * Remove all strategies registered by the given plugin for the given organization.
17
+ */
18
+ remove(organizationId: string, pluginName: string): void;
19
+ /**
20
+ * Resolve organization id, falling back to request context org or global scope.
21
+ */
22
+ protected resolveOrganization(organizationId?: string): string;
23
+ /**
24
+ * Get strategy by type from the given organization including global strategies as fallback.
25
+ *
26
+ * @param type
27
+ * @param organizationId
28
+ * @returns
29
+ */
30
+ get(type: string, organizationId?: string): S;
31
+ /**
32
+ * List all strategies for the given organization including global strategies, or only global strategies if global org is specified.
33
+ *
34
+ * @param organizationId
35
+ * @returns
36
+ */
37
+ list(organizationId?: string): S[];
12
38
  }
@@ -2,4 +2,4 @@ export declare const TOOLSET_STRATEGY = "TOOLSET_STRATEGY";
2
2
  /**
3
3
  * Decorator to mark a provider as a Toolset Strategy
4
4
  */
5
- export declare const ToolsetStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
5
+ export declare const ToolsetStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1,6 +1,10 @@
1
1
  import { PluginMeta } from '@metad/contracts';
2
2
  import type { DynamicModule, INestApplicationContext } from '@nestjs/common';
3
3
  import type { ZodSchema } from 'zod';
4
+ export declare const ORGANIZATION_METADATA_KEY = "xpert:organizationId";
5
+ export declare const PLUGIN_METADATA_KEY = "xpert:pluginName";
6
+ export declare const GLOBAL_ORGANIZATION_SCOPE = "global";
7
+ export declare const STRATEGY_META_KEY = "XPERT_STRATEGY_META_KEY";
4
8
  export interface PluginLifecycle {
5
9
  /** Called after module registration but before application startup */
6
10
  onInit?(ctx: PluginContext): Promise<void> | void;
@@ -1,2 +1,2 @@
1
1
  export declare const VECTOR_STORE_STRATEGY = "VECTOR_STORE_STRATEGY";
2
- export declare const VectorStoreStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
2
+ export declare const VectorStoreStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -0,0 +1 @@
1
+ export * from './wrap-workflow-node-execution.command';
@@ -0,0 +1,26 @@
1
+ import { IXpertAgentExecution, JSONValue } from '@metad/contracts';
2
+ import { Command } from '@nestjs/cqrs';
3
+ import { Subscriber } from 'rxjs';
4
+ /**
5
+ * Wrap Workflow Node Execution Command
6
+ */
7
+ export declare class WrapWorkflowNodeExecutionCommand<T = any> extends Command<T> {
8
+ readonly fuc: (execution: Partial<IXpertAgentExecution>) => Promise<{
9
+ output?: string | JSONValue;
10
+ state: T;
11
+ }>;
12
+ readonly params: {
13
+ execution: Partial<IXpertAgentExecution>;
14
+ subscriber?: Subscriber<MessageEvent>;
15
+ catchError?: (error: Error) => Promise<void>;
16
+ };
17
+ static readonly type = "[Workflow] Wrap Workflow Node Execution";
18
+ constructor(fuc: (execution: Partial<IXpertAgentExecution>) => Promise<{
19
+ output?: string | JSONValue;
20
+ state: T;
21
+ }>, params: {
22
+ execution: Partial<IXpertAgentExecution>;
23
+ subscriber?: Subscriber<MessageEvent>;
24
+ catchError?: (error: Error) => Promise<void>;
25
+ });
26
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './trigger/index';
2
2
  export * from './node/index';
3
+ export * from './commands/index';
@@ -2,4 +2,4 @@ export declare const WORKFLOW_NODE_STRATEGY = "WORKFLOW_NODE_STRATEGY";
2
2
  /**
3
3
  * Decorator to mark a provider as a Workflow Node Strategy
4
4
  */
5
- export declare const WorkflowNodeStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
5
+ export declare const WorkflowNodeStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1,2 +1,2 @@
1
1
  export declare const WORKFLOW_TRIGGER_STRATEGY = "WORKFLOW_TRIGGER_STRATEGY";
2
- export declare const WorkflowTriggerStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
2
+ export declare const WorkflowTriggerStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;