@computesdk/daytona 1.0.1
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/LICENSE +21 -0
- package/README.md +86 -0
- package/dist/index.d.mts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +274 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +248 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 computesdk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @computesdk/daytona
|
|
2
|
+
|
|
3
|
+
Daytona provider for ComputeSDK - Execute code in Daytona workspaces.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install @computesdk/daytona
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { daytona } from '@computesdk/daytona';
|
|
15
|
+
|
|
16
|
+
// Create a Daytona sandbox
|
|
17
|
+
const sandbox = daytona({
|
|
18
|
+
runtime: 'python',
|
|
19
|
+
timeout: 30000
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Execute code
|
|
23
|
+
const result = await sandbox.execute('print("Hello from Daytona!")');
|
|
24
|
+
console.log(result.stdout); // "Hello from Daytona!"
|
|
25
|
+
|
|
26
|
+
// Run commands
|
|
27
|
+
const cmdResult = await sandbox.runCommand('ls', ['-la']);
|
|
28
|
+
console.log(cmdResult.stdout);
|
|
29
|
+
|
|
30
|
+
// File operations
|
|
31
|
+
await sandbox.filesystem.writeFile('/tmp/test.py', 'print("Hello World")');
|
|
32
|
+
const content = await sandbox.filesystem.readFile('/tmp/test.py');
|
|
33
|
+
console.log(content); // 'print("Hello World")'
|
|
34
|
+
|
|
35
|
+
// Clean up
|
|
36
|
+
await sandbox.kill();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Set your Daytona API key as an environment variable:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
export DAYTONA_API_KEY=your_api_key_here
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- ✅ Code execution in Python, Node.js, and other runtimes
|
|
50
|
+
- ✅ Command execution
|
|
51
|
+
- ✅ File system operations (read, write, mkdir, etc.)
|
|
52
|
+
- ❌ Interactive terminal sessions (not supported)
|
|
53
|
+
|
|
54
|
+
## API Reference
|
|
55
|
+
|
|
56
|
+
### `daytona(config?)`
|
|
57
|
+
|
|
58
|
+
Creates a new Daytona sandbox instance.
|
|
59
|
+
|
|
60
|
+
**Parameters:**
|
|
61
|
+
- `config` (optional): Configuration object
|
|
62
|
+
- `runtime`: Runtime environment ('python', 'node', etc.)
|
|
63
|
+
- `timeout`: Execution timeout in milliseconds
|
|
64
|
+
|
|
65
|
+
**Returns:** `DaytonaProvider` instance
|
|
66
|
+
|
|
67
|
+
### Methods
|
|
68
|
+
|
|
69
|
+
- `execute(code, runtime?)`: Execute code in the sandbox
|
|
70
|
+
- `runCode(code, runtime?)`: Alias for execute
|
|
71
|
+
- `runCommand(command, args?)`: Execute shell commands
|
|
72
|
+
- `kill()`: Terminate the sandbox
|
|
73
|
+
- `getInfo()`: Get sandbox information
|
|
74
|
+
|
|
75
|
+
### File System
|
|
76
|
+
|
|
77
|
+
- `filesystem.readFile(path)`: Read file contents
|
|
78
|
+
- `filesystem.writeFile(path, content)`: Write file contents
|
|
79
|
+
- `filesystem.mkdir(path)`: Create directory
|
|
80
|
+
- `filesystem.readdir(path)`: List directory contents
|
|
81
|
+
- `filesystem.exists(path)`: Check if file/directory exists
|
|
82
|
+
- `filesystem.remove(path)`: Remove file/directory
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Runtime, Provider, ProviderSandboxManager } from 'computesdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Daytona-specific configuration options
|
|
5
|
+
*/
|
|
6
|
+
interface DaytonaConfig {
|
|
7
|
+
/** Daytona API key - if not provided, will fallback to DAYTONA_API_KEY environment variable */
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
/** Default runtime environment */
|
|
10
|
+
runtime?: Runtime;
|
|
11
|
+
/** Execution timeout in milliseconds */
|
|
12
|
+
timeout?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Daytona Provider implementation
|
|
16
|
+
*/
|
|
17
|
+
declare class DaytonaProvider implements Provider {
|
|
18
|
+
readonly name = "daytona";
|
|
19
|
+
readonly sandbox: ProviderSandboxManager;
|
|
20
|
+
constructor(config?: DaytonaConfig);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a Daytona provider instance
|
|
24
|
+
*/
|
|
25
|
+
declare function daytona(config?: DaytonaConfig): DaytonaProvider;
|
|
26
|
+
|
|
27
|
+
export { type DaytonaConfig, DaytonaProvider, daytona };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Runtime, Provider, ProviderSandboxManager } from 'computesdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Daytona-specific configuration options
|
|
5
|
+
*/
|
|
6
|
+
interface DaytonaConfig {
|
|
7
|
+
/** Daytona API key - if not provided, will fallback to DAYTONA_API_KEY environment variable */
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
/** Default runtime environment */
|
|
10
|
+
runtime?: Runtime;
|
|
11
|
+
/** Execution timeout in milliseconds */
|
|
12
|
+
timeout?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Daytona Provider implementation
|
|
16
|
+
*/
|
|
17
|
+
declare class DaytonaProvider implements Provider {
|
|
18
|
+
readonly name = "daytona";
|
|
19
|
+
readonly sandbox: ProviderSandboxManager;
|
|
20
|
+
constructor(config?: DaytonaConfig);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a Daytona provider instance
|
|
24
|
+
*/
|
|
25
|
+
declare function daytona(config?: DaytonaConfig): DaytonaProvider;
|
|
26
|
+
|
|
27
|
+
export { type DaytonaConfig, DaytonaProvider, daytona };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
DaytonaProvider: () => DaytonaProvider,
|
|
24
|
+
daytona: () => daytona
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_sdk = require("@daytonaio/sdk");
|
|
28
|
+
var DaytonaSandboxImpl = class {
|
|
29
|
+
constructor(session, runtime = "python") {
|
|
30
|
+
this.provider = "daytona";
|
|
31
|
+
this.session = session;
|
|
32
|
+
this.sandboxId = session.id;
|
|
33
|
+
this.runtime = runtime;
|
|
34
|
+
this.filesystem = new DaytonaFileSystem(this.session);
|
|
35
|
+
this.terminal = new DaytonaTerminal(this.session);
|
|
36
|
+
}
|
|
37
|
+
async runCode(code, runtime) {
|
|
38
|
+
const startTime = Date.now();
|
|
39
|
+
try {
|
|
40
|
+
const response = await this.session.process.codeRun(code);
|
|
41
|
+
return {
|
|
42
|
+
stdout: response.result || "",
|
|
43
|
+
stderr: "",
|
|
44
|
+
// Daytona doesn't separate stderr in the response
|
|
45
|
+
exitCode: response.exitCode || 0,
|
|
46
|
+
executionTime: Date.now() - startTime,
|
|
47
|
+
sandboxId: this.sandboxId,
|
|
48
|
+
provider: this.provider
|
|
49
|
+
};
|
|
50
|
+
} catch (error) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`Daytona execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async runCommand(command, args = []) {
|
|
57
|
+
const startTime = Date.now();
|
|
58
|
+
try {
|
|
59
|
+
const fullCommand = args.length > 0 ? `${command} ${args.join(" ")}` : command;
|
|
60
|
+
const response = await this.session.process.executeCommand(fullCommand);
|
|
61
|
+
return {
|
|
62
|
+
stdout: response.result || "",
|
|
63
|
+
stderr: "",
|
|
64
|
+
// Daytona doesn't separate stderr in the response
|
|
65
|
+
exitCode: response.exitCode || 0,
|
|
66
|
+
executionTime: Date.now() - startTime,
|
|
67
|
+
sandboxId: this.sandboxId,
|
|
68
|
+
provider: this.provider
|
|
69
|
+
};
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Daytona command execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async getInfo() {
|
|
77
|
+
return {
|
|
78
|
+
id: this.sandboxId,
|
|
79
|
+
provider: this.provider,
|
|
80
|
+
runtime: this.runtime,
|
|
81
|
+
status: this.session.state === "started" ? "running" : "stopped",
|
|
82
|
+
createdAt: this.session.createdAt ? new Date(this.session.createdAt) : /* @__PURE__ */ new Date(),
|
|
83
|
+
timeout: 3e5,
|
|
84
|
+
// Default Daytona timeout
|
|
85
|
+
metadata: {
|
|
86
|
+
daytonaSessionId: this.sandboxId,
|
|
87
|
+
state: this.session.state,
|
|
88
|
+
target: this.session.target,
|
|
89
|
+
cpu: this.session.cpu,
|
|
90
|
+
memory: this.session.memory,
|
|
91
|
+
disk: this.session.disk
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async kill() {
|
|
96
|
+
try {
|
|
97
|
+
throw new Error("Sandbox deletion must be handled by the DaytonaSandboxManager");
|
|
98
|
+
} catch (error) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`Failed to kill Daytona session: ${error instanceof Error ? error.message : String(error)}`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var DaytonaFileSystem = class {
|
|
106
|
+
constructor(session) {
|
|
107
|
+
this.session = session;
|
|
108
|
+
}
|
|
109
|
+
async readFile(path) {
|
|
110
|
+
try {
|
|
111
|
+
const buffer = await this.session.fs.downloadFile(path);
|
|
112
|
+
return buffer.toString("utf-8");
|
|
113
|
+
} catch (error) {
|
|
114
|
+
throw new Error(`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async writeFile(path, content) {
|
|
118
|
+
try {
|
|
119
|
+
const buffer = Buffer.from(content, "utf-8");
|
|
120
|
+
await this.session.fs.uploadFile(buffer, path);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
throw new Error(`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async mkdir(path) {
|
|
126
|
+
try {
|
|
127
|
+
await this.session.fs.createFolder(path, "755");
|
|
128
|
+
} catch (error) {
|
|
129
|
+
throw new Error(`Failed to create directory ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async readdir(path) {
|
|
133
|
+
try {
|
|
134
|
+
const entries = await this.session.fs.listFiles(path);
|
|
135
|
+
return entries.map((entry) => ({
|
|
136
|
+
name: entry.name,
|
|
137
|
+
path: entry.path || `${path}/${entry.name}`,
|
|
138
|
+
isDirectory: Boolean(entry.isDir || entry.isDirectory || entry.type === "directory"),
|
|
139
|
+
size: entry.size || 0,
|
|
140
|
+
lastModified: new Date(entry.modTime || entry.lastModified || Date.now())
|
|
141
|
+
}));
|
|
142
|
+
} catch (error) {
|
|
143
|
+
throw new Error(`Failed to read directory ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async exists(path) {
|
|
147
|
+
try {
|
|
148
|
+
await this.session.fs.getFileDetails(path);
|
|
149
|
+
return true;
|
|
150
|
+
} catch (error) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async remove(path) {
|
|
155
|
+
try {
|
|
156
|
+
await this.session.fs.deleteFile(path);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
throw new Error(`Failed to remove ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
var DaytonaTerminal = class {
|
|
163
|
+
constructor(session) {
|
|
164
|
+
this.session = session;
|
|
165
|
+
}
|
|
166
|
+
async create(options = {}) {
|
|
167
|
+
throw new Error("Terminal operations are not supported by Daytona provider. Use runCode() or runCommand() instead.");
|
|
168
|
+
}
|
|
169
|
+
async list() {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var DaytonaSandboxManager = class {
|
|
174
|
+
constructor(config) {
|
|
175
|
+
this.config = config;
|
|
176
|
+
this.activeSandboxes = /* @__PURE__ */ new Map();
|
|
177
|
+
const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.DAYTONA_API_KEY || "";
|
|
178
|
+
if (!apiKey) {
|
|
179
|
+
throw new Error(
|
|
180
|
+
`Missing Daytona API key. Provide 'apiKey' in config or set DAYTONA_API_KEY environment variable. Get your API key from https://daytona.io/`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
this.daytona = new import_sdk.Daytona({ apiKey });
|
|
184
|
+
}
|
|
185
|
+
async create(options) {
|
|
186
|
+
const runtime = options?.runtime || this.config.runtime || "python";
|
|
187
|
+
try {
|
|
188
|
+
let session;
|
|
189
|
+
if (options?.sandboxId) {
|
|
190
|
+
session = await this.daytona.get(options.sandboxId);
|
|
191
|
+
} else {
|
|
192
|
+
session = await this.daytona.create({
|
|
193
|
+
language: runtime === "python" ? "python" : "typescript"
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const sandbox = new DaytonaSandboxImpl(session, runtime);
|
|
197
|
+
this.activeSandboxes.set(sandbox.sandboxId, sandbox);
|
|
198
|
+
return sandbox;
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error instanceof Error) {
|
|
201
|
+
if (error.message.includes("unauthorized") || error.message.includes("API key")) {
|
|
202
|
+
throw new Error(
|
|
203
|
+
`Daytona authentication failed. Please check your DAYTONA_API_KEY environment variable. Get your API key from https://daytona.io/`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
if (error.message.includes("quota") || error.message.includes("limit")) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
`Daytona quota exceeded. Please check your usage at https://daytona.io/`
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
throw new Error(
|
|
213
|
+
`Failed to create Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async getById(sandboxId) {
|
|
218
|
+
const existing = this.activeSandboxes.get(sandboxId);
|
|
219
|
+
if (existing) {
|
|
220
|
+
return existing;
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
const session = await this.daytona.get(sandboxId);
|
|
224
|
+
const sandbox = new DaytonaSandboxImpl(session, this.config.runtime || "python");
|
|
225
|
+
this.activeSandboxes.set(sandboxId, sandbox);
|
|
226
|
+
return sandbox;
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async list() {
|
|
232
|
+
try {
|
|
233
|
+
const sessions = await this.daytona.list();
|
|
234
|
+
const sandboxes = [];
|
|
235
|
+
for (const session of sessions) {
|
|
236
|
+
let sandbox = this.activeSandboxes.get(session.id);
|
|
237
|
+
if (!sandbox) {
|
|
238
|
+
sandbox = new DaytonaSandboxImpl(session, this.config.runtime || "python");
|
|
239
|
+
this.activeSandboxes.set(session.id, sandbox);
|
|
240
|
+
}
|
|
241
|
+
sandboxes.push(sandbox);
|
|
242
|
+
}
|
|
243
|
+
return sandboxes;
|
|
244
|
+
} catch (error) {
|
|
245
|
+
return Array.from(this.activeSandboxes.values());
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
async destroy(sandboxId) {
|
|
249
|
+
const sandbox = this.activeSandboxes.get(sandboxId);
|
|
250
|
+
if (sandbox) {
|
|
251
|
+
this.activeSandboxes.delete(sandboxId);
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
const session = await this.daytona.get(sandboxId);
|
|
255
|
+
await this.daytona.delete(session);
|
|
256
|
+
} catch (error) {
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
var DaytonaProvider = class {
|
|
261
|
+
constructor(config = {}) {
|
|
262
|
+
this.name = "daytona";
|
|
263
|
+
this.sandbox = new DaytonaSandboxManager(config);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
function daytona(config = {}) {
|
|
267
|
+
return new DaytonaProvider(config);
|
|
268
|
+
}
|
|
269
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
270
|
+
0 && (module.exports = {
|
|
271
|
+
DaytonaProvider,
|
|
272
|
+
daytona
|
|
273
|
+
});
|
|
274
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Daytona, Sandbox as DaytonaSandbox } from '@daytonaio/sdk';\nimport type {\n ExecutionResult,\n Runtime,\n SandboxInfo,\n FileEntry,\n SandboxFileSystem,\n SandboxTerminal,\n TerminalSession,\n TerminalCreateOptions,\n Provider,\n ProviderSandboxManager,\n Sandbox,\n CreateSandboxOptions,\n} from 'computesdk';\n\n/**\n * Daytona-specific configuration options\n */\nexport interface DaytonaConfig {\n /** Daytona API key - if not provided, will fallback to DAYTONA_API_KEY environment variable */\n apiKey?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Daytona Sandbox implementation\n */\nclass DaytonaSandboxImpl implements Sandbox {\n readonly sandboxId: string;\n readonly provider = 'daytona';\n readonly filesystem: SandboxFileSystem;\n readonly terminal: SandboxTerminal;\n\n private session: DaytonaSandbox;\n private readonly runtime: Runtime;\n\n constructor(session: DaytonaSandbox, runtime: Runtime = 'python') {\n this.session = session;\n this.sandboxId = session.id;\n this.runtime = runtime;\n \n // Initialize filesystem and terminal\n this.filesystem = new DaytonaFileSystem(this.session);\n this.terminal = new DaytonaTerminal(this.session);\n }\n\n async runCode(code: string, runtime?: Runtime): Promise<ExecutionResult> {\n const startTime = Date.now();\n\n try {\n // Execute code using Daytona's process.codeRun method\n const response = await this.session.process.codeRun(code);\n \n return {\n stdout: response.result || '',\n stderr: '', // Daytona doesn't separate stderr in the response\n exitCode: response.exitCode || 0,\n executionTime: Date.now() - startTime,\n sandboxId: this.sandboxId,\n provider: this.provider\n };\n } catch (error) {\n throw new Error(\n `Daytona execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async runCommand(command: string, args: string[] = []): Promise<ExecutionResult> {\n const startTime = Date.now();\n\n try {\n // Construct full command with arguments\n const fullCommand = args.length > 0 ? `${command} ${args.join(' ')}` : command;\n\n // Execute command using Daytona's process.executeCommand method\n const response = await this.session.process.executeCommand(fullCommand);\n \n return {\n stdout: response.result || '',\n stderr: '', // Daytona doesn't separate stderr in the response\n exitCode: response.exitCode || 0,\n executionTime: Date.now() - startTime,\n sandboxId: this.sandboxId,\n provider: this.provider\n };\n } catch (error) {\n throw new Error(\n `Daytona command execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return {\n id: this.sandboxId,\n provider: this.provider,\n runtime: this.runtime,\n status: this.session.state === 'started' ? 'running' : 'stopped',\n createdAt: this.session.createdAt ? new Date(this.session.createdAt) : new Date(),\n timeout: 300000, // Default Daytona timeout\n metadata: {\n daytonaSessionId: this.sandboxId,\n state: this.session.state,\n target: this.session.target,\n cpu: this.session.cpu,\n memory: this.session.memory,\n disk: this.session.disk\n }\n };\n }\n\n async kill(): Promise<void> {\n try {\n // Use the Daytona client to delete the sandbox\n // Note: We need access to the Daytona client instance for this\n // For now, we'll throw an error indicating this needs to be handled by the manager\n throw new Error('Sandbox deletion must be handled by the DaytonaSandboxManager');\n } catch (error) {\n throw new Error(\n `Failed to kill Daytona session: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n}\n\n/**\n * Daytona FileSystem implementation\n */\nclass DaytonaFileSystem implements SandboxFileSystem {\n constructor(private session: DaytonaSandbox) {}\n\n async readFile(path: string): Promise<string> {\n try {\n // Use Daytona's file system API to download file as buffer, then convert to string\n const buffer = await this.session.fs.downloadFile(path);\n return buffer.toString('utf-8');\n } catch (error) {\n throw new Error(`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n try {\n // Use Daytona's file system API to upload file from buffer\n const buffer = Buffer.from(content, 'utf-8');\n await this.session.fs.uploadFile(buffer, path);\n } catch (error) {\n throw new Error(`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n async mkdir(path: string): Promise<void> {\n try {\n // Use Daytona's file system API to create directory\n await this.session.fs.createFolder(path, '755');\n } catch (error) {\n throw new Error(`Failed to create directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n async readdir(path: string): Promise<FileEntry[]> {\n try {\n // Use Daytona's file system API to list directory\n const entries = await this.session.fs.listFiles(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n path: entry.path || `${path}/${entry.name}`,\n isDirectory: Boolean(entry.isDir || entry.isDirectory || entry.type === 'directory'),\n size: entry.size || 0,\n lastModified: new Date(entry.modTime || entry.lastModified || Date.now())\n }));\n } catch (error) {\n throw new Error(`Failed to read directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n async exists(path: string): Promise<boolean> {\n try {\n // Use Daytona's file system API to get file details - if it succeeds, file exists\n await this.session.fs.getFileDetails(path);\n return true;\n } catch (error) {\n // If the API call fails, assume file doesn't exist\n return false;\n }\n }\n\n async remove(path: string): Promise<void> {\n try {\n // Use Daytona's file system API to delete file/directory\n await this.session.fs.deleteFile(path);\n } catch (error) {\n throw new Error(`Failed to remove ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n}\n\n/**\n * Daytona Terminal implementation (Note: Daytona doesn't support terminal operations by design)\n */\nclass DaytonaTerminal implements SandboxTerminal {\n constructor(private session: DaytonaSandbox) {}\n\n async create(options: TerminalCreateOptions = {}): Promise<TerminalSession> {\n // Daytona doesn't support terminal operations by design\n throw new Error('Terminal operations are not supported by Daytona provider. Use runCode() or runCommand() instead.');\n }\n\n async list(): Promise<TerminalSession[]> {\n // Daytona doesn't support terminal operations by design\n return [];\n }\n}\n\n/**\n * Daytona Sandbox Manager - implements ProviderSandboxManager\n */\nclass DaytonaSandboxManager implements ProviderSandboxManager {\n private activeSandboxes: Map<string, DaytonaSandboxImpl> = new Map();\n private daytona: Daytona;\n\n constructor(private config: DaytonaConfig) {\n // Validate API key\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.DAYTONA_API_KEY) || '';\n \n if (!apiKey) {\n throw new Error(\n `Missing Daytona API key. Provide 'apiKey' in config or set DAYTONA_API_KEY environment variable. Get your API key from https://daytona.io/`\n );\n }\n\n // Initialize Daytona client\n this.daytona = new Daytona({ apiKey: apiKey });\n }\n\n async create(options?: CreateSandboxOptions): Promise<Sandbox> {\n const runtime = options?.runtime || this.config.runtime || 'python';\n\n try {\n let session: DaytonaSandbox;\n\n if (options?.sandboxId) {\n // Reconnect to existing Daytona session\n session = await this.daytona.get(options.sandboxId);\n } else {\n // Create new Daytona session\n session = await this.daytona.create({\n language: runtime === 'python' ? 'python' : 'typescript',\n });\n }\n\n const sandbox = new DaytonaSandboxImpl(session, runtime);\n this.activeSandboxes.set(sandbox.sandboxId, sandbox);\n \n return sandbox;\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(\n `Daytona authentication failed. Please check your DAYTONA_API_KEY environment variable. Get your API key from https://daytona.io/`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `Daytona quota exceeded. Please check your usage at https://daytona.io/`\n );\n }\n }\n throw new Error(\n `Failed to create Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async getById(sandboxId: string): Promise<Sandbox | null> {\n // Check if we have it in our active sandboxes\n const existing = this.activeSandboxes.get(sandboxId);\n if (existing) {\n return existing;\n }\n\n // Try to reconnect to existing Daytona session\n try {\n const session = await this.daytona.get(sandboxId);\n \n const sandbox = new DaytonaSandboxImpl(session, this.config.runtime || 'python');\n this.activeSandboxes.set(sandboxId, sandbox);\n \n return sandbox;\n } catch (error) {\n // Sandbox doesn't exist or can't be accessed\n return null;\n }\n }\n\n async list(): Promise<Sandbox[]> {\n try {\n // Use Daytona's list API to get all sandboxes\n const sessions = await this.daytona.list();\n const sandboxes: Sandbox[] = [];\n\n for (const session of sessions) {\n let sandbox = this.activeSandboxes.get(session.id);\n if (!sandbox) {\n sandbox = new DaytonaSandboxImpl(session, this.config.runtime || 'python');\n this.activeSandboxes.set(session.id, sandbox);\n }\n sandboxes.push(sandbox);\n }\n\n return sandboxes;\n } catch (error) {\n // If list fails, return our active sandboxes\n return Array.from(this.activeSandboxes.values());\n }\n }\n\n async destroy(sandboxId: string): Promise<void> {\n const sandbox = this.activeSandboxes.get(sandboxId);\n if (sandbox) {\n this.activeSandboxes.delete(sandboxId);\n }\n \n // Use Daytona client to delete the sandbox\n try {\n const session = await this.daytona.get(sandboxId);\n await this.daytona.delete(session);\n } catch (error) {\n // Sandbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n }\n}\n\n/**\n * Daytona Provider implementation\n */\nexport class DaytonaProvider implements Provider {\n readonly name = 'daytona';\n readonly sandbox: ProviderSandboxManager;\n\n constructor(config: DaytonaConfig = {}) {\n this.sandbox = new DaytonaSandboxManager(config);\n }\n}\n\n/**\n * Create a Daytona provider instance\n */\nexport function daytona(config: DaytonaConfig = {}): DaytonaProvider {\n return new DaytonaProvider(config);\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmD;AA+BnD,IAAM,qBAAN,MAA4C;AAAA,EAS1C,YAAY,SAAyB,UAAmB,UAAU;AAPlE,SAAS,WAAW;AAQlB,SAAK,UAAU;AACf,SAAK,YAAY,QAAQ;AACzB,SAAK,UAAU;AAGf,SAAK,aAAa,IAAI,kBAAkB,KAAK,OAAO;AACpD,SAAK,WAAW,IAAI,gBAAgB,KAAK,OAAO;AAAA,EAClD;AAAA,EAEA,MAAM,QAAQ,MAAc,SAA6C;AACvE,UAAM,YAAY,KAAK,IAAI;AAE3B,QAAI;AAEF,YAAM,WAAW,MAAM,KAAK,QAAQ,QAAQ,QAAQ,IAAI;AAExD,aAAO;AAAA,QACL,QAAQ,SAAS,UAAU;AAAA,QAC3B,QAAQ;AAAA;AAAA,QACR,UAAU,SAAS,YAAY;AAAA,QAC/B,eAAe,KAAK,IAAI,IAAI;AAAA,QAC5B,WAAW,KAAK;AAAA,QAChB,UAAU,KAAK;AAAA,MACjB;AAAA,IACF,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,6BAA6B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MACrF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW,SAAiB,OAAiB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W,UAAU;AAC9B,YAAI,UAAU,KAAK,gBAAgB,IAAI,QAAQ,EAAE;AACjD,YAAI,CAAC,SAAS;AACZ,oBAAU,IAAI,mBAAmB,SAAS,KAAK,OAAO,WAAW,QAAQ;AACzE,eAAK,gBAAgB,IAAI,QAAQ,IAAI,OAAO;AAAA,QAC9C;AACA,kBAAU,KAAK,OAAO;AAAA,MACxB;AAEA,aAAO;AAAA,IACT,SAAS,OAAO;AAEd,aAAO,MAAM,KAAK,KAAK,gBAAgB,OAAO,CAAC;AAAA,IACjD;AAAA,EACF;AAAA,EAEA,MAAM,QAAQ,WAAkC;AAC9C,UAAM,UAAU,KAAK,gBAAgB,IAAI,SAAS;AAClD,QAAI,SAAS;AACX,WAAK,gBAAgB,OAAO,SAAS;AAAA,IACvC;AAGA,QAAI;AACF,YAAM,UAAU,MAAM,KAAK,QAAQ,IAAI,SAAS;AAChD,YAAM,KAAK,QAAQ,OAAO,OAAO;AAAA,IACnC,SAAS,OAAO;AAAA,IAGhB;AAAA,EACF;AACF;AAKO,IAAM,kBAAN,MAA0C;AAAA,EAI/C,YAAY,SAAwB,CAAC,GAAG;AAHxC,SAAS,OAAO;AAId,SAAK,UAAU,IAAI,sBAAsB,MAAM;AAAA,EACjD;AACF;AAKO,SAAS,QAAQ,SAAwB,CAAC,GAAoB;AACnE,SAAO,IAAI,gBAAgB,MAAM;AACnC;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { Daytona } from "@daytonaio/sdk";
|
|
3
|
+
var DaytonaSandboxImpl = class {
|
|
4
|
+
constructor(session, runtime = "python") {
|
|
5
|
+
this.provider = "daytona";
|
|
6
|
+
this.session = session;
|
|
7
|
+
this.sandboxId = session.id;
|
|
8
|
+
this.runtime = runtime;
|
|
9
|
+
this.filesystem = new DaytonaFileSystem(this.session);
|
|
10
|
+
this.terminal = new DaytonaTerminal(this.session);
|
|
11
|
+
}
|
|
12
|
+
async runCode(code, runtime) {
|
|
13
|
+
const startTime = Date.now();
|
|
14
|
+
try {
|
|
15
|
+
const response = await this.session.process.codeRun(code);
|
|
16
|
+
return {
|
|
17
|
+
stdout: response.result || "",
|
|
18
|
+
stderr: "",
|
|
19
|
+
// Daytona doesn't separate stderr in the response
|
|
20
|
+
exitCode: response.exitCode || 0,
|
|
21
|
+
executionTime: Date.now() - startTime,
|
|
22
|
+
sandboxId: this.sandboxId,
|
|
23
|
+
provider: this.provider
|
|
24
|
+
};
|
|
25
|
+
} catch (error) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Daytona execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async runCommand(command, args = []) {
|
|
32
|
+
const startTime = Date.now();
|
|
33
|
+
try {
|
|
34
|
+
const fullCommand = args.length > 0 ? `${command} ${args.join(" ")}` : command;
|
|
35
|
+
const response = await this.session.process.executeCommand(fullCommand);
|
|
36
|
+
return {
|
|
37
|
+
stdout: response.result || "",
|
|
38
|
+
stderr: "",
|
|
39
|
+
// Daytona doesn't separate stderr in the response
|
|
40
|
+
exitCode: response.exitCode || 0,
|
|
41
|
+
executionTime: Date.now() - startTime,
|
|
42
|
+
sandboxId: this.sandboxId,
|
|
43
|
+
provider: this.provider
|
|
44
|
+
};
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`Daytona command execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async getInfo() {
|
|
52
|
+
return {
|
|
53
|
+
id: this.sandboxId,
|
|
54
|
+
provider: this.provider,
|
|
55
|
+
runtime: this.runtime,
|
|
56
|
+
status: this.session.state === "started" ? "running" : "stopped",
|
|
57
|
+
createdAt: this.session.createdAt ? new Date(this.session.createdAt) : /* @__PURE__ */ new Date(),
|
|
58
|
+
timeout: 3e5,
|
|
59
|
+
// Default Daytona timeout
|
|
60
|
+
metadata: {
|
|
61
|
+
daytonaSessionId: this.sandboxId,
|
|
62
|
+
state: this.session.state,
|
|
63
|
+
target: this.session.target,
|
|
64
|
+
cpu: this.session.cpu,
|
|
65
|
+
memory: this.session.memory,
|
|
66
|
+
disk: this.session.disk
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async kill() {
|
|
71
|
+
try {
|
|
72
|
+
throw new Error("Sandbox deletion must be handled by the DaytonaSandboxManager");
|
|
73
|
+
} catch (error) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Failed to kill Daytona session: ${error instanceof Error ? error.message : String(error)}`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var DaytonaFileSystem = class {
|
|
81
|
+
constructor(session) {
|
|
82
|
+
this.session = session;
|
|
83
|
+
}
|
|
84
|
+
async readFile(path) {
|
|
85
|
+
try {
|
|
86
|
+
const buffer = await this.session.fs.downloadFile(path);
|
|
87
|
+
return buffer.toString("utf-8");
|
|
88
|
+
} catch (error) {
|
|
89
|
+
throw new Error(`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async writeFile(path, content) {
|
|
93
|
+
try {
|
|
94
|
+
const buffer = Buffer.from(content, "utf-8");
|
|
95
|
+
await this.session.fs.uploadFile(buffer, path);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
throw new Error(`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async mkdir(path) {
|
|
101
|
+
try {
|
|
102
|
+
await this.session.fs.createFolder(path, "755");
|
|
103
|
+
} catch (error) {
|
|
104
|
+
throw new Error(`Failed to create directory ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async readdir(path) {
|
|
108
|
+
try {
|
|
109
|
+
const entries = await this.session.fs.listFiles(path);
|
|
110
|
+
return entries.map((entry) => ({
|
|
111
|
+
name: entry.name,
|
|
112
|
+
path: entry.path || `${path}/${entry.name}`,
|
|
113
|
+
isDirectory: Boolean(entry.isDir || entry.isDirectory || entry.type === "directory"),
|
|
114
|
+
size: entry.size || 0,
|
|
115
|
+
lastModified: new Date(entry.modTime || entry.lastModified || Date.now())
|
|
116
|
+
}));
|
|
117
|
+
} catch (error) {
|
|
118
|
+
throw new Error(`Failed to read directory ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async exists(path) {
|
|
122
|
+
try {
|
|
123
|
+
await this.session.fs.getFileDetails(path);
|
|
124
|
+
return true;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async remove(path) {
|
|
130
|
+
try {
|
|
131
|
+
await this.session.fs.deleteFile(path);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
throw new Error(`Failed to remove ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
var DaytonaTerminal = class {
|
|
138
|
+
constructor(session) {
|
|
139
|
+
this.session = session;
|
|
140
|
+
}
|
|
141
|
+
async create(options = {}) {
|
|
142
|
+
throw new Error("Terminal operations are not supported by Daytona provider. Use runCode() or runCommand() instead.");
|
|
143
|
+
}
|
|
144
|
+
async list() {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
var DaytonaSandboxManager = class {
|
|
149
|
+
constructor(config) {
|
|
150
|
+
this.config = config;
|
|
151
|
+
this.activeSandboxes = /* @__PURE__ */ new Map();
|
|
152
|
+
const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.DAYTONA_API_KEY || "";
|
|
153
|
+
if (!apiKey) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
`Missing Daytona API key. Provide 'apiKey' in config or set DAYTONA_API_KEY environment variable. Get your API key from https://daytona.io/`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
this.daytona = new Daytona({ apiKey });
|
|
159
|
+
}
|
|
160
|
+
async create(options) {
|
|
161
|
+
const runtime = options?.runtime || this.config.runtime || "python";
|
|
162
|
+
try {
|
|
163
|
+
let session;
|
|
164
|
+
if (options?.sandboxId) {
|
|
165
|
+
session = await this.daytona.get(options.sandboxId);
|
|
166
|
+
} else {
|
|
167
|
+
session = await this.daytona.create({
|
|
168
|
+
language: runtime === "python" ? "python" : "typescript"
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const sandbox = new DaytonaSandboxImpl(session, runtime);
|
|
172
|
+
this.activeSandboxes.set(sandbox.sandboxId, sandbox);
|
|
173
|
+
return sandbox;
|
|
174
|
+
} catch (error) {
|
|
175
|
+
if (error instanceof Error) {
|
|
176
|
+
if (error.message.includes("unauthorized") || error.message.includes("API key")) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
`Daytona authentication failed. Please check your DAYTONA_API_KEY environment variable. Get your API key from https://daytona.io/`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (error.message.includes("quota") || error.message.includes("limit")) {
|
|
182
|
+
throw new Error(
|
|
183
|
+
`Daytona quota exceeded. Please check your usage at https://daytona.io/`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
throw new Error(
|
|
188
|
+
`Failed to create Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
async getById(sandboxId) {
|
|
193
|
+
const existing = this.activeSandboxes.get(sandboxId);
|
|
194
|
+
if (existing) {
|
|
195
|
+
return existing;
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
const session = await this.daytona.get(sandboxId);
|
|
199
|
+
const sandbox = new DaytonaSandboxImpl(session, this.config.runtime || "python");
|
|
200
|
+
this.activeSandboxes.set(sandboxId, sandbox);
|
|
201
|
+
return sandbox;
|
|
202
|
+
} catch (error) {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async list() {
|
|
207
|
+
try {
|
|
208
|
+
const sessions = await this.daytona.list();
|
|
209
|
+
const sandboxes = [];
|
|
210
|
+
for (const session of sessions) {
|
|
211
|
+
let sandbox = this.activeSandboxes.get(session.id);
|
|
212
|
+
if (!sandbox) {
|
|
213
|
+
sandbox = new DaytonaSandboxImpl(session, this.config.runtime || "python");
|
|
214
|
+
this.activeSandboxes.set(session.id, sandbox);
|
|
215
|
+
}
|
|
216
|
+
sandboxes.push(sandbox);
|
|
217
|
+
}
|
|
218
|
+
return sandboxes;
|
|
219
|
+
} catch (error) {
|
|
220
|
+
return Array.from(this.activeSandboxes.values());
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async destroy(sandboxId) {
|
|
224
|
+
const sandbox = this.activeSandboxes.get(sandboxId);
|
|
225
|
+
if (sandbox) {
|
|
226
|
+
this.activeSandboxes.delete(sandboxId);
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
const session = await this.daytona.get(sandboxId);
|
|
230
|
+
await this.daytona.delete(session);
|
|
231
|
+
} catch (error) {
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
var DaytonaProvider = class {
|
|
236
|
+
constructor(config = {}) {
|
|
237
|
+
this.name = "daytona";
|
|
238
|
+
this.sandbox = new DaytonaSandboxManager(config);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
function daytona(config = {}) {
|
|
242
|
+
return new DaytonaProvider(config);
|
|
243
|
+
}
|
|
244
|
+
export {
|
|
245
|
+
DaytonaProvider,
|
|
246
|
+
daytona
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Daytona, Sandbox as DaytonaSandbox } from '@daytonaio/sdk';\nimport type {\n ExecutionResult,\n Runtime,\n SandboxInfo,\n FileEntry,\n SandboxFileSystem,\n SandboxTerminal,\n TerminalSession,\n TerminalCreateOptions,\n Provider,\n ProviderSandboxManager,\n Sandbox,\n CreateSandboxOptions,\n} from 'computesdk';\n\n/**\n * Daytona-specific configuration options\n */\nexport interface DaytonaConfig {\n /** Daytona API key - if not provided, will fallback to DAYTONA_API_KEY environment variable */\n apiKey?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Daytona Sandbox implementation\n */\nclass DaytonaSandboxImpl implements Sandbox {\n readonly sandboxId: string;\n readonly provider = 'daytona';\n readonly filesystem: SandboxFileSystem;\n readonly terminal: SandboxTerminal;\n\n private session: DaytonaSandbox;\n private readonly runtime: Runtime;\n\n constructor(session: DaytonaSandbox, runtime: Runtime = 'python') {\n this.session = session;\n this.sandboxId = session.id;\n this.runtime = runtime;\n \n // Initialize filesystem and terminal\n this.filesystem = new DaytonaFileSystem(this.session);\n this.terminal = new DaytonaTerminal(this.session);\n }\n\n async runCode(code: string, runtime?: Runtime): Promise<ExecutionResult> {\n const startTime = Date.now();\n\n try {\n // Execute code using Daytona's process.codeRun method\n const response = await this.session.process.codeRun(code);\n \n return {\n stdout: response.result || '',\n stderr: '', // Daytona doesn't separate stderr in the response\n exitCode: response.exitCode || 0,\n executionTime: Date.now() - startTime,\n sandboxId: this.sandboxId,\n provider: this.provider\n };\n } catch (error) {\n throw new Error(\n `Daytona execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async runCommand(command: string, args: string[] = []): Promise<ExecutionResult> {\n const startTime = Date.now();\n\n try {\n // Construct full command with arguments\n const fullCommand = args.length > 0 ? `${command} ${args.join(' ')}` : command;\n\n // Execute command using Daytona's process.executeCommand method\n const response = await this.session.process.executeCommand(fullCommand);\n \n return {\n stdout: response.result || '',\n stderr: '', // Daytona doesn't separate stderr in the response\n exitCode: response.exitCode || 0,\n executionTime: Date.now() - startTime,\n sandboxId: this.sandboxId,\n provider: this.provider\n };\n } catch (error) {\n throw new Error(\n `Daytona command execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return {\n id: this.sandboxId,\n provider: this.provider,\n runtime: this.runtime,\n status: this.session.state === 'started' ? 'running' : 'stopped',\n createdAt: this.session.createdAt ? new Date(this.session.createdAt) : new Date(),\n timeout: 300000, // Default Daytona timeout\n metadata: {\n daytonaSessionId: this.sandboxId,\n state: this.session.state,\n target: this.session.target,\n cpu: this.session.cpu,\n memory: this.session.memory,\n disk: this.session.disk\n }\n };\n }\n\n async kill(): Promise<void> {\n try {\n // Use the Daytona client to delete the sandbox\n // Note: We need access to the Daytona client instance for this\n // For now, we'll throw an error indicating this needs to be handled by the manager\n throw new Error('Sandbox deletion must be handled by the DaytonaSandboxManager');\n } catch (error) {\n throw new Error(\n `Failed to kill Daytona session: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n}\n\n/**\n * Daytona FileSystem implementation\n */\nclass DaytonaFileSystem implements SandboxFileSystem {\n constructor(private session: DaytonaSandbox) {}\n\n async readFile(path: string): Promise<string> {\n try {\n // Use Daytona's file system API to download file as buffer, then convert to string\n const buffer = await this.session.fs.downloadFile(path);\n return buffer.toString('utf-8');\n } catch (error) {\n throw new Error(`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n try {\n // Use Daytona's file system API to upload file from buffer\n const buffer = Buffer.from(content, 'utf-8');\n await this.session.fs.uploadFile(buffer, path);\n } catch (error) {\n throw new Error(`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n async mkdir(path: string): Promise<void> {\n try {\n // Use Daytona's file system API to create directory\n await this.session.fs.createFolder(path, '755');\n } catch (error) {\n throw new Error(`Failed to create directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n async readdir(path: string): Promise<FileEntry[]> {\n try {\n // Use Daytona's file system API to list directory\n const entries = await this.session.fs.listFiles(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n path: entry.path || `${path}/${entry.name}`,\n isDirectory: Boolean(entry.isDir || entry.isDirectory || entry.type === 'directory'),\n size: entry.size || 0,\n lastModified: new Date(entry.modTime || entry.lastModified || Date.now())\n }));\n } catch (error) {\n throw new Error(`Failed to read directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n async exists(path: string): Promise<boolean> {\n try {\n // Use Daytona's file system API to get file details - if it succeeds, file exists\n await this.session.fs.getFileDetails(path);\n return true;\n } catch (error) {\n // If the API call fails, assume file doesn't exist\n return false;\n }\n }\n\n async remove(path: string): Promise<void> {\n try {\n // Use Daytona's file system API to delete file/directory\n await this.session.fs.deleteFile(path);\n } catch (error) {\n throw new Error(`Failed to remove ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n}\n\n/**\n * Daytona Terminal implementation (Note: Daytona doesn't support terminal operations by design)\n */\nclass DaytonaTerminal implements SandboxTerminal {\n constructor(private session: DaytonaSandbox) {}\n\n async create(options: TerminalCreateOptions = {}): Promise<TerminalSession> {\n // Daytona doesn't support terminal operations by design\n throw new Error('Terminal operations are not supported by Daytona provider. Use runCode() or runCommand() instead.');\n }\n\n async list(): Promise<TerminalSession[]> {\n // Daytona doesn't support terminal operations by design\n return [];\n }\n}\n\n/**\n * Daytona Sandbox Manager - implements ProviderSandboxManager\n */\nclass DaytonaSandboxManager implements ProviderSandboxManager {\n private activeSandboxes: Map<string, DaytonaSandboxImpl> = new Map();\n private daytona: Daytona;\n\n constructor(private config: DaytonaConfig) {\n // Validate API key\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.DAYTONA_API_KEY) || '';\n \n if (!apiKey) {\n throw new Error(\n `Missing Daytona API key. Provide 'apiKey' in config or set DAYTONA_API_KEY environment variable. Get your API key from https://daytona.io/`\n );\n }\n\n // Initialize Daytona client\n this.daytona = new Daytona({ apiKey: apiKey });\n }\n\n async create(options?: CreateSandboxOptions): Promise<Sandbox> {\n const runtime = options?.runtime || this.config.runtime || 'python';\n\n try {\n let session: DaytonaSandbox;\n\n if (options?.sandboxId) {\n // Reconnect to existing Daytona session\n session = await this.daytona.get(options.sandboxId);\n } else {\n // Create new Daytona session\n session = await this.daytona.create({\n language: runtime === 'python' ? 'python' : 'typescript',\n });\n }\n\n const sandbox = new DaytonaSandboxImpl(session, runtime);\n this.activeSandboxes.set(sandbox.sandboxId, sandbox);\n \n return sandbox;\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(\n `Daytona authentication failed. Please check your DAYTONA_API_KEY environment variable. Get your API key from https://daytona.io/`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `Daytona quota exceeded. Please check your usage at https://daytona.io/`\n );\n }\n }\n throw new Error(\n `Failed to create Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async getById(sandboxId: string): Promise<Sandbox | null> {\n // Check if we have it in our active sandboxes\n const existing = this.activeSandboxes.get(sandboxId);\n if (existing) {\n return existing;\n }\n\n // Try to reconnect to existing Daytona session\n try {\n const session = await this.daytona.get(sandboxId);\n \n const sandbox = new DaytonaSandboxImpl(session, this.config.runtime || 'python');\n this.activeSandboxes.set(sandboxId, sandbox);\n \n return sandbox;\n } catch (error) {\n // Sandbox doesn't exist or can't be accessed\n return null;\n }\n }\n\n async list(): Promise<Sandbox[]> {\n try {\n // Use Daytona's list API to get all sandboxes\n const sessions = await this.daytona.list();\n const sandboxes: Sandbox[] = [];\n\n for (const session of sessions) {\n let sandbox = this.activeSandboxes.get(session.id);\n if (!sandbox) {\n sandbox = new DaytonaSandboxImpl(session, this.config.runtime || 'python');\n this.activeSandboxes.set(session.id, sandbox);\n }\n sandboxes.push(sandbox);\n }\n\n return sandboxes;\n } catch (error) {\n // If list fails, return our active sandboxes\n return Array.from(this.activeSandboxes.values());\n }\n }\n\n async destroy(sandboxId: string): Promise<void> {\n const sandbox = this.activeSandboxes.get(sandboxId);\n if (sandbox) {\n this.activeSandboxes.delete(sandboxId);\n }\n \n // Use Daytona client to delete the sandbox\n try {\n const session = await this.daytona.get(sandboxId);\n await this.daytona.delete(session);\n } catch (error) {\n // Sandbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n }\n}\n\n/**\n * Daytona Provider implementation\n */\nexport class DaytonaProvider implements Provider {\n readonly name = 'daytona';\n readonly sandbox: ProviderSandboxManager;\n\n constructor(config: DaytonaConfig = {}) {\n this.sandbox = new DaytonaSandboxManager(config);\n }\n}\n\n/**\n * Create a Daytona provider instance\n */\nexport function daytona(config: DaytonaConfig = {}): DaytonaProvider {\n return new DaytonaProvider(config);\n}"],"mappings":";AAAA,SAAS,eAA0C;AA+BnD,IAAM,qBAAN,MAA4C;AAAA,EAS1C,YAAY,SAAyB,UAAmB,UAAU;AAPlE,SAAS,WAAW;AAQlB,SAAK,UAAU;AACf,SAAK,YAAY,QAAQ;AACzB,SAAK,UAAU;AAGf,SAAK,aAAa,IAAI,kBAAkB,KAAK,OAAO;AACpD,SAAK,WAAW,IAAI,gBAAgB,KAAK,OAAO;AAAA,EAClD;AAAA,EAEA,MAAM,QAAQ,MAAc,SAA6C;AACvE,UAAM,YAAY,KAAK,IAAI;AAE3B,QAAI;AAEF,YAAM,WAAW,MAAM,KAAK,QAAQ,QAAQ,QAAQ,IAAI;AAExD,aAAO;AAAA,QACL,QAAQ,SAAS,UAAU;AAAA,QAC3B,QAAQ;AAAA;AAAA,QACR,UAAU,SAAS,YAAY;AAAA,QAC/B,eAAe,KAAK,IAAI,IAAI;AAAA,QAC5B,WAAW,KAAK;AAAA,QAChB,UAAU,KAAK;AAAA,MACjB;AAAA,IACF,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,6BAA6B,iBAAiB,Q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AA2B;AAC/B,QAAI;AAEF,YAAM,WAAW,MAAM,KAAK,QAAQ,KAAK;AACzC,YAAM,YAAuB,CAAC;AAE9B,iBAAW,WAAW,UAAU;AAC9B,YAAI,UAAU,KAAK,gBAAgB,IAAI,QAAQ,EAAE;AACjD,YAAI,CAAC,SAAS;AACZ,oBAAU,IAAI,mBAAmB,SAAS,KAAK,OAAO,WAAW,QAAQ;AACzE,eAAK,gBAAgB,IAAI,QAAQ,IAAI,OAAO;AAAA,QAC9C;AACA,kBAAU,KAAK,OAAO;AAAA,MACxB;AAEA,aAAO;AAAA,IACT,SAAS,OAAO;AAEd,aAAO,MAAM,KAAK,KAAK,gBAAgB,OAAO,CAAC;AAAA,IACjD;AAAA,EACF;AAAA,EAEA,MAAM,QAAQ,WAAkC;AAC9C,UAAM,UAAU,KAAK,gBAAgB,IAAI,SAAS;AAClD,QAAI,SAAS;AACX,WAAK,gBAAgB,OAAO,SAAS;AAAA,IACvC;AAGA,QAAI;AACF,YAAM,UAAU,MAAM,KAAK,QAAQ,IAAI,SAAS;AAChD,YAAM,KAAK,QAAQ,OAAO,OAAO;AAAA,IACnC,SAAS,OAAO;AAAA,IAGhB;AAAA,EACF;AACF;AAKO,IAAM,kBAAN,MAA0C;AAAA,EAI/C,YAAY,SAAwB,CAAC,GAAG;AAHxC,SAAS,OAAO;AAId,SAAK,UAAU,IAAI,sBAAsB,MAAM;AAAA,EACjD;AACF;AAKO,SAAS,QAAQ,SAAwB,CAAC,GAAoB;AACnE,SAAO,IAAI,gBAAgB,MAAM;AACnC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@computesdk/daytona",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Daytona provider for ComputeSDK",
|
|
5
|
+
"author": "Garrison",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@daytonaio/sdk": "^0.25.0",
|
|
22
|
+
"computesdk": "1.0.2"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"daytona",
|
|
26
|
+
"sandbox",
|
|
27
|
+
"code-execution",
|
|
28
|
+
"python",
|
|
29
|
+
"cloud",
|
|
30
|
+
"compute"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/computesdk/computesdk.git",
|
|
35
|
+
"directory": "packages/daytona"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/computesdk/computesdk/tree/main/packages/daytona",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/computesdk/computesdk/issues"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^20.0.0",
|
|
43
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
44
|
+
"eslint": "^8.37.0",
|
|
45
|
+
"rimraf": "^5.0.0",
|
|
46
|
+
"tsup": "^8.0.0",
|
|
47
|
+
"typescript": "^5.0.0",
|
|
48
|
+
"vitest": "^1.0.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsup",
|
|
52
|
+
"clean": "rimraf dist",
|
|
53
|
+
"dev": "tsup --watch",
|
|
54
|
+
"test": "vitest run",
|
|
55
|
+
"test:watch": "vitest watch",
|
|
56
|
+
"test:coverage": "vitest run --coverage",
|
|
57
|
+
"typecheck": "tsc --noEmit",
|
|
58
|
+
"lint": "eslint"
|
|
59
|
+
}
|
|
60
|
+
}
|