@computesdk/daytona 1.7.23 → 1.7.25
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 +13 -13
- package/dist/index.js +36 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -75
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ import { compute } from 'computesdk';
|
|
|
21
21
|
const sandbox = await compute.sandbox.create();
|
|
22
22
|
|
|
23
23
|
// Execute code
|
|
24
|
-
const result = await sandbox.
|
|
24
|
+
const result = await sandbox.runCommand('python -c "print(\"Hello from Daytona!\")"');
|
|
25
25
|
console.log(result.stdout); // "Hello from Daytona!"
|
|
26
26
|
|
|
27
27
|
await sandbox.destroy();
|
|
@@ -40,7 +40,7 @@ const compute = daytona({
|
|
|
40
40
|
|
|
41
41
|
const sandbox = await compute.sandbox.create();
|
|
42
42
|
|
|
43
|
-
const result = await sandbox.
|
|
43
|
+
const result = await sandbox.runCommand('python -c "print(\"Hello from Daytona!\")"');
|
|
44
44
|
console.log(result.stdout);
|
|
45
45
|
|
|
46
46
|
await sandbox.destroy();
|
|
@@ -81,20 +81,20 @@ interface DaytonaConfig {
|
|
|
81
81
|
|
|
82
82
|
```typescript
|
|
83
83
|
// Execute Python code
|
|
84
|
-
const result = await sandbox.
|
|
84
|
+
const result = await sandbox.runCommand(`python - <<'PY'
|
|
85
85
|
import json
|
|
86
86
|
data = {"message": "Hello from Python"}
|
|
87
87
|
print(json.dumps(data))
|
|
88
|
-
|
|
88
|
+
PY`);
|
|
89
89
|
|
|
90
90
|
// Execute Node.js code
|
|
91
|
-
const result = await sandbox.
|
|
91
|
+
const result = await sandbox.runCommand(`node - <<'JS'
|
|
92
92
|
const data = { message: "Hello from Node.js" };
|
|
93
93
|
console.log(JSON.stringify(data));
|
|
94
|
-
|
|
94
|
+
JS`);
|
|
95
95
|
|
|
96
96
|
// Auto-detection (based on code patterns)
|
|
97
|
-
const result = await sandbox.
|
|
97
|
+
const result = await sandbox.runCommand('python -c "print(\"Auto-detected as Python\")"');
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
### Command Execution
|
|
@@ -170,7 +170,7 @@ try {
|
|
|
170
170
|
const compute = daytona({ apiKey: process.env.DAYTONA_API_KEY });
|
|
171
171
|
const sandbox = await compute.sandbox.create();
|
|
172
172
|
|
|
173
|
-
const result = await sandbox.
|
|
173
|
+
const result = await sandbox.runCommand('invalid code');
|
|
174
174
|
} catch (error) {
|
|
175
175
|
if (error.message.includes('Syntax error')) {
|
|
176
176
|
console.error('Code has syntax errors');
|
|
@@ -192,7 +192,7 @@ import { daytona } from '@computesdk/daytona';
|
|
|
192
192
|
const compute = daytona({ apiKey: process.env.DAYTONA_API_KEY });
|
|
193
193
|
const sandbox = await compute.sandbox.create();
|
|
194
194
|
|
|
195
|
-
const result = await sandbox.
|
|
195
|
+
const result = await sandbox.runCommand(`python - <<'PY'
|
|
196
196
|
import json
|
|
197
197
|
|
|
198
198
|
# Process data
|
|
@@ -204,7 +204,7 @@ result = {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
print(json.dumps(result))
|
|
207
|
-
`);
|
|
207
|
+
PY`);
|
|
208
208
|
|
|
209
209
|
const output = JSON.parse(result.stdout);
|
|
210
210
|
console.log(output); // { sum: 15, average: 3, max: 5 }
|
|
@@ -226,7 +226,7 @@ await sandbox.filesystem.writeFile('/workspace/data.json',
|
|
|
226
226
|
);
|
|
227
227
|
|
|
228
228
|
// Process file
|
|
229
|
-
const result = await sandbox.
|
|
229
|
+
const result = await sandbox.runCommand(`python - <<'PY'
|
|
230
230
|
import json
|
|
231
231
|
|
|
232
232
|
with open('/workspace/data.json', 'r') as f:
|
|
@@ -240,7 +240,7 @@ print(f"Found {user_count} users")
|
|
|
240
240
|
result = {"user_count": user_count, "processed": True}
|
|
241
241
|
with open('/workspace/result.json', 'w') as f:
|
|
242
242
|
json.dump(result, f)
|
|
243
|
-
`);
|
|
243
|
+
PY`);
|
|
244
244
|
|
|
245
245
|
// Read result
|
|
246
246
|
const resultData = await sandbox.filesystem.readFile('/workspace/result.json');
|
|
@@ -251,4 +251,4 @@ await sandbox.destroy();
|
|
|
251
251
|
|
|
252
252
|
## License
|
|
253
253
|
|
|
254
|
-
MIT
|
|
254
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -43,51 +43,44 @@ var daytona = (0, import_provider.defineProvider)({
|
|
|
43
43
|
const daytona2 = new import_sdk.Daytona({ apiKey });
|
|
44
44
|
let session;
|
|
45
45
|
let sandboxId;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
createParams.name = name;
|
|
75
|
-
}
|
|
76
|
-
if (metadata && typeof metadata === "object") {
|
|
77
|
-
const labels = {};
|
|
78
|
-
for (const [k, v] of Object.entries(metadata)) {
|
|
79
|
-
labels[k] = typeof v === "string" ? v : JSON.stringify(v);
|
|
80
|
-
}
|
|
81
|
-
createParams.labels = labels;
|
|
82
|
-
}
|
|
83
|
-
const sourceId = templateId || snapshotId;
|
|
84
|
-
if (sourceId) {
|
|
85
|
-
createParams.snapshot = sourceId;
|
|
46
|
+
const {
|
|
47
|
+
runtime: _runtime,
|
|
48
|
+
timeout: _timeout,
|
|
49
|
+
envs,
|
|
50
|
+
name,
|
|
51
|
+
metadata,
|
|
52
|
+
templateId,
|
|
53
|
+
snapshotId,
|
|
54
|
+
sandboxId: _sandboxId,
|
|
55
|
+
namespace: _namespace,
|
|
56
|
+
directory: _directory,
|
|
57
|
+
...providerOptions
|
|
58
|
+
} = options || {};
|
|
59
|
+
const createParams = {
|
|
60
|
+
language: runtime === "python" ? "python" : "javascript",
|
|
61
|
+
...providerOptions
|
|
62
|
+
// Spread provider-specific options (e.g., resources, public, autoStopInterval)
|
|
63
|
+
};
|
|
64
|
+
if (envs && Object.keys(envs).length > 0) {
|
|
65
|
+
createParams.envVars = envs;
|
|
66
|
+
}
|
|
67
|
+
if (name) {
|
|
68
|
+
createParams.name = name;
|
|
69
|
+
}
|
|
70
|
+
if (metadata && typeof metadata === "object") {
|
|
71
|
+
const labels = {};
|
|
72
|
+
for (const [k, v] of Object.entries(metadata)) {
|
|
73
|
+
labels[k] = typeof v === "string" ? v : JSON.stringify(v);
|
|
86
74
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
createParams.labels = labels;
|
|
76
|
+
}
|
|
77
|
+
const sourceId = templateId || snapshotId;
|
|
78
|
+
if (sourceId) {
|
|
79
|
+
createParams.snapshot = sourceId;
|
|
90
80
|
}
|
|
81
|
+
const createOptions = timeout ? { timeout: Math.ceil(timeout / 1e3) } : void 0;
|
|
82
|
+
session = await daytona2.create(createParams, createOptions);
|
|
83
|
+
sandboxId = session.id;
|
|
91
84
|
return {
|
|
92
85
|
sandbox: session,
|
|
93
86
|
sandboxId
|
|
@@ -159,38 +152,6 @@ var daytona = (0, import_provider.defineProvider)({
|
|
|
159
152
|
}
|
|
160
153
|
},
|
|
161
154
|
// Instance operations (sandbox.*)
|
|
162
|
-
runCode: async (sandbox, code, runtime) => {
|
|
163
|
-
const startTime = Date.now();
|
|
164
|
-
try {
|
|
165
|
-
const effectiveRuntime = runtime || // Strong Python indicators
|
|
166
|
-
(code.includes("print(") || code.includes("import ") || code.includes("def ") || code.includes("sys.") || code.includes("json.") || code.includes("__") || code.includes('f"') || code.includes("f'") || code.includes("raise ") ? "python" : "node");
|
|
167
|
-
let response;
|
|
168
|
-
const encoded = Buffer.from(code).toString("base64");
|
|
169
|
-
if (effectiveRuntime === "python") {
|
|
170
|
-
response = await sandbox.process.executeCommand(`echo "${encoded}" | base64 -d | python3`);
|
|
171
|
-
} else {
|
|
172
|
-
response = await sandbox.process.executeCommand(`echo "${encoded}" | base64 -d | node`);
|
|
173
|
-
}
|
|
174
|
-
const output = response.result || "";
|
|
175
|
-
const hasError = output.includes("Error:") || output.includes("error TS") || output.includes("SyntaxError:") || output.includes("TypeError:") || output.includes("ReferenceError:") || output.includes("Traceback (most recent call last)");
|
|
176
|
-
if (hasError && (output.includes("SyntaxError:") || output.includes("invalid syntax") || output.includes("Unexpected token") || output.includes("Unexpected identifier") || output.includes("error TS1434"))) {
|
|
177
|
-
throw new Error(`Syntax error: ${output.trim()}`);
|
|
178
|
-
}
|
|
179
|
-
const actualExitCode = hasError ? 1 : response.exitCode || 0;
|
|
180
|
-
return {
|
|
181
|
-
output,
|
|
182
|
-
exitCode: actualExitCode,
|
|
183
|
-
language: effectiveRuntime
|
|
184
|
-
};
|
|
185
|
-
} catch (error) {
|
|
186
|
-
if (error instanceof Error && error.message.includes("Syntax error")) {
|
|
187
|
-
throw error;
|
|
188
|
-
}
|
|
189
|
-
throw new Error(
|
|
190
|
-
`Daytona execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
155
|
runCommand: async (sandbox, command, options) => {
|
|
195
156
|
const startTime = Date.now();
|
|
196
157
|
try {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Daytona Provider - Factory-based Implementation\n * \n * Code execution only provider using the factory pattern.\n * Reduces ~300 lines of boilerplate to ~80 lines of core logic.\n */\n\nimport { Daytona, Sandbox as DaytonaSandbox } from '@daytonaio/sdk';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { Runtime, CodeResult, CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\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 * Create a Daytona provider instance using the factory pattern\n */\nexport const daytona = defineProvider<DaytonaSandbox, DaytonaConfig>({\n name: 'daytona',\n methods: {\n sandbox: {\n // Collection operations (compute.sandbox.*)\n create: async (config: DaytonaConfig, options?: CreateSandboxOptions) => {\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 const runtime = options?.runtime || config.runtime || 'node';\n const timeout = options?.timeout ?? config.timeout;\n\n try {\n // Initialize Daytona client\n const daytona = new Daytona({ apiKey: apiKey });\n\n let session: DaytonaSandbox;\n let sandboxId: string;\n\n if (options?.sandboxId) {\n // Reconnect to existing Daytona sandbox\n session = await daytona.get(options.sandboxId);\n sandboxId = options.sandboxId;\n } else {\n // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n runtime: _runtime,\n timeout: _timeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: _sandboxId,\n namespace: _namespace,\n directory: _directory,\n overlays: _overlays,\n servers: _servers,\n ...providerOptions\n } = options || {};\n\n // Build create params from options\n // Daytona SDK uses envVars (not envs), labels (not metadata)\n const createParams: Record<string, any> = {\n language: runtime === 'python' ? 'python' : 'javascript',\n ...providerOptions, // Spread provider-specific options (e.g., resources, public, autoStopInterval)\n };\n\n // Remap ComputeSDK fields to Daytona SDK fields\n if (envs && Object.keys(envs).length > 0) {\n createParams.envVars = envs;\n }\n\n if (name) {\n createParams.name = name;\n }\n\n // Pass metadata as labels (Daytona uses labels: Record<string, string>)\n if (metadata && typeof metadata === 'object') {\n const labels: Record<string, string> = {};\n for (const [k, v] of Object.entries(metadata)) {\n labels[k] = typeof v === 'string' ? v : JSON.stringify(v);\n }\n createParams.labels = labels;\n }\n\n // If templateId or snapshotId is provided, use it as the source\n const sourceId = templateId || snapshotId;\n if (sourceId) {\n createParams.snapshot = sourceId;\n }\n\n // Daytona SDK accepts timeout in seconds as a second argument\n const createOptions = timeout\n ? { timeout: Math.ceil(timeout / 1000) }\n : undefined;\n\n session = await daytona.create(createParams as any, createOptions);\n sandboxId = session.id;\n }\n\n return {\n sandbox: session,\n sandboxId\n };\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 getById: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const session = await daytona.get(sandboxId);\n\n return {\n sandbox: session,\n sandboxId\n };\n } catch (error) {\n // Sandbox not found is expected -- return null per the interface contract\n if (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return null;\n }\n // Propagate unexpected errors (auth failures, network issues, etc.)\n throw new Error(\n `Failed to get Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const result = await daytona.list();\n\n return result.items.map((session: any) => ({\n sandbox: session,\n sandboxId: session.id\n }));\n } catch (error) {\n throw new Error(\n `Failed to list Daytona sandboxes: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n destroy: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const sandbox = await daytona.get(sandboxId);\n await sandbox.delete();\n } catch (error) {\n // If the sandbox is already gone (404), that's fine for destroy semantics\n if (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return;\n }\n // Propagate all other errors (auth failures, network issues, etc.)\n throw new Error(\n `Failed to destroy Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Instance operations (sandbox.*)\n runCode: async (sandbox: DaytonaSandbox, code: string, runtime?: Runtime): Promise<CodeResult> => {\n const startTime = Date.now();\n\n try {\n // Auto-detect runtime if not specified\n const effectiveRuntime = runtime || (\n // Strong Python indicators\n code.includes('print(') || \n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\") ||\n code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n \n // Use direct command execution like Vercel for consistency\n let response;\n \n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n \n if (effectiveRuntime === 'python') {\n response = await sandbox.process.executeCommand(`echo \"${encoded}\" | base64 -d | python3`);\n } else {\n response = await sandbox.process.executeCommand(`echo \"${encoded}\" | base64 -d | node`);\n }\n\n // Daytona always returns exitCode: 0, so we need to detect errors from output\n const output = response.result || '';\n const hasError = output.includes('Error:') || \n output.includes('error TS') || \n output.includes('SyntaxError:') ||\n output.includes('TypeError:') ||\n output.includes('ReferenceError:') ||\n output.includes('Traceback (most recent call last)');\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (hasError && (output.includes('SyntaxError:') || \n output.includes('invalid syntax') ||\n output.includes('Unexpected token') ||\n output.includes('Unexpected identifier') ||\n output.includes('error TS1434'))) {\n throw new Error(`Syntax error: ${output.trim()}`);\n }\n\n const actualExitCode = hasError ? 1 : (response.exitCode || 0);\n\n return {\n output: output,\n exitCode: actualExitCode,\n language: effectiveRuntime\n };\n } catch (error) {\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `Daytona execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (sandbox: DaytonaSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n\n try {\n // Build command with options\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n // Execute command using Daytona's process.executeCommand method\n const response = await sandbox.process.executeCommand(fullCommand);\n\n return {\n stdout: response.result || '',\n stderr: '',\n exitCode: response.exitCode || 0,\n durationMs: Date.now() - startTime\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 getInfo: async (sandbox: DaytonaSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.id,\n provider: 'daytona',\n runtime: 'python', // Daytona default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n daytonaSandboxId: sandbox.id\n }\n };\n },\n\n getUrl: async (sandbox: DaytonaSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use Daytona's built-in getPreviewLink method\n const previewInfo = await sandbox.getPreviewLink(options.port);\n let url = previewInfo.url;\n \n // If a specific protocol is requested, replace the URL's protocol\n if (options.protocol) {\n const urlObj = new URL(url);\n urlObj.protocol = options.protocol + ':';\n url = urlObj.toString();\n }\n \n return url;\n } catch (error) {\n throw new Error(\n `Failed to get Daytona preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Filesystem operations via terminal commands\n filesystem: {\n readFile: async (sandbox: DaytonaSandbox, path: string): Promise<string> => {\n try {\n const response = await sandbox.process.executeCommand(`cat \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`File not found or cannot be read: ${path}`);\n }\n return response.result || '';\n } catch (error) {\n throw new Error(`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n writeFile: async (sandbox: DaytonaSandbox, path: string, content: string): Promise<void> => {\n try {\n // Use base64 encoding to safely handle special characters, newlines, and binary content\n const encoded = Buffer.from(content).toString('base64');\n const response = await sandbox.process.executeCommand(`echo \"${encoded}\" | base64 -d > \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to write to file: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n mkdir: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n try {\n const response = await sandbox.process.executeCommand(`mkdir -p \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to create directory: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to create directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n readdir: async (sandbox: DaytonaSandbox, path: string): Promise<FileEntry[]> => {\n try {\n const response = await sandbox.process.executeCommand(`ls -la \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Directory not found or cannot be read: ${path}`);\n }\n\n // Parse ls -la output into FileEntry objects\n const lines = response.result.split('\\n').filter(line => line.trim());\n const entries: FileEntry[] = [];\n\n for (const line of lines) {\n // Skip total line and current/parent directory entries\n if (line.startsWith('total ') || line.endsWith(' .') || line.endsWith(' ..')) {\n continue;\n }\n\n // Parse ls -la format: permissions links owner group size date time name\n const parts = line.trim().split(/\\s+/);\n if (parts.length >= 9) {\n const permissions = parts[0];\n const name = parts.slice(8).join(' '); // Handle filenames with spaces\n const isDirectory = permissions.startsWith('d');\n const size = parseInt(parts[4]) || 0;\n\n entries.push({\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size,\n modified: new Date() // ls -la date parsing is complex, use current time\n });\n }\n }\n\n return entries;\n } catch (error) {\n throw new Error(`Failed to read directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n exists: async (sandbox: DaytonaSandbox, path: string): Promise<boolean> => {\n try {\n const response = await sandbox.process.executeCommand(`test -e \"${path}\"`);\n return response.exitCode === 0;\n } catch (error) {\n // If command execution fails, assume file doesn't exist\n return false;\n }\n },\n\n remove: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n try {\n const response = await sandbox.process.executeCommand(`rm -rf \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to remove: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to remove ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: DaytonaSandbox): DaytonaSandbox => {\n return sandbox;\n },\n\n },\n\n snapshot: {\n create: async (config: DaytonaConfig, sandboxId: string, options?: { name?: string }) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n // Note: Using 'any' cast as we are using internal service property\n const snapshot = await (daytona as any).snapshots.create({\n workspaceId: sandboxId,\n name: options?.name || `snapshot-${Date.now()}`\n });\n return snapshot;\n } catch (error) {\n throw new Error(`Failed to create Daytona snapshot: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n const result = await (daytona as any).snapshots.list();\n return result;\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: DaytonaConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n // Note: Daytona SDK might not expose delete directly or it might be 'remove'\n // We'll try the common pattern\n await (daytona as any).snapshots.delete(snapshotId);\n } catch (error) {\n // Ignore if not found\n }\n }\n },\n\n // Templates in Daytona are effectively Snapshots\n template: {\n create: async (config: DaytonaConfig, options: { name: string }) => {\n throw new Error('To create a template in Daytona, create a snapshot from a running sandbox using snapshot.create()');\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n const result = await (daytona as any).snapshots.list();\n return result;\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: DaytonaConfig, templateId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n await (daytona as any).snapshots.delete(templateId);\n } catch (error) {\n // Ignore if not found\n }\n }\n }\n }\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAmD;AACnD,sBAA+C;AAmBxC,IAAM,cAAU,gCAA8C;AAAA,EACnE,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAAoB;AAEpG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,SAAS,WAAW,OAAO,WAAW;AACtD,cAAM,UAAU,SAAS,WAAW,OAAO;AAE3C,YAAI;AAEF,gBAAMA,WAAU,I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C,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,cAAMA,WAAU,IAAI,mBAAQ,EAAE,OAAe,CAAC;AAE9C,YAAI;AACF,gBAAM,SAAS,MAAOA,SAAgB,UAAU,KAAK;AACrD,iBAAO;AAAA,QACT,SAAS,OAAO;AACd,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,MAEA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,cAAMA,WAAU,IAAI,mBAAQ,EAAE,OAAe,CAAC;AAE9C,YAAI;AACF,gBAAOA,SAAgB,UAAU,OAAO,UAAU;AAAA,QACpD,SAAS,OAAO;AAAA,QAEhB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["daytona"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Daytona Provider - Factory-based Implementation\n * \n * Code execution only provider using the factory pattern.\n * Reduces ~300 lines of boilerplate to ~80 lines of core logic.\n */\n\nimport { Daytona, Sandbox as DaytonaSandbox } from '@daytonaio/sdk';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { Runtime, CodeResult, CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\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 * Create a Daytona provider instance using the factory pattern\n */\nexport const daytona = defineProvider<DaytonaSandbox, DaytonaConfig>({\n name: 'daytona',\n methods: {\n sandbox: {\n // Collection operations (compute.sandbox.*)\n create: async (config: DaytonaConfig, options?: CreateSandboxOptions) => {\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 const runtime = options?.runtime || config.runtime || 'node';\n const timeout = options?.timeout ?? config.timeout;\n\n try {\n // Initialize Daytona client\n const daytona = new Daytona({ apiKey: apiKey });\n\n let session: DaytonaSandbox;\n let sandboxId: string;\n\n // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n runtime: _runtime,\n timeout: _timeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: _sandboxId,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n // Build create params from options\n // Daytona SDK uses envVars (not envs), labels (not metadata)\n const createParams: Record<string, any> = {\n language: runtime === 'python' ? 'python' : 'javascript',\n ...providerOptions, // Spread provider-specific options (e.g., resources, public, autoStopInterval)\n };\n\n // Remap ComputeSDK fields to Daytona SDK fields\n if (envs && Object.keys(envs).length > 0) {\n createParams.envVars = envs;\n }\n\n if (name) {\n createParams.name = name;\n }\n\n // Pass metadata as labels (Daytona uses labels: Record<string, string>)\n if (metadata && typeof metadata === 'object') {\n const labels: Record<string, string> = {};\n for (const [k, v] of Object.entries(metadata)) {\n labels[k] = typeof v === 'string' ? v : JSON.stringify(v);\n }\n createParams.labels = labels;\n }\n\n // If templateId or snapshotId is provided, use it as the source\n const sourceId = templateId || snapshotId;\n if (sourceId) {\n createParams.snapshot = sourceId;\n }\n\n // Daytona SDK accepts timeout in seconds as a second argument\n const createOptions = timeout\n ? { timeout: Math.ceil(timeout / 1000) }\n : undefined;\n\n session = await daytona.create(createParams as any, createOptions);\n sandboxId = session.id;\n\n return {\n sandbox: session,\n sandboxId\n };\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 getById: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const session = await daytona.get(sandboxId);\n\n return {\n sandbox: session,\n sandboxId\n };\n } catch (error) {\n // Sandbox not found is expected -- return null per the interface contract\n if (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return null;\n }\n // Propagate unexpected errors (auth failures, network issues, etc.)\n throw new Error(\n `Failed to get Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const result = await daytona.list();\n\n return result.items.map((session: any) => ({\n sandbox: session,\n sandboxId: session.id\n }));\n } catch (error) {\n throw new Error(\n `Failed to list Daytona sandboxes: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n destroy: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const sandbox = await daytona.get(sandboxId);\n await sandbox.delete();\n } catch (error) {\n // If the sandbox is already gone (404), that's fine for destroy semantics\n if (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return;\n }\n // Propagate all other errors (auth failures, network issues, etc.)\n throw new Error(\n `Failed to destroy Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Instance operations (sandbox.*)\n\n runCommand: async (sandbox: DaytonaSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n\n try {\n // Build command with options\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n // Execute command using Daytona's process.executeCommand method\n const response = await sandbox.process.executeCommand(fullCommand);\n\n return {\n stdout: response.result || '',\n stderr: '',\n exitCode: response.exitCode || 0,\n durationMs: Date.now() - startTime\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 getInfo: async (sandbox: DaytonaSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.id,\n provider: 'daytona',\n runtime: 'python', // Daytona default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n daytonaSandboxId: sandbox.id\n }\n };\n },\n\n getUrl: async (sandbox: DaytonaSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use Daytona's built-in getPreviewLink method\n const previewInfo = await sandbox.getPreviewLink(options.port);\n let url = previewInfo.url;\n \n // If a specific protocol is requested, replace the URL's protocol\n if (options.protocol) {\n const urlObj = new URL(url);\n urlObj.protocol = options.protocol + ':';\n url = urlObj.toString();\n }\n \n return url;\n } catch (error) {\n throw new Error(\n `Failed to get Daytona preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Filesystem operations via terminal commands\n filesystem: {\n readFile: async (sandbox: DaytonaSandbox, path: string): Promise<string> => {\n try {\n const response = await sandbox.process.executeCommand(`cat \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`File not found or cannot be read: ${path}`);\n }\n return response.result || '';\n } catch (error) {\n throw new Error(`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n writeFile: async (sandbox: DaytonaSandbox, path: string, content: string): Promise<void> => {\n try {\n // Use base64 encoding to safely handle special characters, newlines, and binary content\n const encoded = Buffer.from(content).toString('base64');\n const response = await sandbox.process.executeCommand(`echo \"${encoded}\" | base64 -d > \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to write to file: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n mkdir: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n try {\n const response = await sandbox.process.executeCommand(`mkdir -p \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to create directory: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to create directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n readdir: async (sandbox: DaytonaSandbox, path: string): Promise<FileEntry[]> => {\n try {\n const response = await sandbox.process.executeCommand(`ls -la \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Directory not found or cannot be read: ${path}`);\n }\n\n // Parse ls -la output into FileEntry objects\n const lines = response.result.split('\\n').filter(line => line.trim());\n const entries: FileEntry[] = [];\n\n for (const line of lines) {\n // Skip total line and current/parent directory entries\n if (line.startsWith('total ') || line.endsWith(' .') || line.endsWith(' ..')) {\n continue;\n }\n\n // Parse ls -la format: permissions links owner group size date time name\n const parts = line.trim().split(/\\s+/);\n if (parts.length >= 9) {\n const permissions = parts[0];\n const name = parts.slice(8).join(' '); // Handle filenames with spaces\n const isDirectory = permissions.startsWith('d');\n const size = parseInt(parts[4]) || 0;\n\n entries.push({\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size,\n modified: new Date() // ls -la date parsing is complex, use current time\n });\n }\n }\n\n return entries;\n } catch (error) {\n throw new Error(`Failed to read directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n exists: async (sandbox: DaytonaSandbox, path: string): Promise<boolean> => {\n try {\n const response = await sandbox.process.executeCommand(`test -e \"${path}\"`);\n return response.exitCode === 0;\n } catch (error) {\n // If command execution fails, assume file doesn't exist\n return false;\n }\n },\n\n remove: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n try {\n const response = await sandbox.process.executeCommand(`rm -rf \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to remove: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to remove ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: DaytonaSandbox): DaytonaSandbox => {\n return sandbox;\n },\n\n },\n\n snapshot: {\n create: async (config: DaytonaConfig, sandboxId: string, options?: { name?: string }) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n // Note: Using 'any' cast as we are using internal service property\n const snapshot = await (daytona as any).snapshots.create({\n workspaceId: sandboxId,\n name: options?.name || `snapshot-${Date.now()}`\n });\n return snapshot;\n } catch (error) {\n throw new Error(`Failed to create Daytona snapshot: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n const result = await (daytona as any).snapshots.list();\n return result;\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: DaytonaConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n // Note: Daytona SDK might not expose delete directly or it might be 'remove'\n // We'll try the common pattern\n await (daytona as any).snapshots.delete(snapshotId);\n } catch (error) {\n // Ignore if not found\n }\n }\n },\n\n // Templates in Daytona are effectively Snapshots\n template: {\n create: async (config: DaytonaConfig, options: { name: string }) => {\n throw new Error('To create a template in Daytona, create a snapshot from a running sandbox using snapshot.create()');\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n const result = await (daytona as any).snapshots.list();\n return result;\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: DaytonaConfig, templateId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n await (daytona as any).snapshots.delete(templateId);\n } catch (error) {\n // Ignore if not found\n }\n }\n }\n }\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAmD;AACnD,sBAA+C;AAmBxC,IAAM,cAAU,gCAA8C;AAAA,EACnE,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAAoB;AAEpG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,SAAS,WAAW,OAAO,WAAW;AACtD,cAAM,UAAU,SAAS,WAAW,OAAO;AAE3C,YAAI;AAEF,gBAAMA,WAAU,IAAI,mBAAQ,EAAE,OAAe,CAAC;AAE9C,cAAI;AACJ,cAAI;AAGJ,gBAAM;AAAA,YACJ,SAAS;AAAA,YACT,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,WAAW;AAAA,YACX,WAAW;AAAA,YACX,WAAW;AAAA,YACX,GAAG;AAAA,UACL,IAAI,WAAW,CAAC;AAId,gBAAM,eAAoC;AAAA,YACxC,UAAU,YAAY,WAAW,WAAW;AAAA,YAC5C,GAAG;AAAA;AAAA,UACL;AAGA,cAAI,QAAQ,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AACxC,yBAAa,UAAU;AAAA,UACzB;A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I;AACF,gBAAM,SAAS,MAAOA,SAAgB,UAAU,KAAK;AACrD,iBAAO;AAAA,QACT,SAAS,OAAO;AACd,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,MAEA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,cAAMA,WAAU,IAAI,mBAAQ,EAAE,OAAe,CAAC;AAE9C,YAAI;AAGF,gBAAOA,SAAgB,UAAU,OAAO,UAAU;AAAA,QACpD,SAAS,OAAO;AAAA,QAEhB;AAAA,MACF;AAAA,IACF;AAAA;AAAA,IAGA,UAAU;AAAA,MACR,QAAQ,OAAO,QAAuB,YAA8B;AACjE,cAAM,IAAI,MAAM,mGAAmG;AAAA,MACtH;AAAA,MAEA,MAAM,OAAO,WAA0B;AACrC,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,cAAMA,WAAU,IAAI,mBAAQ,EAAE,OAAe,CAAC;AAE9C,YAAI;AACF,gBAAM,SAAS,MAAOA,SAAgB,UAAU,KAAK;AACrD,iBAAO;AAAA,QACT,SAAS,OAAO;AACd,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,MAEA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,cAAMA,WAAU,IAAI,mBAAQ,EAAE,OAAe,CAAC;AAE9C,YAAI;AACF,gBAAOA,SAAgB,UAAU,OAAO,UAAU;AAAA,QACpD,SAAS,OAAO;AAAA,QAEhB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["daytona"]}
|
package/dist/index.mjs
CHANGED
|
@@ -19,51 +19,44 @@ var daytona = defineProvider({
|
|
|
19
19
|
const daytona2 = new Daytona({ apiKey });
|
|
20
20
|
let session;
|
|
21
21
|
let sandboxId;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
createParams.name = name;
|
|
51
|
-
}
|
|
52
|
-
if (metadata && typeof metadata === "object") {
|
|
53
|
-
const labels = {};
|
|
54
|
-
for (const [k, v] of Object.entries(metadata)) {
|
|
55
|
-
labels[k] = typeof v === "string" ? v : JSON.stringify(v);
|
|
56
|
-
}
|
|
57
|
-
createParams.labels = labels;
|
|
58
|
-
}
|
|
59
|
-
const sourceId = templateId || snapshotId;
|
|
60
|
-
if (sourceId) {
|
|
61
|
-
createParams.snapshot = sourceId;
|
|
22
|
+
const {
|
|
23
|
+
runtime: _runtime,
|
|
24
|
+
timeout: _timeout,
|
|
25
|
+
envs,
|
|
26
|
+
name,
|
|
27
|
+
metadata,
|
|
28
|
+
templateId,
|
|
29
|
+
snapshotId,
|
|
30
|
+
sandboxId: _sandboxId,
|
|
31
|
+
namespace: _namespace,
|
|
32
|
+
directory: _directory,
|
|
33
|
+
...providerOptions
|
|
34
|
+
} = options || {};
|
|
35
|
+
const createParams = {
|
|
36
|
+
language: runtime === "python" ? "python" : "javascript",
|
|
37
|
+
...providerOptions
|
|
38
|
+
// Spread provider-specific options (e.g., resources, public, autoStopInterval)
|
|
39
|
+
};
|
|
40
|
+
if (envs && Object.keys(envs).length > 0) {
|
|
41
|
+
createParams.envVars = envs;
|
|
42
|
+
}
|
|
43
|
+
if (name) {
|
|
44
|
+
createParams.name = name;
|
|
45
|
+
}
|
|
46
|
+
if (metadata && typeof metadata === "object") {
|
|
47
|
+
const labels = {};
|
|
48
|
+
for (const [k, v] of Object.entries(metadata)) {
|
|
49
|
+
labels[k] = typeof v === "string" ? v : JSON.stringify(v);
|
|
62
50
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
createParams.labels = labels;
|
|
52
|
+
}
|
|
53
|
+
const sourceId = templateId || snapshotId;
|
|
54
|
+
if (sourceId) {
|
|
55
|
+
createParams.snapshot = sourceId;
|
|
66
56
|
}
|
|
57
|
+
const createOptions = timeout ? { timeout: Math.ceil(timeout / 1e3) } : void 0;
|
|
58
|
+
session = await daytona2.create(createParams, createOptions);
|
|
59
|
+
sandboxId = session.id;
|
|
67
60
|
return {
|
|
68
61
|
sandbox: session,
|
|
69
62
|
sandboxId
|
|
@@ -135,38 +128,6 @@ var daytona = defineProvider({
|
|
|
135
128
|
}
|
|
136
129
|
},
|
|
137
130
|
// Instance operations (sandbox.*)
|
|
138
|
-
runCode: async (sandbox, code, runtime) => {
|
|
139
|
-
const startTime = Date.now();
|
|
140
|
-
try {
|
|
141
|
-
const effectiveRuntime = runtime || // Strong Python indicators
|
|
142
|
-
(code.includes("print(") || code.includes("import ") || code.includes("def ") || code.includes("sys.") || code.includes("json.") || code.includes("__") || code.includes('f"') || code.includes("f'") || code.includes("raise ") ? "python" : "node");
|
|
143
|
-
let response;
|
|
144
|
-
const encoded = Buffer.from(code).toString("base64");
|
|
145
|
-
if (effectiveRuntime === "python") {
|
|
146
|
-
response = await sandbox.process.executeCommand(`echo "${encoded}" | base64 -d | python3`);
|
|
147
|
-
} else {
|
|
148
|
-
response = await sandbox.process.executeCommand(`echo "${encoded}" | base64 -d | node`);
|
|
149
|
-
}
|
|
150
|
-
const output = response.result || "";
|
|
151
|
-
const hasError = output.includes("Error:") || output.includes("error TS") || output.includes("SyntaxError:") || output.includes("TypeError:") || output.includes("ReferenceError:") || output.includes("Traceback (most recent call last)");
|
|
152
|
-
if (hasError && (output.includes("SyntaxError:") || output.includes("invalid syntax") || output.includes("Unexpected token") || output.includes("Unexpected identifier") || output.includes("error TS1434"))) {
|
|
153
|
-
throw new Error(`Syntax error: ${output.trim()}`);
|
|
154
|
-
}
|
|
155
|
-
const actualExitCode = hasError ? 1 : response.exitCode || 0;
|
|
156
|
-
return {
|
|
157
|
-
output,
|
|
158
|
-
exitCode: actualExitCode,
|
|
159
|
-
language: effectiveRuntime
|
|
160
|
-
};
|
|
161
|
-
} catch (error) {
|
|
162
|
-
if (error instanceof Error && error.message.includes("Syntax error")) {
|
|
163
|
-
throw error;
|
|
164
|
-
}
|
|
165
|
-
throw new Error(
|
|
166
|
-
`Daytona execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
131
|
runCommand: async (sandbox, command, options) => {
|
|
171
132
|
const startTime = Date.now();
|
|
172
133
|
try {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Daytona Provider - Factory-based Implementation\n * \n * Code execution only provider using the factory pattern.\n * Reduces ~300 lines of boilerplate to ~80 lines of core logic.\n */\n\nimport { Daytona, Sandbox as DaytonaSandbox } from '@daytonaio/sdk';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { Runtime, CodeResult, CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\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 * Create a Daytona provider instance using the factory pattern\n */\nexport const daytona = defineProvider<DaytonaSandbox, DaytonaConfig>({\n name: 'daytona',\n methods: {\n sandbox: {\n // Collection operations (compute.sandbox.*)\n create: async (config: DaytonaConfig, options?: CreateSandboxOptions) => {\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 const runtime = options?.runtime || config.runtime || 'node';\n const timeout = options?.timeout ?? config.timeout;\n\n try {\n // Initialize Daytona client\n const daytona = new Daytona({ apiKey: apiKey });\n\n let session: DaytonaSandbox;\n let sandboxId: string;\n\n if (options?.sandboxId) {\n // Reconnect to existing Daytona sandbox\n session = await daytona.get(options.sandboxId);\n sandboxId = options.sandboxId;\n } else {\n // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n runtime: _runtime,\n timeout: _timeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: _sandboxId,\n namespace: _namespace,\n directory: _directory,\n overlays: _overlays,\n servers: _servers,\n ...providerOptions\n } = options || {};\n\n // Build create params from options\n // Daytona SDK uses envVars (not envs), labels (not metadata)\n const createParams: Record<string, any> = {\n language: runtime === 'python' ? 'python' : 'javascript',\n ...providerOptions, // Spread provider-specific options (e.g., resources, public, autoStopInterval)\n };\n\n // Remap ComputeSDK fields to Daytona SDK fields\n if (envs && Object.keys(envs).length > 0) {\n createParams.envVars = envs;\n }\n\n if (name) {\n createParams.name = name;\n }\n\n // Pass metadata as labels (Daytona uses labels: Record<string, string>)\n if (metadata && typeof metadata === 'object') {\n const labels: Record<string, string> = {};\n for (const [k, v] of Object.entries(metadata)) {\n labels[k] = typeof v === 'string' ? v : JSON.stringify(v);\n }\n createParams.labels = labels;\n }\n\n // If templateId or snapshotId is provided, use it as the source\n const sourceId = templateId || snapshotId;\n if (sourceId) {\n createParams.snapshot = sourceId;\n }\n\n // Daytona SDK accepts timeout in seconds as a second argument\n const createOptions = timeout\n ? { timeout: Math.ceil(timeout / 1000) }\n : undefined;\n\n session = await daytona.create(createParams as any, createOptions);\n sandboxId = session.id;\n }\n\n return {\n sandbox: session,\n sandboxId\n };\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 getById: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const session = await daytona.get(sandboxId);\n\n return {\n sandbox: session,\n sandboxId\n };\n } catch (error) {\n // Sandbox not found is expected -- return null per the interface contract\n if (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return null;\n }\n // Propagate unexpected errors (auth failures, network issues, etc.)\n throw new Error(\n `Failed to get Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const result = await daytona.list();\n\n return result.items.map((session: any) => ({\n sandbox: session,\n sandboxId: session.id\n }));\n } catch (error) {\n throw new Error(\n `Failed to list Daytona sandboxes: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n destroy: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const sandbox = await daytona.get(sandboxId);\n await sandbox.delete();\n } catch (error) {\n // If the sandbox is already gone (404), that's fine for destroy semantics\n if (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return;\n }\n // Propagate all other errors (auth failures, network issues, etc.)\n throw new Error(\n `Failed to destroy Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Instance operations (sandbox.*)\n runCode: async (sandbox: DaytonaSandbox, code: string, runtime?: Runtime): Promise<CodeResult> => {\n const startTime = Date.now();\n\n try {\n // Auto-detect runtime if not specified\n const effectiveRuntime = runtime || (\n // Strong Python indicators\n code.includes('print(') || \n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\") ||\n code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n \n // Use direct command execution like Vercel for consistency\n let response;\n \n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n \n if (effectiveRuntime === 'python') {\n response = await sandbox.process.executeCommand(`echo \"${encoded}\" | base64 -d | python3`);\n } else {\n response = await sandbox.process.executeCommand(`echo \"${encoded}\" | base64 -d | node`);\n }\n\n // Daytona always returns exitCode: 0, so we need to detect errors from output\n const output = response.result || '';\n const hasError = output.includes('Error:') || \n output.includes('error TS') || \n output.includes('SyntaxError:') ||\n output.includes('TypeError:') ||\n output.includes('ReferenceError:') ||\n output.includes('Traceback (most recent call last)');\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (hasError && (output.includes('SyntaxError:') || \n output.includes('invalid syntax') ||\n output.includes('Unexpected token') ||\n output.includes('Unexpected identifier') ||\n output.includes('error TS1434'))) {\n throw new Error(`Syntax error: ${output.trim()}`);\n }\n\n const actualExitCode = hasError ? 1 : (response.exitCode || 0);\n\n return {\n output: output,\n exitCode: actualExitCode,\n language: effectiveRuntime\n };\n } catch (error) {\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `Daytona execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (sandbox: DaytonaSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n\n try {\n // Build command with options\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n // Execute command using Daytona's process.executeCommand method\n const response = await sandbox.process.executeCommand(fullCommand);\n\n return {\n stdout: response.result || '',\n stderr: '',\n exitCode: response.exitCode || 0,\n durationMs: Date.now() - startTime\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 getInfo: async (sandbox: DaytonaSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.id,\n provider: 'daytona',\n runtime: 'python', // Daytona default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n daytonaSandboxId: sandbox.id\n }\n };\n },\n\n getUrl: async (sandbox: DaytonaSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use Daytona's built-in getPreviewLink method\n const previewInfo = await sandbox.getPreviewLink(options.port);\n let url = previewInfo.url;\n \n // If a specific protocol is requested, replace the URL's protocol\n if (options.protocol) {\n const urlObj = new URL(url);\n urlObj.protocol = options.protocol + ':';\n url = urlObj.toString();\n }\n \n return url;\n } catch (error) {\n throw new Error(\n `Failed to get Daytona preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Filesystem operations via terminal commands\n filesystem: {\n readFile: async (sandbox: DaytonaSandbox, path: string): Promise<string> => {\n try {\n const response = await sandbox.process.executeCommand(`cat \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`File not found or cannot be read: ${path}`);\n }\n return response.result || '';\n } catch (error) {\n throw new Error(`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n writeFile: async (sandbox: DaytonaSandbox, path: string, content: string): Promise<void> => {\n try {\n // Use base64 encoding to safely handle special characters, newlines, and binary content\n const encoded = Buffer.from(content).toString('base64');\n const response = await sandbox.process.executeCommand(`echo \"${encoded}\" | base64 -d > \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to write to file: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n mkdir: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n try {\n const response = await sandbox.process.executeCommand(`mkdir -p \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to create directory: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to create directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n readdir: async (sandbox: DaytonaSandbox, path: string): Promise<FileEntry[]> => {\n try {\n const response = await sandbox.process.executeCommand(`ls -la \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Directory not found or cannot be read: ${path}`);\n }\n\n // Parse ls -la output into FileEntry objects\n const lines = response.result.split('\\n').filter(line => line.trim());\n const entries: FileEntry[] = [];\n\n for (const line of lines) {\n // Skip total line and current/parent directory entries\n if (line.startsWith('total ') || line.endsWith(' .') || line.endsWith(' ..')) {\n continue;\n }\n\n // Parse ls -la format: permissions links owner group size date time name\n const parts = line.trim().split(/\\s+/);\n if (parts.length >= 9) {\n const permissions = parts[0];\n const name = parts.slice(8).join(' '); // Handle filenames with spaces\n const isDirectory = permissions.startsWith('d');\n const size = parseInt(parts[4]) || 0;\n\n entries.push({\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size,\n modified: new Date() // ls -la date parsing is complex, use current time\n });\n }\n }\n\n return entries;\n } catch (error) {\n throw new Error(`Failed to read directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n exists: async (sandbox: DaytonaSandbox, path: string): Promise<boolean> => {\n try {\n const response = await sandbox.process.executeCommand(`test -e \"${path}\"`);\n return response.exitCode === 0;\n } catch (error) {\n // If command execution fails, assume file doesn't exist\n return false;\n }\n },\n\n remove: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n try {\n const response = await sandbox.process.executeCommand(`rm -rf \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to remove: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to remove ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: DaytonaSandbox): DaytonaSandbox => {\n return sandbox;\n },\n\n },\n\n snapshot: {\n create: async (config: DaytonaConfig, sandboxId: string, options?: { name?: string }) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n // Note: Using 'any' cast as we are using internal service property\n const snapshot = await (daytona as any).snapshots.create({\n workspaceId: sandboxId,\n name: options?.name || `snapshot-${Date.now()}`\n });\n return snapshot;\n } catch (error) {\n throw new Error(`Failed to create Daytona snapshot: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n const result = await (daytona as any).snapshots.list();\n return result;\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: DaytonaConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n // Note: Daytona SDK might not expose delete directly or it might be 'remove'\n // We'll try the common pattern\n await (daytona as any).snapshots.delete(snapshotId);\n } catch (error) {\n // Ignore if not found\n }\n }\n },\n\n // Templates in Daytona are effectively Snapshots\n template: {\n create: async (config: DaytonaConfig, options: { name: string }) => {\n throw new Error('To create a template in Daytona, create a snapshot from a running sandbox using snapshot.create()');\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n const result = await (daytona as any).snapshots.list();\n return result;\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: DaytonaConfig, templateId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n await (daytona as any).snapshots.delete(templateId);\n } catch (error) {\n // Ignore if not found\n }\n }\n }\n }\n});\n"],"mappings":";AAOA,SAAS,eAA0C;AACnD,SAAS,gBAAgB,sBAAsB;AAmBxC,IAAM,UAAU,eAA8C;AAAA,EACnE,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAAoB;AAEpG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,SAAS,WAAW,OAAO,WAAW;AACtD,cAAM,UAAU,SAAS,WAAW,OAAO;AAE3C,YAAI;AAEF,gBAAMA,WAAU,IAAI,QAAQ,EAAE,OAAe,CAAC;AAE9C,cAAI;AACJ,cAAI;AAEJ,cAAI,SAAS,WAAW;AAEtB,sBAAU,MAAMA,SAAQ,IAAI,QAAQ,SAAS;AAC7C,wBAAY,QAAQ;AAAA,UACtB,OAAO;AAEL,kBAAM;AAAA,cACJ,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,WAAW;AAAA,cACX,WAAW;AAAA,cACX,WAAW;AAAA,cACX,UAAU;AAAA,cACV,SAAS;AAAA,cACT,GAAG;AAAA,YACL,IAAI,WAAW,CAAC;AAIhB,kBAAM,eAAoC;AAAA,cACxC,UAAU,YAAY,WAAW,WAAW;AAAA,cAC5C,GAAG;AAAA;AAAA,Y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"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Daytona Provider - Factory-based Implementation\n * \n * Code execution only provider using the factory pattern.\n * Reduces ~300 lines of boilerplate to ~80 lines of core logic.\n */\n\nimport { Daytona, Sandbox as DaytonaSandbox } from '@daytonaio/sdk';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { Runtime, CodeResult, CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\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 * Create a Daytona provider instance using the factory pattern\n */\nexport const daytona = defineProvider<DaytonaSandbox, DaytonaConfig>({\n name: 'daytona',\n methods: {\n sandbox: {\n // Collection operations (compute.sandbox.*)\n create: async (config: DaytonaConfig, options?: CreateSandboxOptions) => {\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 const runtime = options?.runtime || config.runtime || 'node';\n const timeout = options?.timeout ?? config.timeout;\n\n try {\n // Initialize Daytona client\n const daytona = new Daytona({ apiKey: apiKey });\n\n let session: DaytonaSandbox;\n let sandboxId: string;\n\n // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n runtime: _runtime,\n timeout: _timeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: _sandboxId,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n // Build create params from options\n // Daytona SDK uses envVars (not envs), labels (not metadata)\n const createParams: Record<string, any> = {\n language: runtime === 'python' ? 'python' : 'javascript',\n ...providerOptions, // Spread provider-specific options (e.g., resources, public, autoStopInterval)\n };\n\n // Remap ComputeSDK fields to Daytona SDK fields\n if (envs && Object.keys(envs).length > 0) {\n createParams.envVars = envs;\n }\n\n if (name) {\n createParams.name = name;\n }\n\n // Pass metadata as labels (Daytona uses labels: Record<string, string>)\n if (metadata && typeof metadata === 'object') {\n const labels: Record<string, string> = {};\n for (const [k, v] of Object.entries(metadata)) {\n labels[k] = typeof v === 'string' ? v : JSON.stringify(v);\n }\n createParams.labels = labels;\n }\n\n // If templateId or snapshotId is provided, use it as the source\n const sourceId = templateId || snapshotId;\n if (sourceId) {\n createParams.snapshot = sourceId;\n }\n\n // Daytona SDK accepts timeout in seconds as a second argument\n const createOptions = timeout\n ? { timeout: Math.ceil(timeout / 1000) }\n : undefined;\n\n session = await daytona.create(createParams as any, createOptions);\n sandboxId = session.id;\n\n return {\n sandbox: session,\n sandboxId\n };\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 getById: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const session = await daytona.get(sandboxId);\n\n return {\n sandbox: session,\n sandboxId\n };\n } catch (error) {\n // Sandbox not found is expected -- return null per the interface contract\n if (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return null;\n }\n // Propagate unexpected errors (auth failures, network issues, etc.)\n throw new Error(\n `Failed to get Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const result = await daytona.list();\n\n return result.items.map((session: any) => ({\n sandbox: session,\n sandboxId: session.id\n }));\n } catch (error) {\n throw new Error(\n `Failed to list Daytona sandboxes: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n destroy: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const sandbox = await daytona.get(sandboxId);\n await sandbox.delete();\n } catch (error) {\n // If the sandbox is already gone (404), that's fine for destroy semantics\n if (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return;\n }\n // Propagate all other errors (auth failures, network issues, etc.)\n throw new Error(\n `Failed to destroy Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Instance operations (sandbox.*)\n\n runCommand: async (sandbox: DaytonaSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n\n try {\n // Build command with options\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n // Execute command using Daytona's process.executeCommand method\n const response = await sandbox.process.executeCommand(fullCommand);\n\n return {\n stdout: response.result || '',\n stderr: '',\n exitCode: response.exitCode || 0,\n durationMs: Date.now() - startTime\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 getInfo: async (sandbox: DaytonaSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.id,\n provider: 'daytona',\n runtime: 'python', // Daytona default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n daytonaSandboxId: sandbox.id\n }\n };\n },\n\n getUrl: async (sandbox: DaytonaSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use Daytona's built-in getPreviewLink method\n const previewInfo = await sandbox.getPreviewLink(options.port);\n let url = previewInfo.url;\n \n // If a specific protocol is requested, replace the URL's protocol\n if (options.protocol) {\n const urlObj = new URL(url);\n urlObj.protocol = options.protocol + ':';\n url = urlObj.toString();\n }\n \n return url;\n } catch (error) {\n throw new Error(\n `Failed to get Daytona preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Filesystem operations via terminal commands\n filesystem: {\n readFile: async (sandbox: DaytonaSandbox, path: string): Promise<string> => {\n try {\n const response = await sandbox.process.executeCommand(`cat \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`File not found or cannot be read: ${path}`);\n }\n return response.result || '';\n } catch (error) {\n throw new Error(`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n writeFile: async (sandbox: DaytonaSandbox, path: string, content: string): Promise<void> => {\n try {\n // Use base64 encoding to safely handle special characters, newlines, and binary content\n const encoded = Buffer.from(content).toString('base64');\n const response = await sandbox.process.executeCommand(`echo \"${encoded}\" | base64 -d > \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to write to file: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n mkdir: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n try {\n const response = await sandbox.process.executeCommand(`mkdir -p \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to create directory: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to create directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n readdir: async (sandbox: DaytonaSandbox, path: string): Promise<FileEntry[]> => {\n try {\n const response = await sandbox.process.executeCommand(`ls -la \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Directory not found or cannot be read: ${path}`);\n }\n\n // Parse ls -la output into FileEntry objects\n const lines = response.result.split('\\n').filter(line => line.trim());\n const entries: FileEntry[] = [];\n\n for (const line of lines) {\n // Skip total line and current/parent directory entries\n if (line.startsWith('total ') || line.endsWith(' .') || line.endsWith(' ..')) {\n continue;\n }\n\n // Parse ls -la format: permissions links owner group size date time name\n const parts = line.trim().split(/\\s+/);\n if (parts.length >= 9) {\n const permissions = parts[0];\n const name = parts.slice(8).join(' '); // Handle filenames with spaces\n const isDirectory = permissions.startsWith('d');\n const size = parseInt(parts[4]) || 0;\n\n entries.push({\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size,\n modified: new Date() // ls -la date parsing is complex, use current time\n });\n }\n }\n\n return entries;\n } catch (error) {\n throw new Error(`Failed to read directory ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n exists: async (sandbox: DaytonaSandbox, path: string): Promise<boolean> => {\n try {\n const response = await sandbox.process.executeCommand(`test -e \"${path}\"`);\n return response.exitCode === 0;\n } catch (error) {\n // If command execution fails, assume file doesn't exist\n return false;\n }\n },\n\n remove: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n try {\n const response = await sandbox.process.executeCommand(`rm -rf \"${path}\"`);\n if (response.exitCode !== 0) {\n throw new Error(`Failed to remove: ${path}`);\n }\n } catch (error) {\n throw new Error(`Failed to remove ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: DaytonaSandbox): DaytonaSandbox => {\n return sandbox;\n },\n\n },\n\n snapshot: {\n create: async (config: DaytonaConfig, sandboxId: string, options?: { name?: string }) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n // Note: Using 'any' cast as we are using internal service property\n const snapshot = await (daytona as any).snapshots.create({\n workspaceId: sandboxId,\n name: options?.name || `snapshot-${Date.now()}`\n });\n return snapshot;\n } catch (error) {\n throw new Error(`Failed to create Daytona snapshot: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n const result = await (daytona as any).snapshots.list();\n return result;\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: DaytonaConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n // Note: Daytona SDK might not expose delete directly or it might be 'remove'\n // We'll try the common pattern\n await (daytona as any).snapshots.delete(snapshotId);\n } catch (error) {\n // Ignore if not found\n }\n }\n },\n\n // Templates in Daytona are effectively Snapshots\n template: {\n create: async (config: DaytonaConfig, options: { name: string }) => {\n throw new Error('To create a template in Daytona, create a snapshot from a running sandbox using snapshot.create()');\n },\n\n list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n const result = await (daytona as any).snapshots.list();\n return result;\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: DaytonaConfig, templateId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n\n try {\n await (daytona as any).snapshots.delete(templateId);\n } catch (error) {\n // Ignore if not found\n }\n }\n }\n }\n});\n"],"mappings":";AAOA,SAAS,eAA0C;AACnD,SAAS,gBAAgB,sBAAsB;AAmBxC,IAAM,UAAU,eAA8C;AAAA,EACnE,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAE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AI;AAC5C,cAAMA,WAAU,IAAI,QAAQ,EAAE,OAAe,CAAC;AAE9C,YAAI;AACF,gBAAM,SAAS,MAAOA,SAAgB,UAAU,KAAK;AACrD,iBAAO;AAAA,QACT,SAAS,OAAO;AACd,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,MAEA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,cAAMA,WAAU,IAAI,QAAQ,EAAE,OAAe,CAAC;AAE9C,YAAI;AACF,gBAAOA,SAAgB,UAAU,OAAO,UAAU;AAAA,QACpD,SAAS,OAAO;AAAA,QAEhB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["daytona"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/daytona",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.25",
|
|
4
4
|
"description": "Daytona provider for ComputeSDK - standardized development environments with devcontainer support",
|
|
5
5
|
"author": "Garrison",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@daytonaio/sdk": "^0.143.0",
|
|
22
|
-
"@computesdk/provider": "1.
|
|
23
|
-
"computesdk": "
|
|
22
|
+
"@computesdk/provider": "1.4.0",
|
|
23
|
+
"computesdk": "3.0.0"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"computesdk",
|