@xpert-ai/plugin-sdk 3.8.1 → 3.8.4

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.
@@ -0,0 +1,2 @@
1
+ export * from './file-storage';
2
+ export * from './file-upload';
@@ -2,10 +2,22 @@ import { IIntegration, TIntegrationProvider } from '@metad/contracts';
2
2
  export type TIntegrationStrategyParams = {
3
3
  query: string;
4
4
  };
5
+ export type IntegrationTestProbe = {
6
+ connected?: boolean;
7
+ state?: string;
8
+ lastError?: string | null;
9
+ checkedAt?: number | null;
10
+ };
11
+ export type IntegrationTestResult = {
12
+ webhookUrl?: string;
13
+ mode?: string;
14
+ warnings?: string[];
15
+ probe?: IntegrationTestProbe;
16
+ } & Record<string, unknown>;
5
17
  export interface IntegrationStrategy<T = unknown> {
6
18
  meta: TIntegrationProvider;
7
19
  execute(integration: IIntegration<T>, payload: TIntegrationStrategyParams): Promise<any>;
8
- validateConfig?(config: T, integration?: IIntegration<T>): Promise<void | {
9
- webhookUrl: string;
10
- }>;
20
+ onUpdate?(previous: IIntegration<T>, current: IIntegration<any>): Promise<void> | void;
21
+ onDelete?(integration: IIntegration<T>): Promise<void> | void;
22
+ validateConfig?(config: T, integration?: IIntegration<T>): Promise<void | IntegrationTestResult>;
11
23
  }
@@ -0,0 +1,27 @@
1
+ export interface SandboxExecutionOptions {
2
+ timeoutMs?: number;
3
+ maxOutputBytes?: number;
4
+ }
5
+ export interface ResolvedSandboxExecutionOptions {
6
+ timeoutMs: number;
7
+ maxOutputBytes: number;
8
+ }
9
+ export declare const SANDBOX_SHELL_TIMEOUT_LIMITS_SEC: {
10
+ readonly min: 1;
11
+ readonly max: 3600;
12
+ };
13
+ export declare const DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC = 600;
14
+ export declare const DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC = 120;
15
+ export declare const DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC = 120;
16
+ export declare const DEFAULT_SANDBOX_SHELL_TIMEOUT_MS: number;
17
+ export declare const DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS: number;
18
+ export declare const DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS: number;
19
+ export declare const DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES: number;
20
+ export declare const DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS: Readonly<SandboxExecutionOptions>;
21
+ export declare const DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS: Readonly<SandboxExecutionOptions>;
22
+ export declare const DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS: Readonly<SandboxExecutionOptions>;
23
+ export declare function secondsToMilliseconds(seconds: number): number;
24
+ export declare function formatSandboxTimeout(timeoutMs: number): string;
25
+ export declare function buildSandboxTimeoutMessage(subject: string, timeoutMs: number): string;
26
+ export declare function appendSandboxMessage(output: string, message: string): string;
27
+ export declare function resolveSandboxExecutionOptions(options?: SandboxExecutionOptions, defaults?: SandboxExecutionOptions): ResolvedSandboxExecutionOptions;
@@ -1,3 +1,4 @@
1
+ export * from './execution';
1
2
  export * from './protocol';
2
3
  export * from './sandbox';
3
4
  export * from './sandbox.decorator';
@@ -1,3 +1,4 @@
1
+ import type { SandboxExecutionOptions } from './execution';
1
2
  /**
2
3
  * Protocol definition for pluggable memory backends.
3
4
  *
@@ -151,11 +152,13 @@ export interface ExecuteResponse {
151
152
  exitCode: number | null;
152
153
  /** Whether the output was truncated due to backend limitations */
153
154
  truncated: boolean;
155
+ /** Whether the command exceeded its timeout and was terminated */
156
+ timedOut?: boolean;
154
157
  }
155
158
  /**
156
159
  * Standardized error codes for file upload/download operations.
157
160
  */
158
- export type FileOperationError = "file_not_found" | "permission_denied" | "is_directory" | "invalid_path";
161
+ export type FileOperationError = 'file_not_found' | 'permission_denied' | 'is_directory' | 'invalid_path';
159
162
  /**
160
163
  * Result of a single file download operation.
161
164
  */
@@ -318,7 +321,7 @@ export interface SandboxBackendProtocol extends BackendProtocol {
318
321
  * @param command - Full shell command string to execute
319
322
  * @returns ExecuteResponse with combined output, exit code, and truncation flag
320
323
  */
321
- execute(command: string): MaybePromise<ExecuteResponse>;
324
+ execute(command: string, options?: SandboxExecutionOptions): MaybePromise<ExecuteResponse>;
322
325
  /**
323
326
  * Execute a command with line-by-line streaming output.
324
327
  *
@@ -337,9 +340,11 @@ export interface SandboxBackendProtocol extends BackendProtocol {
337
340
  * @param onLine - Callback invoked once per complete output line
338
341
  * @returns ExecuteResponse with combined output, exit code, and truncation flag
339
342
  */
340
- streamExecute?(command: string, onLine: (line: string) => void): MaybePromise<ExecuteResponse>;
343
+ streamExecute?(command: string, onLine: (line: string) => void, options?: SandboxExecutionOptions): MaybePromise<ExecuteResponse>;
341
344
  /** Unique identifier for the sandbox backend instance */
342
345
  readonly id: string;
346
+ /** Canonical sandbox environment identifier bound to this backend */
347
+ readonly environmentId?: string | null;
343
348
  }
344
349
  /**
345
350
  * Type guard to check if a backend supports execution.
@@ -7,7 +7,8 @@
7
7
  *
8
8
  * Requires Node.js 20+ on the sandbox host.
9
9
  */
10
- import type { EditOperation, EditResult, ExecuteResponse, FileDownloadResponse, FileInfo, FileUploadResponse, GrepMatch, IndentationOptions, MaybePromise, MultiEditResult, ReadMode, SandboxBackendProtocol, WriteResult } from "./protocol";
10
+ import type { EditOperation, EditResult, ExecuteResponse, FileDownloadResponse, FileInfo, FileUploadResponse, GrepMatch, IndentationOptions, MaybePromise, MultiEditResult, ReadMode, SandboxBackendProtocol, WriteResult } from './protocol';
11
+ import { SandboxExecutionOptions } from './execution';
11
12
  /**
12
13
  * Base sandbox implementation with execute() as the only abstract method.
13
14
  *
@@ -21,12 +22,18 @@ export declare abstract class BaseSandbox implements SandboxBackendProtocol {
21
22
  workingDirectory: string;
22
23
  /** Unique identifier for the sandbox backend */
23
24
  abstract readonly id: string;
25
+ /**
26
+ * Internal hook for file/search operations. Concrete backends can override
27
+ * this to distinguish "background helper commands" from user-facing shell
28
+ * execute calls.
29
+ */
30
+ protected executeOperation(command: string, options?: SandboxExecutionOptions): MaybePromise<ExecuteResponse>;
24
31
  /**
25
32
  * Execute a command in the sandbox.
26
33
  * This is the only method concrete implementations must provide.
27
34
  */
28
- abstract execute(command: string): MaybePromise<ExecuteResponse>;
29
- streamExecute(command: string, onLine: (line: string) => void): Promise<ExecuteResponse>;
35
+ abstract execute(command: string, options?: SandboxExecutionOptions): MaybePromise<ExecuteResponse>;
36
+ streamExecute(command: string, onLine: (line: string) => void, options?: SandboxExecutionOptions): Promise<ExecuteResponse>;
30
37
  /**
31
38
  * Upload multiple files to the sandbox.
32
39
  * Implementations must support partial success.
@@ -1,26 +1,22 @@
1
- import { TSandboxProviderMeta } from "@metad/contracts";
2
- import { SandboxBackendProtocol } from "./protocol";
1
+ import { TSandboxProviderMeta, TSandboxWorkForType } from '@metad/contracts';
2
+ import { SandboxBackendProtocol } from './protocol';
3
3
  export type SandboxProviderCreateOptions = {
4
4
  /**
5
5
  * Working space directory for the sandbox instance
6
6
  */
7
7
  workingDirectory?: string;
8
8
  /**
9
- * Sandbox container environment identifier
9
+ * Canonical sandbox environment identifier that owns the container lifecycle.
10
10
  */
11
11
  environmentId?: string;
12
12
  /**
13
13
  * Tenant identifier
14
14
  */
15
15
  tenantId?: string;
16
- /**
17
- * User identifier
18
- */
19
- userId?: string;
20
- /**
21
- * Project identifier
22
- */
23
- projectId?: string;
16
+ workFor: {
17
+ type: TSandboxWorkForType;
18
+ id: string;
19
+ };
24
20
  };
25
21
  export interface ISandboxProvider<T extends SandboxBackendProtocol = SandboxBackendProtocol> {
26
22
  type: string;
@@ -1,4 +1,4 @@
1
- import { PluginMeta } from '@metad/contracts';
1
+ import { JsonSchemaObjectType, PluginMeta } from '@metad/contracts';
2
2
  import type { DynamicModule, INestApplicationContext } from '@nestjs/common';
3
3
  import { ModuleRef } from '@nestjs/core';
4
4
  import type { ZodSchema } from 'zod';
@@ -30,6 +30,8 @@ export interface PluginConfigSpec<T extends object = any> {
30
30
  schema?: ZodSchema<T>;
31
31
  /** Default configuration */
32
32
  defaults?: Partial<T>;
33
+ /** Optional JSON schema used by frontend configuration forms. */
34
+ formSchema?: JsonSchemaObjectType;
33
35
  }
34
36
  export interface XpertPlugin<TConfig extends object = any> extends PluginLifecycle, PluginHealth {
35
37
  meta: PluginMeta;