@xpert-ai/plugin-sdk 3.7.0 → 3.7.2
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/index.cjs.js +522 -381
- package/index.esm.js +519 -384
- package/package.json +4 -1
- package/src/index.d.ts +1 -0
- package/src/lib/agent/middleware/index.d.ts +1 -0
- package/src/lib/agent/middleware/runtime.d.ts +57 -0
- package/src/lib/agent/middleware/strategy.decorator.d.ts +1 -1
- package/src/lib/agent/middleware/types.d.ts +73 -6
- package/src/lib/agent/skill/skill-source-provider.decorator.d.ts +1 -1
- package/src/lib/ai-model/ai-model.d.ts +3 -1
- package/src/lib/core/index.d.ts +2 -0
- package/src/lib/core/strategy-bus.d.ts +17 -0
- package/src/lib/core/types.d.ts +16 -0
- package/src/lib/core/utils.d.ts +6 -0
- package/src/lib/data/datasource/strategy.decorator.d.ts +1 -1
- package/src/lib/integration/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/image/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/knowledge/knowledge-strategy.decorator.d.ts +1 -1
- package/src/lib/rag/retriever/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/source/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/textsplitter/strategy.decorator.d.ts +1 -1
- package/src/lib/rag/transformer/strategy.decorator.d.ts +1 -1
- package/src/lib/strategy.d.ts +29 -3
- package/src/lib/toolset/strategy.decorator.d.ts +1 -1
- package/src/lib/types.d.ts +4 -0
- package/src/lib/vectorstore/strategy.decorator.d.ts +1 -1
- package/src/lib/workflow/node/strategy.decorator.d.ts +1 -1
- package/src/lib/workflow/trigger/strategy.decorator.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.2",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,13 +23,16 @@
|
|
|
23
23
|
"@nestjs/common": "*",
|
|
24
24
|
"@nestjs/core": "*",
|
|
25
25
|
"@nestjs/cqrs": "*",
|
|
26
|
+
"ajv": "*",
|
|
26
27
|
"lodash-es": "*",
|
|
27
28
|
"i18next-fs-backend": "*",
|
|
28
29
|
"i18next": "*",
|
|
30
|
+
"json-schema": "*",
|
|
29
31
|
"jsonwebtoken": "*",
|
|
30
32
|
"fs": "*",
|
|
31
33
|
"path": "*",
|
|
32
34
|
"passport-jwt": "*",
|
|
35
|
+
"rxjs": "*",
|
|
33
36
|
"stream": "*",
|
|
34
37
|
"yaml": "*",
|
|
35
38
|
"zod": "*"
|
package/src/index.d.ts
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Runtime as LangGraphRuntime } from "@langchain/langgraph";
|
|
2
|
+
import type { BaseMessage } from "@langchain/core/messages";
|
|
3
|
+
/**
|
|
4
|
+
* Type for the agent's built-in state properties.
|
|
5
|
+
*/
|
|
6
|
+
export type AgentBuiltInState = {
|
|
7
|
+
/**
|
|
8
|
+
* Array of messages representing the conversation history.
|
|
9
|
+
*
|
|
10
|
+
* This includes all messages exchanged during the agent's execution:
|
|
11
|
+
* - Human messages: Input from the user
|
|
12
|
+
* - AI messages: Responses from the language model
|
|
13
|
+
* - Tool messages: Results from tool executions
|
|
14
|
+
* - System messages: System-level instructions or information
|
|
15
|
+
*
|
|
16
|
+
* Messages are accumulated throughout the agent's lifecycle and can be
|
|
17
|
+
* accessed or modified by middleware hooks during execution.
|
|
18
|
+
*/
|
|
19
|
+
messages: BaseMessage[];
|
|
20
|
+
/**
|
|
21
|
+
* Structured response data returned by the agent when a `responseFormat` is configured.
|
|
22
|
+
*
|
|
23
|
+
* This property is only populated when you provide a `responseFormat` schema
|
|
24
|
+
* (as Zod or JSON schema) to the agent configuration. The agent will format
|
|
25
|
+
* its final output to match the specified schema and store it in this property.
|
|
26
|
+
*
|
|
27
|
+
* Note: The type is specified as `Record<string, unknown>` because TypeScript cannot
|
|
28
|
+
* infer the actual response format type in contexts like middleware, where the agent's
|
|
29
|
+
* generic type parameters are not accessible. You may need to cast this to your specific
|
|
30
|
+
* response type when accessing it.
|
|
31
|
+
*/
|
|
32
|
+
structuredResponse?: Record<string, unknown>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Type helper to check if TContext is an optional Zod schema
|
|
36
|
+
*/
|
|
37
|
+
type IsOptionalZodObject<T> = T extends any ? true : false;
|
|
38
|
+
type IsDefaultZodObject<T> = T extends any ? true : false;
|
|
39
|
+
export type WithMaybeContext<TContext> = undefined extends TContext ? {
|
|
40
|
+
readonly context?: TContext;
|
|
41
|
+
} : IsOptionalZodObject<TContext> extends true ? {
|
|
42
|
+
readonly context?: TContext;
|
|
43
|
+
} : IsDefaultZodObject<TContext> extends true ? {
|
|
44
|
+
readonly context?: TContext;
|
|
45
|
+
} : {
|
|
46
|
+
readonly context: TContext;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Runtime information available to middleware (readonly).
|
|
50
|
+
*/
|
|
51
|
+
export type Runtime<TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext>, "context" | "configurable">> & WithMaybeContext<TContext> & {
|
|
52
|
+
configurable?: {
|
|
53
|
+
thread_id?: string;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const AGENT_MIDDLEWARE_STRATEGY = "AGENT_MIDDLEWARE_STRATEGY";
|
|
2
|
-
export declare const AgentMiddlewareStrategy: (provider: string) =>
|
|
2
|
+
export declare const AgentMiddlewareStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { LanguageModelLike } from '@langchain/core/language_models/base';
|
|
2
2
|
import { AIMessage, BaseMessage, SystemMessage } from '@langchain/core/messages';
|
|
3
|
-
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
4
|
-
import {
|
|
3
|
+
import { DynamicStructuredTool, DynamicTool, StructuredToolInterface } from '@langchain/core/tools';
|
|
4
|
+
import type { ToolCall, ToolMessage } from "@langchain/core/messages/tool";
|
|
5
|
+
import { InferInteropZodOutput, InteropZodObject } from '@langchain/core/utils/types';
|
|
6
|
+
import { RunnableToolLike } from '@langchain/core/runnables';
|
|
7
|
+
import { AgentBuiltInState, Runtime } from './runtime';
|
|
8
|
+
import { Command } from '@langchain/langgraph';
|
|
9
|
+
export type ServerTool = Record<string, unknown>;
|
|
10
|
+
export type ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;
|
|
11
|
+
export type NormalizedSchemaInput<TSchema extends InteropZodObject | undefined | never = any> = [TSchema] extends [never] ? AgentBuiltInState : TSchema extends InteropZodObject ? InferInteropZodOutput<TSchema> & AgentBuiltInState : TSchema extends Record<string, unknown> ? TSchema & AgentBuiltInState : AgentBuiltInState;
|
|
12
|
+
type NormalizeContextSchema<TContextSchema extends InteropZodObject | undefined = undefined> = TContextSchema extends InteropZodObject ? InferInteropZodOutput<TContextSchema> : never;
|
|
5
13
|
/**
|
|
6
14
|
* jump targets (user facing)
|
|
7
15
|
*/
|
|
@@ -94,7 +102,7 @@ export type AfterAgentHook<TSchema extends InteropZodObject | undefined = undefi
|
|
|
94
102
|
* @template TState - The agent's state type, must extend Record<string, unknown>. Defaults to Record<string, unknown>.
|
|
95
103
|
* @template TContext - The runtime context type for accessing metadata and control flow. Defaults to unknown.
|
|
96
104
|
*/
|
|
97
|
-
export interface ModelRequest<TState =
|
|
105
|
+
export interface ModelRequest<TState extends Record<string, unknown> = Record<string, unknown>, TContext = unknown> {
|
|
98
106
|
/**
|
|
99
107
|
* The model to use for this step.
|
|
100
108
|
*/
|
|
@@ -104,6 +112,32 @@ export interface ModelRequest<TState = any, TContext = unknown> {
|
|
|
104
112
|
*/
|
|
105
113
|
messages: BaseMessage[];
|
|
106
114
|
systemMessage?: SystemMessage;
|
|
115
|
+
/**
|
|
116
|
+
* Tool choice configuration (model-specific format).
|
|
117
|
+
* Can be one of:
|
|
118
|
+
* - `"auto"`: means the model can pick between generating a message or calling one or more tools.
|
|
119
|
+
* - `"none"`: means the model will not call any tool and instead generates a message.
|
|
120
|
+
* - `"required"`: means the model must call one or more tools.
|
|
121
|
+
* - `{ type: "function", function: { name: string } }`: The model will use the specified function.
|
|
122
|
+
*/
|
|
123
|
+
toolChoice?: "auto" | "none" | "required" | {
|
|
124
|
+
type: "function";
|
|
125
|
+
function: {
|
|
126
|
+
name: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The tools to make available for this step.
|
|
131
|
+
*/
|
|
132
|
+
tools: (ServerTool | ClientTool)[];
|
|
133
|
+
/**
|
|
134
|
+
* The current agent state (includes both middleware state and built-in state).
|
|
135
|
+
*/
|
|
136
|
+
state: TState & AgentBuiltInState;
|
|
137
|
+
/**
|
|
138
|
+
* The runtime context containing metadata, signal, writer, interrupt, etc.
|
|
139
|
+
*/
|
|
140
|
+
runtime: Runtime<TContext>;
|
|
107
141
|
}
|
|
108
142
|
/**
|
|
109
143
|
* Handler function type for wrapping model calls.
|
|
@@ -112,7 +146,7 @@ export interface ModelRequest<TState = any, TContext = unknown> {
|
|
|
112
146
|
* @param request - The model request containing model, messages, systemPrompt, tools, state, and runtime
|
|
113
147
|
* @returns The AI message response from the model
|
|
114
148
|
*/
|
|
115
|
-
export type WrapModelCallHandler<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ModelRequest<TSchema
|
|
149
|
+
export type WrapModelCallHandler<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ModelRequest<NormalizedSchemaInput<TSchema>, TContext>) => PromiseOrValue<AIMessage>;
|
|
116
150
|
/**
|
|
117
151
|
* Wrapper function type for the wrapModelCall hook.
|
|
118
152
|
* Allows middleware to intercept and modify model execution.
|
|
@@ -126,7 +160,40 @@ export type WrapModelCallHandler<TSchema extends InteropZodObject | undefined =
|
|
|
126
160
|
* @param handler - The function that invokes the model. Call this with a ModelRequest to get the response
|
|
127
161
|
* @returns The AI message response from the model (or a modified version)
|
|
128
162
|
*/
|
|
129
|
-
export type WrapModelCallHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ModelRequest<TSchema
|
|
163
|
+
export type WrapModelCallHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ModelRequest<NormalizedSchemaInput<TSchema>, TContext>, handler: WrapModelCallHandler<TSchema, TContext>) => PromiseOrValue<AIMessage>;
|
|
164
|
+
/**
|
|
165
|
+
* Represents a tool call request for the wrapToolCall hook.
|
|
166
|
+
* Contains the tool call information along with the agent's current state and runtime.
|
|
167
|
+
*/
|
|
168
|
+
export interface ToolCallRequest<TState extends Record<string, unknown> = Record<string, unknown>, TContext = unknown> {
|
|
169
|
+
/**
|
|
170
|
+
* The tool call to be executed
|
|
171
|
+
*/
|
|
172
|
+
toolCall: ToolCall;
|
|
173
|
+
/**
|
|
174
|
+
* The BaseTool instance being invoked.
|
|
175
|
+
* Provides access to tool metadata like name, description, schema, etc.
|
|
176
|
+
*/
|
|
177
|
+
tool: ClientTool | ServerTool;
|
|
178
|
+
/**
|
|
179
|
+
* The current agent state (includes both middleware state and built-in state).
|
|
180
|
+
*/
|
|
181
|
+
state: TState & AgentBuiltInState;
|
|
182
|
+
/**
|
|
183
|
+
* The runtime context containing metadata, signal, writer, interrupt, etc.
|
|
184
|
+
*/
|
|
185
|
+
runtime: Runtime<TContext>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Handler function type for wrapping tool calls.
|
|
189
|
+
* Takes a tool call request and returns the tool result or a command.
|
|
190
|
+
*/
|
|
191
|
+
export type ToolCallHandler<TSchema extends Record<string, unknown> = AgentBuiltInState, TContext = unknown> = (request: ToolCallRequest<TSchema, TContext>) => PromiseOrValue<ToolMessage | Command>;
|
|
192
|
+
/**
|
|
193
|
+
* Wrapper function type for the wrapToolCall hook.
|
|
194
|
+
* Allows middleware to intercept and modify tool execution.
|
|
195
|
+
*/
|
|
196
|
+
export type WrapToolCallHook<TSchema extends InteropZodObject | undefined = undefined, TContext = unknown> = (request: ToolCallRequest<NormalizedSchemaInput<TSchema>, TContext>, handler: ToolCallHandler<NormalizedSchemaInput<TSchema>, TContext>) => PromiseOrValue<ToolMessage | Command>;
|
|
130
197
|
export interface AgentMiddleware<TSchema extends InteropZodObject | undefined = any, TContextSchema extends InteropZodObject | undefined = any, TFullContext = any> {
|
|
131
198
|
/**
|
|
132
199
|
* The name of the middleware.
|
|
@@ -244,6 +311,6 @@ export interface AgentMiddleware<TSchema extends InteropZodObject | undefined =
|
|
|
244
311
|
* }
|
|
245
312
|
* ```
|
|
246
313
|
*/
|
|
247
|
-
wrapToolCall?:
|
|
314
|
+
wrapToolCall?: WrapToolCallHook<TSchema, NormalizeContextSchema<TContextSchema>>;
|
|
248
315
|
}
|
|
249
316
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const SKILL_SOURCE_PROVIDER = "SKILL_SOURCE_PROVIDER";
|
|
2
|
-
export declare const SkillSourceProviderStrategy: (provider: string) =>
|
|
2
|
+
export declare const SkillSourceProviderStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
2
2
|
import { AIModelEntity, AiModelTypeEnum, ICopilotModel, ParameterRule, PriceInfo, PriceType } from '@metad/contracts';
|
|
3
3
|
import { Logger } from '@nestjs/common';
|
|
4
|
-
import { IAIModel, TChatModelOptions } from './types/';
|
|
5
4
|
import { ModelProvider } from './abstract-provider';
|
|
5
|
+
import { IAIModel, TChatModelOptions } from './types/model';
|
|
6
|
+
import { ModelProfile } from './types/profile';
|
|
6
7
|
export declare abstract class AIModel implements IAIModel {
|
|
7
8
|
protected readonly modelProvider: ModelProvider;
|
|
8
9
|
modelType: AiModelTypeEnum;
|
|
@@ -30,4 +31,5 @@ export declare abstract class AIModel implements IAIModel {
|
|
|
30
31
|
private sortModelSchemas;
|
|
31
32
|
protected _commonParameterRules(model: string): ParameterRule[];
|
|
32
33
|
getParameterRules(model: string, credentials: Record<string, string>): ParameterRule[];
|
|
34
|
+
getModelProfile(model: string, credentials: unknown): ModelProfile;
|
|
33
35
|
}
|
package/src/lib/core/index.d.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StrategyEntry } from './types';
|
|
2
|
+
export type StrategyBusEvent<S = any> = {
|
|
3
|
+
type: 'UPSERT';
|
|
4
|
+
strategyType: string;
|
|
5
|
+
entry: StrategyEntry<S>;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'REMOVE';
|
|
8
|
+
strategyType?: string;
|
|
9
|
+
pluginName: string;
|
|
10
|
+
orgId: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class StrategyBus {
|
|
13
|
+
private readonly subject;
|
|
14
|
+
readonly events$: import("rxjs").Observable<StrategyBusEvent<any>>;
|
|
15
|
+
upsert<S>(strategyType: string, entry: StrategyEntry<S>): void;
|
|
16
|
+
remove(orgId: string, pluginName: string): void;
|
|
17
|
+
}
|
|
@@ -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
|
+
}
|
package/src/lib/core/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { JSONSchema4 } from 'json-schema';
|
|
2
3
|
export declare function loadYamlFile<T>(filePath: string, logger?: Logger, ignoreError?: boolean, defaultValue?: T): T;
|
|
3
4
|
/**
|
|
4
5
|
* Get the mapping from name to index from a YAML file
|
|
@@ -10,3 +11,8 @@ export declare function loadYamlFile<T>(filePath: string, logger?: Logger, ignor
|
|
|
10
11
|
export declare function getPositionMap(folderPath: string, fileName?: string, logger?: Logger): Record<string, number>;
|
|
11
12
|
export declare function getPositionList(folderPath: string, fileName?: string, logger?: Logger): string[];
|
|
12
13
|
export declare function getErrorMessage(err: any): string;
|
|
14
|
+
export declare class JsonSchemaValidator {
|
|
15
|
+
private ajv;
|
|
16
|
+
constructor();
|
|
17
|
+
parseAndValidate(schemaStr?: string): JSONSchema4 | undefined;
|
|
18
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const DATASOURCE_STRATEGY = "DATASOURCE_STRATEGY";
|
|
2
|
-
export declare const DataSourceStrategy: (provider: string) =>
|
|
2
|
+
export declare const DataSourceStrategy: (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 INTEGRATION_STRATEGY = "INTEGRATION_STRATEGY";
|
|
2
|
-
export declare const IntegrationStrategyKey: (provider: 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) =>
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
5
|
+
export declare const DocumentTransformerStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
package/src/lib/strategy.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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) =>
|
|
5
|
+
export declare const ToolsetStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
package/src/lib/types.d.ts
CHANGED
|
@@ -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) =>
|
|
2
|
+
export declare const VectorStoreStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -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) =>
|
|
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) =>
|
|
2
|
+
export declare const WorkflowTriggerStrategy: (provider: string) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|