@fastgpt-sdk/sandbox-adapter 0.0.36 → 0.0.38-beta.0
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/dist/adapters/BaseSandboxAdapter.d.ts +3 -1
- package/dist/adapters/OpenSandboxAdapter/index.d.ts +11 -7
- package/dist/adapters/OpenSandboxAdapter/type.d.ts +1 -1
- package/dist/adapters/SealosDevboxAdapter/api.d.ts +4 -2
- package/dist/adapters/SealosDevboxAdapter/index.d.ts +26 -2
- package/dist/adapters/SealosDevboxAdapter/type.d.ts +32 -1
- package/dist/adapters/index.d.ts +3 -3
- package/dist/adapters/ports.d.ts +7 -0
- package/dist/index.cjs +282 -47
- package/dist/index.js +280 -45
- package/dist/interfaces/ISandbox.d.ts +5 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/sandbox.d.ts +45 -0
- package/dist/utils/image.d.ts +3 -0
- package/dist/utils/url.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ISandbox } from '../interfaces/ISandbox';
|
|
2
2
|
import { CommandPolyfillService } from '../polyfill/CommandPolyfillService';
|
|
3
|
-
import type { ContentReplaceEntry, DirectoryEntry, ExecuteOptions, ExecuteResult, FileDeleteResult, FileInfo, FileReadResult, FileWriteEntry, FileWriteResult, MoveEntry, PermissionEntry, ReadFileOptions, SandboxId, SandboxInfo, SandboxMetrics, SandboxStatus, SearchResult, StreamHandlers } from '../types';
|
|
3
|
+
import type { ContentReplaceEntry, DirectoryEntry, Endpoint, ExecuteOptions, ExecuteResult, FileDeleteResult, FileInfo, FileReadResult, FileWriteEntry, FileWriteResult, MoveEntry, PermissionEntry, ReadFileOptions, SandboxEndpointSelector, SandboxId, SandboxInfo, SandboxMetrics, SandboxProxyService, SandboxProxyTarget, SandboxStatus, SearchResult, StreamHandlers } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Abstract base class for all sandbox adapters.
|
|
6
6
|
*
|
|
@@ -37,6 +37,8 @@ export declare abstract class BaseSandboxAdapter implements ISandbox {
|
|
|
37
37
|
waitUntilReady(timeoutMs?: number): Promise<void>;
|
|
38
38
|
waitUntilDeleted(timeoutMs?: number): Promise<void>;
|
|
39
39
|
renewExpiration(_additionalSeconds: number): Promise<void>;
|
|
40
|
+
getEndpoint(_selector: SandboxEndpointSelector): Promise<Endpoint>;
|
|
41
|
+
getProxyTarget(_service?: SandboxProxyService): Promise<SandboxProxyTarget>;
|
|
40
42
|
abstract execute(command: string, options?: ExecuteOptions): Promise<ExecuteResult>;
|
|
41
43
|
executeStream(command: string, handlers: StreamHandlers, options?: ExecuteOptions): Promise<void>;
|
|
42
44
|
executeBackground(_command: string, _options?: ExecuteOptions): Promise<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Endpoint, ExecuteOptions, ExecuteResult, FileWriteEntry, FileWriteResult, SandboxId, SandboxInfo, SandboxMetrics, StreamHandlers } from '@/types';
|
|
1
|
+
import type { Endpoint, ExecuteOptions, ExecuteResult, FileWriteEntry, FileWriteResult, SandboxEndpointSelector, SandboxId, SandboxInfo, SandboxMetrics, SandboxProxyService, SandboxProxyTarget, StreamHandlers } from '@/types';
|
|
2
2
|
import { BaseSandboxAdapter } from '../BaseSandboxAdapter';
|
|
3
3
|
import type { OpenSandboxConfigType } from './type';
|
|
4
4
|
export type { OpenSandboxConfigType } from './type';
|
|
@@ -23,6 +23,11 @@ export interface OpenSandboxConnectionConfig {
|
|
|
23
23
|
debug?: boolean;
|
|
24
24
|
/** Route execd traffic through the OpenSandbox server proxy */
|
|
25
25
|
useServerProxy?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Rewrite OpenSandbox local endpoint host when sandbox-proxy runs on the host
|
|
28
|
+
* instead of inside Docker/Kubernetes.
|
|
29
|
+
*/
|
|
30
|
+
replaceDockerInternalWithLocalhost?: boolean;
|
|
26
31
|
/**
|
|
27
32
|
* Sandbox runtime type.
|
|
28
33
|
* @default 'docker'
|
|
@@ -65,8 +70,6 @@ export declare class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
65
70
|
private createConnectionConfig;
|
|
66
71
|
private static readonly STATE_MAP;
|
|
67
72
|
private mapStatus;
|
|
68
|
-
private convertImageSpec;
|
|
69
|
-
private parseImageSpec;
|
|
70
73
|
private convertResourceLimits;
|
|
71
74
|
private parseResourceLimits;
|
|
72
75
|
private extractExitCode;
|
|
@@ -85,11 +88,12 @@ export declare class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
85
88
|
*/
|
|
86
89
|
close(): Promise<void>;
|
|
87
90
|
/**
|
|
88
|
-
* Get endpoint information for a
|
|
89
|
-
* @param port The port number to get endpoint for
|
|
90
|
-
* @returns Endpoint with host, port, protocol and url fields
|
|
91
|
+
* Get endpoint information for a provider endpoint or well-known service.
|
|
91
92
|
*/
|
|
92
|
-
getEndpoint(
|
|
93
|
+
getEndpoint(selector: SandboxEndpointSelector): Promise<Endpoint>;
|
|
94
|
+
private getOpenSandboxEndpoint;
|
|
95
|
+
getProxyTarget(service?: SandboxProxyService): Promise<SandboxProxyTarget>;
|
|
96
|
+
private getDirectEndpointOrigin;
|
|
93
97
|
getInfo(): Promise<SandboxInfo | null>;
|
|
94
98
|
renewExpiration(additionalSeconds: number): Promise<void>;
|
|
95
99
|
writeFiles(entries: FileWriteEntry[]): Promise<FileWriteResult[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DevboxApiConfig, type DevboxApiResponse, type DevboxInfoData, type DevboxMutationData, type DownloadFileParams, type ExecRequest, type ExecResponseData, type UploadFileParams, type UploadResponseData } from './type';
|
|
1
|
+
import { type DevboxApiConfig, type DevboxApiResponse, type DevboxCreateRequest, type DevboxInfoData, type DevboxMutationData, type DownloadFileParams, type ExecRequest, type ExecResponseData, type UploadFileParams, type UploadResponseData } from './type';
|
|
2
2
|
/**
|
|
3
3
|
* HTTP client for the Sealos Devbox REST API.
|
|
4
4
|
*
|
|
@@ -11,11 +11,13 @@ export declare class DevboxApi {
|
|
|
11
11
|
private url;
|
|
12
12
|
private request;
|
|
13
13
|
/** POST /api/v1/devbox — create a devbox */
|
|
14
|
-
create(
|
|
14
|
+
create(req: DevboxCreateRequest): Promise<DevboxApiResponse<DevboxMutationData>>;
|
|
15
15
|
/** GET /api/v1/devbox/{name} — query devbox info (state + SSH) */
|
|
16
16
|
info(name: string): Promise<DevboxApiResponse<DevboxInfoData>>;
|
|
17
17
|
/** POST /api/v1/devbox/{name}/pause */
|
|
18
18
|
pause(name: string): Promise<DevboxApiResponse<DevboxMutationData>>;
|
|
19
|
+
/** POST /api/v1/devbox/{name}/stop */
|
|
20
|
+
stop(name: string): Promise<DevboxApiResponse<DevboxMutationData>>;
|
|
19
21
|
/** POST /api/v1/devbox/{name}/resume */
|
|
20
22
|
resume(name: string): Promise<DevboxApiResponse<DevboxMutationData>>;
|
|
21
23
|
/** DELETE /api/v1/devbox/{name} */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExecuteOptions, ExecuteResult, SandboxId, SandboxInfo } from '../../types';
|
|
1
|
+
import type { Endpoint, ExecuteOptions, ExecuteResult, ImageSpec, KubeAccessPolicy, LabelSpec, LifecyclePolicy, SandboxEndpointSelector, SandboxId, SandboxInfo, SandboxProxyService, SandboxProxyTarget } from '../../types';
|
|
2
2
|
import { BaseSandboxAdapter } from '../BaseSandboxAdapter';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for Sealos Devbox Adapter.
|
|
@@ -9,16 +9,33 @@ export interface SealosDevboxConfig {
|
|
|
9
9
|
/** JWT authentication token */
|
|
10
10
|
token: string;
|
|
11
11
|
sandboxId: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional override for the Sealos httpgate wildcard domain. When omitted,
|
|
14
|
+
* it is derived from gateway.url returned by Devbox Server.
|
|
15
|
+
*/
|
|
16
|
+
httpgateDomain?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SealosDevboxCreateConfig {
|
|
19
|
+
image?: ImageSpec;
|
|
20
|
+
env?: Record<string, string>;
|
|
21
|
+
labels?: LabelSpec[];
|
|
22
|
+
upstreamID?: string;
|
|
23
|
+
kubeAccess?: KubeAccessPolicy;
|
|
24
|
+
lifecycle?: LifecyclePolicy;
|
|
25
|
+
workingDir?: string;
|
|
12
26
|
}
|
|
13
27
|
export declare class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
14
28
|
private config;
|
|
29
|
+
private createConfig?;
|
|
15
30
|
readonly provider: "sealosdevbox";
|
|
16
31
|
get rootPath(): string;
|
|
17
32
|
private api;
|
|
18
33
|
private _id;
|
|
19
|
-
constructor(config: SealosDevboxConfig);
|
|
34
|
+
constructor(config: SealosDevboxConfig, createConfig?: SealosDevboxCreateConfig | undefined);
|
|
20
35
|
get id(): SandboxId;
|
|
21
36
|
private StatusAdapt;
|
|
37
|
+
private buildCreateRequest;
|
|
38
|
+
private removeUndefined;
|
|
22
39
|
getInfo(): Promise<SandboxInfo | null>;
|
|
23
40
|
ensureRunning(): Promise<void>;
|
|
24
41
|
create(): Promise<void>;
|
|
@@ -26,6 +43,13 @@ export declare class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
|
26
43
|
start(): Promise<void>;
|
|
27
44
|
delete(): Promise<void>;
|
|
28
45
|
execute(command: string, options?: ExecuteOptions): Promise<ExecuteResult>;
|
|
46
|
+
getEndpoint(selector: SandboxEndpointSelector): Promise<Endpoint>;
|
|
47
|
+
getProxyTarget(service?: SandboxProxyService): Promise<SandboxProxyTarget>;
|
|
48
|
+
private waitForCodeServerHealthz;
|
|
49
|
+
private getHttpgateTarget;
|
|
50
|
+
private getGatewayUniqueID;
|
|
51
|
+
private getHttpgateDomain;
|
|
52
|
+
private normalizeHttpgateDomain;
|
|
29
53
|
/**
|
|
30
54
|
* Check if the devbox is ready by querying info endpoint.
|
|
31
55
|
* Ready when spec, status, and phase are all "Running".
|
|
@@ -46,12 +46,30 @@ export interface ExecResponseData {
|
|
|
46
46
|
stderr: string;
|
|
47
47
|
executedAt: string;
|
|
48
48
|
}
|
|
49
|
-
/** Response data from create/pause/resume/delete endpoints. */
|
|
49
|
+
/** Response data from create/pause/stop/resume/delete endpoints. */
|
|
50
50
|
export interface DevboxMutationData {
|
|
51
51
|
name: string;
|
|
52
|
+
namespace?: string;
|
|
52
53
|
state?: string;
|
|
53
54
|
status?: string;
|
|
54
55
|
}
|
|
56
|
+
/** Request body for the create endpoint. */
|
|
57
|
+
export interface DevboxCreateRequest {
|
|
58
|
+
name: string;
|
|
59
|
+
image?: string;
|
|
60
|
+
env?: Record<string, string>;
|
|
61
|
+
labels?: Array<{
|
|
62
|
+
key: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}>;
|
|
65
|
+
upstreamID?: string;
|
|
66
|
+
kubeAccess?: {
|
|
67
|
+
enabled?: boolean;
|
|
68
|
+
roleTemplate?: 'view' | 'edit' | 'admin';
|
|
69
|
+
};
|
|
70
|
+
pauseAt?: string;
|
|
71
|
+
archiveAfterPauseTime?: string;
|
|
72
|
+
}
|
|
55
73
|
/** SSH connection info returned by the info endpoint. */
|
|
56
74
|
export interface DevboxSshInfo {
|
|
57
75
|
user: string;
|
|
@@ -63,14 +81,27 @@ export interface DevboxSshInfo {
|
|
|
63
81
|
privateKeyEncoding: string;
|
|
64
82
|
privateKeyBase64: string;
|
|
65
83
|
}
|
|
84
|
+
/** HTTP gateway info returned by the info endpoint. */
|
|
85
|
+
export interface DevboxGatewayInfo {
|
|
86
|
+
url: string;
|
|
87
|
+
token?: string;
|
|
88
|
+
port?: number;
|
|
89
|
+
uniqueID?: string;
|
|
90
|
+
}
|
|
66
91
|
/** Response data from the GET info endpoint. */
|
|
67
92
|
export interface DevboxInfoData {
|
|
68
93
|
name: string;
|
|
94
|
+
image?: string;
|
|
95
|
+
creationTimestamp?: string;
|
|
69
96
|
deletionTimestamp?: string | null;
|
|
70
97
|
state: {
|
|
71
98
|
phase: `${DevboxPhaseEnum}`;
|
|
72
99
|
};
|
|
73
100
|
ssh: DevboxSshInfo;
|
|
101
|
+
gateway?: DevboxGatewayInfo;
|
|
102
|
+
codeServerGateway?: DevboxGatewayInfo & {
|
|
103
|
+
password?: string;
|
|
104
|
+
};
|
|
74
105
|
}
|
|
75
106
|
/** Response data from the upload endpoint. */
|
|
76
107
|
export interface UploadResponseData {
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type SealosDevboxConfig } from './SealosDevboxAdapter';
|
|
1
|
+
import { type SealosDevboxConfig, type SealosDevboxCreateConfig } from './SealosDevboxAdapter';
|
|
2
2
|
import { type OpenSandboxConnectionConfig, type OpenSandboxConfigType } from './OpenSandboxAdapter';
|
|
3
3
|
import { type E2BConfig } from './E2BAdapter';
|
|
4
4
|
import { ISandbox } from '@/interfaces';
|
|
5
5
|
export { SealosDevboxAdapter } from './SealosDevboxAdapter';
|
|
6
|
-
export type { SealosDevboxConfig } from './SealosDevboxAdapter';
|
|
6
|
+
export type { SealosDevboxConfig, SealosDevboxCreateConfig } from './SealosDevboxAdapter';
|
|
7
7
|
export { OpenSandboxAdapter } from './OpenSandboxAdapter';
|
|
8
8
|
export type { OpenSandboxConfigType, OpenSandboxConnectionConfig } from './OpenSandboxAdapter';
|
|
9
9
|
export type { Volume as OpenSandboxVolume } from '@alibaba-group/opensandbox';
|
|
@@ -13,7 +13,7 @@ export type SandboxProviderType = 'opensandbox' | 'sealosdevbox' | 'e2b';
|
|
|
13
13
|
/** Maps each provider name to the ISandbox config type it exposes. */
|
|
14
14
|
interface SandboxConfigMap {
|
|
15
15
|
opensandbox: OpenSandboxConfigType;
|
|
16
|
-
sealosdevbox:
|
|
16
|
+
sealosdevbox: SealosDevboxCreateConfig;
|
|
17
17
|
e2b: undefined;
|
|
18
18
|
}
|
|
19
19
|
/** Resolves the concrete ISandbox type for a given provider. */
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenSandbox exposes execd through this direct endpoint. code-server itself is
|
|
3
|
+
* still reached via execd path proxying at /proxy/8080.
|
|
4
|
+
*/
|
|
5
|
+
export declare const OPEN_SANDBOX_EXECD_PORT = 44772;
|
|
6
|
+
export declare const OPEN_SANDBOX_CODE_SERVER_PORT = 8080;
|
|
7
|
+
export declare const SEALOS_DEVBOX_CODE_SERVER_PORT = 1318;
|