@arker-ai/sdk 0.5.1 → 0.6.2
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/README.md +154 -0
- package/dist/arker-provider-BNIL8NdM.d.ts +7 -0
- package/dist/arker-provider-DwUib5ZW.d.cts +7 -0
- package/dist/chunk-35IEV6BU.js +286 -0
- package/dist/{chunk-PI3H3TGC.js → chunk-7BHPVQNG.js} +265 -23
- package/dist/cli.cjs +621 -160
- package/dist/cli.js +356 -137
- package/dist/common-C5zJ-LkS.d.cts +9 -0
- package/dist/common-C5zJ-LkS.d.ts +9 -0
- package/dist/daytona.cjs +1274 -0
- package/dist/daytona.d.cts +37 -0
- package/dist/daytona.d.ts +37 -0
- package/dist/daytona.js +65 -0
- package/dist/e2b.cjs +1288 -0
- package/dist/e2b.d.cts +29 -0
- package/dist/e2b.d.ts +29 -0
- package/dist/e2b.js +75 -0
- package/dist/index.cjs +275 -23
- package/dist/index.d.cts +229 -101
- package/dist/index.d.ts +229 -101
- package/dist/index.js +1 -1
- package/dist/modal.cjs +1356 -0
- package/dist/modal.d.cts +49 -0
- package/dist/modal.d.ts +49 -0
- package/dist/modal.js +130 -0
- package/package.json +30 -4
package/dist/modal.d.cts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { U as UniversalSandbox } from './common-C5zJ-LkS.cjs';
|
|
2
|
+
import { A as ArkerComputeProviderConfig } from './arker-provider-DwUib5ZW.cjs';
|
|
3
|
+
import 'computesdk';
|
|
4
|
+
import './index.cjs';
|
|
5
|
+
|
|
6
|
+
interface ModalCompatConfig {
|
|
7
|
+
/** Modal token ID used only for native Modal fallback. */
|
|
8
|
+
tokenId?: string;
|
|
9
|
+
/** Modal token secret used only for native Modal fallback. */
|
|
10
|
+
tokenSecret?: string;
|
|
11
|
+
/** Arker provider options. Falls back to ARKER_* environment variables. */
|
|
12
|
+
arker?: ArkerComputeProviderConfig;
|
|
13
|
+
}
|
|
14
|
+
interface ModalExecOptions {
|
|
15
|
+
workdir?: string;
|
|
16
|
+
env?: Record<string, string>;
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
stdout?: "pipe";
|
|
19
|
+
stderr?: "pipe";
|
|
20
|
+
mode?: "text";
|
|
21
|
+
}
|
|
22
|
+
declare class ModalProcess {
|
|
23
|
+
#private;
|
|
24
|
+
readonly stdout: {
|
|
25
|
+
readText: () => Promise<string>;
|
|
26
|
+
};
|
|
27
|
+
readonly stderr: {
|
|
28
|
+
readText: () => Promise<string>;
|
|
29
|
+
};
|
|
30
|
+
constructor(out: string, err: string, exitCode: number);
|
|
31
|
+
wait(): Promise<number>;
|
|
32
|
+
}
|
|
33
|
+
declare class Sandbox {
|
|
34
|
+
#private;
|
|
35
|
+
readonly sandboxId: string;
|
|
36
|
+
constructor(box: UniversalSandbox);
|
|
37
|
+
exec(cmd: string[] | string, opts?: ModalExecOptions): Promise<ModalProcess>;
|
|
38
|
+
terminate(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
declare class ModalClient {
|
|
41
|
+
#private;
|
|
42
|
+
constructor(config?: ModalCompatConfig);
|
|
43
|
+
readonly sandboxes: {
|
|
44
|
+
create: (...args: unknown[]) => Promise<Sandbox>;
|
|
45
|
+
fromId: (sandboxId: string) => Promise<Sandbox>;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { ModalClient, type ModalCompatConfig, Sandbox };
|
package/dist/modal.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { U as UniversalSandbox } from './common-C5zJ-LkS.js';
|
|
2
|
+
import { A as ArkerComputeProviderConfig } from './arker-provider-BNIL8NdM.js';
|
|
3
|
+
import 'computesdk';
|
|
4
|
+
import './index.js';
|
|
5
|
+
|
|
6
|
+
interface ModalCompatConfig {
|
|
7
|
+
/** Modal token ID used only for native Modal fallback. */
|
|
8
|
+
tokenId?: string;
|
|
9
|
+
/** Modal token secret used only for native Modal fallback. */
|
|
10
|
+
tokenSecret?: string;
|
|
11
|
+
/** Arker provider options. Falls back to ARKER_* environment variables. */
|
|
12
|
+
arker?: ArkerComputeProviderConfig;
|
|
13
|
+
}
|
|
14
|
+
interface ModalExecOptions {
|
|
15
|
+
workdir?: string;
|
|
16
|
+
env?: Record<string, string>;
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
stdout?: "pipe";
|
|
19
|
+
stderr?: "pipe";
|
|
20
|
+
mode?: "text";
|
|
21
|
+
}
|
|
22
|
+
declare class ModalProcess {
|
|
23
|
+
#private;
|
|
24
|
+
readonly stdout: {
|
|
25
|
+
readText: () => Promise<string>;
|
|
26
|
+
};
|
|
27
|
+
readonly stderr: {
|
|
28
|
+
readText: () => Promise<string>;
|
|
29
|
+
};
|
|
30
|
+
constructor(out: string, err: string, exitCode: number);
|
|
31
|
+
wait(): Promise<number>;
|
|
32
|
+
}
|
|
33
|
+
declare class Sandbox {
|
|
34
|
+
#private;
|
|
35
|
+
readonly sandboxId: string;
|
|
36
|
+
constructor(box: UniversalSandbox);
|
|
37
|
+
exec(cmd: string[] | string, opts?: ModalExecOptions): Promise<ModalProcess>;
|
|
38
|
+
terminate(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
declare class ModalClient {
|
|
41
|
+
#private;
|
|
42
|
+
constructor(config?: ModalCompatConfig);
|
|
43
|
+
readonly sandboxes: {
|
|
44
|
+
create: (...args: unknown[]) => Promise<Sandbox>;
|
|
45
|
+
fromId: (sandboxId: string) => Promise<Sandbox>;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { ModalClient, type ModalCompatConfig, Sandbox };
|
package/dist/modal.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {
|
|
2
|
+
argvToCommand,
|
|
3
|
+
assertNoUnsupportedArgs,
|
|
4
|
+
assertSupportedObjectKeys,
|
|
5
|
+
createCompatSdk,
|
|
6
|
+
guardUnsupported,
|
|
7
|
+
isStringRecord
|
|
8
|
+
} from "./chunk-35IEV6BU.js";
|
|
9
|
+
import "./chunk-7BHPVQNG.js";
|
|
10
|
+
|
|
11
|
+
// src/modal.ts
|
|
12
|
+
import { modal as createModalProvider } from "@computesdk/modal";
|
|
13
|
+
var MODAL_CONFIG_KEYS = ["tokenId", "tokenSecret", "arker"];
|
|
14
|
+
var MODAL_EXEC_OPTION_KEYS = ["workdir", "env", "timeoutMs", "stdout", "stderr", "mode"];
|
|
15
|
+
function lazyModalProvider(config) {
|
|
16
|
+
let provider = null;
|
|
17
|
+
const getProvider = () => {
|
|
18
|
+
provider ??= createModalProvider({
|
|
19
|
+
tokenId: config?.tokenId,
|
|
20
|
+
tokenSecret: config?.tokenSecret
|
|
21
|
+
});
|
|
22
|
+
return provider;
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
name: "modal",
|
|
26
|
+
sandbox: {
|
|
27
|
+
create: (options) => getProvider().sandbox.create(options),
|
|
28
|
+
getById: (sandboxId) => getProvider().sandbox.getById(sandboxId),
|
|
29
|
+
destroy: (sandboxId) => getProvider().sandbox.destroy(sandboxId),
|
|
30
|
+
list: () => getProvider().sandbox.list()
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function assertOptionValue(condition, message) {
|
|
35
|
+
if (!condition) throw new Error(message);
|
|
36
|
+
}
|
|
37
|
+
function toRunCommandOptions(opts) {
|
|
38
|
+
assertSupportedObjectKeys(opts, MODAL_EXEC_OPTION_KEYS, "modal", "Sandbox.exec");
|
|
39
|
+
if (opts === void 0) return void 0;
|
|
40
|
+
const modalOpts = opts;
|
|
41
|
+
assertOptionValue(
|
|
42
|
+
modalOpts.workdir === void 0 || typeof modalOpts.workdir === "string",
|
|
43
|
+
"Sandbox.exec option 'workdir' must be a string in the Arker compatibility layer for modal."
|
|
44
|
+
);
|
|
45
|
+
assertOptionValue(
|
|
46
|
+
modalOpts.timeoutMs === void 0 || typeof modalOpts.timeoutMs === "number",
|
|
47
|
+
"Sandbox.exec option 'timeoutMs' must be a number in the Arker compatibility layer for modal."
|
|
48
|
+
);
|
|
49
|
+
assertOptionValue(
|
|
50
|
+
modalOpts.env === void 0 || isStringRecord(modalOpts.env),
|
|
51
|
+
"Sandbox.exec option 'env' must be an object in the Arker compatibility layer for modal."
|
|
52
|
+
);
|
|
53
|
+
assertOptionValue(
|
|
54
|
+
modalOpts.stdout === void 0 || modalOpts.stdout === "pipe",
|
|
55
|
+
"Sandbox.exec only supports stdout: 'pipe' in the Arker compatibility layer for modal."
|
|
56
|
+
);
|
|
57
|
+
assertOptionValue(
|
|
58
|
+
modalOpts.stderr === void 0 || modalOpts.stderr === "pipe",
|
|
59
|
+
"Sandbox.exec only supports stderr: 'pipe' in the Arker compatibility layer for modal."
|
|
60
|
+
);
|
|
61
|
+
assertOptionValue(
|
|
62
|
+
modalOpts.mode === void 0 || modalOpts.mode === "text",
|
|
63
|
+
"Sandbox.exec only supports mode: 'text' in the Arker compatibility layer for modal."
|
|
64
|
+
);
|
|
65
|
+
const runOptions = {};
|
|
66
|
+
if (modalOpts.workdir !== void 0) runOptions.cwd = modalOpts.workdir;
|
|
67
|
+
if (modalOpts.env !== void 0) runOptions.env = modalOpts.env;
|
|
68
|
+
if (modalOpts.timeoutMs !== void 0) runOptions.timeout = modalOpts.timeoutMs;
|
|
69
|
+
return Object.keys(runOptions).length > 0 ? runOptions : void 0;
|
|
70
|
+
}
|
|
71
|
+
var ModalProcess = class {
|
|
72
|
+
stdout;
|
|
73
|
+
stderr;
|
|
74
|
+
#exitCode;
|
|
75
|
+
constructor(out, err, exitCode) {
|
|
76
|
+
this.#exitCode = exitCode;
|
|
77
|
+
this.stdout = { readText: async () => out };
|
|
78
|
+
this.stderr = { readText: async () => err };
|
|
79
|
+
}
|
|
80
|
+
async wait() {
|
|
81
|
+
return this.#exitCode;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var Sandbox = class {
|
|
85
|
+
sandboxId;
|
|
86
|
+
#box;
|
|
87
|
+
constructor(box) {
|
|
88
|
+
this.#box = box;
|
|
89
|
+
this.sandboxId = box.sandboxId;
|
|
90
|
+
}
|
|
91
|
+
async exec(cmd, opts) {
|
|
92
|
+
const command = argvToCommand(cmd);
|
|
93
|
+
const runOptions = toRunCommandOptions(opts);
|
|
94
|
+
const result = runOptions ? await this.#box.runCommand(command, runOptions) : await this.#box.runCommand(command);
|
|
95
|
+
return new ModalProcess(result.stdout, result.stderr, result.exitCode);
|
|
96
|
+
}
|
|
97
|
+
async terminate() {
|
|
98
|
+
await this.#box.destroy();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var ModalClient = class {
|
|
102
|
+
#sdk;
|
|
103
|
+
constructor(config) {
|
|
104
|
+
assertSupportedObjectKeys(config, MODAL_CONFIG_KEYS, "modal", "new ModalClient");
|
|
105
|
+
this.#sdk = createCompatSdk({
|
|
106
|
+
arker: config?.arker,
|
|
107
|
+
fallbackProvider: lazyModalProvider({
|
|
108
|
+
tokenId: config?.tokenId,
|
|
109
|
+
tokenSecret: config?.tokenSecret
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
return guardUnsupported(this, "modal");
|
|
113
|
+
}
|
|
114
|
+
sandboxes = {
|
|
115
|
+
create: async (...args) => {
|
|
116
|
+
assertNoUnsupportedArgs(args, "modal", "ModalClient.sandboxes.create");
|
|
117
|
+
const box = await this.#sdk.sandbox.create({});
|
|
118
|
+
return guardUnsupported(new Sandbox(box), "modal");
|
|
119
|
+
},
|
|
120
|
+
fromId: async (sandboxId) => {
|
|
121
|
+
const box = await this.#sdk.sandbox.getById(sandboxId);
|
|
122
|
+
if (!box) throw new Error(`Sandbox ${sandboxId} not found`);
|
|
123
|
+
return guardUnsupported(new Sandbox(box), "modal");
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export {
|
|
128
|
+
ModalClient,
|
|
129
|
+
Sandbox
|
|
130
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arker-ai/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "TypeScript SDK for the Arker virtual computer platform
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"description": "TypeScript SDK for the Arker virtual computer platform \u2014 spawn sandboxed VMs, run code, sync files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -14,6 +14,21 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"require": "./dist/index.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./daytona": {
|
|
19
|
+
"types": "./dist/daytona.d.ts",
|
|
20
|
+
"import": "./dist/daytona.js",
|
|
21
|
+
"require": "./dist/daytona.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./e2b": {
|
|
24
|
+
"types": "./dist/e2b.d.ts",
|
|
25
|
+
"import": "./dist/e2b.js",
|
|
26
|
+
"require": "./dist/e2b.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./modal": {
|
|
29
|
+
"types": "./dist/modal.d.ts",
|
|
30
|
+
"import": "./dist/modal.js",
|
|
31
|
+
"require": "./dist/modal.cjs"
|
|
17
32
|
}
|
|
18
33
|
},
|
|
19
34
|
"files": [
|
|
@@ -25,12 +40,15 @@
|
|
|
25
40
|
"node": ">=18"
|
|
26
41
|
},
|
|
27
42
|
"scripts": {
|
|
28
|
-
"build": "tsup src/index.ts src/cli.ts --format esm,cjs --dts --clean --target=node18",
|
|
43
|
+
"build": "tsup src/index.ts src/cli.ts src/daytona.ts src/e2b.ts src/modal.ts --format esm,cjs --dts --clean --target=node18",
|
|
29
44
|
"check:api-types": "openapi-typescript ../contract/openapi.json --default-non-nullable false -o src/generated/api-types.ts --check",
|
|
30
45
|
"demo": "tsx tests/demo.ts",
|
|
31
46
|
"generate:api-types": "openapi-typescript ../contract/openapi.json --default-non-nullable false -o src/generated/api-types.ts",
|
|
32
47
|
"smoke": "tsx tests/conformance/fork-run-sync.ts",
|
|
33
|
-
"test": "tsx tests/unit.ts",
|
|
48
|
+
"test": "tsx tests/unit.ts && tsx tests/compat.ts && tsx tests/cli.ts",
|
|
49
|
+
"test:compat": "tsx tests/compat.ts",
|
|
50
|
+
"test:compat-live": "tsx tests/compat-live.ts",
|
|
51
|
+
"test:compat-fallback-live": "tsx tests/compat-fallback-live.ts",
|
|
34
52
|
"typecheck": "tsc -p tsconfig.test.json",
|
|
35
53
|
"prepublishOnly": "npm run build"
|
|
36
54
|
},
|
|
@@ -51,9 +69,17 @@
|
|
|
51
69
|
"bugs": "https://github.com/ArkerHQ/arker-sdk/issues",
|
|
52
70
|
"devDependencies": {
|
|
53
71
|
"@types/node": "^25.6.0",
|
|
72
|
+
"@types/ws": "^8.18.1",
|
|
54
73
|
"openapi-typescript": "^7.13.0",
|
|
55
74
|
"tsup": "^8.3.0",
|
|
56
75
|
"tsx": "^4.19.0",
|
|
57
76
|
"typescript": "^5.6.0"
|
|
77
|
+
},
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"@computesdk/daytona": "^1.7.30",
|
|
80
|
+
"@computesdk/e2b": "^1.7.51",
|
|
81
|
+
"@computesdk/modal": "^1.9.3",
|
|
82
|
+
"computesdk": "^4.1.3",
|
|
83
|
+
"ws": "^8.21.0"
|
|
58
84
|
}
|
|
59
85
|
}
|