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

@computesdk/freestyle

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@computesdk/freestyle - npm Package Compare versions

Comparing version
0.1.4
to
0.1.5
+0
-27
dist/index.js

@@ -64,7 +64,2 @@ "use strict";

}
function detectRuntime(code, hint, fallback) {
if (hint) return hint;
const isPython = 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 ");
return isPython ? "python" : fallback ?? "node";
}
var freestyle = (0, import_provider.defineProvider)({

@@ -149,24 +144,2 @@ name: "freestyle",

// ── Instance operations ───────────────────────────────────────────────
runCode: async (handle, code, runtime) => {
const effectiveRuntime = detectRuntime(code, runtime, handle.config.runtime);
try {
const res = effectiveRuntime === "python" ? await handle.vm.python.runCode({ code }) : await handle.vm.js.runCode({ code });
const stdout = res.stdout ?? "";
const stderr = res.stderr ?? "";
const statusCode = res.statusCode ?? 0;
if (statusCode !== 0 && stderr && (stderr.includes("SyntaxError") || stderr.includes("invalid syntax") || stderr.includes("Unexpected token") || stderr.includes("Unexpected identifier"))) {
throw new Error(`Syntax error: ${stderr.trim()}`);
}
const output = stderr ? `${stdout}${stdout && stderr ? "\n" : ""}${stderr}` : stdout;
return { output, exitCode: statusCode, language: effectiveRuntime };
} catch (err) {
if (err instanceof Error && err.message.includes("Syntax error"))
throw err;
return {
output: err instanceof Error ? err.message : String(err),
exitCode: 1,
language: effectiveRuntime
};
}
},
runCommand: async (handle, command, options) => {

@@ -173,0 +146,0 @@ const startTime = Date.now();

+1
-1

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Freestyle, VmSpec, type Vm } from \"freestyle-sandboxes\";\nimport { VmNodeJs } from \"@freestyle-sh/with-nodejs\";\nimport { VmPython } from \"@freestyle-sh/with-python\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type { Runtime } from \"@computesdk/provider\";\n\nexport type { Freestyle as FreestyleSandbox } from \"freestyle-sandboxes\";\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Freestyle provider configuration for ComputeSDK.\n * Runs code in full Linux microVMs via the Freestyle VM API.\n */\nexport interface FreestyleConfig {\n /**\n * Freestyle API key.\n * Falls back to the FREESTYLE_API_KEY environment variable if not provided.\n */\n apiKey?: string;\n\n /**\n * Default runtime hint used to auto-detect the language when not specified.\n * @default \"node\"\n */\n runtime?: Runtime;\n\n /**\n * Timeout in milliseconds for shell commands (`runCommand`).\n * Note: `runCode` does not support timeouts in the Freestyle SDK.\n * @default 30000\n */\n timeout?: number;\n}\n\n// ─── Internal sandbox handle ──────────────────────────────────────────────────\n\ninterface FreestyleSandboxHandle {\n client: Freestyle;\n config: Required<FreestyleConfig>;\n vm: Vm & { js: any; python: any };\n vmId: string;\n sandboxId: string;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nconst RUNTIME_SPEC = new VmSpec({\n with: {\n js: new VmNodeJs(),\n python: new VmPython(),\n },\n});\n\n// Cache snapshot ensures per API key so we only build once\nconst snapshotCache = new Map<string, Promise<void>>();\n\nasync function ensureSnapshot(client: Freestyle, apiKey: string): Promise<void> {\n if (!snapshotCache.has(apiKey)) {\n const promise = client.vms.snapshots\n .ensure({ spec: RUNTIME_SPEC })\n .then(() => {})\n .catch((err) => {\n snapshotCache.delete(apiKey);\n throw err;\n });\n snapshotCache.set(apiKey, promise);\n }\n return snapshotCache.get(apiKey)!;\n}\n\nfunction getApiKey(config: FreestyleConfig): string {\n const key =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.FREESTYLE_API_KEY) ||\n \"\";\n\n if (!key) {\n throw new Error(\n \"Missing Freestyle API key. Provide 'apiKey' in config or set FREESTYLE_API_KEY \" +\n \"environment variable. Get your API key from https://dash.freestyle.sh\"\n );\n }\n\n return key;\n}\n\nfunction resolveConfig(config: FreestyleConfig): Required<FreestyleConfig> {\n return {\n apiKey: getApiKey(config),\n runtime: config.runtime ?? \"node\",\n timeout: config.timeout ?? 30_000,\n };\n}\n\n/**\n * Detect whether a piece of code looks like Python.\n * Mirrors the same heuristic used by the e2b provider.\n */\nfunction detectRuntime(code: string, hint?: Runtime, fallback?: Runtime): Runtime {\n if (hint) return hint;\n const isPython =\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 return isPython ? \"python\" : (fallback ?? \"node\");\n}\n\n// ─── Provider ─────────────────────────────────────────────────────────────────\n\n/**\n * Freestyle provider for ComputeSDK.\n * Creates full Linux microVMs for isolated code execution with Node.js and Python support.\n *\n * @example\n * import { freestyle } from \"@computesdk/freestyle\";\n *\n * const provider = freestyle({ apiKey: process.env.FREESTYLE_API_KEY });\n * const sandbox = await provider.sandbox.create();\n * const result = await sandbox.runCode('console.log(\"Hello!\")');\n * console.log(result.output); // \"Hello!\"\n * await sandbox.destroy();\n */\nexport const freestyle = defineProvider<FreestyleSandboxHandle, FreestyleConfig>({\n name: \"freestyle\",\n\n methods: {\n sandbox: {\n // ── Collection operations ─────────────────────────────────────────────\n\n create: async (config, _options) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n\n await ensureSnapshot(client, resolved.apiKey);\n\n const { vmId, vm } = await client.vms.create({ spec: RUNTIME_SPEC });\n const sandboxId = `freestyle-vm-${vmId}`;\n\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n },\n\n getById: async (config, sandboxId) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n if (!sandboxId.startsWith(\"freestyle-vm-\")) {\n throw new Error(`Invalid sandbox ID: expected \"freestyle-vm-\" prefix, got \"${sandboxId}\"`);\n }\n const vmId = sandboxId.slice(\"freestyle-vm-\".length);\n\n try {\n const vm = client.vms.ref({ vmId, spec: RUNTIME_SPEC });\n await vm.getInfo();\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n } catch {\n return null;\n }\n },\n\n list: async (config) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n\n try {\n const result = await client.vms.list();\n const vms = (result as any).vms ?? (result as any) ?? [];\n const vmList = Array.isArray(vms) ? vms : [];\n return vmList.map((entry: any) => {\n const vmId = entry.vmId ?? entry.id;\n const sandboxId = `freestyle-vm-${vmId}`;\n const vm = client.vms.ref({ vmId, spec: RUNTIME_SPEC });\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n });\n } catch {\n return [];\n }\n },\n\n destroy: async (config, sandboxId) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n if (!sandboxId.startsWith(\"freestyle-vm-\")) {\n throw new Error(`Invalid sandbox ID: expected \"freestyle-vm-\" prefix, got \"${sandboxId}\"`);\n }\n const vmId = sandboxId.slice(\"freestyle-vm-\".length);\n try {\n await client.vms.delete({ vmId });\n } catch {\n // VM may already be gone\n }\n },\n\n // ── Instance operations ───────────────────────────────────────────────\n\n runCode: async (handle, code, runtime) => {\n const effectiveRuntime = detectRuntime(code, runtime, handle.config.runtime);\n\n try {\n const res =\n effectiveRuntime === \"python\"\n ? await handle.vm.python.runCode({ code })\n : await handle.vm.js.runCode({ code });\n\n const stdout = (res as any).stdout ?? \"\";\n const stderr = (res as any).stderr ?? \"\";\n const statusCode = (res as any).statusCode ?? 0;\n\n if (\n statusCode !== 0 &&\n stderr &&\n (stderr.includes(\"SyntaxError\") ||\n stderr.includes(\"invalid syntax\") ||\n stderr.includes(\"Unexpected token\") ||\n stderr.includes(\"Unexpected identifier\"))\n ) {\n throw new Error(`Syntax error: ${stderr.trim()}`);\n }\n\n const output = stderr\n ? `${stdout}${stdout && stderr ? \"\\n\" : \"\"}${stderr}`\n : stdout;\n\n return { output, exitCode: statusCode, language: effectiveRuntime };\n } catch (err) {\n if (err instanceof Error && err.message.includes(\"Syntax error\"))\n throw err;\n return {\n output: err instanceof Error ? err.message : String(err),\n exitCode: 1,\n language: effectiveRuntime,\n };\n }\n },\n\n runCommand: async (handle, command, options) => {\n const startTime = Date.now();\n let fullCommand = command;\n\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 if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n try {\n const execResult = await handle.vm.exec({\n command: fullCommand,\n timeoutMs: handle.config.timeout,\n });\n return {\n stdout: (execResult as any).stdout ?? \"\",\n stderr: (execResult as any).stderr ?? \"\",\n exitCode: (execResult as any).statusCode ?? 0,\n durationMs: Date.now() - startTime,\n };\n } catch (err) {\n const result = (err as any)?.result;\n if (result) {\n return {\n stdout: result.stdout ?? \"\",\n stderr: result.stderr ?? \"\",\n exitCode: result.statusCode ?? result.exitCode ?? 1,\n durationMs: Date.now() - startTime,\n };\n }\n return {\n stdout: \"\",\n stderr: err instanceof Error ? err.message : String(err),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n },\n\n getInfo: async (handle) => ({\n id: handle.sandboxId,\n provider: \"freestyle\",\n runtime: handle.config.runtime,\n status: \"running\",\n createdAt: new Date(),\n timeout: handle.config.timeout,\n metadata: { freestyleVmId: handle.vmId },\n }),\n\n getUrl: async (handle, options) => {\n const protocol = options.protocol ?? \"https\";\n return `${protocol}://${handle.vmId}.vm.freestyle.sh:${options.port}`;\n },\n\n getInstance: (handle) => handle,\n\n // ── Filesystem (native Freestyle fs API) ──────────────────────────────\n\n filesystem: {\n readFile: async (handle, path) => {\n return await handle.vm.fs.readTextFile(path);\n },\n\n writeFile: async (handle, path, content) => {\n await handle.vm.fs.writeTextFile(path, content);\n },\n\n mkdir: async (handle, path) => {\n await handle.vm.fs.mkdir(path, true);\n },\n\n readdir: async (handle, path, runCommand) => {\n // Use shell-based readdir for richer metadata (size, type, modified)\n const result = await runCommand(\n handle,\n `ls -la \"${escapeShellArg(path)}\" 2>/dev/null || echo \"\"`\n );\n if (result.exitCode !== 0) return [];\n\n return result.stdout\n .split(\"\\n\")\n .filter((line) => line.trim() && !line.startsWith(\"total\"))\n .map((line) => {\n const parts = line.trim().split(/\\s+/);\n const permissions = parts[0] ?? \"\";\n const name = parts.slice(8).join(' ') || parts[parts.length - 1] || '';\n const size = parseInt(parts[4] ?? \"0\", 10);\n return {\n name,\n type: (permissions.startsWith(\"d\")\n ? \"directory\"\n : \"file\") as \"directory\" | \"file\",\n size: isNaN(size) ? 0 : size,\n modified: new Date(),\n };\n })\n .filter((e) => e.name !== \".\" && e.name !== \"..\");\n },\n\n exists: async (handle, path) => {\n return await handle.vm.fs.exists(path);\n },\n\n remove: async (handle, path) => {\n await handle.vm.fs.remove(path, true);\n },\n },\n },\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAA2C;AAC3C,yBAAyB;AACzB,yBAAyB;AACzB,sBAA+C;AA4C/C,IAAM,eAAe,IAAI,kCAAO;AAAA,EAC9B,MAAM;AAAA,IACJ,IAAI,IAAI,4BAAS;AAAA,IACjB,QAAQ,IAAI,4BAAS;AAAA,EACvB;AACF,CAAC;AAGD,IAAM,gBAAgB,oBAAI,IAA2B;AAErD,e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BAAO,OAAO,OACX,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,KAAK,KAAK,KAAK,CAAC,KAAK,WAAW,OAAO,CAAC,EACzD,IAAI,CAAC,SAAS;AACb,kBAAM,QAAQ,KAAK,KAAK,EAAE,MAAM,KAAK;AACrC,kBAAM,cAAc,MAAM,CAAC,KAAK;AAChC,kBAAM,OAAO,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,MAAM,MAAM,SAAS,CAAC,KAAK;AACpE,kBAAM,OAAO,SAAS,MAAM,CAAC,KAAK,KAAK,EAAE;AACzC,mBAAO;AAAA,cACL;AAAA,cACA,MAAO,YAAY,WAAW,GAAG,IAC7B,cACA;AAAA,cACJ,MAAM,MAAM,IAAI,IAAI,IAAI;AAAA,cACxB,UAAU,oBAAI,KAAK;AAAA,YACrB;AAAA,UACF,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,SAAS,IAAI;AAAA,QACpD;AAAA,QAEA,QAAQ,OAAO,QAAQ,SAAS;AAC9B,iBAAO,MAAM,OAAO,GAAG,GAAG,OAAO,IAAI;AAAA,QACvC;AAAA,QAEA,QAAQ,OAAO,QAAQ,SAAS;AAC9B,gBAAM,OAAO,GAAG,GAAG,OAAO,MAAM,IAAI;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Freestyle, VmSpec, type Vm } from \"freestyle-sandboxes\";\nimport { VmNodeJs } from \"@freestyle-sh/with-nodejs\";\nimport { VmPython } from \"@freestyle-sh/with-python\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type { Runtime } from \"@computesdk/provider\";\n\nexport type { Freestyle as FreestyleSandbox } from \"freestyle-sandboxes\";\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Freestyle provider configuration for ComputeSDK.\n * Runs code in full Linux microVMs via the Freestyle VM API.\n */\nexport interface FreestyleConfig {\n /**\n * Freestyle API key.\n * Falls back to the FREESTYLE_API_KEY environment variable if not provided.\n */\n apiKey?: string;\n\n /**\n * Default runtime hint used to auto-detect the language when not specified.\n * @default \"node\"\n */\n runtime?: Runtime;\n\n /**\n * Timeout in milliseconds for shell commands (`runCommand`).\n * Note: `runCode` does not support timeouts in the Freestyle SDK.\n * @default 30000\n */\n timeout?: number;\n}\n\n// ─── Internal sandbox handle ──────────────────────────────────────────────────\n\ninterface FreestyleSandboxHandle {\n client: Freestyle;\n config: Required<FreestyleConfig>;\n vm: Vm & { js: any; python: any };\n vmId: string;\n sandboxId: string;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nconst RUNTIME_SPEC = new VmSpec({\n with: {\n js: new VmNodeJs(),\n python: new VmPython(),\n },\n});\n\n// Cache snapshot ensures per API key so we only build once\nconst snapshotCache = new Map<string, Promise<void>>();\n\nasync function ensureSnapshot(client: Freestyle, apiKey: string): Promise<void> {\n if (!snapshotCache.has(apiKey)) {\n const promise = client.vms.snapshots\n .ensure({ spec: RUNTIME_SPEC })\n .then(() => {})\n .catch((err) => {\n snapshotCache.delete(apiKey);\n throw err;\n });\n snapshotCache.set(apiKey, promise);\n }\n return snapshotCache.get(apiKey)!;\n}\n\nfunction getApiKey(config: FreestyleConfig): string {\n const key =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.FREESTYLE_API_KEY) ||\n \"\";\n\n if (!key) {\n throw new Error(\n \"Missing Freestyle API key. Provide 'apiKey' in config or set FREESTYLE_API_KEY \" +\n \"environment variable. Get your API key from https://dash.freestyle.sh\"\n );\n }\n\n return key;\n}\n\nfunction resolveConfig(config: FreestyleConfig): Required<FreestyleConfig> {\n return {\n apiKey: getApiKey(config),\n runtime: config.runtime ?? \"node\",\n timeout: config.timeout ?? 30_000,\n };\n}\n\n/**\n * Detect whether a piece of code looks like Python.\n * Mirrors the same heuristic used by the e2b provider.\n */\nfunction detectRuntime(code: string, hint?: Runtime, fallback?: Runtime): Runtime {\n if (hint) return hint;\n const isPython =\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 return isPython ? \"python\" : (fallback ?? \"node\");\n}\n\n// ─── Provider ─────────────────────────────────────────────────────────────────\n\n/**\n * Freestyle provider for ComputeSDK.\n * Creates full Linux microVMs for isolated code execution with Node.js and Python support.\n *\n * @example\n * import { freestyle } from \"@computesdk/freestyle\";\n *\n * const provider = freestyle({ apiKey: process.env.FREESTYLE_API_KEY });\n * const sandbox = await provider.sandbox.create();\n * const result = await sandbox.runCode('console.log(\"Hello!\")');\n * console.log(result.output); // \"Hello!\"\n * await sandbox.destroy();\n */\nexport const freestyle = defineProvider<FreestyleSandboxHandle, FreestyleConfig>({\n name: \"freestyle\",\n\n methods: {\n sandbox: {\n // ── Collection operations ─────────────────────────────────────────────\n\n create: async (config, _options) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n\n await ensureSnapshot(client, resolved.apiKey);\n\n const { vmId, vm } = await client.vms.create({ spec: RUNTIME_SPEC });\n const sandboxId = `freestyle-vm-${vmId}`;\n\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n },\n\n getById: async (config, sandboxId) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n if (!sandboxId.startsWith(\"freestyle-vm-\")) {\n throw new Error(`Invalid sandbox ID: expected \"freestyle-vm-\" prefix, got \"${sandboxId}\"`);\n }\n const vmId = sandboxId.slice(\"freestyle-vm-\".length);\n\n try {\n const vm = client.vms.ref({ vmId, spec: RUNTIME_SPEC });\n await vm.getInfo();\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n } catch {\n return null;\n }\n },\n\n list: async (config) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n\n try {\n const result = await client.vms.list();\n const vms = (result as any).vms ?? (result as any) ?? [];\n const vmList = Array.isArray(vms) ? vms : [];\n return vmList.map((entry: any) => {\n const vmId = entry.vmId ?? entry.id;\n const sandboxId = `freestyle-vm-${vmId}`;\n const vm = client.vms.ref({ vmId, spec: RUNTIME_SPEC });\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n });\n } catch {\n return [];\n }\n },\n\n destroy: async (config, sandboxId) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n if (!sandboxId.startsWith(\"freestyle-vm-\")) {\n throw new Error(`Invalid sandbox ID: expected \"freestyle-vm-\" prefix, got \"${sandboxId}\"`);\n }\n const vmId = sandboxId.slice(\"freestyle-vm-\".length);\n try {\n await client.vms.delete({ vmId });\n } catch {\n // VM may already be gone\n }\n },\n\n // ── Instance operations ───────────────────────────────────────────────\n\n runCommand: async (handle, command, options) => {\n const startTime = Date.now();\n let fullCommand = command;\n\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 if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n try {\n const execResult = await handle.vm.exec({\n command: fullCommand,\n timeoutMs: handle.config.timeout,\n });\n return {\n stdout: (execResult as any).stdout ?? \"\",\n stderr: (execResult as any).stderr ?? \"\",\n exitCode: (execResult as any).statusCode ?? 0,\n durationMs: Date.now() - startTime,\n };\n } catch (err) {\n const result = (err as any)?.result;\n if (result) {\n return {\n stdout: result.stdout ?? \"\",\n stderr: result.stderr ?? \"\",\n exitCode: result.statusCode ?? result.exitCode ?? 1,\n durationMs: Date.now() - startTime,\n };\n }\n return {\n stdout: \"\",\n stderr: err instanceof Error ? err.message : String(err),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n },\n\n getInfo: async (handle) => ({\n id: handle.sandboxId,\n provider: \"freestyle\",\n runtime: handle.config.runtime,\n status: \"running\",\n createdAt: new Date(),\n timeout: handle.config.timeout,\n metadata: { freestyleVmId: handle.vmId },\n }),\n\n getUrl: async (handle, options) => {\n const protocol = options.protocol ?? \"https\";\n return `${protocol}://${handle.vmId}.vm.freestyle.sh:${options.port}`;\n },\n\n getInstance: (handle) => handle,\n\n // ── Filesystem (native Freestyle fs API) ──────────────────────────────\n\n filesystem: {\n readFile: async (handle, path) => {\n return await handle.vm.fs.readTextFile(path);\n },\n\n writeFile: async (handle, path, content) => {\n await handle.vm.fs.writeTextFile(path, content);\n },\n\n mkdir: async (handle, path) => {\n await handle.vm.fs.mkdir(path, true);\n },\n\n readdir: async (handle, path, runCommand) => {\n // Use shell-based readdir for richer metadata (size, type, modified)\n const result = await runCommand(\n handle,\n `ls -la \"${escapeShellArg(path)}\" 2>/dev/null || echo \"\"`\n );\n if (result.exitCode !== 0) return [];\n\n return result.stdout\n .split(\"\\n\")\n .filter((line) => line.trim() && !line.startsWith(\"total\"))\n .map((line) => {\n const parts = line.trim().split(/\\s+/);\n const permissions = parts[0] ?? \"\";\n const name = parts.slice(8).join(' ') || parts[parts.length - 1] || '';\n const size = parseInt(parts[4] ?? \"0\", 10);\n return {\n name,\n type: (permissions.startsWith(\"d\")\n ? \"directory\"\n : \"file\") as \"directory\" | \"file\",\n size: isNaN(size) ? 0 : size,\n modified: new Date(),\n };\n })\n .filter((e) => e.name !== \".\" && e.name !== \"..\");\n },\n\n exists: async (handle, path) => {\n return await handle.vm.fs.exists(path);\n },\n\n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index.ts

}
function detectRuntime(code, hint, fallback) {
if (hint) return hint;
const isPython = 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 ");
return isPython ? "python" : fallback ?? "node";
}
var freestyle = defineProvider({

@@ -125,24 +120,2 @@ name: "freestyle",

// ── Instance operations ───────────────────────────────────────────────
runCode: async (handle, code, runtime) => {
const effectiveRuntime = detectRuntime(code, runtime, handle.config.runtime);
try {
const res = effectiveRuntime === "python" ? await handle.vm.python.runCode({ code }) : await handle.vm.js.runCode({ code });
const stdout = res.stdout ?? "";
const stderr = res.stderr ?? "";
const statusCode = res.statusCode ?? 0;
if (statusCode !== 0 && stderr && (stderr.includes("SyntaxError") || stderr.includes("invalid syntax") || stderr.includes("Unexpected token") || stderr.includes("Unexpected identifier"))) {
throw new Error(`Syntax error: ${stderr.trim()}`);
}
const output = stderr ? `${stdout}${stdout && stderr ? "\n" : ""}${stderr}` : stdout;
return { output, exitCode: statusCode, language: effectiveRuntime };
} catch (err) {
if (err instanceof Error && err.message.includes("Syntax error"))
throw err;
return {
output: err instanceof Error ? err.message : String(err),
exitCode: 1,
language: effectiveRuntime
};
}
},
runCommand: async (handle, command, options) => {

@@ -149,0 +122,0 @@ const startTime = Date.now();

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Freestyle, VmSpec, type Vm } from \"freestyle-sandboxes\";\nimport { VmNodeJs } from \"@freestyle-sh/with-nodejs\";\nimport { VmPython } from \"@freestyle-sh/with-python\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type { Runtime } from \"@computesdk/provider\";\n\nexport type { Freestyle as FreestyleSandbox } from \"freestyle-sandboxes\";\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Freestyle provider configuration for ComputeSDK.\n * Runs code in full Linux microVMs via the Freestyle VM API.\n */\nexport interface FreestyleConfig {\n /**\n * Freestyle API key.\n * Falls back to the FREESTYLE_API_KEY environment variable if not provided.\n */\n apiKey?: string;\n\n /**\n * Default runtime hint used to auto-detect the language when not specified.\n * @default \"node\"\n */\n runtime?: Runtime;\n\n /**\n * Timeout in milliseconds for shell commands (`runCommand`).\n * Note: `runCode` does not support timeouts in the Freestyle SDK.\n * @default 30000\n */\n timeout?: number;\n}\n\n// ─── Internal sandbox handle ──────────────────────────────────────────────────\n\ninterface FreestyleSandboxHandle {\n client: Freestyle;\n config: Required<FreestyleConfig>;\n vm: Vm & { js: any; python: any };\n vmId: string;\n sandboxId: string;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nconst RUNTIME_SPEC = new VmSpec({\n with: {\n js: new VmNodeJs(),\n python: new VmPython(),\n },\n});\n\n// Cache snapshot ensures per API key so we only build once\nconst snapshotCache = new Map<string, Promise<void>>();\n\nasync function ensureSnapshot(client: Freestyle, apiKey: string): Promise<void> {\n if (!snapshotCache.has(apiKey)) {\n const promise = client.vms.snapshots\n .ensure({ spec: RUNTIME_SPEC })\n .then(() => {})\n .catch((err) => {\n snapshotCache.delete(apiKey);\n throw err;\n });\n snapshotCache.set(apiKey, promise);\n }\n return snapshotCache.get(apiKey)!;\n}\n\nfunction getApiKey(config: FreestyleConfig): string {\n const key =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.FREESTYLE_API_KEY) ||\n \"\";\n\n if (!key) {\n throw new Error(\n \"Missing Freestyle API key. Provide 'apiKey' in config or set FREESTYLE_API_KEY \" +\n \"environment variable. Get your API key from https://dash.freestyle.sh\"\n );\n }\n\n return key;\n}\n\nfunction resolveConfig(config: FreestyleConfig): Required<FreestyleConfig> {\n return {\n apiKey: getApiKey(config),\n runtime: config.runtime ?? \"node\",\n timeout: config.timeout ?? 30_000,\n };\n}\n\n/**\n * Detect whether a piece of code looks like Python.\n * Mirrors the same heuristic used by the e2b provider.\n */\nfunction detectRuntime(code: string, hint?: Runtime, fallback?: Runtime): Runtime {\n if (hint) return hint;\n const isPython =\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 return isPython ? \"python\" : (fallback ?? \"node\");\n}\n\n// ─── Provider ─────────────────────────────────────────────────────────────────\n\n/**\n * Freestyle provider for ComputeSDK.\n * Creates full Linux microVMs for isolated code execution with Node.js and Python support.\n *\n * @example\n * import { freestyle } from \"@computesdk/freestyle\";\n *\n * const provider = freestyle({ apiKey: process.env.FREESTYLE_API_KEY });\n * const sandbox = await provider.sandbox.create();\n * const result = await sandbox.runCode('console.log(\"Hello!\")');\n * console.log(result.output); // \"Hello!\"\n * await sandbox.destroy();\n */\nexport const freestyle = defineProvider<FreestyleSandboxHandle, FreestyleConfig>({\n name: \"freestyle\",\n\n methods: {\n sandbox: {\n // ── Collection operations ─────────────────────────────────────────────\n\n create: async (config, _options) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n\n await ensureSnapshot(client, resolved.apiKey);\n\n const { vmId, vm } = await client.vms.create({ spec: RUNTIME_SPEC });\n const sandboxId = `freestyle-vm-${vmId}`;\n\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n },\n\n getById: async (config, sandboxId) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n if (!sandboxId.startsWith(\"freestyle-vm-\")) {\n throw new Error(`Invalid sandbox ID: expected \"freestyle-vm-\" prefix, got \"${sandboxId}\"`);\n }\n const vmId = sandboxId.slice(\"freestyle-vm-\".length);\n\n try {\n const vm = client.vms.ref({ vmId, spec: RUNTIME_SPEC });\n await vm.getInfo();\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n } catch {\n return null;\n }\n },\n\n list: async (config) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n\n try {\n const result = await client.vms.list();\n const vms = (result as any).vms ?? (result as any) ?? [];\n const vmList = Array.isArray(vms) ? vms : [];\n return vmList.map((entry: any) => {\n const vmId = entry.vmId ?? entry.id;\n const sandboxId = `freestyle-vm-${vmId}`;\n const vm = client.vms.ref({ vmId, spec: RUNTIME_SPEC });\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n });\n } catch {\n return [];\n }\n },\n\n destroy: async (config, sandboxId) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n if (!sandboxId.startsWith(\"freestyle-vm-\")) {\n throw new Error(`Invalid sandbox ID: expected \"freestyle-vm-\" prefix, got \"${sandboxId}\"`);\n }\n const vmId = sandboxId.slice(\"freestyle-vm-\".length);\n try {\n await client.vms.delete({ vmId });\n } catch {\n // VM may already be gone\n }\n },\n\n // ── Instance operations ───────────────────────────────────────────────\n\n runCode: async (handle, code, runtime) => {\n const effectiveRuntime = detectRuntime(code, runtime, handle.config.runtime);\n\n try {\n const res =\n effectiveRuntime === \"python\"\n ? await handle.vm.python.runCode({ code })\n : await handle.vm.js.runCode({ code });\n\n const stdout = (res as any).stdout ?? \"\";\n const stderr = (res as any).stderr ?? \"\";\n const statusCode = (res as any).statusCode ?? 0;\n\n if (\n statusCode !== 0 &&\n stderr &&\n (stderr.includes(\"SyntaxError\") ||\n stderr.includes(\"invalid syntax\") ||\n stderr.includes(\"Unexpected token\") ||\n stderr.includes(\"Unexpected identifier\"))\n ) {\n throw new Error(`Syntax error: ${stderr.trim()}`);\n }\n\n const output = stderr\n ? `${stdout}${stdout && stderr ? \"\\n\" : \"\"}${stderr}`\n : stdout;\n\n return { output, exitCode: statusCode, language: effectiveRuntime };\n } catch (err) {\n if (err instanceof Error && err.message.includes(\"Syntax error\"))\n throw err;\n return {\n output: err instanceof Error ? err.message : String(err),\n exitCode: 1,\n language: effectiveRuntime,\n };\n }\n },\n\n runCommand: async (handle, command, options) => {\n const startTime = Date.now();\n let fullCommand = command;\n\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 if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n try {\n const execResult = await handle.vm.exec({\n command: fullCommand,\n timeoutMs: handle.config.timeout,\n });\n return {\n stdout: (execResult as any).stdout ?? \"\",\n stderr: (execResult as any).stderr ?? \"\",\n exitCode: (execResult as any).statusCode ?? 0,\n durationMs: Date.now() - startTime,\n };\n } catch (err) {\n const result = (err as any)?.result;\n if (result) {\n return {\n stdout: result.stdout ?? \"\",\n stderr: result.stderr ?? \"\",\n exitCode: result.statusCode ?? result.exitCode ?? 1,\n durationMs: Date.now() - startTime,\n };\n }\n return {\n stdout: \"\",\n stderr: err instanceof Error ? err.message : String(err),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n },\n\n getInfo: async (handle) => ({\n id: handle.sandboxId,\n provider: \"freestyle\",\n runtime: handle.config.runtime,\n status: \"running\",\n createdAt: new Date(),\n timeout: handle.config.timeout,\n metadata: { freestyleVmId: handle.vmId },\n }),\n\n getUrl: async (handle, options) => {\n const protocol = options.protocol ?? \"https\";\n return `${protocol}://${handle.vmId}.vm.freestyle.sh:${options.port}`;\n },\n\n getInstance: (handle) => handle,\n\n // ── Filesystem (native Freestyle fs API) ──────────────────────────────\n\n filesystem: {\n readFile: async (handle, path) => {\n return await handle.vm.fs.readTextFile(path);\n },\n\n writeFile: async (handle, path, content) => {\n await handle.vm.fs.writeTextFile(path, content);\n },\n\n mkdir: async (handle, path) => {\n await handle.vm.fs.mkdir(path, true);\n },\n\n readdir: async (handle, path, runCommand) => {\n // Use shell-based readdir for richer metadata (size, type, modified)\n const result = await runCommand(\n handle,\n `ls -la \"${escapeShellArg(path)}\" 2>/dev/null || echo \"\"`\n );\n if (result.exitCode !== 0) return [];\n\n return result.stdout\n .split(\"\\n\")\n .filter((line) => line.trim() && !line.startsWith(\"total\"))\n .map((line) => {\n const parts = line.trim().split(/\\s+/);\n const permissions = parts[0] ?? \"\";\n const name = parts.slice(8).join(' ') || parts[parts.length - 1] || '';\n const size = parseInt(parts[4] ?? \"0\", 10);\n return {\n name,\n type: (permissions.startsWith(\"d\")\n ? \"directory\"\n : \"file\") as \"directory\" | \"file\",\n size: isNaN(size) ? 0 : size,\n modified: new Date(),\n };\n })\n .filter((e) => e.name !== \".\" && e.name !== \"..\");\n },\n\n exists: async (handle, path) => {\n return await handle.vm.fs.exists(path);\n },\n\n remove: async (handle, path) => {\n await handle.vm.fs.remove(path, true);\n },\n },\n },\n },\n});\n"],"mappings":";AAAA,SAAS,WAAW,cAAuB;AAC3C,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB,sBAAsB;AA4C/C,IAAM,eAAe,IAAI,OAAO;AAAA,EAC9B,MAAM;AAAA,IACJ,IAAI,IAAI,SAAS;AAAA,IACjB,QAAQ,IAAI,SAAS;AAAA,EACvB;AACF,CAAC;AAGD,IAAM,gBAAgB,oBAAI,IAA2B;AAErD,eAAe,eAAe,QAAmB,QAA+B;AAC9E,MAAI,CAAC,cAAc,IAAI,MAAM,GAAG;AAC9B,UAAM,UAAU,OAAO,IAAI,UACxB,OAAO,EAAE,MAAM,aAAa,CAAC,EAC7B,KAAK,MAAM;AAAA,IAAC,CAAC,EACb,MAAM,CAAC,QAAQ;AACd,oBAAc,OAAO,MAAM;AAC3B,YAAM;AAAA,IACR,CAAC;AACH,kBAAc,IAAI,QAAQ,OAAO;AAAA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AK;AACpE,kBAAM,OAAO,SAAS,MAAM,CAAC,KAAK,KAAK,EAAE;AACzC,mBAAO;AAAA,cACL;AAAA,cACA,MAAO,YAAY,WAAW,GAAG,IAC7B,cACA;AAAA,cACJ,MAAM,MAAM,IAAI,IAAI,IAAI;AAAA,cACxB,UAAU,oBAAI,KAAK;AAAA,YACrB;AAAA,UACF,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,SAAS,IAAI;AAAA,QACpD;AAAA,QAEA,QAAQ,OAAO,QAAQ,SAAS;AAC9B,iBAAO,MAAM,OAAO,GAAG,GAAG,OAAO,IAAI;AAAA,QACvC;AAAA,QAEA,QAAQ,OAAO,QAAQ,SAAS;AAC9B,gBAAM,OAAO,GAAG,GAAG,OAAO,MAAM,IAAI;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Freestyle, VmSpec, type Vm } from \"freestyle-sandboxes\";\nimport { VmNodeJs } from \"@freestyle-sh/with-nodejs\";\nimport { VmPython } from \"@freestyle-sh/with-python\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type { Runtime } from \"@computesdk/provider\";\n\nexport type { Freestyle as FreestyleSandbox } from \"freestyle-sandboxes\";\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Freestyle provider configuration for ComputeSDK.\n * Runs code in full Linux microVMs via the Freestyle VM API.\n */\nexport interface FreestyleConfig {\n /**\n * Freestyle API key.\n * Falls back to the FREESTYLE_API_KEY environment variable if not provided.\n */\n apiKey?: string;\n\n /**\n * Default runtime hint used to auto-detect the language when not specified.\n * @default \"node\"\n */\n runtime?: Runtime;\n\n /**\n * Timeout in milliseconds for shell commands (`runCommand`).\n * Note: `runCode` does not support timeouts in the Freestyle SDK.\n * @default 30000\n */\n timeout?: number;\n}\n\n// ─── Internal sandbox handle ──────────────────────────────────────────────────\n\ninterface FreestyleSandboxHandle {\n client: Freestyle;\n config: Required<FreestyleConfig>;\n vm: Vm & { js: any; python: any };\n vmId: string;\n sandboxId: string;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nconst RUNTIME_SPEC = new VmSpec({\n with: {\n js: new VmNodeJs(),\n python: new VmPython(),\n },\n});\n\n// Cache snapshot ensures per API key so we only build once\nconst snapshotCache = new Map<string, Promise<void>>();\n\nasync function ensureSnapshot(client: Freestyle, apiKey: string): Promise<void> {\n if (!snapshotCache.has(apiKey)) {\n const promise = client.vms.snapshots\n .ensure({ spec: RUNTIME_SPEC })\n .then(() => {})\n .catch((err) => {\n snapshotCache.delete(apiKey);\n throw err;\n });\n snapshotCache.set(apiKey, promise);\n }\n return snapshotCache.get(apiKey)!;\n}\n\nfunction getApiKey(config: FreestyleConfig): string {\n const key =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.FREESTYLE_API_KEY) ||\n \"\";\n\n if (!key) {\n throw new Error(\n \"Missing Freestyle API key. Provide 'apiKey' in config or set FREESTYLE_API_KEY \" +\n \"environment variable. Get your API key from https://dash.freestyle.sh\"\n );\n }\n\n return key;\n}\n\nfunction resolveConfig(config: FreestyleConfig): Required<FreestyleConfig> {\n return {\n apiKey: getApiKey(config),\n runtime: config.runtime ?? \"node\",\n timeout: config.timeout ?? 30_000,\n };\n}\n\n/**\n * Detect whether a piece of code looks like Python.\n * Mirrors the same heuristic used by the e2b provider.\n */\nfunction detectRuntime(code: string, hint?: Runtime, fallback?: Runtime): Runtime {\n if (hint) return hint;\n const isPython =\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 return isPython ? \"python\" : (fallback ?? \"node\");\n}\n\n// ─── Provider ─────────────────────────────────────────────────────────────────\n\n/**\n * Freestyle provider for ComputeSDK.\n * Creates full Linux microVMs for isolated code execution with Node.js and Python support.\n *\n * @example\n * import { freestyle } from \"@computesdk/freestyle\";\n *\n * const provider = freestyle({ apiKey: process.env.FREESTYLE_API_KEY });\n * const sandbox = await provider.sandbox.create();\n * const result = await sandbox.runCode('console.log(\"Hello!\")');\n * console.log(result.output); // \"Hello!\"\n * await sandbox.destroy();\n */\nexport const freestyle = defineProvider<FreestyleSandboxHandle, FreestyleConfig>({\n name: \"freestyle\",\n\n methods: {\n sandbox: {\n // ── Collection operations ─────────────────────────────────────────────\n\n create: async (config, _options) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n\n await ensureSnapshot(client, resolved.apiKey);\n\n const { vmId, vm } = await client.vms.create({ spec: RUNTIME_SPEC });\n const sandboxId = `freestyle-vm-${vmId}`;\n\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n },\n\n getById: async (config, sandboxId) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n if (!sandboxId.startsWith(\"freestyle-vm-\")) {\n throw new Error(`Invalid sandbox ID: expected \"freestyle-vm-\" prefix, got \"${sandboxId}\"`);\n }\n const vmId = sandboxId.slice(\"freestyle-vm-\".length);\n\n try {\n const vm = client.vms.ref({ vmId, spec: RUNTIME_SPEC });\n await vm.getInfo();\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n } catch {\n return null;\n }\n },\n\n list: async (config) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n\n try {\n const result = await client.vms.list();\n const vms = (result as any).vms ?? (result as any) ?? [];\n const vmList = Array.isArray(vms) ? vms : [];\n return vmList.map((entry: any) => {\n const vmId = entry.vmId ?? entry.id;\n const sandboxId = `freestyle-vm-${vmId}`;\n const vm = client.vms.ref({ vmId, spec: RUNTIME_SPEC });\n const handle: FreestyleSandboxHandle = {\n client,\n config: resolved,\n vm: vm as any,\n vmId,\n sandboxId,\n };\n return { sandbox: handle, sandboxId };\n });\n } catch {\n return [];\n }\n },\n\n destroy: async (config, sandboxId) => {\n const resolved = resolveConfig(config);\n const client = new Freestyle({ apiKey: resolved.apiKey });\n if (!sandboxId.startsWith(\"freestyle-vm-\")) {\n throw new Error(`Invalid sandbox ID: expected \"freestyle-vm-\" prefix, got \"${sandboxId}\"`);\n }\n const vmId = sandboxId.slice(\"freestyle-vm-\".length);\n try {\n await client.vms.delete({ vmId });\n } catch {\n // VM may already be gone\n }\n },\n\n // ── Instance operations ───────────────────────────────────────────────\n\n runCommand: async (handle, command, options) => {\n const startTime = Date.now();\n let fullCommand = command;\n\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 if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n try {\n const execResult = await handle.vm.exec({\n command: fullCommand,\n timeoutMs: handle.config.timeout,\n });\n return {\n stdout: (execResult as any).stdout ?? \"\",\n stderr: (execResult as any).stderr ?? \"\",\n exitCode: (execResult as any).statusCode ?? 0,\n durationMs: Date.now() - startTime,\n };\n } catch (err) {\n const result = (err as any)?.result;\n if (result) {\n return {\n stdout: result.stdout ?? \"\",\n stderr: result.stderr ?? \"\",\n exitCode: result.statusCode ?? result.exitCode ?? 1,\n durationMs: Date.now() - startTime,\n };\n }\n return {\n stdout: \"\",\n stderr: err instanceof Error ? err.message : String(err),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n },\n\n getInfo: async (handle) => ({\n id: handle.sandboxId,\n provider: \"freestyle\",\n runtime: handle.config.runtime,\n status: \"running\",\n createdAt: new Date(),\n timeout: handle.config.timeout,\n metadata: { freestyleVmId: handle.vmId },\n }),\n\n getUrl: async (handle, options) => {\n const protocol = options.protocol ?? \"https\";\n return `${protocol}://${handle.vmId}.vm.freestyle.sh:${options.port}`;\n },\n\n getInstance: (handle) => handle,\n\n // ── Filesystem (native Freestyle fs API) ──────────────────────────────\n\n filesystem: {\n readFile: async (handle, path) => {\n return await handle.vm.fs.readTextFile(path);\n },\n\n writeFile: async (handle, path, content) => {\n await handle.vm.fs.writeTextFile(path, content);\n },\n\n mkdir: async (handle, path) => {\n await handle.vm.fs.mkdir(path, true);\n },\n\n readdir: async (handle, path, runCommand) => {\n // Use shell-based readdir for richer metadata (size, type, modified)\n const result = await runCommand(\n handle,\n `ls -la \"${escapeShellArg(path)}\" 2>/dev/null || echo \"\"`\n );\n if (result.exitCode !== 0) return [];\n\n return result.stdout\n .split(\"\\n\")\n .filter((line) => line.trim() && !line.startsWith(\"total\"))\n .map((line) => {\n const parts = line.trim().split(/\\s+/);\n const permissions = parts[0] ?? \"\";\n const name = parts.slice(8).join(' ') || parts[parts.length - 1] || '';\n const size = parseInt(parts[4] ?? \"0\", 10);\n return {\n name,\n type: (permissions.startsWith(\"d\")\n ? \"directory\"\n : \"file\") as \"directory\" | \"file\",\n size: isNaN(size) ? 0 : size,\n modified: new Date(),\n };\n })\n .filter((e) => e.name !== \".\" && e.name !== \"..\");\n },\n\n exists: async (handle, path) => {\n return await handle.vm.fs.exists(path);\n },\n\n remove: async (handle, path) => {\n await handle.vm.fs.remove(path, true);\n },\n },\n },\n },\n});\n"],"mappings":";AAAA,SAAS,WAAW,cAAuB;AAC3C,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB,sBAAsB;AA4C/C,IAAM,eAAe,IAAI,OAAO;AAAA,EAC9B,MAAM;AAAA,IACJ,IAAI,IAAI,SAAS;AAAA,IACjB,QAAQ,IAAI,SAAS;AAAA,EACvB;AACF,CAAC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AAG,QAAO,CAAC;AAEnC,iBAAO,OAAO,OACX,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,KAAK,KAAK,KAAK,CAAC,KAAK,WAAW,OAAO,CAAC,EACzD,IAAI,CAAC,SAAS;AACb,kBAAM,QAAQ,KAAK,KAAK,EAAE,MAAM,KAAK;AACrC,kBAAM,cAAc,MAAM,CAAC,KAAK;AAChC,kBAAM,OAAO,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,MAAM,MAAM,SAAS,CAAC,KAAK;AACpE,kBAAM,OAAO,SAAS,MAAM,CAAC,KAAK,KAAK,EAAE;AACzC,mBAAO;AAAA,cACL;AAAA,cACA,MAAO,YAAY,WAAW,GAAG,IAC7B,cACA;AAAA,cACJ,MAAM,MAAM,IAAI,IAAI,IAAI;AAAA,cACxB,UAAU,oBAAI,KAAK;AAAA,YACrB;AAAA,UACF,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,SAAS,IAAI;AAAA,QACpD;AAAA,QAEA,QAAQ,OAAO,QAAQ,SAAS;AAC9B,iBAAO,MAAM,OAAO,GAAG,GAAG,OAAO,IAAI;AAAA,QACvC;AAAA,QAEA,QAAQ,OAAO,QAAQ,SAAS;AAC9B,gBAAM,OAAO,GAAG,GAAG,OAAO,MAAM,IAAI;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
{
"name": "@computesdk/freestyle",
"version": "0.1.4",
"version": "0.1.5",
"description": "Freestyle provider for ComputeSDK - cloud sandboxes powered by Freestyle",

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

"@freestyle-sh/with-nodejs": "^0.2.8",
"@computesdk/provider": "1.3.0",
"computesdk": "2.6.0"
"@computesdk/provider": "1.4.0",
"computesdk": "3.0.0"
},

@@ -28,0 +28,0 @@ "keywords": [