@xpert-ai/plugin-sdk 3.6.0 → 3.6.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 (157) hide show
  1. package/index.cjs.d.ts +1 -0
  2. package/index.cjs.js +45273 -5
  3. package/index.esm.d.ts +1 -0
  4. package/index.esm.js +45192 -0
  5. package/package.json +3 -3
  6. package/src/index.d.ts +12 -0
  7. package/src/lib/ai-model/abstract-provider.d.ts +41 -0
  8. package/src/lib/ai-model/ai-model-provider.decorator.d.ts +2 -0
  9. package/src/lib/ai-model/ai-model-provider.interface.d.ts +42 -0
  10. package/src/lib/ai-model/ai-model-provider.registry.d.ts +6 -0
  11. package/src/lib/ai-model/ai-model.d.ts +33 -0
  12. package/src/lib/ai-model/entities/defaults.d.ts +3 -0
  13. package/src/lib/ai-model/entities/index.d.ts +2 -0
  14. package/src/lib/ai-model/entities/model_entities.d.ts +14 -0
  15. package/src/lib/ai-model/errors.d.ts +5 -0
  16. package/src/lib/ai-model/index.d.ts +8 -0
  17. package/src/lib/ai-model/llm.d.ts +49 -0
  18. package/src/lib/ai-model/openai-compatible/completions.d.ts +23 -0
  19. package/src/lib/ai-model/openai-compatible/index.d.ts +3 -0
  20. package/src/lib/ai-model/openai-compatible/rerank.d.ts +20 -0
  21. package/src/lib/ai-model/openai-compatible/speech2text.d.ts +17 -0
  22. package/src/lib/ai-model/types/index.d.ts +11 -0
  23. package/src/lib/ai-model/types/model.d.ts +43 -0
  24. package/src/lib/ai-model/types/rerank.d.ts +20 -0
  25. package/src/lib/ai-model/types/speech2text.d.ts +3 -0
  26. package/src/lib/ai-model/types/text-embedding-model.d.ts +7 -0
  27. package/src/lib/ai-model/types/tts.d.ts +5 -0
  28. package/src/lib/core/file-system.d.ts +55 -0
  29. package/src/lib/core/i18n.d.ts +2 -0
  30. package/src/lib/core/index.d.ts +5 -0
  31. package/src/lib/core/permissions.d.ts +74 -0
  32. package/src/lib/core/schema.d.ts +22 -0
  33. package/src/lib/core/utils.d.ts +12 -0
  34. package/src/lib/integration/index.d.ts +3 -0
  35. package/src/lib/integration/strategy.decorator.d.ts +2 -0
  36. package/src/lib/integration/strategy.interface.d.ts +9 -0
  37. package/src/lib/integration/strategy.registry.d.ts +6 -0
  38. package/src/lib/logger.d.ts +2 -0
  39. package/src/lib/plugin-metadata.d.ts +17 -0
  40. package/src/lib/plugin.d.ts +8 -0
  41. package/src/lib/{plugin.hook.ts → plugin.hook.d.ts} +0 -4
  42. package/src/lib/plugin.interface.d.ts +59 -0
  43. package/src/lib/rag/image/index.d.ts +3 -0
  44. package/src/lib/rag/image/strategy.decorator.d.ts +5 -0
  45. package/src/lib/rag/image/strategy.interface.d.ts +31 -0
  46. package/src/lib/rag/image/strategy.registry.d.ts +6 -0
  47. package/src/lib/rag/index.d.ts +7 -0
  48. package/src/lib/rag/knowledge/index.d.ts +3 -0
  49. package/src/lib/rag/knowledge/knowledge-strategy.decorator.d.ts +2 -0
  50. package/src/lib/rag/knowledge/knowledge-strategy.interface.d.ts +15 -0
  51. package/src/lib/rag/knowledge/knowledge-strategy.registry.d.ts +6 -0
  52. package/src/lib/rag/retriever/index.d.ts +3 -0
  53. package/src/lib/rag/retriever/strategy.decorator.d.ts +5 -0
  54. package/src/lib/rag/retriever/strategy.interface.d.ts +30 -0
  55. package/src/lib/rag/retriever/strategy.registry.d.ts +6 -0
  56. package/src/lib/rag/source/index.d.ts +3 -0
  57. package/src/lib/rag/source/strategy.decorator.d.ts +5 -0
  58. package/src/lib/rag/source/strategy.interface.d.ts +36 -0
  59. package/src/lib/rag/source/strategy.registry.d.ts +6 -0
  60. package/src/lib/rag/textsplitter/index.d.ts +3 -0
  61. package/src/lib/rag/textsplitter/strategy.decorator.d.ts +2 -0
  62. package/src/lib/rag/textsplitter/strategy.interface.d.ts +23 -0
  63. package/src/lib/rag/textsplitter/strategy.registry.d.ts +6 -0
  64. package/src/lib/rag/transformer/index.d.ts +3 -0
  65. package/src/lib/rag/transformer/strategy.decorator.d.ts +5 -0
  66. package/src/lib/rag/transformer/strategy.interface.d.ts +26 -0
  67. package/src/lib/rag/transformer/strategy.registry.d.ts +6 -0
  68. package/src/lib/rag/types.d.ts +18 -0
  69. package/src/lib/strategy.d.ts +12 -0
  70. package/src/lib/toolset/builtin.d.ts +54 -0
  71. package/src/lib/toolset/index.d.ts +5 -0
  72. package/src/lib/toolset/strategy.decorator.d.ts +5 -0
  73. package/src/lib/toolset/strategy.interface.d.ts +28 -0
  74. package/src/lib/toolset/strategy.registry.d.ts +6 -0
  75. package/src/lib/toolset/toolset.d.ts +53 -0
  76. package/src/lib/types.d.ts +47 -0
  77. package/src/lib/vectorstore/index.d.ts +3 -0
  78. package/src/lib/vectorstore/strategy.decorator.d.ts +2 -0
  79. package/src/lib/vectorstore/strategy.interface.d.ts +24 -0
  80. package/src/lib/vectorstore/strategy.registry.d.ts +6 -0
  81. package/src/lib/workflow/index.d.ts +2 -0
  82. package/src/lib/workflow/node/index.d.ts +3 -0
  83. package/src/lib/workflow/node/strategy.decorator.d.ts +5 -0
  84. package/src/lib/workflow/node/strategy.interface.d.ts +41 -0
  85. package/src/lib/workflow/node/strategy.registry.d.ts +9 -0
  86. package/src/lib/workflow/trigger/index.d.ts +3 -0
  87. package/src/lib/workflow/trigger/strategy.decorator.d.ts +2 -0
  88. package/src/lib/workflow/trigger/strategy.interface.d.ts +22 -0
  89. package/src/lib/workflow/trigger/strategy.registry.d.ts +6 -0
  90. package/.eslintrc.json +0 -30
  91. package/.swcrc +0 -29
  92. package/jest.config.ts +0 -28
  93. package/project.json +0 -59
  94. package/src/index.ts +0 -11
  95. package/src/lib/core/file-system.ts +0 -113
  96. package/src/lib/core/i18n.ts +0 -31
  97. package/src/lib/core/index.ts +0 -4
  98. package/src/lib/core/permissions.ts +0 -97
  99. package/src/lib/core/schema.ts +0 -23
  100. package/src/lib/integration/index.ts +0 -3
  101. package/src/lib/integration/strategy.decorator.ts +0 -6
  102. package/src/lib/integration/strategy.interface.ts +0 -11
  103. package/src/lib/integration/strategy.registry.ts +0 -12
  104. package/src/lib/logger.ts +0 -18
  105. package/src/lib/plugin-metadata.ts +0 -20
  106. package/src/lib/plugin.interface.ts +0 -67
  107. package/src/lib/plugin.ts +0 -32
  108. package/src/lib/rag/image/index.ts +0 -3
  109. package/src/lib/rag/image/strategy.decorator.ts +0 -9
  110. package/src/lib/rag/image/strategy.interface.ts +0 -37
  111. package/src/lib/rag/image/strategy.registry.ts +0 -17
  112. package/src/lib/rag/index.ts +0 -7
  113. package/src/lib/rag/knowledge/index.ts +0 -3
  114. package/src/lib/rag/knowledge/knowledge-strategy.decorator.ts +0 -6
  115. package/src/lib/rag/knowledge/knowledge-strategy.interface.ts +0 -15
  116. package/src/lib/rag/knowledge/knowledge-strategy.registry.ts +0 -12
  117. package/src/lib/rag/retriever/index.ts +0 -3
  118. package/src/lib/rag/retriever/strategy.decorator.ts +0 -9
  119. package/src/lib/rag/retriever/strategy.interface.ts +0 -32
  120. package/src/lib/rag/retriever/strategy.registry.ts +0 -12
  121. package/src/lib/rag/source/index.ts +0 -3
  122. package/src/lib/rag/source/strategy.decorator.ts +0 -9
  123. package/src/lib/rag/source/strategy.interface.ts +0 -36
  124. package/src/lib/rag/source/strategy.registry.ts +0 -17
  125. package/src/lib/rag/textsplitter/index.ts +0 -3
  126. package/src/lib/rag/textsplitter/strategy.decorator.ts +0 -6
  127. package/src/lib/rag/textsplitter/strategy.interface.ts +0 -28
  128. package/src/lib/rag/textsplitter/strategy.registry.ts +0 -17
  129. package/src/lib/rag/transformer/index.ts +0 -3
  130. package/src/lib/rag/transformer/strategy.decorator.ts +0 -9
  131. package/src/lib/rag/transformer/strategy.interface.ts +0 -34
  132. package/src/lib/rag/transformer/strategy.registry.ts +0 -14
  133. package/src/lib/rag/types.ts +0 -76
  134. package/src/lib/strategy.ts +0 -37
  135. package/src/lib/toolset/builtin.ts +0 -111
  136. package/src/lib/toolset/index.ts +0 -5
  137. package/src/lib/toolset/strategy.decorator.ts +0 -9
  138. package/src/lib/toolset/strategy.interface.ts +0 -32
  139. package/src/lib/toolset/strategy.registry.ts +0 -17
  140. package/src/lib/toolset/toolset.ts +0 -76
  141. package/src/lib/types.ts +0 -47
  142. package/src/lib/vectorstore/index.ts +0 -3
  143. package/src/lib/vectorstore/strategy.decorator.ts +0 -6
  144. package/src/lib/vectorstore/strategy.interface.ts +0 -25
  145. package/src/lib/vectorstore/strategy.registry.ts +0 -17
  146. package/src/lib/workflow/index.ts +0 -2
  147. package/src/lib/workflow/node/index.ts +0 -3
  148. package/src/lib/workflow/node/strategy.decorator.ts +0 -9
  149. package/src/lib/workflow/node/strategy.interface.ts +0 -51
  150. package/src/lib/workflow/node/strategy.registry.ts +0 -18
  151. package/src/lib/workflow/trigger/index.ts +0 -3
  152. package/src/lib/workflow/trigger/strategy.decorator.ts +0 -6
  153. package/src/lib/workflow/trigger/strategy.interface.ts +0 -27
  154. package/src/lib/workflow/trigger/strategy.registry.ts +0 -17
  155. package/tsconfig.json +0 -22
  156. package/tsconfig.lib.json +0 -10
  157. package/tsconfig.spec.json +0 -9
@@ -1,111 +0,0 @@
1
- import { StructuredToolInterface } from '@langchain/core/tools'
2
- import { BaseStore } from '@langchain/langgraph'
3
- import {
4
- I18nObject,
5
- IBuiltinTool,
6
- IXpertToolset,
7
- ToolProviderCredentials,
8
- TToolCredentials,
9
- TToolsetParams,
10
- XpertToolsetCategoryEnum
11
- } from '@metad/contracts'
12
- import { Logger } from '@nestjs/common'
13
- import { CommandBus, QueryBus } from '@nestjs/cqrs'
14
- import { BaseToolset } from './toolset'
15
-
16
- /**
17
- * The context params of creating toolset
18
- */
19
- export type TBuiltinToolsetParams = TToolsetParams & {
20
- commandBus: CommandBus
21
- queryBus: QueryBus
22
- store?: BaseStore
23
- }
24
-
25
- export interface IBuiltinToolset {
26
- validateCredentials(credentials: TToolCredentials): Promise<void>
27
- }
28
-
29
- export abstract class BuiltinToolset<T extends StructuredToolInterface = StructuredToolInterface, C = TToolCredentials>
30
- extends BaseToolset<T>
31
- implements IBuiltinToolset
32
- {
33
- static provider = ''
34
- protected logger = new Logger(this.constructor.name)
35
-
36
- providerType: XpertToolsetCategoryEnum.BUILTIN
37
-
38
- credentialsSchema?: { [key: string]: ToolProviderCredentials }
39
-
40
- get tenantId() {
41
- return this.params?.tenantId
42
- }
43
- get organizationId() {
44
- return this.params?.organizationId
45
- }
46
- get commandBus() {
47
- return this.params?.commandBus
48
- }
49
- get queryBus() {
50
- return this.params?.queryBus
51
- }
52
-
53
- get xpertId() {
54
- return this.params?.xpertId
55
- }
56
-
57
- constructor(
58
- public providerName: string,
59
- protected toolset?: IXpertToolset,
60
- protected override params?: TBuiltinToolsetParams
61
- ) {
62
- super(params)
63
- }
64
-
65
- async validateCredentials(credentials: C): Promise<void> {
66
- await this._validateCredentials(credentials)
67
- }
68
-
69
- async _validateCredentials(credentials: C) {
70
- throw new Error('Method not implemented.')
71
- }
72
-
73
- getId() {
74
- return this.toolset?.id
75
- }
76
-
77
- getCredentials() {
78
- return this.toolset?.credentials as C
79
- }
80
-
81
- getToolTitle(name: string): string | I18nObject {
82
- const tool = this.toolset?.tools?.find((tool) => tool.name === name)
83
- const identity = (<IBuiltinTool>tool?.schema)?.identity
84
- if (identity) {
85
- return identity.label
86
- }
87
- return null
88
- }
89
-
90
- /**
91
- * Get credentials schema
92
- *
93
- * @returns Credentials schema
94
- */
95
- getCredentialsSchema(): { [key: string]: ToolProviderCredentials } {
96
- return { ...this.credentialsSchema }
97
- }
98
-
99
- /**
100
- * Get toolset entity
101
- *
102
- * @returns XpertToolset
103
- */
104
- getToolset() {
105
- return this.toolset
106
- }
107
-
108
- getName() {
109
- return this.getToolset()?.name
110
- }
111
- }
@@ -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,9 +0,0 @@
1
- import { SetMetadata } from '@nestjs/common';
2
-
3
- export const TOOLSET_STRATEGY = 'TOOLSET_STRATEGY';
4
-
5
- /**
6
- * Decorator to mark a provider as a Toolset Strategy
7
- */
8
- export const ToolsetStrategy = (provider: string) =>
9
- SetMetadata(TOOLSET_STRATEGY, provider);
@@ -1,32 +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
-
6
- export interface IToolsetStrategy<TConfig = any> {
7
- /**
8
- * Metadata about this toolset
9
- */
10
- readonly meta: {
11
- author: string // author name
12
- tags: string[] // tags for categorization
13
- name: string // unique key
14
- label: I18nObject // i18n label
15
- description?: I18nObject // optional i18n description
16
- configSchema: any // JSON schema for config validation
17
- icon?: {
18
- svg?: string
19
- png?: string // base64 encoded png image
20
- color?: string
21
- }
22
- }
23
-
24
- /**
25
- * Validate the configuration
26
- */
27
- validateConfig(config: TConfig): Promise<void>
28
-
29
- create(config: TConfig): Promise<BuiltinToolset>
30
-
31
- createTools(): DynamicStructuredTool<ZodSchema>[]
32
- }
@@ -1,17 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { DiscoveryService, Reflector } from '@nestjs/core';
3
- import { TOOLSET_STRATEGY } from './strategy.decorator';
4
- import { IToolsetStrategy } from './strategy.interface';
5
- import { BaseStrategyRegistry } from '../strategy';
6
-
7
- @Injectable()
8
- export class ToolsetRegistry<TConfig = any>
9
- extends BaseStrategyRegistry<IToolsetStrategy<TConfig>>
10
- {
11
- constructor(
12
- discoveryService: DiscoveryService,
13
- reflector: Reflector
14
- ) {
15
- super(TOOLSET_STRATEGY, discoveryService, reflector);
16
- }
17
- }
@@ -1,76 +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
-
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- type ZodObjectAny = z.ZodObject<any, any, any, any>;
7
-
8
- /**
9
- * Base ability for all toolsets
10
- */
11
- export abstract class BaseToolset<T extends StructuredToolInterface = StructuredToolInterface> extends BaseToolkit {
12
- abstract providerName: string
13
- // For Langchain
14
- tools: T[]
15
- // For Langgraph
16
- stateVariables: TStateVariable[]
17
-
18
- constructor(protected params?: TToolsetParams) {
19
- super()
20
- }
21
-
22
- /**
23
- * Async init tools
24
- *
25
- * @returns
26
- */
27
- async initTools() {
28
- return this.tools
29
- }
30
-
31
- /**
32
- * Get ID of the toolset
33
- */
34
- abstract getId(): string
35
- /**
36
- * Get name of the toolset
37
- */
38
- abstract getName(): string
39
-
40
- /**
41
- * Get one tool
42
- *
43
- * @param toolName
44
- * @returns
45
- */
46
- getTool(toolName: string) {
47
- return this.getTools()?.find((tool) => tool.name === toolName)
48
- }
49
-
50
- /**
51
- * Get state variables config
52
- *
53
- * @returns State variables
54
- */
55
- async getVariables(): Promise<TStateVariable[]> {
56
- return null
57
- }
58
-
59
- /**
60
- * Get title of tool
61
- */
62
- abstract getToolTitle(name: string): string | I18nObject
63
-
64
- /**
65
- * Close all (connections).
66
- */
67
- async close(): Promise<void> {
68
- //
69
- }
70
- }
71
-
72
- export abstract class BaseTool<T extends ZodObjectAny = ZodObjectAny> extends StructuredTool<T> {
73
- schema: any = z
74
- .object({ input: z.string().optional() })
75
- .transform((obj) => obj.input)
76
- }
package/src/lib/types.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
-
5
- export interface PluginLifecycle {
6
- /** Called after module registration but before application startup */
7
- onInit?(ctx: PluginContext): Promise<void> | void;
8
- /** Called after application startup (can start serving externally) */
9
- onStart?(ctx: PluginContext): Promise<void> | void;
10
- /** Called during graceful shutdown */
11
- onStop?(ctx: PluginContext): Promise<void> | void;
12
- }
13
-
14
- export interface PluginHealth {
15
- /** Returns health status and optional dependency check details */
16
- checkHealth?(ctx: PluginContext): Promise<{ status: 'up' | 'down'; details?: any }> | { status: 'up' | 'down'; details?: any };
17
- }
18
-
19
- export interface PluginConfigSpec<T extends object = any> {
20
- /** Zod validation schema for plugin-level config (optional) */
21
- schema?: ZodSchema<T>;
22
- /** Default configuration */
23
- defaults?: Partial<T>;
24
- }
25
-
26
- export interface XpertPlugin<TConfig extends object = any> extends PluginLifecycle, PluginHealth {
27
- meta: PluginMeta;
28
- config?: PluginConfigSpec<TConfig>;
29
- /** Returns the DynamicModule to be mounted to the main application (can be set as global) */
30
- register(ctx: PluginContext<TConfig>): DynamicModule;
31
- }
32
-
33
- export interface PluginContext<TConfig extends object = any> {
34
- app: INestApplicationContext; // Nest runtime context (injected after startup)
35
- logger: PluginLogger; // Logger wrapper provided by SDK
36
- config: TConfig; // Final config after validation and merging
37
- /** Helper method to access other Providers in the container */
38
- resolve<TInput = any, TResult = TInput>(token: any): TResult;
39
- }
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,3 +0,0 @@
1
- export * from './strategy.decorator'
2
- export * from './strategy.interface'
3
- export * from './strategy.registry'
@@ -1,6 +0,0 @@
1
- import { SetMetadata } from '@nestjs/common';
2
-
3
- export const VECTOR_STORE_STRATEGY = 'VECTOR_STORE_STRATEGY';
4
-
5
- export const VectorStoreStrategy = (provider: string) =>
6
- SetMetadata(VECTOR_STORE_STRATEGY, provider);
@@ -1,25 +0,0 @@
1
- import { EmbeddingsInterface } from '@langchain/core/embeddings'
2
- import { VectorStore } from '@langchain/core/vectorstores'
3
-
4
- /**
5
- * Interface for VectorStore strategy。
6
- *
7
- *
8
- */
9
- export interface IVectorStoreStrategy<TConfig extends {collectionName?: string}> {
10
- /**
11
- * Metadata about the strategy
12
- */
13
- readonly name: string;
14
- readonly description?: string;
15
-
16
- /**
17
- * Validate configuration for VectorStore
18
- */
19
- validateConfig(config: TConfig): Promise<void>;
20
-
21
- /**
22
- * Create a VectorStore with given config
23
- */
24
- createStore(embeddings: EmbeddingsInterface, config: TConfig): Promise<VectorStore>;
25
- }
@@ -1,17 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { DiscoveryService, Reflector } from '@nestjs/core';
3
- import { BaseStrategyRegistry } from '../strategy';
4
- import { VECTOR_STORE_STRATEGY } from './strategy.decorator';
5
- import { IVectorStoreStrategy } from './strategy.interface';
6
-
7
- @Injectable()
8
- export class VectorStoreRegistry<TConfig = any>
9
- extends BaseStrategyRegistry<IVectorStoreStrategy<TConfig>>
10
- {
11
- constructor(
12
- discoveryService: DiscoveryService,
13
- reflector: Reflector
14
- ) {
15
- super(VECTOR_STORE_STRATEGY, discoveryService, reflector);
16
- }
17
- }
@@ -1,2 +0,0 @@
1
- export * from './trigger/index'
2
- export * from './node/index'
@@ -1,3 +0,0 @@
1
- export * from './strategy.decorator'
2
- export * from './strategy.interface'
3
- export * from './strategy.registry'
@@ -1,9 +0,0 @@
1
- import { SetMetadata } from '@nestjs/common';
2
-
3
- export const WORKFLOW_NODE_STRATEGY = 'WORKFLOW_NODE_STRATEGY';
4
-
5
- /**
6
- * Decorator to mark a provider as a Workflow Node Strategy
7
- */
8
- export const WorkflowNodeStrategy = (provider: string) =>
9
- SetMetadata(WORKFLOW_NODE_STRATEGY, provider);
@@ -1,51 +0,0 @@
1
- import { Runnable } from '@langchain/core/runnables'
2
- import { BaseChannel } from '@langchain/langgraph'
3
- import {
4
- IEnvironment,
5
- IWorkflowNode,
6
- TWorkflowNodeMeta,
7
- TXpertGraph,
8
- TXpertParameter,
9
- TXpertTeamNode
10
- } from '@metad/contracts'
11
-
12
- export type TWorkflowNodeParams<TConfig = any> = {
13
- xpertId: string
14
- agentKey?: string
15
- node: TXpertTeamNode
16
- config: TConfig
17
- }
18
-
19
- export type TWorkflowNodeResult = {
20
- name?: string
21
- graph: Runnable
22
- ends: string[]
23
- channel?: {
24
- name: string
25
- annotation: BaseChannel
26
- }
27
- navigator?: (state, config) => Promise<any>
28
- }
29
-
30
- /**
31
- * Workflow Node Strategy interface
32
- */
33
- export interface IWorkflowNodeStrategy<TConfig = any, TResult = any> {
34
- /**
35
- * Metadata describing the node (type, label, description, config schema, etc.)
36
- */
37
- meta: TWorkflowNodeMeta
38
-
39
- /**
40
- * Create the node subgraph
41
- */
42
- create(payload: {
43
- graph: TXpertGraph
44
- node: TXpertTeamNode & { type: 'workflow' }
45
- xpertId: string
46
- environment: IEnvironment
47
- isDraft: boolean
48
- }): TWorkflowNodeResult
49
-
50
- outputVariables(entity: IWorkflowNode): TXpertParameter[]
51
- }
@@ -1,18 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { DiscoveryService, Reflector } from '@nestjs/core';
3
- import { BaseStrategyRegistry } from '../../strategy';
4
- import { WORKFLOW_NODE_STRATEGY } from './strategy.decorator';
5
- import { IWorkflowNodeStrategy } from './strategy.interface';
6
-
7
- /**
8
- * Registry for Workflow Node Strategies
9
- */
10
- @Injectable()
11
- export class WorkflowNodeRegistry<TConfig = any, TResult = any> extends BaseStrategyRegistry<IWorkflowNodeStrategy<TConfig, TResult>> {
12
- constructor(
13
- discoveryService: DiscoveryService,
14
- reflector: Reflector
15
- ) {
16
- super(WORKFLOW_NODE_STRATEGY, discoveryService, reflector);
17
- }
18
- }
@@ -1,3 +0,0 @@
1
- export * from './strategy.decorator'
2
- export * from './strategy.interface'
3
- export * from './strategy.registry'
@@ -1,6 +0,0 @@
1
- import { SetMetadata } from '@nestjs/common';
2
-
3
- export const WORKFLOW_TRIGGER_STRATEGY = 'WORKFLOW_TRIGGER_STRATEGY';
4
-
5
- export const WorkflowTriggerStrategy = (provider: string) =>
6
- SetMetadata(WORKFLOW_TRIGGER_STRATEGY, provider);
@@ -1,27 +0,0 @@
1
- import { TWorkflowTriggerMeta, TXpertTeamNode } from '@metad/contracts'
2
-
3
- export type TWorkflowTriggerParams<T> = {
4
- xpertId: string
5
- agentKey?: string
6
- node?: TXpertTeamNode
7
- config: T
8
- }
9
-
10
- export interface IWorkflowTriggerStrategy<T> {
11
- meta: TWorkflowTriggerMeta
12
-
13
- validate(payload: TWorkflowTriggerParams<T>): Promise<any[]>
14
-
15
- /**
16
- * Initialize the trigger when publish xpert workflow
17
- *
18
- * @param payload
19
- * @param callback
20
- */
21
- publish(payload: TWorkflowTriggerParams<T>, callback: (payload: any) => void): Promise<any> | void
22
-
23
- /**
24
- * Stop the trigger
25
- */
26
- stop(payload: TWorkflowTriggerParams<T>): void;
27
- }
@@ -1,17 +0,0 @@
1
- import { Injectable } from '@nestjs/common'
2
- import { DiscoveryService, Reflector } from '@nestjs/core'
3
- import { BaseStrategyRegistry } from '../../strategy'
4
- import { WORKFLOW_TRIGGER_STRATEGY } from './strategy.decorator'
5
- import { IWorkflowTriggerStrategy } from './strategy.interface'
6
-
7
- @Injectable()
8
- export class WorkflowTriggerRegistry<T = any> extends BaseStrategyRegistry<IWorkflowTriggerStrategy<T>> {
9
-
10
- constructor(
11
- discoveryService: DiscoveryService,
12
- reflector: Reflector
13
- ) {
14
- super(WORKFLOW_TRIGGER_STRATEGY, discoveryService, reflector);
15
- }
16
-
17
- }
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "forceConsistentCasingInFileNames": true,
6
- "strict": true,
7
- "noImplicitOverride": true,
8
- "noPropertyAccessFromIndexSignature": true,
9
- "noImplicitReturns": true,
10
- "noFallthroughCasesInSwitch": true
11
- },
12
- "files": [],
13
- "include": [],
14
- "references": [
15
- {
16
- "path": "./tsconfig.lib.json"
17
- },
18
- {
19
- "path": "./tsconfig.spec.json"
20
- }
21
- ]
22
- }
package/tsconfig.lib.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "declaration": true,
6
- "types": ["node"]
7
- },
8
- "include": ["src/**/*.ts"],
9
- "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
10
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "module": "commonjs",
6
- "types": ["jest", "node"]
7
- },
8
- "include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
9
- }