@xpert-ai/plugin-sdk 3.7.2 → 3.8.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.
- package/index.cjs.js +1282 -0
- package/index.esm.js +1256 -1
- package/package.json +2 -1
- package/src/index.d.ts +2 -0
- package/src/lib/agent/handoff/agent-chat.contract.d.ts +20 -0
- package/src/lib/agent/handoff/handoff-processor.decorator.d.ts +11 -0
- package/src/lib/agent/handoff/handoff-processor.registry.d.ts +6 -0
- package/src/lib/agent/handoff/handoff.interface.d.ts +17 -0
- package/src/lib/agent/handoff/index.d.ts +6 -0
- package/src/lib/agent/handoff/message-type.d.ts +24 -0
- package/src/lib/agent/handoff/types.d.ts +110 -0
- package/src/lib/agent/index.d.ts +1 -0
- package/src/lib/agent/middleware/runtime.d.ts +2 -0
- package/src/lib/agent/middleware/strategy.interface.d.ts +5 -1
- package/src/lib/agent/middleware/types.d.ts +2 -2
- package/src/lib/ai-model/utils/index.d.ts +1 -0
- package/src/lib/ai-model/utils/limits.d.ts +4 -0
- package/src/lib/channel/cancel-conversation.command.d.ts +14 -0
- package/src/lib/channel/index.d.ts +4 -0
- package/src/lib/channel/strategy.decorator.d.ts +23 -0
- package/src/lib/channel/strategy.interface.d.ts +345 -0
- package/src/lib/channel/strategy.registry.d.ts +30 -0
- package/src/lib/core/permissions/analytics.d.ts +46 -0
- package/src/lib/core/{permissions.d.ts → permissions/general.d.ts} +9 -12
- package/src/lib/core/permissions/handoff.d.ts +36 -0
- package/src/lib/core/permissions/index.d.ts +24 -0
- package/src/lib/core/permissions/operation.d.ts +8 -0
- package/src/lib/core/permissions/user.d.ts +29 -0
- package/src/lib/integration/strategy.interface.d.ts +3 -1
- package/src/lib/sandbox/index.d.ts +8 -0
- package/src/lib/sandbox/protocol.d.ts +383 -0
- package/src/lib/sandbox/sandbox.d.ts +103 -0
- package/src/lib/sandbox/sandbox.decorator.d.ts +2 -0
- package/src/lib/sandbox/sandbox.interface.d.ts +38 -0
- package/src/lib/sandbox/sandbox.registry.d.ts +6 -0
- package/src/lib/toolset/strategy.interface.d.ts +2 -6
- package/src/lib/types.d.ts +7 -1
- package/src/lib/workflow/node/strategy.interface.d.ts +4 -2
- package/src/lib/workflow/trigger/strategy.interface.d.ts +13 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseSandbox: Abstract base class for sandbox backends with command execution.
|
|
3
|
+
*
|
|
4
|
+
* This class provides default implementations for all SandboxBackendProtocol
|
|
5
|
+
* methods using shell commands executed via execute(). Concrete implementations
|
|
6
|
+
* only need to implement the execute() method.
|
|
7
|
+
*
|
|
8
|
+
* Requires Node.js 20+ on the sandbox host.
|
|
9
|
+
*/
|
|
10
|
+
import type { EditOperation, EditResult, ExecuteResponse, FileDownloadResponse, FileInfo, FileUploadResponse, GrepMatch, IndentationOptions, MaybePromise, MultiEditResult, ReadMode, SandboxBackendProtocol, WriteResult } from "./protocol";
|
|
11
|
+
/**
|
|
12
|
+
* Base sandbox implementation with execute() as the only abstract method.
|
|
13
|
+
*
|
|
14
|
+
* This class provides default implementations for all SandboxBackendProtocol
|
|
15
|
+
* methods using shell commands executed via execute(). Concrete implementations
|
|
16
|
+
* only need to implement the execute() method.
|
|
17
|
+
*
|
|
18
|
+
* Requires Node.js 20+ on the sandbox host.
|
|
19
|
+
*/
|
|
20
|
+
export declare abstract class BaseSandbox implements SandboxBackendProtocol {
|
|
21
|
+
workingDirectory: string;
|
|
22
|
+
/** Unique identifier for the sandbox backend */
|
|
23
|
+
abstract readonly id: string;
|
|
24
|
+
/**
|
|
25
|
+
* Execute a command in the sandbox.
|
|
26
|
+
* This is the only method concrete implementations must provide.
|
|
27
|
+
*/
|
|
28
|
+
abstract execute(command: string): MaybePromise<ExecuteResponse>;
|
|
29
|
+
streamExecute(command: string, onLine: (line: string) => void): Promise<ExecuteResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* Upload multiple files to the sandbox.
|
|
32
|
+
* Implementations must support partial success.
|
|
33
|
+
*/
|
|
34
|
+
abstract uploadFiles(files: Array<[string, Uint8Array]>): MaybePromise<FileUploadResponse[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Download multiple files from the sandbox.
|
|
37
|
+
* Implementations must support partial success.
|
|
38
|
+
*/
|
|
39
|
+
abstract downloadFiles(paths: string[]): MaybePromise<FileDownloadResponse[]>;
|
|
40
|
+
/**
|
|
41
|
+
* List files and directories in the specified directory (non-recursive).
|
|
42
|
+
*
|
|
43
|
+
* @param path - Absolute path to directory
|
|
44
|
+
* @returns List of FileInfo objects for files and directories directly in the directory.
|
|
45
|
+
*/
|
|
46
|
+
lsInfo(path: string): Promise<FileInfo[]>;
|
|
47
|
+
/**
|
|
48
|
+
* List directory contents recursively with depth control and pagination.
|
|
49
|
+
*
|
|
50
|
+
* @param dirPath - Absolute path to directory
|
|
51
|
+
* @param offset - 1-indexed entry number to start from (default: 1)
|
|
52
|
+
* @param limit - Maximum number of entries to return (default: 25)
|
|
53
|
+
* @param depth - Maximum depth to traverse (default: 2)
|
|
54
|
+
* @returns Human-readable directory tree with indentation
|
|
55
|
+
*/
|
|
56
|
+
listDir(dirPath: string, offset?: number, limit?: number, depth?: number): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Read file content with line numbers.
|
|
59
|
+
*
|
|
60
|
+
* @param filePath - Absolute file path
|
|
61
|
+
* @param offset - Line offset to start reading from (1-indexed)
|
|
62
|
+
* @param limit - Maximum number of lines to read
|
|
63
|
+
* @param mode - Read mode: 'slice' (default) or 'indentation'
|
|
64
|
+
* @param indentation - Configuration for indentation mode
|
|
65
|
+
* @returns Formatted file content with line numbers, or error message
|
|
66
|
+
*/
|
|
67
|
+
read(filePath: string, offset?: number, limit?: number, mode?: ReadMode, indentation?: IndentationOptions): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Structured search results or error string for invalid input.
|
|
70
|
+
*/
|
|
71
|
+
grepRaw(pattern: string, path?: string, include?: string | null): Promise<GrepMatch[] | string>;
|
|
72
|
+
/**
|
|
73
|
+
* Search file contents for a regex pattern, returning human-readable output.
|
|
74
|
+
*/
|
|
75
|
+
grep(pattern: string, path?: string, include?: string | null): Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Structured glob matching returning FileInfo objects.
|
|
78
|
+
*/
|
|
79
|
+
globInfo(pattern: string, path?: string): Promise<FileInfo[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Find files matching a glob pattern, returning human-readable output.
|
|
82
|
+
*/
|
|
83
|
+
glob(pattern: string, path?: string): Promise<string>;
|
|
84
|
+
/**
|
|
85
|
+
* Create a new file with content.
|
|
86
|
+
*/
|
|
87
|
+
write(filePath: string, content: string): Promise<WriteResult>;
|
|
88
|
+
private writeViaUpload;
|
|
89
|
+
/**
|
|
90
|
+
* Append content to a file. Creates the file if it doesn't exist.
|
|
91
|
+
*/
|
|
92
|
+
append(filePath: string, content: string): Promise<WriteResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Edit a file by replacing string occurrences.
|
|
95
|
+
*/
|
|
96
|
+
edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
|
|
97
|
+
/**
|
|
98
|
+
* Perform multiple sequential edits on a single file.
|
|
99
|
+
* All edits are applied sequentially, with each edit operating on the result of the previous edit.
|
|
100
|
+
* All edits must succeed for the operation to succeed (atomic).
|
|
101
|
+
*/
|
|
102
|
+
multiEdit(filePath: string, edits: EditOperation[]): Promise<MultiEditResult>;
|
|
103
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TSandboxProviderMeta } from "@metad/contracts";
|
|
2
|
+
import { SandboxBackendProtocol } from "./protocol";
|
|
3
|
+
export type SandboxProviderCreateOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Working space directory for the sandbox instance
|
|
6
|
+
*/
|
|
7
|
+
workingDirectory?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Sandbox container environment identifier
|
|
10
|
+
*/
|
|
11
|
+
environmentId?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Tenant identifier
|
|
14
|
+
*/
|
|
15
|
+
tenantId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* User identifier
|
|
18
|
+
*/
|
|
19
|
+
userId?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Project identifier
|
|
22
|
+
*/
|
|
23
|
+
projectId?: string;
|
|
24
|
+
};
|
|
25
|
+
export interface ISandboxProvider<T extends SandboxBackendProtocol = SandboxBackendProtocol> {
|
|
26
|
+
type: string;
|
|
27
|
+
meta: TSandboxProviderMeta;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new sandbox instance
|
|
30
|
+
*
|
|
31
|
+
* @param options
|
|
32
|
+
*/
|
|
33
|
+
create(options?: SandboxProviderCreateOptions): Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Get default working directory for the sandbox instances
|
|
36
|
+
*/
|
|
37
|
+
getDefaultWorkingDir(): string;
|
|
38
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { BaseStrategyRegistry } from '../strategy';
|
|
3
|
+
import { ISandboxProvider } from './sandbox.interface';
|
|
4
|
+
export declare class SandboxProviderRegistry extends BaseStrategyRegistry<ISandboxProvider> {
|
|
5
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
2
|
-
import { I18nObject } from '@metad/contracts';
|
|
2
|
+
import { I18nObject, IconDefinition } from '@metad/contracts';
|
|
3
3
|
import { ZodSchema } from 'zod';
|
|
4
4
|
import { BuiltinToolset } from './builtin';
|
|
5
5
|
export interface IToolsetStrategy<TConfig = any> {
|
|
@@ -13,11 +13,7 @@ export interface IToolsetStrategy<TConfig = any> {
|
|
|
13
13
|
label: I18nObject;
|
|
14
14
|
description?: I18nObject;
|
|
15
15
|
configSchema: any;
|
|
16
|
-
icon?:
|
|
17
|
-
svg?: string;
|
|
18
|
-
png?: string;
|
|
19
|
-
color?: string;
|
|
20
|
-
};
|
|
16
|
+
icon?: IconDefinition;
|
|
21
17
|
};
|
|
22
18
|
/**
|
|
23
19
|
* Validate the configuration
|
package/src/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PluginMeta } from '@metad/contracts';
|
|
2
2
|
import type { DynamicModule, INestApplicationContext } from '@nestjs/common';
|
|
3
|
+
import { ModuleRef } from '@nestjs/core';
|
|
3
4
|
import type { ZodSchema } from 'zod';
|
|
5
|
+
import type { Permissions } from './core/permissions';
|
|
4
6
|
export declare const ORGANIZATION_METADATA_KEY = "xpert:organizationId";
|
|
5
7
|
export declare const PLUGIN_METADATA_KEY = "xpert:pluginName";
|
|
6
8
|
export declare const GLOBAL_ORGANIZATION_SCOPE = "global";
|
|
@@ -32,11 +34,14 @@ export interface PluginConfigSpec<T extends object = any> {
|
|
|
32
34
|
export interface XpertPlugin<TConfig extends object = any> extends PluginLifecycle, PluginHealth {
|
|
33
35
|
meta: PluginMeta;
|
|
34
36
|
config?: PluginConfigSpec<TConfig>;
|
|
37
|
+
/** Declares the required system-level permissions for this plugin. */
|
|
38
|
+
permissions?: Permissions;
|
|
35
39
|
/** Returns the DynamicModule to be mounted to the main application (can be set as global) */
|
|
36
40
|
register(ctx: PluginContext<TConfig>): DynamicModule;
|
|
37
41
|
}
|
|
38
42
|
export interface PluginContext<TConfig extends object = any> {
|
|
39
|
-
|
|
43
|
+
module: ModuleRef;
|
|
44
|
+
app?: INestApplicationContext;
|
|
40
45
|
logger: PluginLogger;
|
|
41
46
|
config: TConfig;
|
|
42
47
|
/** Helper method to access other Providers in the container */
|
|
@@ -49,3 +54,4 @@ export interface PluginLogger {
|
|
|
49
54
|
warn(msg: string, meta?: any): void;
|
|
50
55
|
error(msg: string, meta?: any): void;
|
|
51
56
|
}
|
|
57
|
+
export type PromiseOrValue<T> = T | Promise<T>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Runnable } from '@langchain/core/runnables';
|
|
2
2
|
import { BaseChannel } from '@langchain/langgraph';
|
|
3
|
-
import { IEnvironment, IWorkflowNode, TWorkflowNodeMeta, TXpertGraph, TXpertParameter, TXpertTeamNode } from '@metad/contracts';
|
|
3
|
+
import { IEnvironment, IWorkflowNode, TWorkflowNodeMeta, TXpertGraph, TWorkflowVarGroup, TXpertParameter, TXpertTeamNode } from '@metad/contracts';
|
|
4
|
+
import { PromiseOrValue } from '../../types';
|
|
4
5
|
export type TWorkflowNodeParams<TConfig = any> = {
|
|
5
6
|
xpertId: string;
|
|
6
7
|
agentKey?: string;
|
|
@@ -36,6 +37,7 @@ export interface IWorkflowNodeStrategy<TConfig = any, TResult = any> {
|
|
|
36
37
|
xpertId: string;
|
|
37
38
|
environment: IEnvironment;
|
|
38
39
|
isDraft: boolean;
|
|
39
|
-
}): TWorkflowNodeResult
|
|
40
|
+
}): PromiseOrValue<TWorkflowNodeResult>;
|
|
41
|
+
inputVariables?(entity: IWorkflowNode, variables?: TWorkflowVarGroup[]): TXpertParameter[];
|
|
40
42
|
outputVariables(entity: IWorkflowNode): TXpertParameter[];
|
|
41
43
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { TWorkflowTriggerMeta, TXpertTeamNode } from '@metad/contracts';
|
|
2
|
+
export type TWorkflowTriggerBootstrapMode = 'replay_publish' | 'skip';
|
|
3
|
+
export type TWorkflowTriggerBootstrapConfig = {
|
|
4
|
+
mode: TWorkflowTriggerBootstrapMode;
|
|
5
|
+
critical?: boolean;
|
|
6
|
+
};
|
|
2
7
|
export type TWorkflowTriggerParams<T> = {
|
|
3
8
|
xpertId: string;
|
|
4
9
|
agentKey?: string;
|
|
@@ -7,6 +12,14 @@ export type TWorkflowTriggerParams<T> = {
|
|
|
7
12
|
};
|
|
8
13
|
export interface IWorkflowTriggerStrategy<T> {
|
|
9
14
|
meta: TWorkflowTriggerMeta;
|
|
15
|
+
/**
|
|
16
|
+
* Controls how this trigger should be recovered during system bootstrap.
|
|
17
|
+
*
|
|
18
|
+
* Default when omitted:
|
|
19
|
+
* - mode: "replay_publish"
|
|
20
|
+
* - critical: false
|
|
21
|
+
*/
|
|
22
|
+
bootstrap?: TWorkflowTriggerBootstrapConfig;
|
|
10
23
|
validate(payload: TWorkflowTriggerParams<T>): Promise<any[]>;
|
|
11
24
|
/**
|
|
12
25
|
* Initialize the trigger when publish xpert workflow
|