@computesdk/blaxel 1.6.10 → 1.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -32,7 +32,6 @@ var blaxel = (0, import_provider.defineProvider)({
|
|
|
32
32
|
// Collection operations (map to compute.sandbox.*)
|
|
33
33
|
create: async (config, options) => {
|
|
34
34
|
const {
|
|
35
|
-
runtime: optRuntime,
|
|
36
35
|
timeout: optTimeout,
|
|
37
36
|
envs,
|
|
38
37
|
name: _name,
|
|
@@ -44,6 +43,7 @@ var blaxel = (0, import_provider.defineProvider)({
|
|
|
44
43
|
directory: _directory,
|
|
45
44
|
...providerOptions
|
|
46
45
|
} = options || {};
|
|
46
|
+
const optRuntime = options?.runtime;
|
|
47
47
|
let image = config.image || "blaxel/base-image:latest";
|
|
48
48
|
if (!config.image && optRuntime) {
|
|
49
49
|
switch (optRuntime) {
|
|
@@ -166,14 +166,15 @@ var blaxel = (0, import_provider.defineProvider)({
|
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
168
|
getInfo: async (sandbox) => {
|
|
169
|
+
const runtime = sandbox.spec?.runtime?.image?.includes("py") ? "python" : "node";
|
|
169
170
|
return {
|
|
170
171
|
id: sandbox.metadata?.name || "blaxel-unknown",
|
|
171
172
|
provider: "blaxel",
|
|
172
|
-
runtime: sandbox.spec?.runtime?.image?.includes("py") ? "python" : "node",
|
|
173
173
|
status: convertSandboxStatus(sandbox.status),
|
|
174
174
|
createdAt: sandbox.metadata?.createdAt ? new Date(sandbox.metadata.createdAt) : /* @__PURE__ */ new Date(),
|
|
175
175
|
timeout: parseTTLToMilliseconds(sandbox.spec?.runtime?.ttl),
|
|
176
176
|
metadata: {
|
|
177
|
+
runtime,
|
|
177
178
|
...sandbox.metadata?.labels
|
|
178
179
|
}
|
|
179
180
|
};
|
|
@@ -346,9 +347,7 @@ var blaxel = (0, import_provider.defineProvider)({
|
|
|
346
347
|
});
|
|
347
348
|
function parseTTLToMilliseconds(ttl) {
|
|
348
349
|
if (!ttl) return 3e5;
|
|
349
|
-
if (typeof ttl === "number")
|
|
350
|
-
return ttl * 1e3;
|
|
351
|
-
}
|
|
350
|
+
if (typeof ttl === "number") return ttl * 1e3;
|
|
352
351
|
const match = ttl.match(/^(\d+)([smhd])?$/);
|
|
353
352
|
if (!match) return 3e5;
|
|
354
353
|
const value = parseInt(match[1], 10);
|
|
@@ -356,16 +355,12 @@ function parseTTLToMilliseconds(ttl) {
|
|
|
356
355
|
switch (unit) {
|
|
357
356
|
case "s":
|
|
358
357
|
return value * 1e3;
|
|
359
|
-
// seconds to ms
|
|
360
358
|
case "m":
|
|
361
359
|
return value * 60 * 1e3;
|
|
362
|
-
// minutes to ms
|
|
363
360
|
case "h":
|
|
364
361
|
return value * 60 * 60 * 1e3;
|
|
365
|
-
// hours to ms
|
|
366
362
|
case "d":
|
|
367
363
|
return value * 24 * 60 * 60 * 1e3;
|
|
368
|
-
// days to ms
|
|
369
364
|
default:
|
|
370
365
|
return 3e5;
|
|
371
366
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Blaxel Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n */\n\nimport { SandboxInstance, initialize } from '@blaxel/core';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions, CreateSnapshotOptions, ListSnapshotsOptions } from '@computesdk/provider';\n\n/**\n * Blaxel-specific configuration options\n */\nexport interface BlaxelConfig {\n\t/** Blaxel workspace ID - if not provided, will fallback to BL_WORKSPACE environment variable */\n\tworkspace?: string;\n\t/** Blaxel API key - if not provided, will fallback to BL_API_KEY environment variable */\n\tapiKey?: string;\n\t/** Default image for sandboxes */\n\timage?: string;\n\t/** Default region for sandbox deployment */\n\tregion?: string;\n\t/** Default memory allocation in MB */\n\tmemory?: number | 4096;\n\t/** Default ports for sandbox */\n\tports?: number[] | [3000];\n}\n\n/**\n * Create a Blaxel provider instance using the factory pattern\n */\nexport const blaxel = defineProvider<SandboxInstance, BlaxelConfig, any, any>({\n\tname: 'blaxel',\n\tmethods: {\n\t\tsandbox: {\n\t\t\t// Collection operations (map to compute.sandbox.*)\n\t\t\tcreate: async (config: BlaxelConfig, options?: CreateSandboxOptions) => {\n\t\t\t\t// Destructure known ComputeSDK fields, collect the rest for passthrough\n\t\t\t\tconst {\n\t\t\t\t\truntime: optRuntime,\n\t\t\t\t\ttimeout: optTimeout,\n\t\t\t\t\tenvs,\n\t\t\t\t\tname: _name,\n\t\t\t\t\tmetadata,\n\t\t\t\t\ttemplateId: _templateId,\n\t\t\t\t\tsnapshotId,\n\t\t\t\t\tsandboxId: optSandboxId,\n\t\t\t\t\tnamespace: _namespace,\n\t\t\t\t\tdirectory: _directory,\n\t\t\t\t\t...providerOptions\n\t\t\t\t} = options || {};\n\n\t\t\t\t// Determine the image to use\n\t\t\t\tlet image = config.image || 'blaxel/base-image:latest'; // Default to prod-base\n\n\t\t\t\t// Override with runtime-specific image if runtime is specified and no explicit image\n\t\t\t\tif (!config.image && optRuntime) {\n\t\t\t\t\tswitch (optRuntime) {\n\t\t\t\t\t\tcase 'python':\n\t\t\t\t\t\t\timage = 'blaxel/py-app:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'node':\n\t\t\t\t\t\t\timage = 'blaxel/ts-app:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\timage = 'blaxel/base-image:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst memory = config.memory;\n\t\t\t\tconst region = config.region;\n\t\t\t\tconst ttl = optTimeout ? `${Math.ceil(optTimeout / 1000)}s` : undefined;\n\n\t\t\ttry {\n\t\t\t\t// Initialize Blaxel SDK with credentials\n\t\t\t\tinitializeBlaxel(config);\n\n\t\t\t\tlet sandbox: SandboxInstance;\n\n\t\t\t\t// Check if we should resume an existing sandbox or create new\n\t\t\t\tconst existingId = optSandboxId || snapshotId;\n\t\t\t\t\n\t\t\t\tif (existingId) {\n\t\t\t\t\t// Resume existing sandbox or snapshot\n\t\t\t\t\tsandbox = await SandboxInstance.get(existingId);\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\tthrow new Error(`Sandbox ${existingId} not found`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Create new Blaxel sandbox\n\t\t\t\t\tsandbox = await SandboxInstance.createIfNotExists({\n\t\t\t\t\t\timage,\n\t\t\t\t\t\tmemory,\n\t\t\t\t\t\tenvs: Object.entries(envs || {}).map(([name, value]) => ({ name, value: value as string })),\n\t\t\t\t\t\t...(metadata?.labels && { labels: metadata.labels }),\n\t\t\t\t\t\tttl,\n\t\t\t\t\t\tports: config.ports?.map(port => ({ target: port, protocol: 'HTTP' })),\n\t\t\t\t\t\t...(region && { region }),\n\t\t\t\t\t\t...providerOptions, // Spread provider-specific options\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tsandbox,\n\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\t\tconst errorDetail = error instanceof Error\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: typeof error === 'object' && error !== null\n\t\t\t\t\t\t\t? JSON.stringify(error)\n\t\t\t\t\t\t\t: String(error);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\terrorDetail.includes('unauthorized') ||\n\t\t\t\t\t\terrorDetail.includes('Unauthorized') ||\n\t\t\t\t\t\terrorDetail.includes('Forbidden') ||\n\t\t\t\t\t\terrorDetail.includes('API key')\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Blaxel authentication failed: ${errorDetail}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (errorDetail.includes('quota') || errorDetail.includes('limit')) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Blaxel quota exceeded: ${errorDetail}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to create Blaxel sandbox: ${errorDetail}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tgetById: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tconst sandbox = await SandboxInstance.get(sandboxId);\n\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsandbox,\n\t\t\t\t\t\tsandboxId,\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Sandbox doesn't exist or can't be accessed\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tlist: async (config: BlaxelConfig) => {\n\t\t\t\tinitializeBlaxel(config);\n\t\t\t\tconst sandboxList = await SandboxInstance.list();\n\t\t\t\treturn sandboxList.map(sandbox => ({\n\t\t\t\t\tsandbox,\n\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown'\n\t\t\t\t}));\n\t\t\t},\n\n\t\t\tdestroy: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tawait SandboxInstance.delete(sandboxId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Sandbox might already be destroyed or doesn't exist\n\t\t\t\t\t// This is acceptable for destroy operations\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Instance operations (map to individual Sandbox methods)\n\t\trunCommand: async (sandbox: SandboxInstance, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n\t\t\tconst startTime = Date.now();\n\n\t\t\ttry {\n\t\t\t\t// Build command with options\n\t\t\t\tlet fullCommand = command;\n\t\t\t\t\n\t\t\t\t// Handle environment variables\n\t\t\t\tif (options?.env && Object.keys(options.env).length > 0) {\n\t\t\t\t\tconst envPrefix = Object.entries(options.env)\n\t\t\t\t\t\t.map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n\t\t\t\t\t\t.join(' ');\n\t\t\t\t\tfullCommand = `${envPrefix} ${fullCommand}`;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Handle working directory\n\t\t\t\tif (options?.cwd) {\n\t\t\t\t\tfullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Handle background execution\n\t\t\t\tif (options?.background) {\n\t\t\t\t\tfullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n\t\t\t\t}\n\n\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, fullCommand);\n\n\t\t\t\treturn {\n\t\t\t\t\tstdout,\n\t\t\t\t\tstderr,\n\t\t\t\t\texitCode,\n\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn {\n\t\t\t\t\tstdout: '',\n\t\t\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\texitCode: 127,\n\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t\t\tgetInfo: async (sandbox: SandboxInstance): Promise<SandboxInfo> => {\n\t\t\t\treturn {\n\t\t\t\t\tid: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\truntime: sandbox.spec?.runtime?.image?.includes('py') ? 'python' : 'node',\n\t\t\t\t\tstatus: convertSandboxStatus(sandbox.status),\n\t\t\t\t\tcreatedAt: sandbox.metadata?.createdAt ? new Date(sandbox.metadata.createdAt) : new Date(),\n\t\t\t\t\ttimeout: parseTTLToMilliseconds(sandbox.spec?.runtime?.ttl),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...sandbox.metadata?.labels\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\n\t\t\tgetUrl: async (sandbox: SandboxInstance, options: {\n\t\t\t\tport: number;\n\t\t\t\tttl?: number;\n\t\t\t\tprefixUrl?: string;\n\t\t\t\theaders?: {\n\t\t\t\t\tresponse?: Record<string, string>;\n\t\t\t\t\trequest?: Record<string, string>;\n\t\t\t\t};\n\t\t\t\tcustomDomain?: string;\n\t\t\t\tauthentication?: {\n\t\t\t\t\tpublic?: boolean;\n\t\t\t\t\ttokenExpiryMinutes?: number;\n\t\t\t\t};\n\t\t\t}): Promise<string> => {\n\t\t\t\ttry {\n\t\t\t\t\t// If public is not set, default to true\n\t\t\t\t\tconst isPublic = options.authentication?.public !== undefined ? options.authentication.public : true;\n\n\t\t\t\t\t// Default CORS headers for broad compatibility\n\t\t\t\t\tconst defaultHeaders = {\n\t\t\t\t\t\t\"Access-Control-Allow-Origin\": \"*\",\n\t\t\t\t\t\t\"Access-Control-Allow-Methods\": \"GET, POST, PUT, DELETE, OPTIONS, PATCH\",\n\t\t\t\t\t\t\"Access-Control-Allow-Headers\": \"Content-Type, Authorization, X-Requested-With, X-Blaxel-Preview-Token, X-Blaxel-Authorization\",\n\t\t\t\t\t\t\"Access-Control-Allow-Credentials\": \"true\",\n\t\t\t\t\t\t\"Access-Control-Expose-Headers\": \"Content-Length, X-Request-Id\",\n\t\t\t\t\t\t\"Access-Control-Max-Age\": \"86400\",\n\t\t\t\t\t\t\"Vary\": \"Origin\"\n\t\t\t\t\t};\n\n\t\t\t\t\t// Use custom headers if provided, otherwise use defaults\n\t\t\t\t\tconst responseHeaders = options.headers?.response || defaultHeaders;\n\n\t\t\t\t\t// Create or get existing preview URL using Blaxel's preview API\n\t\t\t\t\tconst preview = await sandbox.previews.createIfNotExists({\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tname: `preview-port-${options.port}-${isPublic ? 'public' : 'private'}`\n\t\t\t\t\t\t},\n\t\t\t\t\t\tspec: {\n\t\t\t\t\t\t\tport: options.port,\n\t\t\t\t\t\t\tpublic: isPublic,\n\t\t\t\t\t\t\tresponseHeaders,\n\t\t\t\t\t\t\trequestHeaders: options.headers?.request || defaultHeaders,\n\t\t\t\t\t\t\tcustomDomain: options.customDomain,\n\t\t\t\t\t\t\tprefixUrl: options.prefixUrl,\n\t\t\t\t\t\t\tttl: options.ttl ? `${Math.ceil(options.ttl / 1000)}s` : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// Get the preview URL\n\t\t\t\t\tconst url = preview.spec?.url;\n\t\t\t\t\tif (!url) {\n\t\t\t\t\t\tthrow new Error(`Failed to get preview URL for port ${options.port}`);\n\t\t\t\t\t}\n\n\t\t\t\t\t// For private previews, create an access token and append it to the URL\n\t\t\t\t\tif (!isPublic) {\n\t\t\t\t\t\t// Create token with specified expiry (default 60 minutes)\n\t\t\t\t\t\tconst expiryMinutes = options.authentication?.tokenExpiryMinutes || 60;\n\t\t\t\t\t\tconst expiresAt = new Date(Date.now() + expiryMinutes * 60 * 1000);\n\t\t\t\t\t\tconst token = await preview.tokens.create(expiresAt);\n\n\t\t\t\t\t\t// Return URL with token as query parameter\n\t\t\t\t\t\tconst separator = url.includes('?') ? '&' : '?';\n\t\t\t\t\t\treturn `${url}${separator}bl_preview_token=${token.value}`;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For public previews, just return the URL\n\t\t\t\t\treturn url;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to get Blaxel preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Optional filesystem methods - implement using Blaxel's filesystem API\n\t\t\tfilesystem: {\n\t\t\t\treadFile: async (sandbox: SandboxInstance, path: string): Promise<string> => {\n\t\t\t\t\tconst result = await sandbox.fs.read(path);\n\t\t\t\t\treturn result || '';\n\t\t\t\t},\n\n\t\t\t\twriteFile: async (sandbox: SandboxInstance, path: string, content: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.write(path, content);\n\t\t\t\t},\n\n\t\t\t\tmkdir: async (sandbox: SandboxInstance, path: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.mkdir(path);\n\t\t\t\t},\n\n\t\t\t\treaddir: async (sandbox: SandboxInstance, path: string): Promise<FileEntry[]> => {\n\t\t\t\t\tconst result = await sandbox.fs.ls(path);\n\t\t\t\t\tconst files = result.files || [];\n\t\t\t\t\tconst directories = result.subdirectories || [];\n\t\t\t\t\tlet entries = [];\n\t\t\t\t\tfor (const file of files) {\n\t\t\t\t\t\tentries.push({\n\t\t\t\t\t\t\tname: file.name,\n\t\t\t\t\t\t\ttype: 'file' as const,\n\t\t\t\t\t\t\tsize: file.size || 0,\n\t\t\t\t\t\t\tmodified: new Date(file.lastModified || Date.now())\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tfor (const directory of directories) {\n\t\t\t\t\t\tentries.push({\n\t\t\t\t\t\t\tname: directory.name,\n\t\t\t\t\t\t\ttype: 'directory' as const,\n\t\t\t\t\t\t\tsize: 0,\n\t\t\t\t\t\t\tmodified: new Date()\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn entries;\n\t\t\t\t},\n\n\t\t\t\texists: async (sandbox: SandboxInstance, path: string): Promise<boolean> => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait sandbox.fs.read(path);\n\t\t\t\t\t\treturn true; // It's a file and exists\n\t\t\t\t\t} catch {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait sandbox.fs.ls(path);\n\t\t\t\t\t\t\treturn true; // It's a directory and exists\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn false; // Path doesn't exist\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tremove: async (sandbox: SandboxInstance, path: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.rm(path);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Provider-specific typed getInstance method\n\t\t\tgetInstance: (sandbox: SandboxInstance): SandboxInstance => {\n\t\t\t\treturn sandbox;\n\t\t\t},\n\t\t},\n\n\t\tsnapshot: {\n\t\t\tcreate: async (config: BlaxelConfig, sandboxId: string, options?: { name?: string }) => {\n\t\t\t\t// Blaxel automatically snapshots on scale-down, but we can trigger a manual snapshot\n\t\t\t\t// by stopping the sandbox which saves its state\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\t\n\t\t\t\t\t// Get the sandbox to access its snapshot\n\t\t\t\t\tconst sandbox = await SandboxInstance.get(sandboxId);\n\t\t\t\t\t\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\tthrow new Error(`Sandbox ${sandboxId} not found`);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Return the current state as a snapshot\n\t\t\t\t\t// Blaxel's auto-snapshot on scale-down is the primary mechanism\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: sandboxId,\n\t\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tname: options?.name,\n\t\t\t\t\t\t\timage: sandbox.spec?.runtime?.image\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to create Blaxel snapshot: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tlist: async (config: BlaxelConfig) => {\n\t\t\t\t// Blaxel doesn't have a separate snapshot listing API\n\t\t\t\t// List sandboxes as they contain the snapshot state\n\t\t\t\tinitializeBlaxel(config);\n\t\t\t\tconst sandboxList = await SandboxInstance.list();\n\t\t\t\treturn sandboxList.map(sandbox => ({\n\t\t\t\t\tid: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\tcreatedAt: sandbox.metadata?.createdAt ? new Date(sandbox.metadata.createdAt) : new Date(),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\timage: sandbox.spec?.runtime?.image,\n\t\t\t\t\t\tstatus: sandbox.status\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t},\n\n\t\t\tdelete: async (config: BlaxelConfig, snapshotId: string) => {\n\t\t\t\t// Deleting a snapshot in Blaxel is just deleting the sandbox\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tawait SandboxInstance.delete(snapshotId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Ignore if not found\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Templates in Blaxel are pre-configured images\n\t\ttemplate: {\n\t\t\tcreate: async (_config: BlaxelConfig, _options: { name: string }) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel templates must be created via the Blaxel dashboard or CLI. Use image in sandbox.create() to specify a base image.`\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tlist: async (_config: BlaxelConfig) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel provider does not support listing templates via API. Use the dashboard to manage templates.`\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tdelete: async (_config: BlaxelConfig, _templateId: string) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel templates must be deleted via the Blaxel dashboard or CLI.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n});\n\n/**\n * Parse TTL value from Blaxel's format to milliseconds\n * Supports formats like \"30m\", \"24h\", \"7d\" or plain numbers (seconds)\n */\nfunction parseTTLToMilliseconds(ttl: string | number | undefined): number {\n\tif (!ttl) return 300000; // Default to 5 minutes\n\n\t// If it's already a number, treat it as seconds and convert to milliseconds\n\tif (typeof ttl === 'number') {\n\t\treturn ttl * 1000;\n\t}\n\n\t// Parse string formats like \"30m\", \"24h\", \"7d\"\n\tconst match = ttl.match(/^(\\d+)([smhd])?$/);\n\tif (!match) return 300000; // Default if format is invalid\n\n\tconst value = parseInt(match[1], 10);\n\tconst unit = match[2] || 's'; // Default to seconds if no unit\n\n\tswitch (unit) {\n\t\tcase 's': return value * 1000; // seconds to ms\n\t\tcase 'm': return value * 60 * 1000; // minutes to ms\n\t\tcase 'h': return value * 60 * 60 * 1000; // hours to ms\n\t\tcase 'd': return value * 24 * 60 * 60 * 1000; // days to ms\n\t\tdefault: return 300000; // Default fallback\n\t}\n}\n\n/**\n * Initialize the Blaxel SDK with credentials from config or environment variables\n */\nfunction initializeBlaxel(config: BlaxelConfig): void {\n\tconst apiKey = config.apiKey || process.env?.BL_API_KEY!;\n\tconst workspace = config.workspace || process.env?.BL_WORKSPACE!;\n\tinitialize({ apikey: apiKey, workspace: workspace });\n}\n\nfunction convertSandboxStatus(status: string | undefined): 'running' | 'stopped' | 'error' {\n\tswitch (status?.toLowerCase()) {\n\t\tcase 'deployed': return 'running';\n\t\tcase 'deleting': return 'stopped';\n\t\tcase 'failed': return 'error';\n\t\tdefault: return 'running';\n\t}\n}\n\n/**\n * Execute a command in the sandbox and capture stdout/stderr\n * Handles the common pattern of executing, streaming logs, and waiting for completion\n */\nasync function executeWithStreaming(\n\tsandbox: SandboxInstance,\n\tcommand: string\n): Promise<{ stdout: string; stderr: string; exitCode: number }> {\n\t// Execute the command\n\tconst processResult = await sandbox.process.exec({\n\t\tcommand,\n\t\twaitForCompletion: true,\n\t});\n\t// Handle union type - ProcessResponseWithLog has stdout/stderr\n\tconst result = processResult as { stdout?: string; stderr?: string; exitCode?: number };\n\treturn {\n\t\tstdout: result.stdout || '',\n\t\tstderr: result.stderr || '',\n\t\texitCode: result.exitCode || 0,\n\t};\n}\n\n// Export the Blaxel SandboxInstance type for explicit typing\nexport type { SandboxInstance as BlaxelSandbox } from '@blaxel/core';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,kBAA4C;AAC5C,sBAA+C;AAyBxC,IAAM,aAAS,gCAAwD;AAAA,EAC7E,MAAM;AAAA,EACN,SAAS;AAAA,IACR,SAAS;AAAA;AAAA,MAER,QAAQ,OAAO,QAAsB,YAAmC;AAEvE,cAAM;AAAA,UACL,SAAS;AAAA,UACT,SAAS;AAAA,UACT;AAAA,UACA,MAAM;AAAA,UACN;AAAA,UACA,YAAY;AAAA,UACZ;AAAA,UACA,WAAW;AAAA,UACX,WAAW;AAAA,UACX,WAAW;AAAA,UACX,GAAG;AAAA,QACJ,IAAI,WAAW,CAAC;AAGhB,YAAI,QAAQ,OAAO,SAAS;AAG5B,YAAI,CAAC,OAAO,SAAS,YAAY;AAChC,kBAAQ,YAAY;AAAA,YACnB,KAAK;AACJ,sBAAQ;AACR;AAAA,YACD,KAAK;AACJ,sBAAQ;AACR;AAAA,YACD;AACC,sBAAQ;AACR;AAAA,UACF;AAAA,QACD;AACA,cAAM,SAAS,OAAO;AACtB,cAAM,SAAS,OAAO;AACtB,cAAM,MAAM,aAAa,GAAG,KAAK,KAAK,aAAa,GAAI,CAAC,MAAM;AAE/D,YAAI;AAEH,2BAAiB,MAAM;AAEvB,cAAI;AAGJ,gBAAM,aAAa,gBAAgB;AAEnC,cAAI,YAAY;AAEf,sBAAU,MAAM,4BAAgB,IAAI,UAAU;AAC9C,gBAAI,CAAC,SAAS;AACb,oBAAM,IAAI,MAAM,WAAW,UAAU,YAAY;AAAA,YAClD;AAAA,UACD,OAAO;AAEN,sBAAU,MAAM,4BAAgB,kBAAkB;AAAA,cACj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O,QAAQ,KAAK;AAAA;AAAA,IAC9B,KAAK;AAAK,aAAO,QAAQ,KAAK,KAAK;AAAA;AAAA,IACnC,KAAK;AAAK,aAAO,QAAQ,KAAK,KAAK,KAAK;AAAA;AAAA,IACxC;AAAS,aAAO;AAAA,EACjB;AACD;AAKA,SAAS,iBAAiB,QAA4B;AACrD,QAAM,SAAS,OAAO,UAAU,QAAQ,KAAK;AAC7C,QAAM,YAAY,OAAO,aAAa,QAAQ,KAAK;AACnD,8BAAW,EAAE,QAAQ,QAAQ,UAAqB,CAAC;AACpD;AAEA,SAAS,qBAAqB,QAA6D;AAC1F,UAAQ,QAAQ,YAAY,GAAG;AAAA,IAC9B,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAU,aAAO;AAAA,IACtB;AAAS,aAAO;AAAA,EACjB;AACD;AAMA,eAAe,qBACd,SACA,SACgE;AAEhE,QAAM,gBAAgB,MAAM,QAAQ,QAAQ,KAAK;AAAA,IAChD;AAAA,IACA,mBAAmB;AAAA,EACpB,CAAC;AAED,QAAM,SAAS;AACf,SAAO;AAAA,IACN,QAAQ,OAAO,UAAU;AAAA,IACzB,QAAQ,OAAO,UAAU;AAAA,IACzB,UAAU,OAAO,YAAY;AAAA,EAC9B;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Blaxel Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n */\n\nimport { SandboxInstance, initialize } from '@blaxel/core';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions, CreateSnapshotOptions, ListSnapshotsOptions } from '@computesdk/provider';\n\n/**\n * Blaxel-specific configuration options\n */\nexport interface BlaxelConfig {\n\t/** Blaxel workspace ID - if not provided, will fallback to BL_WORKSPACE environment variable */\n\tworkspace?: string;\n\t/** Blaxel API key - if not provided, will fallback to BL_API_KEY environment variable */\n\tapiKey?: string;\n\t/** Default image for sandboxes */\n\timage?: string;\n\t/** Default region for sandbox deployment */\n\tregion?: string;\n\t/** Default memory allocation in MB */\n\tmemory?: number | 4096;\n\t/** Default ports for sandbox */\n\tports?: number[] | [3000];\n}\n\n/**\n * Create a Blaxel provider instance using the factory pattern\n */\nexport const blaxel = defineProvider<SandboxInstance, BlaxelConfig, any, any>({\n\tname: 'blaxel',\n\tmethods: {\n\t\tsandbox: {\n\t\t\t// Collection operations (map to compute.sandbox.*)\n\t\t\tcreate: async (config: BlaxelConfig, options?: CreateSandboxOptions) => {\n\t\t\t\t// Destructure known ComputeSDK fields, collect the rest for passthrough\n\t\t\t\tconst {\n\t\t\t\t\ttimeout: optTimeout,\n\t\t\t\t\tenvs,\n\t\t\t\t\tname: _name,\n\t\t\t\t\tmetadata,\n\t\t\t\t\ttemplateId: _templateId,\n\t\t\t\t\tsnapshotId,\n\t\t\t\t\tsandboxId: optSandboxId,\n\t\t\t\t\tnamespace: _namespace,\n\t\t\t\t\tdirectory: _directory,\n\t\t\t\t\t...providerOptions\n\t\t\t\t} = options || {};\n\n\t\t\t\tconst optRuntime = (options as any)?.runtime as string | undefined;\n\n\t\t\t\t// Determine the image to use\n\t\t\t\tlet image = config.image || 'blaxel/base-image:latest'; // Default to prod-base\n\n\t\t\t\t// Override with runtime-specific image if runtime is specified and no explicit image\n\t\t\t\tif (!config.image && optRuntime) {\n\t\t\t\t\tswitch (optRuntime) {\n\t\t\t\t\t\tcase 'python':\n\t\t\t\t\t\t\timage = 'blaxel/py-app:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'node':\n\t\t\t\t\t\t\timage = 'blaxel/ts-app:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\timage = 'blaxel/base-image:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst memory = config.memory;\n\t\t\t\tconst region = config.region;\n\t\t\t\tconst ttl = optTimeout ? `${Math.ceil(optTimeout / 1000)}s` : undefined;\n\n\t\t\ttry {\n\t\t\t\t// Initialize Blaxel SDK with credentials\n\t\t\t\tinitializeBlaxel(config);\n\n\t\t\t\tlet sandbox: SandboxInstance;\n\n\t\t\t\t// Check if we should resume an existing sandbox or create new\n\t\t\t\tconst existingId = optSandboxId || snapshotId;\n\t\t\t\t\n\t\t\t\tif (existingId) {\n\t\t\t\t\t// Resume existing sandbox or snapshot\n\t\t\t\t\tsandbox = await SandboxInstance.get(existingId);\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\tthrow new Error(`Sandbox ${existingId} not found`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Create new Blaxel sandbox\n\t\t\t\t\tsandbox = await SandboxInstance.createIfNotExists({\n\t\t\t\t\t\timage,\n\t\t\t\t\t\tmemory,\n\t\t\t\t\t\tenvs: Object.entries(envs || {}).map(([name, value]) => ({ name, value: value as string })),\n\t\t\t\t\t\t...(metadata?.labels && { labels: metadata.labels }),\n\t\t\t\t\t\tttl,\n\t\t\t\t\t\tports: config.ports?.map(port => ({ target: port, protocol: 'HTTP' })),\n\t\t\t\t\t\t...(region && { region }),\n\t\t\t\t\t\t...providerOptions, // Spread provider-specific options\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tsandbox,\n\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\t\tconst errorDetail = error instanceof Error\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: typeof error === 'object' && error !== null\n\t\t\t\t\t\t\t? JSON.stringify(error)\n\t\t\t\t\t\t\t: String(error);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\terrorDetail.includes('unauthorized') ||\n\t\t\t\t\t\terrorDetail.includes('Unauthorized') ||\n\t\t\t\t\t\terrorDetail.includes('Forbidden') ||\n\t\t\t\t\t\terrorDetail.includes('API key')\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Blaxel authentication failed: ${errorDetail}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (errorDetail.includes('quota') || errorDetail.includes('limit')) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Blaxel quota exceeded: ${errorDetail}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to create Blaxel sandbox: ${errorDetail}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tgetById: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tconst sandbox = await SandboxInstance.get(sandboxId);\n\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsandbox,\n\t\t\t\t\t\tsandboxId,\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Sandbox doesn't exist or can't be accessed\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tlist: async (config: BlaxelConfig) => {\n\t\t\t\tinitializeBlaxel(config);\n\t\t\t\tconst sandboxList = await SandboxInstance.list();\n\t\t\t\treturn sandboxList.map(sandbox => ({\n\t\t\t\t\tsandbox,\n\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown'\n\t\t\t\t}));\n\t\t\t},\n\n\t\t\tdestroy: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tawait SandboxInstance.delete(sandboxId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Sandbox might already be destroyed or doesn't exist\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Instance operations (map to individual Sandbox methods)\n\t\trunCommand: async (sandbox: SandboxInstance, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n\t\t\tconst startTime = Date.now();\n\n\t\t\ttry {\n\t\t\t\t// Build command with options\n\t\t\t\tlet fullCommand = command;\n\t\t\t\t\n\t\t\t\t// Handle environment variables\n\t\t\t\tif (options?.env && Object.keys(options.env).length > 0) {\n\t\t\t\t\tconst envPrefix = Object.entries(options.env)\n\t\t\t\t\t\t.map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n\t\t\t\t\t\t.join(' ');\n\t\t\t\t\tfullCommand = `${envPrefix} ${fullCommand}`;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Handle working directory\n\t\t\t\tif (options?.cwd) {\n\t\t\t\t\tfullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Handle background execution\n\t\t\t\tif (options?.background) {\n\t\t\t\t\tfullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n\t\t\t\t}\n\n\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, fullCommand);\n\n\t\t\t\treturn {\n\t\t\t\t\tstdout,\n\t\t\t\t\tstderr,\n\t\t\t\t\texitCode,\n\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn {\n\t\t\t\t\tstdout: '',\n\t\t\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\texitCode: 127,\n\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t\t\tgetInfo: async (sandbox: SandboxInstance): Promise<SandboxInfo> => {\n\t\t\t\tconst runtime = sandbox.spec?.runtime?.image?.includes('py') ? 'python' : 'node';\n\t\t\t\treturn {\n\t\t\t\t\tid: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\tstatus: convertSandboxStatus(sandbox.status),\n\t\t\t\t\tcreatedAt: sandbox.metadata?.createdAt ? new Date(sandbox.metadata.createdAt) : new Date(),\n\t\t\t\t\ttimeout: parseTTLToMilliseconds(sandbox.spec?.runtime?.ttl),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\truntime,\n\t\t\t\t\t\t...sandbox.metadata?.labels\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\n\t\t\tgetUrl: async (sandbox: SandboxInstance, options: {\n\t\t\t\tport: number;\n\t\t\t\tttl?: number;\n\t\t\t\tprefixUrl?: string;\n\t\t\t\theaders?: {\n\t\t\t\t\tresponse?: Record<string, string>;\n\t\t\t\t\trequest?: Record<string, string>;\n\t\t\t\t};\n\t\t\t\tcustomDomain?: string;\n\t\t\t\tauthentication?: {\n\t\t\t\t\tpublic?: boolean;\n\t\t\t\t\ttokenExpiryMinutes?: number;\n\t\t\t\t};\n\t\t\t}): Promise<string> => {\n\t\t\t\ttry {\n\t\t\t\t\t// If public is not set, default to true\n\t\t\t\t\tconst isPublic = options.authentication?.public !== undefined ? options.authentication.public : true;\n\n\t\t\t\t\t// Default CORS headers for broad compatibility\n\t\t\t\t\tconst defaultHeaders = {\n\t\t\t\t\t\t\"Access-Control-Allow-Origin\": \"*\",\n\t\t\t\t\t\t\"Access-Control-Allow-Methods\": \"GET, POST, PUT, DELETE, OPTIONS, PATCH\",\n\t\t\t\t\t\t\"Access-Control-Allow-Headers\": \"Content-Type, Authorization, X-Requested-With, X-Blaxel-Preview-Token, X-Blaxel-Authorization\",\n\t\t\t\t\t\t\"Access-Control-Allow-Credentials\": \"true\",\n\t\t\t\t\t\t\"Access-Control-Expose-Headers\": \"Content-Length, X-Request-Id\",\n\t\t\t\t\t\t\"Access-Control-Max-Age\": \"86400\",\n\t\t\t\t\t\t\"Vary\": \"Origin\"\n\t\t\t\t\t};\n\n\t\t\t\t\t// Use custom headers if provided, otherwise use defaults\n\t\t\t\t\tconst responseHeaders = options.headers?.response || defaultHeaders;\n\n\t\t\t\t\t// Create or get existing preview URL using Blaxel's preview API\n\t\t\t\t\tconst preview = await sandbox.previews.createIfNotExists({\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tname: `preview-port-${options.port}-${isPublic ? 'public' : 'private'}`\n\t\t\t\t\t\t},\n\t\t\t\t\t\tspec: {\n\t\t\t\t\t\t\tport: options.port,\n\t\t\t\t\t\t\tpublic: isPublic,\n\t\t\t\t\t\t\tresponseHeaders,\n\t\t\t\t\t\t\trequestHeaders: options.headers?.request || defaultHeaders,\n\t\t\t\t\t\t\tcustomDomain: options.customDomain,\n\t\t\t\t\t\t\tprefixUrl: options.prefixUrl,\n\t\t\t\t\t\t\tttl: options.ttl ? `${Math.ceil(options.ttl / 1000)}s` : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// Get the preview URL\n\t\t\t\t\tconst url = preview.spec?.url;\n\t\t\t\t\tif (!url) {\n\t\t\t\t\t\tthrow new Error(`Failed to get preview URL for port ${options.port}`);\n\t\t\t\t\t}\n\n\t\t\t\t\t// For private previews, create an access token and append it to the URL\n\t\t\t\t\tif (!isPublic) {\n\t\t\t\t\t\t// Create token with specified expiry (default 60 minutes)\n\t\t\t\t\t\tconst expiryMinutes = options.authentication?.tokenExpiryMinutes || 60;\n\t\t\t\t\t\tconst expiresAt = new Date(Date.now() + expiryMinutes * 60 * 1000);\n\t\t\t\t\t\tconst token = await preview.tokens.create(expiresAt);\n\n\t\t\t\t\t\t// Return URL with token as query parameter\n\t\t\t\t\t\tconst separator = url.includes('?') ? '&' : '?';\n\t\t\t\t\t\treturn `${url}${separator}bl_preview_token=${token.value}`;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For public previews, just return the URL\n\t\t\t\t\treturn url;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to get Blaxel preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Optional filesystem methods - implement using Blaxel's filesystem API\n\t\t\tfilesystem: {\n\t\t\t\treadFile: async (sandbox: SandboxInstance, path: string): Promise<string> => {\n\t\t\t\t\tconst result = await sandbox.fs.read(path);\n\t\t\t\t\treturn result || '';\n\t\t\t\t},\n\n\t\t\t\twriteFile: async (sandbox: SandboxInstance, path: string, content: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.write(path, content);\n\t\t\t\t},\n\n\t\t\t\tmkdir: async (sandbox: SandboxInstance, path: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.mkdir(path);\n\t\t\t\t},\n\n\t\t\t\treaddir: async (sandbox: SandboxInstance, path: string): Promise<FileEntry[]> => {\n\t\t\t\t\tconst result = await sandbox.fs.ls(path);\n\t\t\t\t\tconst files = result.files || [];\n\t\t\t\t\tconst directories = result.subdirectories || [];\n\t\t\t\t\tlet entries = [];\n\t\t\t\t\tfor (const file of files) {\n\t\t\t\t\t\tentries.push({\n\t\t\t\t\t\t\tname: file.name,\n\t\t\t\t\t\t\ttype: 'file' as const,\n\t\t\t\t\t\t\tsize: file.size || 0,\n\t\t\t\t\t\t\tmodified: new Date(file.lastModified || Date.now())\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tfor (const directory of directories) {\n\t\t\t\t\t\tentries.push({\n\t\t\t\t\t\t\tname: directory.name,\n\t\t\t\t\t\t\ttype: 'directory' as const,\n\t\t\t\t\t\t\tsize: 0,\n\t\t\t\t\t\t\tmodified: new Date()\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn entries;\n\t\t\t\t},\n\n\t\t\t\texists: async (sandbox: SandboxInstance, path: string): Promise<boolean> => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait sandbox.fs.read(path);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait sandbox.fs.ls(path);\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tremove: async (sandbox: SandboxInstance, path: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.rm(path);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Provider-specific typed getInstance method\n\t\t\tgetInstance: (sandbox: SandboxInstance): SandboxInstance => {\n\t\t\t\treturn sandbox;\n\t\t\t},\n\t\t},\n\n\t\tsnapshot: {\n\t\t\tcreate: async (config: BlaxelConfig, sandboxId: string, options?: { name?: string }) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\t\n\t\t\t\t\tconst sandbox = await SandboxInstance.get(sandboxId);\n\t\t\t\t\t\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\tthrow new Error(`Sandbox ${sandboxId} not found`);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: sandboxId,\n\t\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tname: options?.name,\n\t\t\t\t\t\t\timage: sandbox.spec?.runtime?.image\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to create Blaxel snapshot: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tlist: async (config: BlaxelConfig) => {\n\t\t\t\tinitializeBlaxel(config);\n\t\t\t\tconst sandboxList = await SandboxInstance.list();\n\t\t\t\treturn sandboxList.map(sandbox => ({\n\t\t\t\t\tid: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\tcreatedAt: sandbox.metadata?.createdAt ? new Date(sandbox.metadata.createdAt) : new Date(),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\timage: sandbox.spec?.runtime?.image,\n\t\t\t\t\t\tstatus: sandbox.status\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t},\n\n\t\t\tdelete: async (config: BlaxelConfig, snapshotId: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tawait SandboxInstance.delete(snapshotId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Ignore if not found\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Templates in Blaxel are pre-configured images\n\t\ttemplate: {\n\t\t\tcreate: async (_config: BlaxelConfig, _options: { name: string }) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel templates must be created via the Blaxel dashboard or CLI. Use image in sandbox.create() to specify a base image.`\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tlist: async (_config: BlaxelConfig) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel provider does not support listing templates via API. Use the dashboard to manage templates.`\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tdelete: async (_config: BlaxelConfig, _templateId: string) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel templates must be deleted via the Blaxel dashboard or CLI.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n});\n\n/**\n * Parse TTL value from Blaxel's format to milliseconds\n */\nfunction parseTTLToMilliseconds(ttl: string | number | undefined): number {\n\tif (!ttl) return 300000;\n\tif (typeof ttl === 'number') return ttl * 1000;\n\tconst match = ttl.match(/^(\\d+)([smhd])?$/);\n\tif (!match) return 300000;\n\tconst value = parseInt(match[1], 10);\n\tconst unit = match[2] || 's';\n\tswitch (unit) {\n\t\tcase 's': return value * 1000;\n\t\tcase 'm': return value * 60 * 1000;\n\t\tcase 'h': return value * 60 * 60 * 1000;\n\t\tcase 'd': return value * 24 * 60 * 60 * 1000;\n\t\tdefault: return 300000;\n\t}\n}\n\n/**\n * Initialize the Blaxel SDK with credentials from config or environment variables\n */\nfunction initializeBlaxel(config: BlaxelConfig): void {\n\tconst apiKey = config.apiKey || process.env?.BL_API_KEY!;\n\tconst workspace = config.workspace || process.env?.BL_WORKSPACE!;\n\tinitialize({ apikey: apiKey, workspace: workspace });\n}\n\nfunction convertSandboxStatus(status: string | undefined): 'running' | 'stopped' | 'error' {\n\tswitch (status?.toLowerCase()) {\n\t\tcase 'deployed': return 'running';\n\t\tcase 'deleting': return 'stopped';\n\t\tcase 'failed': return 'error';\n\t\tdefault: return 'running';\n\t}\n}\n\n/**\n * Execute a command in the sandbox and capture stdout/stderr\n */\nasync function executeWithStreaming(\n\tsandbox: SandboxInstance,\n\tcommand: string\n): Promise<{ stdout: string; stderr: string; exitCode: number }> {\n\tconst processResult = await sandbox.process.exec({\n\t\tcommand,\n\t\twaitForCompletion: true,\n\t});\n\tconst result = processResult as { stdout?: string; stderr?: string; exitCode?: number };\n\treturn {\n\t\tstdout: result.stdout || '',\n\t\tstderr: result.stderr || '',\n\t\texitCode: result.exitCode || 0,\n\t};\n}\n\n// Export the Blaxel SandboxInstance type for explicit typing\nexport type { SandboxInstance as BlaxelSandbox } from '@blaxel/core';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,kBAA4C;AAC5C,sBAA+C;AAyBxC,IAAM,aAAS,gCAAwD;AAAA,EAC7E,MAAM;AAAA,EACN,SAAS;AAAA,IACR,SAAS;AAAA;AAAA,MAER,QAAQ,OAAO,QAAsB,YAAmC;AAEvE,cAAM;AAAA,UACL,SAAS;AAAA,UACT;AAAA,UACA,MAAM;AAAA,UACN;AAAA,UACA,YAAY;AAAA,UACZ;AAAA,UACA,WAAW;AAAA,UACX,WAAW;AAAA,UACX,WAAW;AAAA,UACX,GAAG;AAAA,QACJ,IAAI,WAAW,CA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AAA,IACA,mBAAmB;AAAA,EACpB,CAAC;AACD,QAAM,SAAS;AACf,SAAO;AAAA,IACN,QAAQ,OAAO,UAAU;AAAA,IACzB,QAAQ,OAAO,UAAU;AAAA,IACzB,UAAU,OAAO,YAAY;AAAA,EAC9B;AACD;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,6 @@ var blaxel = defineProvider({
|
|
|
8
8
|
// Collection operations (map to compute.sandbox.*)
|
|
9
9
|
create: async (config, options) => {
|
|
10
10
|
const {
|
|
11
|
-
runtime: optRuntime,
|
|
12
11
|
timeout: optTimeout,
|
|
13
12
|
envs,
|
|
14
13
|
name: _name,
|
|
@@ -20,6 +19,7 @@ var blaxel = defineProvider({
|
|
|
20
19
|
directory: _directory,
|
|
21
20
|
...providerOptions
|
|
22
21
|
} = options || {};
|
|
22
|
+
const optRuntime = options?.runtime;
|
|
23
23
|
let image = config.image || "blaxel/base-image:latest";
|
|
24
24
|
if (!config.image && optRuntime) {
|
|
25
25
|
switch (optRuntime) {
|
|
@@ -142,14 +142,15 @@ var blaxel = defineProvider({
|
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
144
|
getInfo: async (sandbox) => {
|
|
145
|
+
const runtime = sandbox.spec?.runtime?.image?.includes("py") ? "python" : "node";
|
|
145
146
|
return {
|
|
146
147
|
id: sandbox.metadata?.name || "blaxel-unknown",
|
|
147
148
|
provider: "blaxel",
|
|
148
|
-
runtime: sandbox.spec?.runtime?.image?.includes("py") ? "python" : "node",
|
|
149
149
|
status: convertSandboxStatus(sandbox.status),
|
|
150
150
|
createdAt: sandbox.metadata?.createdAt ? new Date(sandbox.metadata.createdAt) : /* @__PURE__ */ new Date(),
|
|
151
151
|
timeout: parseTTLToMilliseconds(sandbox.spec?.runtime?.ttl),
|
|
152
152
|
metadata: {
|
|
153
|
+
runtime,
|
|
153
154
|
...sandbox.metadata?.labels
|
|
154
155
|
}
|
|
155
156
|
};
|
|
@@ -322,9 +323,7 @@ var blaxel = defineProvider({
|
|
|
322
323
|
});
|
|
323
324
|
function parseTTLToMilliseconds(ttl) {
|
|
324
325
|
if (!ttl) return 3e5;
|
|
325
|
-
if (typeof ttl === "number")
|
|
326
|
-
return ttl * 1e3;
|
|
327
|
-
}
|
|
326
|
+
if (typeof ttl === "number") return ttl * 1e3;
|
|
328
327
|
const match = ttl.match(/^(\d+)([smhd])?$/);
|
|
329
328
|
if (!match) return 3e5;
|
|
330
329
|
const value = parseInt(match[1], 10);
|
|
@@ -332,16 +331,12 @@ function parseTTLToMilliseconds(ttl) {
|
|
|
332
331
|
switch (unit) {
|
|
333
332
|
case "s":
|
|
334
333
|
return value * 1e3;
|
|
335
|
-
// seconds to ms
|
|
336
334
|
case "m":
|
|
337
335
|
return value * 60 * 1e3;
|
|
338
|
-
// minutes to ms
|
|
339
336
|
case "h":
|
|
340
337
|
return value * 60 * 60 * 1e3;
|
|
341
|
-
// hours to ms
|
|
342
338
|
case "d":
|
|
343
339
|
return value * 24 * 60 * 60 * 1e3;
|
|
344
|
-
// days to ms
|
|
345
340
|
default:
|
|
346
341
|
return 3e5;
|
|
347
342
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Blaxel Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n */\n\nimport { SandboxInstance, initialize } from '@blaxel/core';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions, CreateSnapshotOptions, ListSnapshotsOptions } from '@computesdk/provider';\n\n/**\n * Blaxel-specific configuration options\n */\nexport interface BlaxelConfig {\n\t/** Blaxel workspace ID - if not provided, will fallback to BL_WORKSPACE environment variable */\n\tworkspace?: string;\n\t/** Blaxel API key - if not provided, will fallback to BL_API_KEY environment variable */\n\tapiKey?: string;\n\t/** Default image for sandboxes */\n\timage?: string;\n\t/** Default region for sandbox deployment */\n\tregion?: string;\n\t/** Default memory allocation in MB */\n\tmemory?: number | 4096;\n\t/** Default ports for sandbox */\n\tports?: number[] | [3000];\n}\n\n/**\n * Create a Blaxel provider instance using the factory pattern\n */\nexport const blaxel = defineProvider<SandboxInstance, BlaxelConfig, any, any>({\n\tname: 'blaxel',\n\tmethods: {\n\t\tsandbox: {\n\t\t\t// Collection operations (map to compute.sandbox.*)\n\t\t\tcreate: async (config: BlaxelConfig, options?: CreateSandboxOptions) => {\n\t\t\t\t// Destructure known ComputeSDK fields, collect the rest for passthrough\n\t\t\t\tconst {\n\t\t\t\t\truntime: optRuntime,\n\t\t\t\t\ttimeout: optTimeout,\n\t\t\t\t\tenvs,\n\t\t\t\t\tname: _name,\n\t\t\t\t\tmetadata,\n\t\t\t\t\ttemplateId: _templateId,\n\t\t\t\t\tsnapshotId,\n\t\t\t\t\tsandboxId: optSandboxId,\n\t\t\t\t\tnamespace: _namespace,\n\t\t\t\t\tdirectory: _directory,\n\t\t\t\t\t...providerOptions\n\t\t\t\t} = options || {};\n\n\t\t\t\t// Determine the image to use\n\t\t\t\tlet image = config.image || 'blaxel/base-image:latest'; // Default to prod-base\n\n\t\t\t\t// Override with runtime-specific image if runtime is specified and no explicit image\n\t\t\t\tif (!config.image && optRuntime) {\n\t\t\t\t\tswitch (optRuntime) {\n\t\t\t\t\t\tcase 'python':\n\t\t\t\t\t\t\timage = 'blaxel/py-app:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'node':\n\t\t\t\t\t\t\timage = 'blaxel/ts-app:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\timage = 'blaxel/base-image:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst memory = config.memory;\n\t\t\t\tconst region = config.region;\n\t\t\t\tconst ttl = optTimeout ? `${Math.ceil(optTimeout / 1000)}s` : undefined;\n\n\t\t\ttry {\n\t\t\t\t// Initialize Blaxel SDK with credentials\n\t\t\t\tinitializeBlaxel(config);\n\n\t\t\t\tlet sandbox: SandboxInstance;\n\n\t\t\t\t// Check if we should resume an existing sandbox or create new\n\t\t\t\tconst existingId = optSandboxId || snapshotId;\n\t\t\t\t\n\t\t\t\tif (existingId) {\n\t\t\t\t\t// Resume existing sandbox or snapshot\n\t\t\t\t\tsandbox = await SandboxInstance.get(existingId);\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\tthrow new Error(`Sandbox ${existingId} not found`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Create new Blaxel sandbox\n\t\t\t\t\tsandbox = await SandboxInstance.createIfNotExists({\n\t\t\t\t\t\timage,\n\t\t\t\t\t\tmemory,\n\t\t\t\t\t\tenvs: Object.entries(envs || {}).map(([name, value]) => ({ name, value: value as string })),\n\t\t\t\t\t\t...(metadata?.labels && { labels: metadata.labels }),\n\t\t\t\t\t\tttl,\n\t\t\t\t\t\tports: config.ports?.map(port => ({ target: port, protocol: 'HTTP' })),\n\t\t\t\t\t\t...(region && { region }),\n\t\t\t\t\t\t...providerOptions, // Spread provider-specific options\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tsandbox,\n\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\t\tconst errorDetail = error instanceof Error\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: typeof error === 'object' && error !== null\n\t\t\t\t\t\t\t? JSON.stringify(error)\n\t\t\t\t\t\t\t: String(error);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\terrorDetail.includes('unauthorized') ||\n\t\t\t\t\t\terrorDetail.includes('Unauthorized') ||\n\t\t\t\t\t\terrorDetail.includes('Forbidden') ||\n\t\t\t\t\t\terrorDetail.includes('API key')\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Blaxel authentication failed: ${errorDetail}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (errorDetail.includes('quota') || errorDetail.includes('limit')) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Blaxel quota exceeded: ${errorDetail}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to create Blaxel sandbox: ${errorDetail}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tgetById: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tconst sandbox = await SandboxInstance.get(sandboxId);\n\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsandbox,\n\t\t\t\t\t\tsandboxId,\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Sandbox doesn't exist or can't be accessed\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tlist: async (config: BlaxelConfig) => {\n\t\t\t\tinitializeBlaxel(config);\n\t\t\t\tconst sandboxList = await SandboxInstance.list();\n\t\t\t\treturn sandboxList.map(sandbox => ({\n\t\t\t\t\tsandbox,\n\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown'\n\t\t\t\t}));\n\t\t\t},\n\n\t\t\tdestroy: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tawait SandboxInstance.delete(sandboxId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Sandbox might already be destroyed or doesn't exist\n\t\t\t\t\t// This is acceptable for destroy operations\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Instance operations (map to individual Sandbox methods)\n\t\trunCommand: async (sandbox: SandboxInstance, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n\t\t\tconst startTime = Date.now();\n\n\t\t\ttry {\n\t\t\t\t// Build command with options\n\t\t\t\tlet fullCommand = command;\n\t\t\t\t\n\t\t\t\t// Handle environment variables\n\t\t\t\tif (options?.env && Object.keys(options.env).length > 0) {\n\t\t\t\t\tconst envPrefix = Object.entries(options.env)\n\t\t\t\t\t\t.map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n\t\t\t\t\t\t.join(' ');\n\t\t\t\t\tfullCommand = `${envPrefix} ${fullCommand}`;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Handle working directory\n\t\t\t\tif (options?.cwd) {\n\t\t\t\t\tfullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Handle background execution\n\t\t\t\tif (options?.background) {\n\t\t\t\t\tfullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n\t\t\t\t}\n\n\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, fullCommand);\n\n\t\t\t\treturn {\n\t\t\t\t\tstdout,\n\t\t\t\t\tstderr,\n\t\t\t\t\texitCode,\n\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn {\n\t\t\t\t\tstdout: '',\n\t\t\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\texitCode: 127,\n\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t\t\tgetInfo: async (sandbox: SandboxInstance): Promise<SandboxInfo> => {\n\t\t\t\treturn {\n\t\t\t\t\tid: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\truntime: sandbox.spec?.runtime?.image?.includes('py') ? 'python' : 'node',\n\t\t\t\t\tstatus: convertSandboxStatus(sandbox.status),\n\t\t\t\t\tcreatedAt: sandbox.metadata?.createdAt ? new Date(sandbox.metadata.createdAt) : new Date(),\n\t\t\t\t\ttimeout: parseTTLToMilliseconds(sandbox.spec?.runtime?.ttl),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...sandbox.metadata?.labels\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\n\t\t\tgetUrl: async (sandbox: SandboxInstance, options: {\n\t\t\t\tport: number;\n\t\t\t\tttl?: number;\n\t\t\t\tprefixUrl?: string;\n\t\t\t\theaders?: {\n\t\t\t\t\tresponse?: Record<string, string>;\n\t\t\t\t\trequest?: Record<string, string>;\n\t\t\t\t};\n\t\t\t\tcustomDomain?: string;\n\t\t\t\tauthentication?: {\n\t\t\t\t\tpublic?: boolean;\n\t\t\t\t\ttokenExpiryMinutes?: number;\n\t\t\t\t};\n\t\t\t}): Promise<string> => {\n\t\t\t\ttry {\n\t\t\t\t\t// If public is not set, default to true\n\t\t\t\t\tconst isPublic = options.authentication?.public !== undefined ? options.authentication.public : true;\n\n\t\t\t\t\t// Default CORS headers for broad compatibility\n\t\t\t\t\tconst defaultHeaders = {\n\t\t\t\t\t\t\"Access-Control-Allow-Origin\": \"*\",\n\t\t\t\t\t\t\"Access-Control-Allow-Methods\": \"GET, POST, PUT, DELETE, OPTIONS, PATCH\",\n\t\t\t\t\t\t\"Access-Control-Allow-Headers\": \"Content-Type, Authorization, X-Requested-With, X-Blaxel-Preview-Token, X-Blaxel-Authorization\",\n\t\t\t\t\t\t\"Access-Control-Allow-Credentials\": \"true\",\n\t\t\t\t\t\t\"Access-Control-Expose-Headers\": \"Content-Length, X-Request-Id\",\n\t\t\t\t\t\t\"Access-Control-Max-Age\": \"86400\",\n\t\t\t\t\t\t\"Vary\": \"Origin\"\n\t\t\t\t\t};\n\n\t\t\t\t\t// Use custom headers if provided, otherwise use defaults\n\t\t\t\t\tconst responseHeaders = options.headers?.response || defaultHeaders;\n\n\t\t\t\t\t// Create or get existing preview URL using Blaxel's preview API\n\t\t\t\t\tconst preview = await sandbox.previews.createIfNotExists({\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tname: `preview-port-${options.port}-${isPublic ? 'public' : 'private'}`\n\t\t\t\t\t\t},\n\t\t\t\t\t\tspec: {\n\t\t\t\t\t\t\tport: options.port,\n\t\t\t\t\t\t\tpublic: isPublic,\n\t\t\t\t\t\t\tresponseHeaders,\n\t\t\t\t\t\t\trequestHeaders: options.headers?.request || defaultHeaders,\n\t\t\t\t\t\t\tcustomDomain: options.customDomain,\n\t\t\t\t\t\t\tprefixUrl: options.prefixUrl,\n\t\t\t\t\t\t\tttl: options.ttl ? `${Math.ceil(options.ttl / 1000)}s` : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// Get the preview URL\n\t\t\t\t\tconst url = preview.spec?.url;\n\t\t\t\t\tif (!url) {\n\t\t\t\t\t\tthrow new Error(`Failed to get preview URL for port ${options.port}`);\n\t\t\t\t\t}\n\n\t\t\t\t\t// For private previews, create an access token and append it to the URL\n\t\t\t\t\tif (!isPublic) {\n\t\t\t\t\t\t// Create token with specified expiry (default 60 minutes)\n\t\t\t\t\t\tconst expiryMinutes = options.authentication?.tokenExpiryMinutes || 60;\n\t\t\t\t\t\tconst expiresAt = new Date(Date.now() + expiryMinutes * 60 * 1000);\n\t\t\t\t\t\tconst token = await preview.tokens.create(expiresAt);\n\n\t\t\t\t\t\t// Return URL with token as query parameter\n\t\t\t\t\t\tconst separator = url.includes('?') ? '&' : '?';\n\t\t\t\t\t\treturn `${url}${separator}bl_preview_token=${token.value}`;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For public previews, just return the URL\n\t\t\t\t\treturn url;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to get Blaxel preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Optional filesystem methods - implement using Blaxel's filesystem API\n\t\t\tfilesystem: {\n\t\t\t\treadFile: async (sandbox: SandboxInstance, path: string): Promise<string> => {\n\t\t\t\t\tconst result = await sandbox.fs.read(path);\n\t\t\t\t\treturn result || '';\n\t\t\t\t},\n\n\t\t\t\twriteFile: async (sandbox: SandboxInstance, path: string, content: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.write(path, content);\n\t\t\t\t},\n\n\t\t\t\tmkdir: async (sandbox: SandboxInstance, path: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.mkdir(path);\n\t\t\t\t},\n\n\t\t\t\treaddir: async (sandbox: SandboxInstance, path: string): Promise<FileEntry[]> => {\n\t\t\t\t\tconst result = await sandbox.fs.ls(path);\n\t\t\t\t\tconst files = result.files || [];\n\t\t\t\t\tconst directories = result.subdirectories || [];\n\t\t\t\t\tlet entries = [];\n\t\t\t\t\tfor (const file of files) {\n\t\t\t\t\t\tentries.push({\n\t\t\t\t\t\t\tname: file.name,\n\t\t\t\t\t\t\ttype: 'file' as const,\n\t\t\t\t\t\t\tsize: file.size || 0,\n\t\t\t\t\t\t\tmodified: new Date(file.lastModified || Date.now())\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tfor (const directory of directories) {\n\t\t\t\t\t\tentries.push({\n\t\t\t\t\t\t\tname: directory.name,\n\t\t\t\t\t\t\ttype: 'directory' as const,\n\t\t\t\t\t\t\tsize: 0,\n\t\t\t\t\t\t\tmodified: new Date()\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn entries;\n\t\t\t\t},\n\n\t\t\t\texists: async (sandbox: SandboxInstance, path: string): Promise<boolean> => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait sandbox.fs.read(path);\n\t\t\t\t\t\treturn true; // It's a file and exists\n\t\t\t\t\t} catch {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait sandbox.fs.ls(path);\n\t\t\t\t\t\t\treturn true; // It's a directory and exists\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn false; // Path doesn't exist\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tremove: async (sandbox: SandboxInstance, path: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.rm(path);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Provider-specific typed getInstance method\n\t\t\tgetInstance: (sandbox: SandboxInstance): SandboxInstance => {\n\t\t\t\treturn sandbox;\n\t\t\t},\n\t\t},\n\n\t\tsnapshot: {\n\t\t\tcreate: async (config: BlaxelConfig, sandboxId: string, options?: { name?: string }) => {\n\t\t\t\t// Blaxel automatically snapshots on scale-down, but we can trigger a manual snapshot\n\t\t\t\t// by stopping the sandbox which saves its state\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\t\n\t\t\t\t\t// Get the sandbox to access its snapshot\n\t\t\t\t\tconst sandbox = await SandboxInstance.get(sandboxId);\n\t\t\t\t\t\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\tthrow new Error(`Sandbox ${sandboxId} not found`);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Return the current state as a snapshot\n\t\t\t\t\t// Blaxel's auto-snapshot on scale-down is the primary mechanism\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: sandboxId,\n\t\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tname: options?.name,\n\t\t\t\t\t\t\timage: sandbox.spec?.runtime?.image\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to create Blaxel snapshot: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tlist: async (config: BlaxelConfig) => {\n\t\t\t\t// Blaxel doesn't have a separate snapshot listing API\n\t\t\t\t// List sandboxes as they contain the snapshot state\n\t\t\t\tinitializeBlaxel(config);\n\t\t\t\tconst sandboxList = await SandboxInstance.list();\n\t\t\t\treturn sandboxList.map(sandbox => ({\n\t\t\t\t\tid: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\tcreatedAt: sandbox.metadata?.createdAt ? new Date(sandbox.metadata.createdAt) : new Date(),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\timage: sandbox.spec?.runtime?.image,\n\t\t\t\t\t\tstatus: sandbox.status\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t},\n\n\t\t\tdelete: async (config: BlaxelConfig, snapshotId: string) => {\n\t\t\t\t// Deleting a snapshot in Blaxel is just deleting the sandbox\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tawait SandboxInstance.delete(snapshotId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Ignore if not found\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Templates in Blaxel are pre-configured images\n\t\ttemplate: {\n\t\t\tcreate: async (_config: BlaxelConfig, _options: { name: string }) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel templates must be created via the Blaxel dashboard or CLI. Use image in sandbox.create() to specify a base image.`\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tlist: async (_config: BlaxelConfig) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel provider does not support listing templates via API. Use the dashboard to manage templates.`\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tdelete: async (_config: BlaxelConfig, _templateId: string) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel templates must be deleted via the Blaxel dashboard or CLI.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n});\n\n/**\n * Parse TTL value from Blaxel's format to milliseconds\n * Supports formats like \"30m\", \"24h\", \"7d\" or plain numbers (seconds)\n */\nfunction parseTTLToMilliseconds(ttl: string | number | undefined): number {\n\tif (!ttl) return 300000; // Default to 5 minutes\n\n\t// If it's already a number, treat it as seconds and convert to milliseconds\n\tif (typeof ttl === 'number') {\n\t\treturn ttl * 1000;\n\t}\n\n\t// Parse string formats like \"30m\", \"24h\", \"7d\"\n\tconst match = ttl.match(/^(\\d+)([smhd])?$/);\n\tif (!match) return 300000; // Default if format is invalid\n\n\tconst value = parseInt(match[1], 10);\n\tconst unit = match[2] || 's'; // Default to seconds if no unit\n\n\tswitch (unit) {\n\t\tcase 's': return value * 1000; // seconds to ms\n\t\tcase 'm': return value * 60 * 1000; // minutes to ms\n\t\tcase 'h': return value * 60 * 60 * 1000; // hours to ms\n\t\tcase 'd': return value * 24 * 60 * 60 * 1000; // days to ms\n\t\tdefault: return 300000; // Default fallback\n\t}\n}\n\n/**\n * Initialize the Blaxel SDK with credentials from config or environment variables\n */\nfunction initializeBlaxel(config: BlaxelConfig): void {\n\tconst apiKey = config.apiKey || process.env?.BL_API_KEY!;\n\tconst workspace = config.workspace || process.env?.BL_WORKSPACE!;\n\tinitialize({ apikey: apiKey, workspace: workspace });\n}\n\nfunction convertSandboxStatus(status: string | undefined): 'running' | 'stopped' | 'error' {\n\tswitch (status?.toLowerCase()) {\n\t\tcase 'deployed': return 'running';\n\t\tcase 'deleting': return 'stopped';\n\t\tcase 'failed': return 'error';\n\t\tdefault: return 'running';\n\t}\n}\n\n/**\n * Execute a command in the sandbox and capture stdout/stderr\n * Handles the common pattern of executing, streaming logs, and waiting for completion\n */\nasync function executeWithStreaming(\n\tsandbox: SandboxInstance,\n\tcommand: string\n): Promise<{ stdout: string; stderr: string; exitCode: number }> {\n\t// Execute the command\n\tconst processResult = await sandbox.process.exec({\n\t\tcommand,\n\t\twaitForCompletion: true,\n\t});\n\t// Handle union type - ProcessResponseWithLog has stdout/stderr\n\tconst result = processResult as { stdout?: string; stderr?: string; exitCode?: number };\n\treturn {\n\t\tstdout: result.stdout || '',\n\t\tstderr: result.stderr || '',\n\t\texitCode: result.exitCode || 0,\n\t};\n}\n\n// Export the Blaxel SandboxInstance type for explicit typing\nexport type { SandboxInstance as BlaxelSandbox } from '@blaxel/core';\n"],"mappings":";AAMA,SAAS,iBAAiB,kBAAkB;AAC5C,SAAS,gBAAgB,sBAAsB;AAyBxC,IAAM,SAAS,eAAwD;AAAA,EAC7E,MAAM;AAAA,EACN,SAAS;AAAA,IACR,SAAS;AAAA;AAAA,MAER,QAAQ,OAAO,QAAsB,YAAmC;AAEvE,cAAM;AAAA,UACL,SAAS;AAAA,UACT,SAAS;AAAA,UACT;AAAA,UACA,MAAM;AAAA,UACN;AAAA,UACA,YAAY;AAAA,UACZ;AAAA,UACA,WAAW;AAAA,UACX,WAAW;AAAA,UACX,WAAW;AAAA,UACX,GAAG;AAAA,QACJ,IAAI,WAAW,CAAC;AAGhB,YAAI,QAAQ,OAAO,SAAS;AAG5B,YAAI,CAAC,OAAO,SAAS,YAAY;AAChC,kBAAQ,YAAY;AAAA,YACnB,KAAK;AACJ,sBAAQ;AACR;AAAA,YACD,KAAK;AACJ,sBAAQ;AACR;AAAA,YACD;AACC,sBAAQ;AACR;AAAA,UACF;AAAA,QACD;AACA,cAAM,SAAS,OAAO;AACtB,cAAM,SAAS,OAAO;AACtB,cAAM,MAAM,aAAa,GAAG,KAAK,KAAK,aAAa,GAAI,CAAC,MAAM;AAE/D,YAAI;AAEH,2BAAiB,MAAM;AAEvB,cAAI;AAGJ,gBAAM,aAAa,gBAAgB;AAEnC,cAAI,YAAY;AAEf,sBAAU,MAAM,gBAAgB,IAAI,UAAU;AAC9C,gBAAI,CAAC,SAAS;AACb,oBAAM,IAAI,MAAM,WAAW,UAAU,YAAY;AAAA,YAClD;AAAA,UACD,OAAO;AAEN,sBAAU,MAAM,gBAAgB,kBAAkB;AAAA,cACjD;AAAA,cACA;AAAA,cACA,MAAM,OAAO,QAAQ,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,MA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AAK;AAAK,aAAO,QAAQ,KAAK,KAAK,KAAK;AAAA;AAAA,IACxC;AAAS,aAAO;AAAA,EACjB;AACD;AAKA,SAAS,iBAAiB,QAA4B;AACrD,QAAM,SAAS,OAAO,UAAU,QAAQ,KAAK;AAC7C,QAAM,YAAY,OAAO,aAAa,QAAQ,KAAK;AACnD,aAAW,EAAE,QAAQ,QAAQ,UAAqB,CAAC;AACpD;AAEA,SAAS,qBAAqB,QAA6D;AAC1F,UAAQ,QAAQ,YAAY,GAAG;AAAA,IAC9B,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAY,aAAO;AAAA,IACxB,KAAK;AAAU,aAAO;AAAA,IACtB;AAAS,aAAO;AAAA,EACjB;AACD;AAMA,eAAe,qBACd,SACA,SACgE;AAEhE,QAAM,gBAAgB,MAAM,QAAQ,QAAQ,KAAK;AAAA,IAChD;AAAA,IACA,mBAAmB;AAAA,EACpB,CAAC;AAED,QAAM,SAAS;AACf,SAAO;AAAA,IACN,QAAQ,OAAO,UAAU;AAAA,IACzB,QAAQ,OAAO,UAAU;AAAA,IACzB,UAAU,OAAO,YAAY;AAAA,EAC9B;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Blaxel Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n */\n\nimport { SandboxInstance, initialize } from '@blaxel/core';\nimport { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions, CreateSnapshotOptions, ListSnapshotsOptions } from '@computesdk/provider';\n\n/**\n * Blaxel-specific configuration options\n */\nexport interface BlaxelConfig {\n\t/** Blaxel workspace ID - if not provided, will fallback to BL_WORKSPACE environment variable */\n\tworkspace?: string;\n\t/** Blaxel API key - if not provided, will fallback to BL_API_KEY environment variable */\n\tapiKey?: string;\n\t/** Default image for sandboxes */\n\timage?: string;\n\t/** Default region for sandbox deployment */\n\tregion?: string;\n\t/** Default memory allocation in MB */\n\tmemory?: number | 4096;\n\t/** Default ports for sandbox */\n\tports?: number[] | [3000];\n}\n\n/**\n * Create a Blaxel provider instance using the factory pattern\n */\nexport const blaxel = defineProvider<SandboxInstance, BlaxelConfig, any, any>({\n\tname: 'blaxel',\n\tmethods: {\n\t\tsandbox: {\n\t\t\t// Collection operations (map to compute.sandbox.*)\n\t\t\tcreate: async (config: BlaxelConfig, options?: CreateSandboxOptions) => {\n\t\t\t\t// Destructure known ComputeSDK fields, collect the rest for passthrough\n\t\t\t\tconst {\n\t\t\t\t\ttimeout: optTimeout,\n\t\t\t\t\tenvs,\n\t\t\t\t\tname: _name,\n\t\t\t\t\tmetadata,\n\t\t\t\t\ttemplateId: _templateId,\n\t\t\t\t\tsnapshotId,\n\t\t\t\t\tsandboxId: optSandboxId,\n\t\t\t\t\tnamespace: _namespace,\n\t\t\t\t\tdirectory: _directory,\n\t\t\t\t\t...providerOptions\n\t\t\t\t} = options || {};\n\n\t\t\t\tconst optRuntime = (options as any)?.runtime as string | undefined;\n\n\t\t\t\t// Determine the image to use\n\t\t\t\tlet image = config.image || 'blaxel/base-image:latest'; // Default to prod-base\n\n\t\t\t\t// Override with runtime-specific image if runtime is specified and no explicit image\n\t\t\t\tif (!config.image && optRuntime) {\n\t\t\t\t\tswitch (optRuntime) {\n\t\t\t\t\t\tcase 'python':\n\t\t\t\t\t\t\timage = 'blaxel/py-app:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'node':\n\t\t\t\t\t\t\timage = 'blaxel/ts-app:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\timage = 'blaxel/base-image:latest';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst memory = config.memory;\n\t\t\t\tconst region = config.region;\n\t\t\t\tconst ttl = optTimeout ? `${Math.ceil(optTimeout / 1000)}s` : undefined;\n\n\t\t\ttry {\n\t\t\t\t// Initialize Blaxel SDK with credentials\n\t\t\t\tinitializeBlaxel(config);\n\n\t\t\t\tlet sandbox: SandboxInstance;\n\n\t\t\t\t// Check if we should resume an existing sandbox or create new\n\t\t\t\tconst existingId = optSandboxId || snapshotId;\n\t\t\t\t\n\t\t\t\tif (existingId) {\n\t\t\t\t\t// Resume existing sandbox or snapshot\n\t\t\t\t\tsandbox = await SandboxInstance.get(existingId);\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\tthrow new Error(`Sandbox ${existingId} not found`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Create new Blaxel sandbox\n\t\t\t\t\tsandbox = await SandboxInstance.createIfNotExists({\n\t\t\t\t\t\timage,\n\t\t\t\t\t\tmemory,\n\t\t\t\t\t\tenvs: Object.entries(envs || {}).map(([name, value]) => ({ name, value: value as string })),\n\t\t\t\t\t\t...(metadata?.labels && { labels: metadata.labels }),\n\t\t\t\t\t\tttl,\n\t\t\t\t\t\tports: config.ports?.map(port => ({ target: port, protocol: 'HTTP' })),\n\t\t\t\t\t\t...(region && { region }),\n\t\t\t\t\t\t...providerOptions, // Spread provider-specific options\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tsandbox,\n\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\t\tconst errorDetail = error instanceof Error\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: typeof error === 'object' && error !== null\n\t\t\t\t\t\t\t? JSON.stringify(error)\n\t\t\t\t\t\t\t: String(error);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\terrorDetail.includes('unauthorized') ||\n\t\t\t\t\t\terrorDetail.includes('Unauthorized') ||\n\t\t\t\t\t\terrorDetail.includes('Forbidden') ||\n\t\t\t\t\t\terrorDetail.includes('API key')\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Blaxel authentication failed: ${errorDetail}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (errorDetail.includes('quota') || errorDetail.includes('limit')) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Blaxel quota exceeded: ${errorDetail}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to create Blaxel sandbox: ${errorDetail}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tgetById: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tconst sandbox = await SandboxInstance.get(sandboxId);\n\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsandbox,\n\t\t\t\t\t\tsandboxId,\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Sandbox doesn't exist or can't be accessed\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tlist: async (config: BlaxelConfig) => {\n\t\t\t\tinitializeBlaxel(config);\n\t\t\t\tconst sandboxList = await SandboxInstance.list();\n\t\t\t\treturn sandboxList.map(sandbox => ({\n\t\t\t\t\tsandbox,\n\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown'\n\t\t\t\t}));\n\t\t\t},\n\n\t\t\tdestroy: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tawait SandboxInstance.delete(sandboxId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Sandbox might already be destroyed or doesn't exist\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Instance operations (map to individual Sandbox methods)\n\t\trunCommand: async (sandbox: SandboxInstance, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n\t\t\tconst startTime = Date.now();\n\n\t\t\ttry {\n\t\t\t\t// Build command with options\n\t\t\t\tlet fullCommand = command;\n\t\t\t\t\n\t\t\t\t// Handle environment variables\n\t\t\t\tif (options?.env && Object.keys(options.env).length > 0) {\n\t\t\t\t\tconst envPrefix = Object.entries(options.env)\n\t\t\t\t\t\t.map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n\t\t\t\t\t\t.join(' ');\n\t\t\t\t\tfullCommand = `${envPrefix} ${fullCommand}`;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Handle working directory\n\t\t\t\tif (options?.cwd) {\n\t\t\t\t\tfullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Handle background execution\n\t\t\t\tif (options?.background) {\n\t\t\t\t\tfullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n\t\t\t\t}\n\n\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, fullCommand);\n\n\t\t\t\treturn {\n\t\t\t\t\tstdout,\n\t\t\t\t\tstderr,\n\t\t\t\t\texitCode,\n\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn {\n\t\t\t\t\tstdout: '',\n\t\t\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\texitCode: 127,\n\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t\t\tgetInfo: async (sandbox: SandboxInstance): Promise<SandboxInfo> => {\n\t\t\t\tconst runtime = sandbox.spec?.runtime?.image?.includes('py') ? 'python' : 'node';\n\t\t\t\treturn {\n\t\t\t\t\tid: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\tstatus: convertSandboxStatus(sandbox.status),\n\t\t\t\t\tcreatedAt: sandbox.metadata?.createdAt ? new Date(sandbox.metadata.createdAt) : new Date(),\n\t\t\t\t\ttimeout: parseTTLToMilliseconds(sandbox.spec?.runtime?.ttl),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\truntime,\n\t\t\t\t\t\t...sandbox.metadata?.labels\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\n\t\t\tgetUrl: async (sandbox: SandboxInstance, options: {\n\t\t\t\tport: number;\n\t\t\t\tttl?: number;\n\t\t\t\tprefixUrl?: string;\n\t\t\t\theaders?: {\n\t\t\t\t\tresponse?: Record<string, string>;\n\t\t\t\t\trequest?: Record<string, string>;\n\t\t\t\t};\n\t\t\t\tcustomDomain?: string;\n\t\t\t\tauthentication?: {\n\t\t\t\t\tpublic?: boolean;\n\t\t\t\t\ttokenExpiryMinutes?: number;\n\t\t\t\t};\n\t\t\t}): Promise<string> => {\n\t\t\t\ttry {\n\t\t\t\t\t// If public is not set, default to true\n\t\t\t\t\tconst isPublic = options.authentication?.public !== undefined ? options.authentication.public : true;\n\n\t\t\t\t\t// Default CORS headers for broad compatibility\n\t\t\t\t\tconst defaultHeaders = {\n\t\t\t\t\t\t\"Access-Control-Allow-Origin\": \"*\",\n\t\t\t\t\t\t\"Access-Control-Allow-Methods\": \"GET, POST, PUT, DELETE, OPTIONS, PATCH\",\n\t\t\t\t\t\t\"Access-Control-Allow-Headers\": \"Content-Type, Authorization, X-Requested-With, X-Blaxel-Preview-Token, X-Blaxel-Authorization\",\n\t\t\t\t\t\t\"Access-Control-Allow-Credentials\": \"true\",\n\t\t\t\t\t\t\"Access-Control-Expose-Headers\": \"Content-Length, X-Request-Id\",\n\t\t\t\t\t\t\"Access-Control-Max-Age\": \"86400\",\n\t\t\t\t\t\t\"Vary\": \"Origin\"\n\t\t\t\t\t};\n\n\t\t\t\t\t// Use custom headers if provided, otherwise use defaults\n\t\t\t\t\tconst responseHeaders = options.headers?.response || defaultHeaders;\n\n\t\t\t\t\t// Create or get existing preview URL using Blaxel's preview API\n\t\t\t\t\tconst preview = await sandbox.previews.createIfNotExists({\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tname: `preview-port-${options.port}-${isPublic ? 'public' : 'private'}`\n\t\t\t\t\t\t},\n\t\t\t\t\t\tspec: {\n\t\t\t\t\t\t\tport: options.port,\n\t\t\t\t\t\t\tpublic: isPublic,\n\t\t\t\t\t\t\tresponseHeaders,\n\t\t\t\t\t\t\trequestHeaders: options.headers?.request || defaultHeaders,\n\t\t\t\t\t\t\tcustomDomain: options.customDomain,\n\t\t\t\t\t\t\tprefixUrl: options.prefixUrl,\n\t\t\t\t\t\t\tttl: options.ttl ? `${Math.ceil(options.ttl / 1000)}s` : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// Get the preview URL\n\t\t\t\t\tconst url = preview.spec?.url;\n\t\t\t\t\tif (!url) {\n\t\t\t\t\t\tthrow new Error(`Failed to get preview URL for port ${options.port}`);\n\t\t\t\t\t}\n\n\t\t\t\t\t// For private previews, create an access token and append it to the URL\n\t\t\t\t\tif (!isPublic) {\n\t\t\t\t\t\t// Create token with specified expiry (default 60 minutes)\n\t\t\t\t\t\tconst expiryMinutes = options.authentication?.tokenExpiryMinutes || 60;\n\t\t\t\t\t\tconst expiresAt = new Date(Date.now() + expiryMinutes * 60 * 1000);\n\t\t\t\t\t\tconst token = await preview.tokens.create(expiresAt);\n\n\t\t\t\t\t\t// Return URL with token as query parameter\n\t\t\t\t\t\tconst separator = url.includes('?') ? '&' : '?';\n\t\t\t\t\t\treturn `${url}${separator}bl_preview_token=${token.value}`;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For public previews, just return the URL\n\t\t\t\t\treturn url;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to get Blaxel preview URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Optional filesystem methods - implement using Blaxel's filesystem API\n\t\t\tfilesystem: {\n\t\t\t\treadFile: async (sandbox: SandboxInstance, path: string): Promise<string> => {\n\t\t\t\t\tconst result = await sandbox.fs.read(path);\n\t\t\t\t\treturn result || '';\n\t\t\t\t},\n\n\t\t\t\twriteFile: async (sandbox: SandboxInstance, path: string, content: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.write(path, content);\n\t\t\t\t},\n\n\t\t\t\tmkdir: async (sandbox: SandboxInstance, path: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.mkdir(path);\n\t\t\t\t},\n\n\t\t\t\treaddir: async (sandbox: SandboxInstance, path: string): Promise<FileEntry[]> => {\n\t\t\t\t\tconst result = await sandbox.fs.ls(path);\n\t\t\t\t\tconst files = result.files || [];\n\t\t\t\t\tconst directories = result.subdirectories || [];\n\t\t\t\t\tlet entries = [];\n\t\t\t\t\tfor (const file of files) {\n\t\t\t\t\t\tentries.push({\n\t\t\t\t\t\t\tname: file.name,\n\t\t\t\t\t\t\ttype: 'file' as const,\n\t\t\t\t\t\t\tsize: file.size || 0,\n\t\t\t\t\t\t\tmodified: new Date(file.lastModified || Date.now())\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tfor (const directory of directories) {\n\t\t\t\t\t\tentries.push({\n\t\t\t\t\t\t\tname: directory.name,\n\t\t\t\t\t\t\ttype: 'directory' as const,\n\t\t\t\t\t\t\tsize: 0,\n\t\t\t\t\t\t\tmodified: new Date()\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn entries;\n\t\t\t\t},\n\n\t\t\t\texists: async (sandbox: SandboxInstance, path: string): Promise<boolean> => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait sandbox.fs.read(path);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait sandbox.fs.ls(path);\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tremove: async (sandbox: SandboxInstance, path: string): Promise<void> => {\n\t\t\t\t\tawait sandbox.fs.rm(path);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// Provider-specific typed getInstance method\n\t\t\tgetInstance: (sandbox: SandboxInstance): SandboxInstance => {\n\t\t\t\treturn sandbox;\n\t\t\t},\n\t\t},\n\n\t\tsnapshot: {\n\t\t\tcreate: async (config: BlaxelConfig, sandboxId: string, options?: { name?: string }) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\t\n\t\t\t\t\tconst sandbox = await SandboxInstance.get(sandboxId);\n\t\t\t\t\t\n\t\t\t\t\tif (!sandbox) {\n\t\t\t\t\t\tthrow new Error(`Sandbox ${sandboxId} not found`);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: sandboxId,\n\t\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tname: options?.name,\n\t\t\t\t\t\t\timage: sandbox.spec?.runtime?.image\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to create Blaxel snapshot: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tlist: async (config: BlaxelConfig) => {\n\t\t\t\tinitializeBlaxel(config);\n\t\t\t\tconst sandboxList = await SandboxInstance.list();\n\t\t\t\treturn sandboxList.map(sandbox => ({\n\t\t\t\t\tid: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\tcreatedAt: sandbox.metadata?.createdAt ? new Date(sandbox.metadata.createdAt) : new Date(),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\timage: sandbox.spec?.runtime?.image,\n\t\t\t\t\t\tstatus: sandbox.status\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t},\n\n\t\t\tdelete: async (config: BlaxelConfig, snapshotId: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tinitializeBlaxel(config);\n\t\t\t\t\tawait SandboxInstance.delete(snapshotId);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Ignore if not found\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Templates in Blaxel are pre-configured images\n\t\ttemplate: {\n\t\t\tcreate: async (_config: BlaxelConfig, _options: { name: string }) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel templates must be created via the Blaxel dashboard or CLI. Use image in sandbox.create() to specify a base image.`\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tlist: async (_config: BlaxelConfig) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel provider does not support listing templates via API. Use the dashboard to manage templates.`\n\t\t\t\t);\n\t\t\t},\n\n\t\t\tdelete: async (_config: BlaxelConfig, _templateId: string) => {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Blaxel templates must be deleted via the Blaxel dashboard or CLI.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n});\n\n/**\n * Parse TTL value from Blaxel's format to milliseconds\n */\nfunction parseTTLToMilliseconds(ttl: string | number | undefined): number {\n\tif (!ttl) return 300000;\n\tif (typeof ttl === 'number') return ttl * 1000;\n\tconst match = ttl.match(/^(\\d+)([smhd])?$/);\n\tif (!match) return 300000;\n\tconst value = parseInt(match[1], 10);\n\tconst unit = match[2] || 's';\n\tswitch (unit) {\n\t\tcase 's': return value * 1000;\n\t\tcase 'm': return value * 60 * 1000;\n\t\tcase 'h': return value * 60 * 60 * 1000;\n\t\tcase 'd': return value * 24 * 60 * 60 * 1000;\n\t\tdefault: return 300000;\n\t}\n}\n\n/**\n * Initialize the Blaxel SDK with credentials from config or environment variables\n */\nfunction initializeBlaxel(config: BlaxelConfig): void {\n\tconst apiKey = config.apiKey || process.env?.BL_API_KEY!;\n\tconst workspace = config.workspace || process.env?.BL_WORKSPACE!;\n\tinitialize({ apikey: apiKey, workspace: workspace });\n}\n\nfunction convertSandboxStatus(status: string | undefined): 'running' | 'stopped' | 'error' {\n\tswitch (status?.toLowerCase()) {\n\t\tcase 'deployed': return 'running';\n\t\tcase 'deleting': return 'stopped';\n\t\tcase 'failed': return 'error';\n\t\tdefault: return 'running';\n\t}\n}\n\n/**\n * Execute a command in the sandbox and capture stdout/stderr\n */\nasync function executeWithStreaming(\n\tsandbox: SandboxInstance,\n\tcommand: string\n): Promise<{ stdout: string; stderr: string; exitCode: number }> {\n\tconst processResult = await sandbox.process.exec({\n\t\tcommand,\n\t\twaitForCompletion: true,\n\t});\n\tconst result = processResult as { stdout?: string; stderr?: string; exitCode?: number };\n\treturn {\n\t\tstdout: result.stdout || '',\n\t\tstderr: result.stderr || '',\n\t\texitCode: result.exitCode || 0,\n\t};\n}\n\n// Export the Blaxel SandboxInstance type for explicit typing\nexport type { SandboxInstance as BlaxelSandbox } from '@blaxel/core';\n"],"mappings":";AAMA,SAAS,iBAAiB,kBAAkB;AAC5C,SAAS,gBAAgB,sBAAsB;AAyBxC,IAAM,SAAS,eAAwD;AAAA,EAC7E,MAAM;AAAA,EACN,SAAS;AAAA,IACR,SAAS;AAAA;AAAA,MAER,QAAQ,OAAO,QAAsB,YAAmC;AAEvE,cAAM;AAAA,UACL,SAAS;AAAA,UACT;AAAA,UACA,MAAM;AAAA,UACN;AAAA,UACA,YAAY;AAAA,UACZ;AAAA,UACA,WAAW;AAAA,UACX,WAAW;AAAA,UACX,WAAW;AAAA,UACX,GAAG;AAAA,QACJ,IAAI,WAAW,CAAC;AAEhB,cAAM,aAAc,SAAiB;AAGrC,YAAI,QAAQ,OAAO,SAAS;AAG5B,YAAI,CAAC,OAAO,SAAS,YAAY;AAChC,kBAAQ,YAA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AU;AAAA,IACzB,UAAU,OAAO,YAAY;AAAA,EAC9B;AACD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/blaxel",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.11",
|
|
4
4
|
"description": "Blaxel provider for ComputeSDK - lightweight cloud sandboxes for code execution",
|
|
5
5
|
"author": "ComputeSDK",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@blaxel/core": "^0.2.75",
|
|
22
|
-
"@computesdk/provider": "
|
|
23
|
-
"computesdk": "
|
|
22
|
+
"@computesdk/provider": "2.0.0",
|
|
23
|
+
"computesdk": "4.0.0"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"computesdk",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"tsup": "^8.0.0",
|
|
50
50
|
"typescript": "^5.0.0",
|
|
51
51
|
"vitest": "^1.0.0",
|
|
52
|
-
"@computesdk/test-utils": "
|
|
52
|
+
"@computesdk/test-utils": "2.0.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsup",
|