@run-cloud/sdk 0.5.1 → 0.7.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.
@@ -0,0 +1,67 @@
1
+ import { type CompatibilityClientOptions, type NativeSandbox } from "./common.js";
2
+ export interface DaytonaConfig extends CompatibilityClientOptions {
3
+ serverUrl?: string;
4
+ }
5
+ declare class Process {
6
+ private readonly native;
7
+ constructor(native: NativeSandbox);
8
+ exec(command: string, options?: {
9
+ cwd?: string;
10
+ timeout?: number;
11
+ }): Promise<{
12
+ exitCode: number;
13
+ result: string;
14
+ stdout: string;
15
+ stderr: string;
16
+ }>;
17
+ executeCommand(command: string, cwd?: string, env?: Record<string, string>, timeout?: number): Promise<{
18
+ exitCode: number;
19
+ result: string;
20
+ stdout: string;
21
+ stderr: string;
22
+ artifacts: {
23
+ stdout: string;
24
+ charts: never[];
25
+ };
26
+ }>;
27
+ }
28
+ declare class FileSystem {
29
+ private readonly native;
30
+ constructor(native: NativeSandbox);
31
+ downloadFile(path: string): Promise<Uint8Array>;
32
+ downloadText(path: string): Promise<string>;
33
+ uploadFile(): never;
34
+ listFiles(): never;
35
+ deleteFile(): never;
36
+ createFolder(): never;
37
+ }
38
+ export declare class DaytonaSandbox {
39
+ readonly native: NativeSandbox;
40
+ readonly process: Process;
41
+ readonly fs: FileSystem;
42
+ constructor(native: NativeSandbox);
43
+ get id(): string;
44
+ getPreviewLink(): never;
45
+ delete(): Promise<void>;
46
+ start(): Promise<void>;
47
+ stop(): Promise<void>;
48
+ }
49
+ export declare class Daytona {
50
+ private readonly options;
51
+ constructor(config?: DaytonaConfig);
52
+ create(params?: {
53
+ image?: string;
54
+ name?: string;
55
+ size?: string;
56
+ region?: string;
57
+ resources?: {
58
+ cpu?: number;
59
+ memory?: number;
60
+ disk?: number;
61
+ };
62
+ }): Promise<DaytonaSandbox>;
63
+ get(id: string): Promise<DaytonaSandbox>;
64
+ remove(sandbox: DaytonaSandbox): Promise<void>;
65
+ delete(sandbox: DaytonaSandbox): Promise<void>;
66
+ }
67
+ export {};
@@ -0,0 +1,109 @@
1
+ import { bytesToText, compatibilityClient, createNative, getNative, unsupported, } from "./common.js";
2
+ class Process {
3
+ native;
4
+ constructor(native) {
5
+ this.native = native;
6
+ }
7
+ async exec(command, options = {}) {
8
+ const result = await this.native.exec(command, {
9
+ cwd: options.cwd,
10
+ timeoutSeconds: options.timeout,
11
+ });
12
+ return {
13
+ exitCode: result.exitCode,
14
+ result: result.stdout,
15
+ stdout: result.stdout,
16
+ stderr: result.stderr,
17
+ };
18
+ }
19
+ async executeCommand(command, cwd, env, timeout) {
20
+ const result = await this.native.exec(command, { cwd, env, timeoutSeconds: timeout });
21
+ return {
22
+ exitCode: result.exitCode,
23
+ result: result.stdout,
24
+ stdout: result.stdout,
25
+ stderr: result.stderr,
26
+ artifacts: { stdout: result.stdout, charts: [] },
27
+ };
28
+ }
29
+ }
30
+ class FileSystem {
31
+ native;
32
+ constructor(native) {
33
+ this.native = native;
34
+ }
35
+ async downloadFile(path) {
36
+ return await this.native.readFile(path);
37
+ }
38
+ async downloadText(path) {
39
+ return bytesToText(await this.native.readFile(path));
40
+ }
41
+ uploadFile() {
42
+ return unsupported("Daytona", "file uploads", "use an image or a command that writes the content");
43
+ }
44
+ listFiles() {
45
+ return unsupported("Daytona", "directory listing");
46
+ }
47
+ deleteFile() {
48
+ return unsupported("Daytona", "file deletion");
49
+ }
50
+ createFolder() {
51
+ return unsupported("Daytona", "directory creation");
52
+ }
53
+ }
54
+ export class DaytonaSandbox {
55
+ native;
56
+ process;
57
+ fs;
58
+ constructor(native) {
59
+ this.native = native;
60
+ this.process = new Process(native);
61
+ this.fs = new FileSystem(native);
62
+ }
63
+ get id() {
64
+ return this.native.id;
65
+ }
66
+ getPreviewLink() {
67
+ return unsupported("Daytona", "preview links", "run.cloud public port capabilities are not available in the SDK yet");
68
+ }
69
+ async delete() {
70
+ await this.native.destroy();
71
+ }
72
+ async start() {
73
+ await this.native.resume();
74
+ }
75
+ async stop() {
76
+ await this.native.pause();
77
+ }
78
+ }
79
+ export class Daytona {
80
+ options;
81
+ constructor(config = {}) {
82
+ this.options = {
83
+ ...config,
84
+ apiUrl: config.apiUrl ?? config.serverUrl,
85
+ };
86
+ }
87
+ async create(params = {}) {
88
+ const client = compatibilityClient(this.options);
89
+ return new DaytonaSandbox(await createNative(client, {
90
+ image: params.image,
91
+ name: params.name,
92
+ region: params.region,
93
+ cpu: params.resources?.cpu,
94
+ memory: params.resources?.memory ? params.resources.memory * 1024 : undefined,
95
+ disk: params.resources?.disk,
96
+ }));
97
+ }
98
+ async get(id) {
99
+ const client = compatibilityClient(this.options);
100
+ return new DaytonaSandbox(await getNative(client, id));
101
+ }
102
+ async remove(sandbox) {
103
+ await sandbox.delete();
104
+ }
105
+ async delete(sandbox) {
106
+ await sandbox.delete();
107
+ }
108
+ }
109
+ //# sourceMappingURL=daytona.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daytona.js","sourceRoot":"","sources":["../../src/compat/daytona.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,SAAS,EAGT,WAAW,GACZ,MAAM,aAAa,CAAC;AAMrB,MAAM,OAAO;IACkB;IAA7B,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD,KAAK,CAAC,IAAI,CAAC,OAAe,EAAE,UAA8C,EAAE;QAC1E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE;YAC7C,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,cAAc,EAAE,OAAO,CAAC,OAAO;SAChC,CAAC,CAAC;QACH,OAAO;YACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;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AAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS;YAC7E,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,IAAI;SAC7B,CAAC,CACH,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,IAAI,cAAc,CAAC,MAAM,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAuB;QAClC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAuB;QAClC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,65 @@
1
+ import { type CompatibilityClientOptions, type NativeSandbox } from "./common.js";
2
+ export interface CommandResult {
3
+ stdout: string;
4
+ stderr: string;
5
+ exitCode: number;
6
+ }
7
+ export interface CreateOpts extends CompatibilityClientOptions {
8
+ template?: string;
9
+ timeoutMs?: number;
10
+ metadata?: Record<string, string>;
11
+ envs?: Record<string, string>;
12
+ }
13
+ declare class Commands {
14
+ private readonly sandbox;
15
+ constructor(sandbox: Sandbox);
16
+ run(command: string, options?: {
17
+ cwd?: string;
18
+ envs?: Record<string, string>;
19
+ timeoutMs?: number;
20
+ background?: boolean;
21
+ }): Promise<CommandResult>;
22
+ }
23
+ declare class Files {
24
+ private readonly native;
25
+ constructor(native: NativeSandbox);
26
+ read(path: string): Promise<string>;
27
+ readBytes(path: string): Promise<Uint8Array>;
28
+ write(): never;
29
+ list(): never;
30
+ remove(): never;
31
+ rename(): never;
32
+ makeDir(): never;
33
+ }
34
+ export declare class Sandbox {
35
+ readonly native: NativeSandbox;
36
+ private readonly client;
37
+ readonly environment: Record<string, string>;
38
+ private readonly metadata;
39
+ private readonly template?;
40
+ readonly commands: Commands;
41
+ readonly files: Files;
42
+ private constructor();
43
+ static create(options?: CreateOpts): Promise<Sandbox>;
44
+ static connect(sandboxId: string, options?: CompatibilityClientOptions): Promise<Sandbox>;
45
+ static list(options?: CompatibilityClientOptions): Promise<{
46
+ nextItems(): Promise<Array<{
47
+ sandboxId: string;
48
+ name: string;
49
+ metadata: Record<string, string>;
50
+ }>>;
51
+ }>;
52
+ get sandboxId(): string;
53
+ getInfo(): {
54
+ sandboxId: string;
55
+ name: string;
56
+ templateId: string | undefined;
57
+ metadata: {
58
+ [x: string]: string;
59
+ };
60
+ };
61
+ setTimeout(timeoutMs: number): Promise<void>;
62
+ getHost(): never;
63
+ kill(): Promise<boolean>;
64
+ }
65
+ export {};
@@ -0,0 +1,106 @@
1
+ import { bytesToText, compatibilityClient, createNative, getNative, listNative, unsupported, } from "./common.js";
2
+ class Commands {
3
+ sandbox;
4
+ constructor(sandbox) {
5
+ this.sandbox = sandbox;
6
+ }
7
+ async run(command, options = {}) {
8
+ if (options.background) {
9
+ unsupported("E2B", "background commands", "use Client.sandboxes.exec for synchronous execution");
10
+ }
11
+ const result = await this.sandbox.native.exec(command, {
12
+ cwd: options.cwd,
13
+ env: { ...this.sandbox.environment, ...(options.envs ?? {}) },
14
+ timeoutSeconds: options.timeoutMs ? Math.ceil(options.timeoutMs / 1000) : undefined,
15
+ });
16
+ return { stdout: result.stdout, stderr: result.stderr, exitCode: result.exitCode };
17
+ }
18
+ }
19
+ class Files {
20
+ native;
21
+ constructor(native) {
22
+ this.native = native;
23
+ }
24
+ async read(path) {
25
+ return bytesToText(await this.native.readFile(path));
26
+ }
27
+ async readBytes(path) {
28
+ return await this.native.readFile(path);
29
+ }
30
+ write() {
31
+ return unsupported("E2B", "file writes", "upload content in the sandbox command or use an image");
32
+ }
33
+ list() {
34
+ return unsupported("E2B", "directory listing");
35
+ }
36
+ remove() {
37
+ return unsupported("E2B", "file removal");
38
+ }
39
+ rename() {
40
+ return unsupported("E2B", "file rename");
41
+ }
42
+ makeDir() {
43
+ return unsupported("E2B", "directory creation");
44
+ }
45
+ }
46
+ export class Sandbox {
47
+ native;
48
+ client;
49
+ environment;
50
+ metadata;
51
+ template;
52
+ commands;
53
+ files;
54
+ constructor(native, client, environment, metadata, template) {
55
+ this.native = native;
56
+ this.client = client;
57
+ this.environment = environment;
58
+ this.metadata = metadata;
59
+ this.template = template;
60
+ this.commands = new Commands(this);
61
+ this.files = new Files(native);
62
+ }
63
+ static async create(options = {}) {
64
+ const client = compatibilityClient(options);
65
+ const native = await createNative(client, {
66
+ image: !options.template || options.template === "base" ? undefined : options.template,
67
+ timeoutSeconds: options.timeoutMs ? Math.ceil(options.timeoutMs / 1000) : undefined,
68
+ });
69
+ return new Sandbox(native, client, options.envs ?? {}, options.metadata ?? {}, options.template);
70
+ }
71
+ static async connect(sandboxId, options = {}) {
72
+ const client = compatibilityClient(options);
73
+ return new Sandbox(await getNative(client, sandboxId), client, {}, {}, undefined);
74
+ }
75
+ static async list(options = {}) {
76
+ const client = compatibilityClient(options);
77
+ const items = (await listNative(client)).map((sandbox) => ({
78
+ sandboxId: sandbox.id,
79
+ name: sandbox.name,
80
+ metadata: {},
81
+ }));
82
+ return { nextItems: async () => items };
83
+ }
84
+ get sandboxId() {
85
+ return this.native.id;
86
+ }
87
+ getInfo() {
88
+ return {
89
+ sandboxId: this.native.id,
90
+ name: this.native.name,
91
+ templateId: this.template,
92
+ metadata: { ...this.metadata },
93
+ };
94
+ }
95
+ async setTimeout(timeoutMs) {
96
+ await this.client.sandboxes.setTimeout(this.native.id, Math.ceil(timeoutMs / 1000));
97
+ }
98
+ getHost() {
99
+ return unsupported("E2B", "getHost", "run.cloud public port capabilities are not available in the SDK yet");
100
+ }
101
+ async kill() {
102
+ await this.native.destroy();
103
+ return true;
104
+ }
105
+ }
106
+ //# sourceMappingURL=e2b.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"e2b.js","sourceRoot":"","sources":["../../src/comp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AC,IAAI;YACtB,UAAU,EAAE,IAAI,CAAC,QAAQ;YACzB,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE;SAC/B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,SAAiB;QAChC,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,OAAO;QACL,OAAO,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,qEAAqE,CAAC,CAAC;IAC9G,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,28 @@
1
+ import { type CompatibilityClientOptions, type NativeSandbox } from "./common.js";
2
+ export declare class Machine {
3
+ readonly native: NativeSandbox;
4
+ constructor(native: NativeSandbox);
5
+ get id(): string;
6
+ get name(): string;
7
+ exec(command: string | string[]): Promise<import("../index.js").ExecResult>;
8
+ stop(): Promise<void>;
9
+ start(): Promise<void>;
10
+ destroy(): Promise<void>;
11
+ }
12
+ export declare class Machines {
13
+ private readonly options;
14
+ constructor(options?: CompatibilityClientOptions);
15
+ create(options?: {
16
+ name?: string;
17
+ image?: string;
18
+ region?: string;
19
+ guest?: {
20
+ cpus?: number;
21
+ memoryMb?: number;
22
+ };
23
+ }): Promise<Machine>;
24
+ get(id: string): Promise<Machine>;
25
+ list(): Promise<Machine[]>;
26
+ delete(id: string): Promise<void>;
27
+ volumes(): never;
28
+ }
@@ -0,0 +1,56 @@
1
+ import { compatibilityClient, createNative, getNative, listNative, unsupported, } from "./common.js";
2
+ export class Machine {
3
+ native;
4
+ constructor(native) {
5
+ this.native = native;
6
+ }
7
+ get id() {
8
+ return this.native.id;
9
+ }
10
+ get name() {
11
+ return this.native.name;
12
+ }
13
+ async exec(command) {
14
+ return await this.native.exec(command);
15
+ }
16
+ async stop() {
17
+ await this.native.pause();
18
+ }
19
+ async start() {
20
+ await this.native.resume();
21
+ }
22
+ async destroy() {
23
+ await this.native.destroy();
24
+ }
25
+ }
26
+ export class Machines {
27
+ options;
28
+ constructor(options = {}) {
29
+ this.options = options;
30
+ }
31
+ async create(options = {}) {
32
+ const client = compatibilityClient(this.options);
33
+ return new Machine(await createNative(client, {
34
+ name: options.name,
35
+ image: options.image,
36
+ region: options.region,
37
+ cpu: options.guest?.cpus,
38
+ memory: options.guest?.memoryMb,
39
+ }));
40
+ }
41
+ async get(id) {
42
+ const client = compatibilityClient(this.options);
43
+ return new Machine(await getNative(client, id));
44
+ }
45
+ async list() {
46
+ const client = compatibilityClient(this.options);
47
+ return (await listNative(client)).map((sandbox) => new Machine(sandbox));
48
+ }
49
+ async delete(id) {
50
+ await (await this.get(id)).destroy();
51
+ }
52
+ volumes() {
53
+ return unsupported("Fly Machines", "volumes");
54
+ }
55
+ }
56
+ //# sourceMappingURL=fly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fly.js","sourceRoot":"","sources":["../../src/compat/fly.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,UAAU,EAGV,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,OAAO;IACG;IAArB,YAAqB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAE9C,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IA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C;IAC3E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACvC,CAAC;IAED,OAAO;QACL,OAAO,WAAW,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;CACF"}
@@ -0,0 +1,107 @@
1
+ import type { Client } from "../index.js";
2
+ import { type CompatibilityClientOptions, type NativeSandbox } from "./common.js";
3
+ export declare class Image {
4
+ readonly ref: string;
5
+ private constructor();
6
+ static fromRegistry(ref: string): Image;
7
+ static debianSlim(): Image;
8
+ aptInstall(): never;
9
+ pipInstall(): never;
10
+ runCommands(): never;
11
+ env(): never;
12
+ workdir(): never;
13
+ }
14
+ export declare class ContainerProcess {
15
+ private readonly result;
16
+ readonly stdout: {
17
+ read(): Promise<string>;
18
+ readText(): Promise<string>;
19
+ };
20
+ readonly stderr: {
21
+ read(): Promise<string>;
22
+ readText(): Promise<string>;
23
+ };
24
+ private returnCode;
25
+ constructor(result: Promise<{
26
+ stdout: string;
27
+ stderr: string;
28
+ exitCode: number;
29
+ }>);
30
+ wait(): Promise<number>;
31
+ poll(): number | null;
32
+ get returncode(): number | null;
33
+ }
34
+ export declare class App {
35
+ readonly name: string;
36
+ readonly client: Client;
37
+ constructor(name: string, client: Client);
38
+ static lookup(name: string, options?: CompatibilityClientOptions & {
39
+ createIfMissing?: boolean;
40
+ }): Promise<App>;
41
+ createSandbox(image?: string | Image, options?: Omit<CreateOptions, "app" | "image">): Promise<Sandbox>;
42
+ }
43
+ export declare class ModalClient {
44
+ private readonly options;
45
+ readonly apps: {
46
+ fromName: (name: string, options?: CompatibilityClientOptions & {
47
+ createIfMissing?: boolean;
48
+ }) => Promise<App>;
49
+ };
50
+ readonly images: {
51
+ fromRegistry: (ref: string) => Image;
52
+ debianSlim: () => Image;
53
+ };
54
+ readonly sandboxes: {
55
+ create: (app: App, image: Image, options?: {
56
+ command?: string[];
57
+ cpu?: number;
58
+ memoryMiB?: number;
59
+ timeoutMs?: number;
60
+ idleTimeoutMs?: number;
61
+ name?: string;
62
+ regions?: string[];
63
+ volumes?: unknown;
64
+ }) => Promise<Sandbox>;
65
+ fromId: (sandboxId: string) => Promise<Sandbox>;
66
+ fromName: (appName: string, name: string) => Promise<Sandbox>;
67
+ };
68
+ constructor(options?: CompatibilityClientOptions);
69
+ }
70
+ export interface CreateOptions {
71
+ app?: App;
72
+ image?: string | Image;
73
+ cpu?: number | [number, number];
74
+ memory?: number;
75
+ timeout?: number;
76
+ idleTimeout?: number;
77
+ name?: string;
78
+ region?: string;
79
+ command?: string[];
80
+ volumes?: unknown;
81
+ }
82
+ export declare class Sandbox {
83
+ readonly native: NativeSandbox;
84
+ private readonly app?;
85
+ private entrypoint?;
86
+ private constructor();
87
+ static create(options?: CreateOptions): Promise<Sandbox>;
88
+ static fromId(id: string, client?: Client): Promise<Sandbox>;
89
+ static fromName(app: App, name: string): Promise<Sandbox>;
90
+ static list(app?: App): Promise<Sandbox[]>;
91
+ get objectId(): string;
92
+ get sandboxId(): string;
93
+ exec(command: string | string[], options?: {
94
+ workdir?: string;
95
+ env?: Record<string, string>;
96
+ timeout?: number;
97
+ }): ContainerProcess;
98
+ terminate(): Promise<number | null>;
99
+ detach(): void;
100
+ poll(): Promise<number | null>;
101
+ tunnels(): never;
102
+ setTags(): never;
103
+ }
104
+ export declare class Probe {
105
+ static withTcp(): never;
106
+ static withExec(): never;
107
+ }