@fastgpt-sdk/sandbox-adapter 0.0.19 → 0.0.20

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,32 @@
1
+ import { BaseSandboxAdapter } from '../BaseSandboxAdapter';
2
+ import type { ExecuteOptions, ExecuteResult, SandboxId, SandboxInfo, FileWriteEntry, FileWriteResult, FileDeleteResult, FileReadResult, MoveEntry, DirectoryEntry } from '@/types';
3
+ import type { E2BConfig, E2BCreateConfig } from './type';
4
+ /**
5
+ * E2B 沙盒适配器 - 使用官方 SDK
6
+ */
7
+ export declare class E2BAdapter extends BaseSandboxAdapter {
8
+ private config;
9
+ readonly provider: "e2b";
10
+ private sandbox;
11
+ private _id;
12
+ private createConfig?;
13
+ constructor(config: E2BConfig, createConfig?: E2BCreateConfig);
14
+ get id(): SandboxId;
15
+ ensureRunning(): Promise<void>;
16
+ create(): Promise<void>;
17
+ connect(): Promise<void>;
18
+ start(): Promise<void>;
19
+ stop(): Promise<void>;
20
+ delete(): Promise<void>;
21
+ getInfo(): Promise<SandboxInfo | null>;
22
+ execute(command: string, options?: ExecuteOptions): Promise<ExecuteResult>;
23
+ readFiles(paths: string[]): Promise<FileReadResult[]>;
24
+ writeFiles(files: FileWriteEntry[]): Promise<FileWriteResult[]>;
25
+ deleteFiles(paths: string[]): Promise<FileDeleteResult[]>;
26
+ moveFiles(moves: MoveEntry[]): Promise<void>;
27
+ createDirectories(paths: string[]): Promise<void>;
28
+ deleteDirectories(paths: string[]): Promise<void>;
29
+ listDirectory(path: string): Promise<DirectoryEntry[]>;
30
+ ping(): Promise<boolean>;
31
+ }
32
+ export type { E2BConfig, E2BCreateConfig } from './type';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * E2B 适配器配置
3
+ */
4
+ export interface E2BConfig {
5
+ /** E2B API Key */
6
+ apiKey: string;
7
+ /** 可选的沙盒 ID,用于连接到已存在的沙盒 */
8
+ sandboxId?: string;
9
+ /** 可选的模板 ID,用于创建新沙盒 */
10
+ template?: string;
11
+ /** 可选的超时时间(秒) */
12
+ timeout?: number;
13
+ /** 可选的环境变量 */
14
+ envs?: Record<string, string>;
15
+ /** 可选的元数据 */
16
+ metadata?: Record<string, string>;
17
+ }
18
+ /**
19
+ * E2B 创建沙盒配置(用于覆盖构造函数中的配置)
20
+ * 继承自 E2BConfig 但排除 apiKey 和 sandboxId
21
+ */
22
+ export type E2BCreateConfig = Omit<E2BConfig, 'apiKey' | 'sandboxId'>;
@@ -1,21 +1,26 @@
1
1
  import { type SealosDevboxConfig } from './SealosDevboxAdapter';
2
2
  import { type OpenSandboxConnectionConfig, type OpenSandboxConfigType } from './OpenSandboxAdapter';
3
+ import { type E2BConfig, type E2BCreateConfig } from './E2BAdapter';
3
4
  import { ISandbox } from '@/interfaces';
4
5
  export { SealosDevboxAdapter } from './SealosDevboxAdapter';
5
6
  export type { SealosDevboxConfig } from './SealosDevboxAdapter';
6
7
  export { OpenSandboxAdapter } from './OpenSandboxAdapter';
7
8
  export type { OpenSandboxConfigType, OpenSandboxConnectionConfig } from './OpenSandboxAdapter';
8
- export type SandboxProviderType = 'opensandbox' | 'sealosdevbox';
9
+ export { E2BAdapter } from './E2BAdapter';
10
+ export type { E2BConfig, E2BCreateConfig } from './E2BAdapter';
11
+ export type SandboxProviderType = 'opensandbox' | 'sealosdevbox' | 'e2b';
9
12
  /** Maps each provider name to the ISandbox config type it exposes. */
10
13
  interface SandboxConfigMap {
11
14
  opensandbox: OpenSandboxConfigType;
12
15
  sealosdevbox: undefined;
16
+ e2b: E2BCreateConfig;
13
17
  }
14
18
  /** Resolves the concrete ISandbox type for a given provider. */
15
19
  /** Maps each provider name to its constructor (connection) config type. */
16
20
  interface SandboxConnectionConfig {
17
21
  opensandbox: OpenSandboxConnectionConfig;
18
22
  sealosdevbox: SealosDevboxConfig;
23
+ e2b: E2BConfig;
19
24
  }
20
25
  /**
21
26
  * Create a sandbox provider instance.