Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@computesdk/daytona

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@computesdk/daytona - npm Package Compare versions

Comparing version
1.7.25
to
1.7.26
+2
-3
dist/index.d.mts
import * as _computesdk_provider from '@computesdk/provider';
import { Runtime } from '@computesdk/provider';
import { Sandbox } from '@daytonaio/sdk';

@@ -11,4 +10,4 @@

apiKey?: string;
/** Default runtime environment */
runtime?: Runtime;
/** Default runtime environment (e.g. 'python', 'node') */
runtime?: string;
/** Execution timeout in milliseconds */

@@ -15,0 +14,0 @@ timeout?: number;

import * as _computesdk_provider from '@computesdk/provider';
import { Runtime } from '@computesdk/provider';
import { Sandbox } from '@daytonaio/sdk';

@@ -11,4 +10,4 @@

apiKey?: string;
/** Default runtime environment */
runtime?: Runtime;
/** Default runtime environment (e.g. 'python', 'node') */
runtime?: string;
/** Execution timeout in milliseconds */

@@ -15,0 +14,0 @@ timeout?: number;

+51
-138

@@ -32,3 +32,2 @@ "use strict";

sandbox: {
// Collection operations (compute.sandbox.*)
create: async (config, options) => {

@@ -45,6 +44,3 @@ const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.DAYTONA_API_KEY || "";

const daytona2 = new import_sdk.Daytona({ apiKey });
let session;
let sandboxId;
const {
runtime: _runtime,
timeout: _timeout,

@@ -64,3 +60,2 @@ envs,

...providerOptions
// Spread provider-specific options (e.g., resources, public, autoStopInterval)
};

@@ -85,24 +80,15 @@ if (envs && Object.keys(envs).length > 0) {

const createOptions = timeout ? { timeout: Math.ceil(timeout / 1e3) } : void 0;
session = await daytona2.create(createParams, createOptions);
sandboxId = session.id;
return {
sandbox: session,
sandboxId
};
const session = await daytona2.create(createParams, createOptions);
const sandboxId = session.id;
return { sandbox: session, sandboxId };
} catch (error) {
if (error instanceof Error) {
if (error.message.includes("unauthorized") || error.message.includes("API key")) {
throw new Error(
`Daytona authentication failed. Please check your DAYTONA_API_KEY environment variable. Get your API key from https://daytona.io/`
);
throw new Error(`Daytona authentication failed. Please check your DAYTONA_API_KEY environment variable.`);
}
if (error.message.includes("quota") || error.message.includes("limit")) {
throw new Error(
`Daytona quota exceeded. Please check your usage at https://daytona.io/`
);
throw new Error(`Daytona quota exceeded. Please check your usage at https://daytona.io/`);
}
}
throw new Error(
`Failed to create Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Failed to create Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`);
}

@@ -115,6 +101,3 @@ },

const session = await daytona2.get(sandboxId);
return {
sandbox: session,
sandboxId
};
return { sandbox: session, sandboxId };
} catch (error) {

@@ -124,5 +107,3 @@ if (error instanceof Error && (error.message.includes("not found") || error.message.includes("404"))) {

}
throw new Error(
`Failed to get Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Failed to get Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`);
}

@@ -135,10 +116,5 @@ },

const result = await daytona2.list();
return result.items.map((session) => ({
sandbox: session,
sandboxId: session.id
}));
return result.items.map((session) => ({ sandbox: session, sandboxId: session.id }));
} catch (error) {
throw new Error(
`Failed to list Daytona sandboxes: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Failed to list Daytona sandboxes: ${error instanceof Error ? error.message : String(error)}`);
}

@@ -156,8 +132,5 @@ },

}
throw new Error(
`Failed to destroy Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Failed to destroy Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`);
}
},
// Instance operations (sandbox.*)
runCommand: async (sandbox, command, options) => {

@@ -171,8 +144,4 @@ const startTime = Date.now();

}
if (options?.cwd) {
fullCommand = `cd "${(0, import_provider.escapeShellArg)(options.cwd)}" && ${fullCommand}`;
}
if (options?.background) {
fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;
}
if (options?.cwd) fullCommand = `cd "${(0, import_provider.escapeShellArg)(options.cwd)}" && ${fullCommand}`;
if (options?.background) fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;
const response = await sandbox.process.executeCommand(fullCommand);

@@ -186,5 +155,3 @@ return {

} catch (error) {
throw new Error(
`Daytona command execution failed: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Daytona command execution failed: ${error instanceof Error ? error.message : String(error)}`);
}

@@ -196,10 +163,6 @@ },

provider: "daytona",
runtime: "python",
// Daytona default
status: "running",
createdAt: /* @__PURE__ */ new Date(),
timeout: 3e5,
metadata: {
daytonaSandboxId: sandbox.id
}
metadata: { daytonaSandboxId: sandbox.id }
};

@@ -218,96 +181,49 @@ },

} catch (error) {
throw new Error(
`Failed to get Daytona preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Failed to get Daytona preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`);
}
},
// Filesystem operations via terminal commands
filesystem: {
readFile: async (sandbox, path) => {
try {
const response = await sandbox.process.executeCommand(`cat "${path}"`);
if (response.exitCode !== 0) {
throw new Error(`File not found or cannot be read: ${path}`);
}
return response.result || "";
} catch (error) {
throw new Error(`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`);
}
const response = await sandbox.process.executeCommand(`cat "${path}"`);
if (response.exitCode !== 0) throw new Error(`File not found or cannot be read: ${path}`);
return response.result || "";
},
writeFile: async (sandbox, path, content) => {
try {
const encoded = Buffer.from(content).toString("base64");
const response = await sandbox.process.executeCommand(`echo "${encoded}" | base64 -d > "${path}"`);
if (response.exitCode !== 0) {
throw new Error(`Failed to write to file: ${path}`);
}
} catch (error) {
throw new Error(`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`);
}
const encoded = Buffer.from(content).toString("base64");
const response = await sandbox.process.executeCommand(`echo "${encoded}" | base64 -d > "${path}"`);
if (response.exitCode !== 0) throw new Error(`Failed to write to file: ${path}`);
},
mkdir: async (sandbox, path) => {
try {
const response = await sandbox.process.executeCommand(`mkdir -p "${path}"`);
if (response.exitCode !== 0) {
throw new Error(`Failed to create directory: ${path}`);
}
} catch (error) {
throw new Error(`Failed to create directory ${path}: ${error instanceof Error ? error.message : String(error)}`);
}
const response = await sandbox.process.executeCommand(`mkdir -p "${path}"`);
if (response.exitCode !== 0) throw new Error(`Failed to create directory: ${path}`);
},
readdir: async (sandbox, path) => {
try {
const response = await sandbox.process.executeCommand(`ls -la "${path}"`);
if (response.exitCode !== 0) {
throw new Error(`Directory not found or cannot be read: ${path}`);
const response = await sandbox.process.executeCommand(`ls -la "${path}"`);
if (response.exitCode !== 0) throw new Error(`Directory not found or cannot be read: ${path}`);
const lines = response.result.split("\n").filter((l) => l.trim());
const entries = [];
for (const line of lines) {
if (line.startsWith("total ") || line.endsWith(" .") || line.endsWith(" ..")) continue;
const parts = line.trim().split(/\s+/);
if (parts.length >= 9) {
entries.push({
name: parts.slice(8).join(" "),
type: parts[0].startsWith("d") ? "directory" : "file",
size: parseInt(parts[4]) || 0,
modified: /* @__PURE__ */ new Date()
});
}
const lines = response.result.split("\n").filter((line) => line.trim());
const entries = [];
for (const line of lines) {
if (line.startsWith("total ") || line.endsWith(" .") || line.endsWith(" ..")) {
continue;
}
const parts = line.trim().split(/\s+/);
if (parts.length >= 9) {
const permissions = parts[0];
const name = parts.slice(8).join(" ");
const isDirectory = permissions.startsWith("d");
const size = parseInt(parts[4]) || 0;
entries.push({
name,
type: isDirectory ? "directory" : "file",
size,
modified: /* @__PURE__ */ new Date()
// ls -la date parsing is complex, use current time
});
}
}
return entries;
} catch (error) {
throw new Error(`Failed to read directory ${path}: ${error instanceof Error ? error.message : String(error)}`);
}
return entries;
},
exists: async (sandbox, path) => {
try {
const response = await sandbox.process.executeCommand(`test -e "${path}"`);
return response.exitCode === 0;
} catch (error) {
return false;
}
const response = await sandbox.process.executeCommand(`test -e "${path}"`);
return response.exitCode === 0;
},
remove: async (sandbox, path) => {
try {
const response = await sandbox.process.executeCommand(`rm -rf "${path}"`);
if (response.exitCode !== 0) {
throw new Error(`Failed to remove: ${path}`);
}
} catch (error) {
throw new Error(`Failed to remove ${path}: ${error instanceof Error ? error.message : String(error)}`);
}
const response = await sandbox.process.executeCommand(`rm -rf "${path}"`);
if (response.exitCode !== 0) throw new Error(`Failed to remove: ${path}`);
}
},
// Provider-specific typed getInstance method
getInstance: (sandbox) => {
return sandbox;
}
getInstance: (sandbox) => sandbox
},

@@ -332,5 +248,4 @@ snapshot: {

try {
const result = await daytona2.snapshots.list();
return result;
} catch (error) {
return await daytona2.snapshots.list();
} catch {
return [];

@@ -344,9 +259,8 @@ }

await daytona2.snapshots.delete(snapshotId);
} catch (error) {
} catch {
}
}
},
// Templates in Daytona are effectively Snapshots
template: {
create: async (config, options) => {
create: async (_config, _options) => {
throw new Error("To create a template in Daytona, create a snapshot from a running sandbox using snapshot.create()");

@@ -358,5 +272,4 @@ },

try {
const result = await daytona2.snapshots.list();
return result;
} catch (error) {
return await daytona2.snapshots.list();
} catch {
return [];

@@ -370,3 +283,3 @@ }

await daytona2.snapshots.delete(templateId);
} catch (error) {
} catch {
}

@@ -373,0 +286,0 @@ }

@@ -1,1 +0,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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IACF;AAAA,EACF;AACF,CAAC;","names":["daytona"]}
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Daytona Provider - Factory-based Implementation\n */\n\nimport { Daytona, Sandbox as DaytonaSandbox } from '@daytonaio/sdk';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { 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 (e.g. 'python', 'node') */\n runtime?: string;\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 create: async (config: DaytonaConfig, options?: CreateSandboxOptions) => {\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 as any)?.runtime || config.runtime || 'node';\n const timeout = options?.timeout ?? config.timeout;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n\n const {\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 const createParams: Record<string, any> = {\n language: runtime === 'python' ? 'python' : 'javascript',\n ...providerOptions,\n };\n\n if (envs && Object.keys(envs).length > 0) {\n createParams.envVars = envs;\n }\n\n if (name) {\n createParams.name = name;\n }\n\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 const sourceId = templateId || snapshotId;\n if (sourceId) {\n createParams.snapshot = sourceId;\n }\n\n const createOptions = timeout\n ? { timeout: Math.ceil(timeout / 1000) }\n : undefined;\n\n const session = await daytona.create(createParams as any, createOptions);\n const sandboxId = session.id;\n\n return { sandbox: session, sandboxId };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(`Daytona authentication failed. Please check your DAYTONA_API_KEY environment variable.`);\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(`Daytona quota exceeded. Please check your usage at https://daytona.io/`);\n }\n }\n throw new Error(`Failed to create Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n getById: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const session = await daytona.get(sandboxId);\n return { sandbox: session, sandboxId };\n } catch (error) {\n if (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return null;\n }\n throw new Error(`Failed to get Daytona sandbox ${sandboxId}: ${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 try {\n const daytona = new Daytona({ apiKey: apiKey });\n const result = await daytona.list();\n return result.items.map((session: any) => ({ sandbox: session, sandboxId: session.id }));\n } catch (error) {\n throw new Error(`Failed to list Daytona sandboxes: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n destroy: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\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 (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return;\n }\n throw new Error(`Failed to destroy Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n runCommand: async (sandbox: DaytonaSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n try {\n let fullCommand = command;\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 if (options?.cwd) fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n if (options?.background) fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n\n const response = await sandbox.process.executeCommand(fullCommand);\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(`Daytona command execution failed: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n getInfo: async (sandbox: DaytonaSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.id,\n provider: 'daytona',\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: { daytonaSandboxId: sandbox.id }\n };\n },\n\n getUrl: async (sandbox: DaytonaSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n const previewInfo = await sandbox.getPreviewLink(options.port);\n let url = previewInfo.url;\n if (options.protocol) {\n const urlObj = new URL(url);\n urlObj.protocol = options.protocol + ':';\n url = urlObj.toString();\n }\n return url;\n } catch (error) {\n throw new Error(`Failed to get Daytona preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n filesystem: {\n readFile: async (sandbox: DaytonaSandbox, path: string): Promise<string> => {\n const response = await sandbox.process.executeCommand(`cat \"${path}\"`);\n if (response.exitCode !== 0) throw new Error(`File not found or cannot be read: ${path}`);\n return response.result || '';\n },\n writeFile: async (sandbox: DaytonaSandbox, path: string, content: string): Promise<void> => {\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) throw new Error(`Failed to write to file: ${path}`);\n },\n mkdir: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n const response = await sandbox.process.executeCommand(`mkdir -p \"${path}\"`);\n if (response.exitCode !== 0) throw new Error(`Failed to create directory: ${path}`);\n },\n readdir: async (sandbox: DaytonaSandbox, path: string): Promise<FileEntry[]> => {\n const response = await sandbox.process.executeCommand(`ls -la \"${path}\"`);\n if (response.exitCode !== 0) throw new Error(`Directory not found or cannot be read: ${path}`);\n const lines = response.result.split('\\n').filter((l: string) => l.trim());\n const entries: FileEntry[] = [];\n for (const line of lines) {\n if (line.startsWith('total ') || line.endsWith(' .') || line.endsWith(' ..')) continue;\n const parts = line.trim().split(/\\s+/);\n if (parts.length >= 9) {\n entries.push({\n name: parts.slice(8).join(' '),\n type: parts[0].startsWith('d') ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date()\n });\n }\n }\n return entries;\n },\n exists: async (sandbox: DaytonaSandbox, path: string): Promise<boolean> => {\n const response = await sandbox.process.executeCommand(`test -e \"${path}\"`);\n return response.exitCode === 0;\n },\n remove: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n const response = await sandbox.process.executeCommand(`rm -rf \"${path}\"`);\n if (response.exitCode !== 0) throw new Error(`Failed to remove: ${path}`);\n }\n },\n\n getInstance: (sandbox: DaytonaSandbox): DaytonaSandbox => sandbox,\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 try {\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 list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n try { return await (daytona as any).snapshots.list(); } catch { return []; }\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 try { await (daytona as any).snapshots.delete(snapshotId); } catch { /* ignore */ }\n }\n },\n\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 list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n try { return await (daytona as any).snapshots.list(); } catch { return []; }\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 try { await (daytona as any).snapshots.delete(templateId); } catch { /* ignore */ }\n }\n }\n }\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAAmD;AACnD,sBAA+C;AAmBxC,IAAM,cAAU,gCAA8C;AAAA,EACnE,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA,MACP,QAAQ,OAAO,QAAuB,YAAmC;AACvE,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,UAAW,SAAiB,WAAW,OAAO,WAAW;AAC/D,cAAM,UAAU,SAAS,WAAW,OAAO;AAE3C,YAAI;AACF,gBAAMA,WAAU,IAAI,mBAAQ,EAAE,OAAe,CAAC;AAE9C,gBAAM;AAAA,YACJ,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,WAAW;A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AA,EACF;AACF,CAAC;","names":["daytona"]}

@@ -8,3 +8,2 @@ // src/index.ts

sandbox: {
// Collection operations (compute.sandbox.*)
create: async (config, options) => {

@@ -21,6 +20,3 @@ const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.DAYTONA_API_KEY || "";

const daytona2 = new Daytona({ apiKey });
let session;
let sandboxId;
const {
runtime: _runtime,
timeout: _timeout,

@@ -40,3 +36,2 @@ envs,

...providerOptions
// Spread provider-specific options (e.g., resources, public, autoStopInterval)
};

@@ -61,24 +56,15 @@ if (envs && Object.keys(envs).length > 0) {

const createOptions = timeout ? { timeout: Math.ceil(timeout / 1e3) } : void 0;
session = await daytona2.create(createParams, createOptions);
sandboxId = session.id;
return {
sandbox: session,
sandboxId
};
const session = await daytona2.create(createParams, createOptions);
const sandboxId = session.id;
return { sandbox: session, sandboxId };
} catch (error) {
if (error instanceof Error) {
if (error.message.includes("unauthorized") || error.message.includes("API key")) {
throw new Error(
`Daytona authentication failed. Please check your DAYTONA_API_KEY environment variable. Get your API key from https://daytona.io/`
);
throw new Error(`Daytona authentication failed. Please check your DAYTONA_API_KEY environment variable.`);
}
if (error.message.includes("quota") || error.message.includes("limit")) {
throw new Error(
`Daytona quota exceeded. Please check your usage at https://daytona.io/`
);
throw new Error(`Daytona quota exceeded. Please check your usage at https://daytona.io/`);
}
}
throw new Error(
`Failed to create Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Failed to create Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`);
}

@@ -91,6 +77,3 @@ },

const session = await daytona2.get(sandboxId);
return {
sandbox: session,
sandboxId
};
return { sandbox: session, sandboxId };
} catch (error) {

@@ -100,5 +83,3 @@ if (error instanceof Error && (error.message.includes("not found") || error.message.includes("404"))) {

}
throw new Error(
`Failed to get Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Failed to get Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`);
}

@@ -111,10 +92,5 @@ },

const result = await daytona2.list();
return result.items.map((session) => ({
sandbox: session,
sandboxId: session.id
}));
return result.items.map((session) => ({ sandbox: session, sandboxId: session.id }));
} catch (error) {
throw new Error(
`Failed to list Daytona sandboxes: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Failed to list Daytona sandboxes: ${error instanceof Error ? error.message : String(error)}`);
}

@@ -132,8 +108,5 @@ },

}
throw new Error(
`Failed to destroy Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Failed to destroy Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`);
}
},
// Instance operations (sandbox.*)
runCommand: async (sandbox, command, options) => {

@@ -147,8 +120,4 @@ const startTime = Date.now();

}
if (options?.cwd) {
fullCommand = `cd "${escapeShellArg(options.cwd)}" && ${fullCommand}`;
}
if (options?.background) {
fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;
}
if (options?.cwd) fullCommand = `cd "${escapeShellArg(options.cwd)}" && ${fullCommand}`;
if (options?.background) fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;
const response = await sandbox.process.executeCommand(fullCommand);

@@ -162,5 +131,3 @@ return {

} catch (error) {
throw new Error(
`Daytona command execution failed: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Daytona command execution failed: ${error instanceof Error ? error.message : String(error)}`);
}

@@ -172,10 +139,6 @@ },

provider: "daytona",
runtime: "python",
// Daytona default
status: "running",
createdAt: /* @__PURE__ */ new Date(),
timeout: 3e5,
metadata: {
daytonaSandboxId: sandbox.id
}
metadata: { daytonaSandboxId: sandbox.id }
};

@@ -194,96 +157,49 @@ },

} catch (error) {
throw new Error(
`Failed to get Daytona preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`
);
throw new Error(`Failed to get Daytona preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`);
}
},
// Filesystem operations via terminal commands
filesystem: {
readFile: async (sandbox, path) => {
try {
const response = await sandbox.process.executeCommand(`cat "${path}"`);
if (response.exitCode !== 0) {
throw new Error(`File not found or cannot be read: ${path}`);
}
return response.result || "";
} catch (error) {
throw new Error(`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`);
}
const response = await sandbox.process.executeCommand(`cat "${path}"`);
if (response.exitCode !== 0) throw new Error(`File not found or cannot be read: ${path}`);
return response.result || "";
},
writeFile: async (sandbox, path, content) => {
try {
const encoded = Buffer.from(content).toString("base64");
const response = await sandbox.process.executeCommand(`echo "${encoded}" | base64 -d > "${path}"`);
if (response.exitCode !== 0) {
throw new Error(`Failed to write to file: ${path}`);
}
} catch (error) {
throw new Error(`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`);
}
const encoded = Buffer.from(content).toString("base64");
const response = await sandbox.process.executeCommand(`echo "${encoded}" | base64 -d > "${path}"`);
if (response.exitCode !== 0) throw new Error(`Failed to write to file: ${path}`);
},
mkdir: async (sandbox, path) => {
try {
const response = await sandbox.process.executeCommand(`mkdir -p "${path}"`);
if (response.exitCode !== 0) {
throw new Error(`Failed to create directory: ${path}`);
}
} catch (error) {
throw new Error(`Failed to create directory ${path}: ${error instanceof Error ? error.message : String(error)}`);
}
const response = await sandbox.process.executeCommand(`mkdir -p "${path}"`);
if (response.exitCode !== 0) throw new Error(`Failed to create directory: ${path}`);
},
readdir: async (sandbox, path) => {
try {
const response = await sandbox.process.executeCommand(`ls -la "${path}"`);
if (response.exitCode !== 0) {
throw new Error(`Directory not found or cannot be read: ${path}`);
const response = await sandbox.process.executeCommand(`ls -la "${path}"`);
if (response.exitCode !== 0) throw new Error(`Directory not found or cannot be read: ${path}`);
const lines = response.result.split("\n").filter((l) => l.trim());
const entries = [];
for (const line of lines) {
if (line.startsWith("total ") || line.endsWith(" .") || line.endsWith(" ..")) continue;
const parts = line.trim().split(/\s+/);
if (parts.length >= 9) {
entries.push({
name: parts.slice(8).join(" "),
type: parts[0].startsWith("d") ? "directory" : "file",
size: parseInt(parts[4]) || 0,
modified: /* @__PURE__ */ new Date()
});
}
const lines = response.result.split("\n").filter((line) => line.trim());
const entries = [];
for (const line of lines) {
if (line.startsWith("total ") || line.endsWith(" .") || line.endsWith(" ..")) {
continue;
}
const parts = line.trim().split(/\s+/);
if (parts.length >= 9) {
const permissions = parts[0];
const name = parts.slice(8).join(" ");
const isDirectory = permissions.startsWith("d");
const size = parseInt(parts[4]) || 0;
entries.push({
name,
type: isDirectory ? "directory" : "file",
size,
modified: /* @__PURE__ */ new Date()
// ls -la date parsing is complex, use current time
});
}
}
return entries;
} catch (error) {
throw new Error(`Failed to read directory ${path}: ${error instanceof Error ? error.message : String(error)}`);
}
return entries;
},
exists: async (sandbox, path) => {
try {
const response = await sandbox.process.executeCommand(`test -e "${path}"`);
return response.exitCode === 0;
} catch (error) {
return false;
}
const response = await sandbox.process.executeCommand(`test -e "${path}"`);
return response.exitCode === 0;
},
remove: async (sandbox, path) => {
try {
const response = await sandbox.process.executeCommand(`rm -rf "${path}"`);
if (response.exitCode !== 0) {
throw new Error(`Failed to remove: ${path}`);
}
} catch (error) {
throw new Error(`Failed to remove ${path}: ${error instanceof Error ? error.message : String(error)}`);
}
const response = await sandbox.process.executeCommand(`rm -rf "${path}"`);
if (response.exitCode !== 0) throw new Error(`Failed to remove: ${path}`);
}
},
// Provider-specific typed getInstance method
getInstance: (sandbox) => {
return sandbox;
}
getInstance: (sandbox) => sandbox
},

@@ -308,5 +224,4 @@ snapshot: {

try {
const result = await daytona2.snapshots.list();
return result;
} catch (error) {
return await daytona2.snapshots.list();
} catch {
return [];

@@ -320,9 +235,8 @@ }

await daytona2.snapshots.delete(snapshotId);
} catch (error) {
} catch {
}
}
},
// Templates in Daytona are effectively Snapshots
template: {
create: async (config, options) => {
create: async (_config, _options) => {
throw new Error("To create a template in Daytona, create a snapshot from a running sandbox using snapshot.create()");

@@ -334,5 +248,4 @@ },

try {
const result = await daytona2.snapshots.list();
return result;
} catch (error) {
return await daytona2.snapshots.list();
} catch {
return [];

@@ -346,3 +259,3 @@ }

await daytona2.snapshots.delete(templateId);
} catch (error) {
} catch {
}

@@ -349,0 +262,0 @@ }

@@ -1,1 +0,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;AA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AA,MACtH;AAAA,MAEA,MAAM,OAAO,WAA0B;AACrC,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;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"]}
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Daytona Provider - Factory-based Implementation\n */\n\nimport { Daytona, Sandbox as DaytonaSandbox } from '@daytonaio/sdk';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { 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 (e.g. 'python', 'node') */\n runtime?: string;\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 create: async (config: DaytonaConfig, options?: CreateSandboxOptions) => {\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 as any)?.runtime || config.runtime || 'node';\n const timeout = options?.timeout ?? config.timeout;\n\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n\n const {\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 const createParams: Record<string, any> = {\n language: runtime === 'python' ? 'python' : 'javascript',\n ...providerOptions,\n };\n\n if (envs && Object.keys(envs).length > 0) {\n createParams.envVars = envs;\n }\n\n if (name) {\n createParams.name = name;\n }\n\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 const sourceId = templateId || snapshotId;\n if (sourceId) {\n createParams.snapshot = sourceId;\n }\n\n const createOptions = timeout\n ? { timeout: Math.ceil(timeout / 1000) }\n : undefined;\n\n const session = await daytona.create(createParams as any, createOptions);\n const sandboxId = session.id;\n\n return { sandbox: session, sandboxId };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(`Daytona authentication failed. Please check your DAYTONA_API_KEY environment variable.`);\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(`Daytona quota exceeded. Please check your usage at https://daytona.io/`);\n }\n }\n throw new Error(`Failed to create Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n getById: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n try {\n const daytona = new Daytona({ apiKey: apiKey });\n const session = await daytona.get(sandboxId);\n return { sandbox: session, sandboxId };\n } catch (error) {\n if (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return null;\n }\n throw new Error(`Failed to get Daytona sandbox ${sandboxId}: ${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 try {\n const daytona = new Daytona({ apiKey: apiKey });\n const result = await daytona.list();\n return result.items.map((session: any) => ({ sandbox: session, sandboxId: session.id }));\n } catch (error) {\n throw new Error(`Failed to list Daytona sandboxes: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n destroy: async (config: DaytonaConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\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 (error instanceof Error && (error.message.includes('not found') || error.message.includes('404'))) {\n return;\n }\n throw new Error(`Failed to destroy Daytona sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n runCommand: async (sandbox: DaytonaSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n try {\n let fullCommand = command;\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 if (options?.cwd) fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n if (options?.background) fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n\n const response = await sandbox.process.executeCommand(fullCommand);\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(`Daytona command execution failed: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n getInfo: async (sandbox: DaytonaSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.id,\n provider: 'daytona',\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: { daytonaSandboxId: sandbox.id }\n };\n },\n\n getUrl: async (sandbox: DaytonaSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n const previewInfo = await sandbox.getPreviewLink(options.port);\n let url = previewInfo.url;\n if (options.protocol) {\n const urlObj = new URL(url);\n urlObj.protocol = options.protocol + ':';\n url = urlObj.toString();\n }\n return url;\n } catch (error) {\n throw new Error(`Failed to get Daytona preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n filesystem: {\n readFile: async (sandbox: DaytonaSandbox, path: string): Promise<string> => {\n const response = await sandbox.process.executeCommand(`cat \"${path}\"`);\n if (response.exitCode !== 0) throw new Error(`File not found or cannot be read: ${path}`);\n return response.result || '';\n },\n writeFile: async (sandbox: DaytonaSandbox, path: string, content: string): Promise<void> => {\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) throw new Error(`Failed to write to file: ${path}`);\n },\n mkdir: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n const response = await sandbox.process.executeCommand(`mkdir -p \"${path}\"`);\n if (response.exitCode !== 0) throw new Error(`Failed to create directory: ${path}`);\n },\n readdir: async (sandbox: DaytonaSandbox, path: string): Promise<FileEntry[]> => {\n const response = await sandbox.process.executeCommand(`ls -la \"${path}\"`);\n if (response.exitCode !== 0) throw new Error(`Directory not found or cannot be read: ${path}`);\n const lines = response.result.split('\\n').filter((l: string) => l.trim());\n const entries: FileEntry[] = [];\n for (const line of lines) {\n if (line.startsWith('total ') || line.endsWith(' .') || line.endsWith(' ..')) continue;\n const parts = line.trim().split(/\\s+/);\n if (parts.length >= 9) {\n entries.push({\n name: parts.slice(8).join(' '),\n type: parts[0].startsWith('d') ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date()\n });\n }\n }\n return entries;\n },\n exists: async (sandbox: DaytonaSandbox, path: string): Promise<boolean> => {\n const response = await sandbox.process.executeCommand(`test -e \"${path}\"`);\n return response.exitCode === 0;\n },\n remove: async (sandbox: DaytonaSandbox, path: string): Promise<void> => {\n const response = await sandbox.process.executeCommand(`rm -rf \"${path}\"`);\n if (response.exitCode !== 0) throw new Error(`Failed to remove: ${path}`);\n }\n },\n\n getInstance: (sandbox: DaytonaSandbox): DaytonaSandbox => sandbox,\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 try {\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 list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n try { return await (daytona as any).snapshots.list(); } catch { return []; }\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 try { await (daytona as any).snapshots.delete(snapshotId); } catch { /* ignore */ }\n }\n },\n\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 list: async (config: DaytonaConfig) => {\n const apiKey = config.apiKey || process.env.DAYTONA_API_KEY!;\n const daytona = new Daytona({ apiKey: apiKey });\n try { return await (daytona as any).snapshots.list(); } catch { return []; }\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 try { await (daytona as any).snapshots.delete(templateId); } catch { /* ignore */ }\n }\n }\n }\n});\n"],"mappings":";AAIA,SAAS,eAA0C;AACnD,SAAS,gBAAgB,sBAAsB;AAmBxC,IAAM,UAAU,eAA8C;AAAA,EACnE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WAA0B;AACrC,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,cAAMA,WAAU,IAAI,QAAQ,EAAE,OAAe,CAAC;AAC9C,YAAI;AAAE,iBAAO,MAAOA,SAAgB,UAAU,KAAK;AAAA,QAAG,QAAQ;AAAE,iBAAO,CAAC;AAAA,QAAG;AAAA,MAC7E;AAAA,MACA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,cAAMA,WAAU,IAAI,QAAQ,EAAE,OAAe,CAAC;AAC9C,YAAI;AAAE,gBAAOA,SAAgB,UAAU,OAAO,UAAU;AAAA,QAAG,QAAQ;AAAA,QAAe;AAAA,MACpF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["daytona"]}
{
"name": "@computesdk/daytona",
"version": "1.7.25",
"version": "1.7.26",
"description": "Daytona provider for ComputeSDK - standardized development environments with devcontainer support",

@@ -22,4 +22,4 @@ "author": "Garrison",

"@daytonaio/sdk": "^0.143.0",
"@computesdk/provider": "1.4.0",
"computesdk": "3.0.0"
"@computesdk/provider": "2.0.0",
"computesdk": "4.0.0"
},

@@ -55,3 +55,3 @@ "keywords": [

"vitest": "^1.0.0",
"@computesdk/test-utils": "1.6.1"
"@computesdk/test-utils": "2.0.0"
},

@@ -58,0 +58,0 @@ "scripts": {