@computesdk/blaxel 1.2.7 → 1.3.0
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.d.mts +1 -34
- package/dist/index.d.ts +1 -34
- package/dist/index.js +17 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -23,38 +23,5 @@ interface BlaxelConfig {
|
|
|
23
23
|
* Create a Blaxel provider instance using the factory pattern
|
|
24
24
|
*/
|
|
25
25
|
declare const blaxel: (config: BlaxelConfig) => computesdk.Provider<SandboxInstance, any, any>;
|
|
26
|
-
/**
|
|
27
|
-
* Create a properly typed compute instance for Blaxel
|
|
28
|
-
* This version provides full type safety for getInstance() calls
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import { createBlaxelCompute } from '@computesdk/blaxel'
|
|
33
|
-
*
|
|
34
|
-
* const compute = createBlaxelCompute({ workspace: 'your-workspace', apiKey: 'your-key' });
|
|
35
|
-
* const sandbox = await compute.sandbox.create();
|
|
36
|
-
* const instance = sandbox.getInstance(); // ✅ Properly typed as SandboxInstance!
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare function createBlaxelCompute(config: BlaxelConfig): {
|
|
40
|
-
sandbox: {
|
|
41
|
-
create(): Promise<{
|
|
42
|
-
sandboxId: string;
|
|
43
|
-
provider: string;
|
|
44
|
-
runCode(code: string, runtime?: computesdk.Runtime): Promise<computesdk.ExecutionResult>;
|
|
45
|
-
runCommand(command: string, args?: string[]): Promise<computesdk.ExecutionResult>;
|
|
46
|
-
getInfo(): Promise<computesdk.SandboxInfo>;
|
|
47
|
-
getUrl(options: {
|
|
48
|
-
port: number;
|
|
49
|
-
protocol?: string;
|
|
50
|
-
}): Promise<string>;
|
|
51
|
-
getProvider(): ReturnType<typeof blaxel>;
|
|
52
|
-
getInstance(): SandboxInstance;
|
|
53
|
-
kill(): Promise<void>;
|
|
54
|
-
destroy(): Promise<void>;
|
|
55
|
-
filesystem: computesdk.SandboxFileSystem;
|
|
56
|
-
}>;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
26
|
|
|
60
|
-
export { type BlaxelConfig, blaxel
|
|
27
|
+
export { type BlaxelConfig, blaxel };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,38 +23,5 @@ interface BlaxelConfig {
|
|
|
23
23
|
* Create a Blaxel provider instance using the factory pattern
|
|
24
24
|
*/
|
|
25
25
|
declare const blaxel: (config: BlaxelConfig) => computesdk.Provider<SandboxInstance, any, any>;
|
|
26
|
-
/**
|
|
27
|
-
* Create a properly typed compute instance for Blaxel
|
|
28
|
-
* This version provides full type safety for getInstance() calls
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import { createBlaxelCompute } from '@computesdk/blaxel'
|
|
33
|
-
*
|
|
34
|
-
* const compute = createBlaxelCompute({ workspace: 'your-workspace', apiKey: 'your-key' });
|
|
35
|
-
* const sandbox = await compute.sandbox.create();
|
|
36
|
-
* const instance = sandbox.getInstance(); // ✅ Properly typed as SandboxInstance!
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare function createBlaxelCompute(config: BlaxelConfig): {
|
|
40
|
-
sandbox: {
|
|
41
|
-
create(): Promise<{
|
|
42
|
-
sandboxId: string;
|
|
43
|
-
provider: string;
|
|
44
|
-
runCode(code: string, runtime?: computesdk.Runtime): Promise<computesdk.ExecutionResult>;
|
|
45
|
-
runCommand(command: string, args?: string[]): Promise<computesdk.ExecutionResult>;
|
|
46
|
-
getInfo(): Promise<computesdk.SandboxInfo>;
|
|
47
|
-
getUrl(options: {
|
|
48
|
-
port: number;
|
|
49
|
-
protocol?: string;
|
|
50
|
-
}): Promise<string>;
|
|
51
|
-
getProvider(): ReturnType<typeof blaxel>;
|
|
52
|
-
getInstance(): SandboxInstance;
|
|
53
|
-
kill(): Promise<void>;
|
|
54
|
-
destroy(): Promise<void>;
|
|
55
|
-
filesystem: computesdk.SandboxFileSystem;
|
|
56
|
-
}>;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
26
|
|
|
60
|
-
export { type BlaxelConfig, blaxel
|
|
27
|
+
export { type BlaxelConfig, blaxel };
|
package/dist/index.js
CHANGED
|
@@ -20,8 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
blaxel: () => blaxel
|
|
24
|
-
createBlaxelCompute: () => createBlaxelCompute
|
|
23
|
+
blaxel: () => blaxel
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(index_exports);
|
|
27
26
|
var import_core = require("@blaxel/core");
|
|
@@ -137,65 +136,53 @@ var blaxel = (0, import_computesdk.createProvider)({
|
|
|
137
136
|
}
|
|
138
137
|
const escapedCode = code.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\$/g, "\\$").replace(/`/g, "\\`");
|
|
139
138
|
const command = effectiveRuntime === "python" ? `python3 -c "${escapedCode}"` : `node -e "${escapedCode}"`;
|
|
140
|
-
const { stdout, stderr, exitCode } = await executeWithStreaming(sandbox,
|
|
139
|
+
const { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, command);
|
|
141
140
|
if (exitCode !== 0 && stderr) {
|
|
142
141
|
if (stderr.includes("SyntaxError") || stderr.includes("invalid syntax") || stderr.includes("Unexpected token") || stderr.includes("Unexpected identifier")) {
|
|
143
142
|
throw new Error(`Syntax error: ${stderr.trim()}`);
|
|
144
143
|
}
|
|
145
144
|
}
|
|
145
|
+
const output = stderr ? `${stdout}
|
|
146
|
+
${stderr}`.trim() : stdout;
|
|
146
147
|
return {
|
|
147
|
-
|
|
148
|
-
stderr,
|
|
148
|
+
output,
|
|
149
149
|
exitCode,
|
|
150
|
-
|
|
151
|
-
sandboxId: sandbox.metadata?.name || "blaxel-unknown",
|
|
152
|
-
provider: "blaxel"
|
|
150
|
+
language: effectiveRuntime
|
|
153
151
|
};
|
|
154
152
|
} catch (error) {
|
|
155
153
|
if (error instanceof Error && error.message.includes("Syntax error")) {
|
|
156
154
|
throw error;
|
|
157
155
|
}
|
|
158
156
|
return {
|
|
159
|
-
|
|
160
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
157
|
+
output: error instanceof Error ? error.message : String(error),
|
|
161
158
|
exitCode: 1,
|
|
162
|
-
|
|
163
|
-
sandboxId: sandbox.metadata?.name || "blaxel-unknown",
|
|
164
|
-
provider: "blaxel"
|
|
159
|
+
language: runtime || "node"
|
|
165
160
|
};
|
|
166
161
|
}
|
|
167
162
|
},
|
|
168
|
-
runCommand: async (sandbox, command, args = []
|
|
163
|
+
runCommand: async (sandbox, command, args = []) => {
|
|
169
164
|
const startTime = Date.now();
|
|
170
165
|
try {
|
|
171
|
-
const
|
|
172
|
-
const quotedArgs = finalArgs.map((arg) => {
|
|
166
|
+
const quotedArgs = args.map((arg) => {
|
|
173
167
|
if (arg.includes(" ") || arg.includes('"') || arg.includes("'") || arg.includes("$") || arg.includes("`")) {
|
|
174
168
|
return `"${arg.replace(/"/g, '\\"')}"`;
|
|
175
169
|
}
|
|
176
170
|
return arg;
|
|
177
171
|
});
|
|
178
|
-
const fullCommand = quotedArgs.length > 0 ? `${
|
|
179
|
-
const { stdout, stderr, exitCode } = await executeWithStreaming(sandbox,
|
|
172
|
+
const fullCommand = quotedArgs.length > 0 ? `${command} ${quotedArgs.join(" ")}` : command;
|
|
173
|
+
const { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, fullCommand);
|
|
180
174
|
return {
|
|
181
175
|
stdout,
|
|
182
176
|
stderr,
|
|
183
177
|
exitCode,
|
|
184
|
-
|
|
185
|
-
sandboxId: sandbox.metadata?.name || "blaxel-unknown",
|
|
186
|
-
provider: "blaxel",
|
|
187
|
-
isBackground,
|
|
188
|
-
...isBackground && { pid: -1 }
|
|
178
|
+
durationMs: Date.now() - startTime
|
|
189
179
|
};
|
|
190
180
|
} catch (error) {
|
|
191
181
|
return {
|
|
192
182
|
stdout: "",
|
|
193
183
|
stderr: error instanceof Error ? error.message : String(error),
|
|
194
184
|
exitCode: 127,
|
|
195
|
-
|
|
196
|
-
executionTime: Date.now() - startTime,
|
|
197
|
-
sandboxId: sandbox.metadata?.name || "blaxel-unknown",
|
|
198
|
-
provider: "blaxel"
|
|
185
|
+
durationMs: Date.now() - startTime
|
|
199
186
|
};
|
|
200
187
|
}
|
|
201
188
|
},
|
|
@@ -318,22 +305,6 @@ var blaxel = (0, import_computesdk.createProvider)({
|
|
|
318
305
|
}
|
|
319
306
|
}
|
|
320
307
|
});
|
|
321
|
-
function createBlaxelCompute(config) {
|
|
322
|
-
const provider = blaxel(config);
|
|
323
|
-
return {
|
|
324
|
-
sandbox: {
|
|
325
|
-
create: async () => {
|
|
326
|
-
const sandbox = await provider.sandbox.create();
|
|
327
|
-
return {
|
|
328
|
-
...sandbox,
|
|
329
|
-
getInstance: () => {
|
|
330
|
-
return sandbox.getInstance();
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
308
|
async function handleBlaxelAuth(config) {
|
|
338
309
|
try {
|
|
339
310
|
await import_core.settings.authenticate();
|
|
@@ -389,11 +360,9 @@ function convertSandboxStatus(status) {
|
|
|
389
360
|
return "running";
|
|
390
361
|
}
|
|
391
362
|
}
|
|
392
|
-
async function executeWithStreaming(sandbox,
|
|
363
|
+
async function executeWithStreaming(sandbox, command) {
|
|
393
364
|
const result = await sandbox.process.exec({ command });
|
|
394
|
-
|
|
395
|
-
await sandbox.process.wait(result.name);
|
|
396
|
-
}
|
|
365
|
+
await sandbox.process.wait(result.name);
|
|
397
366
|
const processResult = await sandbox.process.get(result.name);
|
|
398
367
|
return {
|
|
399
368
|
stdout: processResult.logs,
|
|
@@ -403,7 +372,6 @@ async function executeWithStreaming(sandbox, isBackground, command) {
|
|
|
403
372
|
}
|
|
404
373
|
// Annotate the CommonJS export names for ESM import in node:
|
|
405
374
|
0 && (module.exports = {
|
|
406
|
-
blaxel
|
|
407
|
-
createBlaxelCompute
|
|
375
|
+
blaxel
|
|
408
376
|
});
|
|
409
377
|
//# sourceMappingURL=index.js.map
|
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, settings } from '@blaxel/core';\nimport { createProvider, createBackgroundCommand } from 'computesdk';\nimport type {\n\tExecutionResult,\n\tSandboxInfo,\n\tRuntime,\n\tCreateSandboxOptions,\n\tFileEntry,\n\tRunCommandOptions,\n\tSandboxStatus\n} from 'computesdk';\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 = createProvider<SandboxInstance, BlaxelConfig>({\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\tawait handleBlaxelAuth(config);\n\n\t\t\t\t// Determine the image to use\n\t\t\t\tlet image = config.image || 'blaxel/prod-base: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 && options?.runtime) {\n\t\t\t\t\tswitch (options.runtime) {\n\t\t\t\t\t\tcase 'python':\n\t\t\t\t\t\t\timage = 'blaxel/prod-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/prod-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/prod-base: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 envs = options?.envs;\n\t\t\t\tconst ttl = options?.timeout ? `${Math.ceil(options.timeout / 1000)}s` : undefined;\n\n\t\t\t\ttry {\n\t\t\t\t\tlet sandbox: SandboxInstance;\n\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\tname: options?.sandboxId || `blaxel-${Date.now()}`,\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 })),\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\t\t...options?.metadata?.labels,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\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});\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsandbox,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown'\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof Error) {\n\t\t\t\t\t\tif (error.message.includes('unauthorized') || error.message.includes('API key')) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Blaxel authentication failed. Please check your BLAXEL_API_KEY environment variable.`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (error.message.includes('quota') || error.message.includes('limit')) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Blaxel quota exceeded. Please check your usage limits.`\n\t\t\t\t\t\t\t);\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: ${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\tgetById: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\tawait handleBlaxelAuth(config);\n\n\t\t\t\ttry {\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\tawait handleBlaxelAuth(config);\n\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\tawait handleBlaxelAuth(config);\n\n\t\t\t\ttry {\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\t\trunCode: async (sandbox: SandboxInstance, code: string, runtime?: Runtime): Promise<ExecutionResult> => {\n\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\ttry {\n\t\t\t\t\t// Determine runtime: \n\t\t\t\t\t// 1. Use explicitly passed runtime if provided\n\t\t\t\t\t// 2. Check sandbox's actual runtime based on its image\n\t\t\t\t\t// 3. Fall back to auto-detection from code content\n\t\t\t\t\tlet effectiveRuntime = runtime;\n\n\t\t\t\t\tif (!effectiveRuntime) {\n\t\t\t\t\t\t// Check sandbox's image to determine its runtime\n\t\t\t\t\t\tconst sandboxImage = sandbox.spec?.runtime?.image || '';\n\t\t\t\t\t\tif (sandboxImage.includes('py')) {\n\t\t\t\t\t\t\teffectiveRuntime = 'python';\n\t\t\t\t\t\t} else if (sandboxImage.includes('ts') || sandboxImage.includes('node') || sandboxImage.includes('base')) {\n\t\t\t\t\t\t\t// prod-base, prod-ts-app are both Node/TypeScript environments\n\t\t\t\t\t\t\teffectiveRuntime = 'node';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Fall back to auto-detection with improved patterns for unknown images\n\t\t\t\t\t\t\teffectiveRuntime = (\n\t\t\t\t\t\t\t\t// Strong Python indicators\n\t\t\t\t\t\t\t\tcode.includes('print(') ||\n\t\t\t\t\t\t\t\t\tcode.includes('import ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('from ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('def ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('class ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('raise ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('except ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('elif ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('lambda ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('True') ||\n\t\t\t\t\t\t\t\t\tcode.includes('False') ||\n\t\t\t\t\t\t\t\t\tcode.includes('None') ||\n\t\t\t\t\t\t\t\t\tcode.includes('sys.') ||\n\t\t\t\t\t\t\t\t\tcode.includes('json.') ||\n\t\t\t\t\t\t\t\t\tcode.includes('__') ||\n\t\t\t\t\t\t\t\t\tcode.includes('f\"') ||\n\t\t\t\t\t\t\t\t\tcode.includes(\"f'\") ||\n\t\t\t\t\t\t\t\t\tcode.includes('\"\"\"') ||\n\t\t\t\t\t\t\t\t\tcode.includes(\"'''\")\n\t\t\t\t\t\t\t\t\t? 'python'\n\t\t\t\t\t\t\t\t\t// Default to Node.js for all other cases (including ambiguous)\n\t\t\t\t\t\t\t\t\t: 'node'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Execute code using Blaxel's process execution\n\t\t\t\t\t// Escape the code properly for shell execution\n\t\t\t\t\tconst escapedCode = code.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\$/g, '\\\\$').replace(/`/g, '\\\\`');\n\n\t\t\t\t\tconst command = effectiveRuntime === 'python'\n\t\t\t\t\t\t? `python3 -c \"${escapedCode}\"`\n\t\t\t\t\t\t: `node -e \"${escapedCode}\"`;\n\n\t\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, false, command);\n\n\t\t\t\t\t// Check for syntax errors and throw them\n\t\t\t\t\tif (exitCode !== 0 && stderr) {\n\t\t\t\t\t\t// Check for common syntax error patterns\n\t\t\t\t\t\tif (stderr.includes('SyntaxError') ||\n\t\t\t\t\t\t\tstderr.includes('invalid syntax') ||\n\t\t\t\t\t\t\tstderr.includes('Unexpected token') ||\n\t\t\t\t\t\t\tstderr.includes('Unexpected identifier')) {\n\t\t\t\t\t\t\tthrow new Error(`Syntax error: ${stderr.trim()}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t\texitCode,\n\t\t\t\t\t\texecutionTime: Date.now() - startTime,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\t\tprovider: 'blaxel'\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Re-throw syntax errors\n\t\t\t\t\tif (error instanceof Error && error.message.includes('Syntax error')) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For runtime errors, return a result instead of throwing\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout: '',\n\t\t\t\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\texitCode: 1,\n\t\t\t\t\t\texecutionTime: Date.now() - startTime,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\t\tprovider: 'blaxel'\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\n\t\t\trunCommand: async (sandbox: SandboxInstance, command: string, args: string[] = [], options?: RunCommandOptions): Promise<ExecutionResult> => {\n\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\ttry {\n\t\t\t\t\t// Handle background command execution\n\t\t\t\t\tconst { command: finalCommand, args: finalArgs, isBackground } = createBackgroundCommand(command, args, options);\n\n\t\t\t\t\t// Construct full command with arguments, properly quoting each arg\n\t\t\t\t\tconst quotedArgs = finalArgs.map(arg => {\n\t\t\t\t\t\t// Quote arguments that contain spaces or special characters\n\t\t\t\t\t\tif (arg.includes(' ') || arg.includes('\"') || arg.includes(\"'\") || arg.includes('$') || arg.includes('`')) {\n\t\t\t\t\t\t\t// Escape any double quotes in the argument and wrap in double quotes\n\t\t\t\t\t\t\treturn `\"${arg.replace(/\"/g, '\\\\\"')}\"`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn arg;\n\t\t\t\t\t});\n\t\t\t\t\tconst fullCommand = quotedArgs.length > 0 ? `${finalCommand} ${quotedArgs.join(' ')}` : finalCommand;\n\n\t\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, isBackground, fullCommand);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t\texitCode,\n\t\t\t\t\t\texecutionTime: Date.now() - startTime,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\t\tisBackground,\n\t\t\t\t\t\t...(isBackground && { pid: -1 })\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// For command failures, return error info instead of throwing\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout: '',\n\t\t\t\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\texitCode: 127, // Command not found exit code\n\t\t\t\t\t\texecutionTime: Date.now() - startTime,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\t\tprovider: 'blaxel'\n\t\t\t\t\t};\n\t\t\t\t}\n\t\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\tpath: `${path}/${file.name}`,\n\t\t\t\t\t\t\tisDirectory: false,\n\t\t\t\t\t\t\tsize: file.size || 0,\n\t\t\t\t\t\t\tlastModified: 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\tpath: `${path}/${directory.name}`,\n\t\t\t\t\t\t\tisDirectory: true,\n\t\t\t\t\t\t\tsize: 0,\n\t\t\t\t\t\t\tlastModified: 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\t}\n});\n\n/**\n * Create a properly typed compute instance for Blaxel\n * This version provides full type safety for getInstance() calls\n * \n * @example\n * ```typescript\n * import { createBlaxelCompute } from '@computesdk/blaxel'\n * \n * const compute = createBlaxelCompute({ workspace: 'your-workspace', apiKey: 'your-key' });\n * const sandbox = await compute.sandbox.create();\n * const instance = sandbox.getInstance(); // ✅ Properly typed as SandboxInstance!\n * ```\n */\nexport function createBlaxelCompute(config: BlaxelConfig): {\n\tsandbox: {\n\t\tcreate(): Promise<{\n\t\t\tsandboxId: string;\n\t\t\tprovider: string;\n\t\t\trunCode(code: string, runtime?: import('computesdk').Runtime): Promise<import('computesdk').ExecutionResult>;\n\t\t\trunCommand(command: string, args?: string[]): Promise<import('computesdk').ExecutionResult>;\n\t\t\tgetInfo(): Promise<import('computesdk').SandboxInfo>;\n\t\t\tgetUrl(options: { port: number; protocol?: string }): Promise<string>;\n\t\t\tgetProvider(): ReturnType<typeof blaxel>;\n\t\t\tgetInstance(): SandboxInstance; // ✅ Properly typed!\n\t\t\tkill(): Promise<void>;\n\t\t\tdestroy(): Promise<void>;\n\t\t\tfilesystem: import('computesdk').SandboxFileSystem;\n\t\t}>;\n\t};\n} {\n\tconst provider = blaxel(config);\n\n\treturn {\n\t\tsandbox: {\n\t\t\tcreate: async () => {\n\t\t\t\tconst sandbox = await provider.sandbox.create();\n\t\t\t\treturn {\n\t\t\t\t\t...sandbox,\n\t\t\t\t\tgetInstance: (): SandboxInstance => {\n\t\t\t\t\t\treturn sandbox.getInstance() as SandboxInstance;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t};\n}\n\nasync function handleBlaxelAuth(config: BlaxelConfig) {\n\t// Check if auth is already set in the SDK\n\ttry {\n\t\tawait settings.authenticate();\n\t} catch (error) {\n\t\t// If not, set the auth from the config\n\t\tif (config.workspace || process.env.BLAXEL_WORKSPACE && typeof process !== 'undefined') {\n\t\t\tprocess.env.BL_WORKSPACE = config.workspace || process.env.BLAXEL_WORKSPACE;\n\t\t}\n\t\tif (config.apiKey || process.env.BLAXEL_API_KEY && typeof process !== 'undefined') {\n\t\t\tprocess.env.BL_API_KEY = config.apiKey || process.env.BLAXEL_API_KEY;\n\t\t}\n\t\ttry {\n\t\t\tawait settings.authenticate();\n\t\t} catch (error) {\n\t\t\tthrow new Error('Blaxel authentication failed. Please check the following documents for more information: https://docs.blaxel.ai/Security/Access-tokens#using-api-keys');\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\nfunction convertSandboxStatus(status: string | undefined): SandboxStatus {\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\tisBackground: boolean,\n\tcommand: string\n): Promise<{ stdout: string; stderr: string; exitCode: number }> {\n\t// Execute the command\n\tconst result = await sandbox.process.exec({ command });\n\n\tif (!isBackground) {\n\t\t// Wait for process completion\n\t\tawait sandbox.process.wait(result.name);\n\t}\n\n\t// Get final process result for exit code\n\tconst processResult = await sandbox.process.get(result.name);\n\n\t// TODO: Handle proper stdout/stderr streaming\n\treturn {\n\t\tstdout: processResult.logs,\n\t\tstderr: processResult.logs,\n\t\texitCode: processResult.exitCode || 0\n\t};\n}\n\n// Export the Blaxel SandboxInstance type for explicit typing\nexport type { SandboxInstance as BlaxelSandbox } from '@blaxel/core';\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,kBAA0C;AAC1C,wBAAwD;AAgCjD,IAAM,aAAS,kCAA8C;AAAA,EACnE,MAAM;AAAA,EACN,SAAS;AAAA,IACR,SAAS;AAAA;AAAA,MAER,QAAQ,OAAO,QAAsB,YAAmC;AACvE,cAAM,iBAAiB,MAAM;AAG7B,YAAI,QAAQ,OAAO,SAAS;AAG5B,YAAI,CAAC,OAAO,SAAS,SAAS,SAAS;AACtC,kBAAQ,QAAQ,SAAS;AAAA,YACxB,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,OAAO,SAAS;AACtB,cAAM,MAAM,SAAS,UAAU,GAAG,KAAK,KAAK,QAAQ,UAAU,GAAI,CAAC,MAAM;AAEzE,YAAI;AACH,cAAI;AAGJ,oBAAU,MAAM,4BAAgB,kBAAkB;AAAA,YACjD,MAAM,SAAS,aAAa,UAAU,KAAK,IAAI,CAAC;AAAA,YAChD;AAAA,YACA;AAAA,YACA,MAAM,OAAO,QAAQ,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QAAQ,SAAS,MAAM,CAAC,GAAG,EAAE;AACnC,QAAM,OAAO,MAAM,CAAC,KAAK;AAEzB,UAAQ,MAAM;AAAA,IACb,KAAK;AAAK,aAAO,QAAQ;AAAA;AAAA,IACzB,KAAK;AAAK,aAAO,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;AAEA,SAAS,qBAAqB,QAA2C;AACxE,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,cACA,SACgE;AAEhE,QAAM,SAAS,MAAM,QAAQ,QAAQ,KAAK,EAAE,QAAQ,CAAC;AAErD,MAAI,CAAC,cAAc;AAElB,UAAM,QAAQ,QAAQ,KAAK,OAAO,IAAI;AAAA,EACvC;AAGA,QAAM,gBAAgB,MAAM,QAAQ,QAAQ,IAAI,OAAO,IAAI;AAG3D,SAAO;AAAA,IACN,QAAQ,cAAc;AAAA,IACtB,QAAQ,cAAc;AAAA,IACtB,UAAU,cAAc,YAAY;AAAA,EACrC;AACD;","names":["error"]}
|
|
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, settings } from '@blaxel/core';\nimport { createProvider } from 'computesdk';\nimport type {\n\tCodeResult,\n\tCommandResult,\n\tSandboxInfo,\n\tRuntime,\n\tCreateSandboxOptions,\n\tFileEntry,\n\tSandboxStatus\n} from 'computesdk';\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 = createProvider<SandboxInstance, BlaxelConfig>({\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\tawait handleBlaxelAuth(config);\n\n\t\t\t\t// Determine the image to use\n\t\t\t\tlet image = config.image || 'blaxel/prod-base: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 && options?.runtime) {\n\t\t\t\t\tswitch (options.runtime) {\n\t\t\t\t\t\tcase 'python':\n\t\t\t\t\t\t\timage = 'blaxel/prod-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/prod-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/prod-base: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 envs = options?.envs;\n\t\t\t\tconst ttl = options?.timeout ? `${Math.ceil(options.timeout / 1000)}s` : undefined;\n\n\t\t\t\ttry {\n\t\t\t\t\tlet sandbox: SandboxInstance;\n\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\tname: options?.sandboxId || `blaxel-${Date.now()}`,\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 })),\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\t\t...options?.metadata?.labels,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\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});\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsandbox,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown'\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof Error) {\n\t\t\t\t\t\tif (error.message.includes('unauthorized') || error.message.includes('API key')) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Blaxel authentication failed. Please check your BLAXEL_API_KEY environment variable.`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (error.message.includes('quota') || error.message.includes('limit')) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Blaxel quota exceeded. Please check your usage limits.`\n\t\t\t\t\t\t\t);\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: ${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\tgetById: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\tawait handleBlaxelAuth(config);\n\n\t\t\t\ttry {\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\tawait handleBlaxelAuth(config);\n\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\tawait handleBlaxelAuth(config);\n\n\t\t\t\ttry {\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\t\trunCode: async (sandbox: SandboxInstance, code: string, runtime?: Runtime): Promise<CodeResult> => {\n\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\ttry {\n\t\t\t\t\t// Determine runtime: \n\t\t\t\t\t// 1. Use explicitly passed runtime if provided\n\t\t\t\t\t// 2. Check sandbox's actual runtime based on its image\n\t\t\t\t\t// 3. Fall back to auto-detection from code content\n\t\t\t\t\tlet effectiveRuntime = runtime;\n\n\t\t\t\t\tif (!effectiveRuntime) {\n\t\t\t\t\t\t// Check sandbox's image to determine its runtime\n\t\t\t\t\t\tconst sandboxImage = sandbox.spec?.runtime?.image || '';\n\t\t\t\t\t\tif (sandboxImage.includes('py')) {\n\t\t\t\t\t\t\teffectiveRuntime = 'python';\n\t\t\t\t\t\t} else if (sandboxImage.includes('ts') || sandboxImage.includes('node') || sandboxImage.includes('base')) {\n\t\t\t\t\t\t\t// prod-base, prod-ts-app are both Node/TypeScript environments\n\t\t\t\t\t\t\teffectiveRuntime = 'node';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Fall back to auto-detection with improved patterns for unknown images\n\t\t\t\t\t\t\teffectiveRuntime = (\n\t\t\t\t\t\t\t\t// Strong Python indicators\n\t\t\t\t\t\t\t\tcode.includes('print(') ||\n\t\t\t\t\t\t\t\t\tcode.includes('import ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('from ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('def ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('class ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('raise ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('except ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('elif ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('lambda ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('True') ||\n\t\t\t\t\t\t\t\t\tcode.includes('False') ||\n\t\t\t\t\t\t\t\t\tcode.includes('None') ||\n\t\t\t\t\t\t\t\t\tcode.includes('sys.') ||\n\t\t\t\t\t\t\t\t\tcode.includes('json.') ||\n\t\t\t\t\t\t\t\t\tcode.includes('__') ||\n\t\t\t\t\t\t\t\t\tcode.includes('f\"') ||\n\t\t\t\t\t\t\t\t\tcode.includes(\"f'\") ||\n\t\t\t\t\t\t\t\t\tcode.includes('\"\"\"') ||\n\t\t\t\t\t\t\t\t\tcode.includes(\"'''\")\n\t\t\t\t\t\t\t\t\t? 'python'\n\t\t\t\t\t\t\t\t\t// Default to Node.js for all other cases (including ambiguous)\n\t\t\t\t\t\t\t\t\t: 'node'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Execute code using Blaxel's process execution\n\t\t\t\t\t// Escape the code properly for shell execution\n\t\t\t\t\tconst escapedCode = code.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\$/g, '\\\\$').replace(/`/g, '\\\\`');\n\n\t\t\t\t\tconst command = effectiveRuntime === 'python'\n\t\t\t\t\t\t? `python3 -c \"${escapedCode}\"`\n\t\t\t\t\t\t: `node -e \"${escapedCode}\"`;\n\n\t\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, command);\n\n\t\t\t\t\t// Check for syntax errors and throw them\n\t\t\t\t\tif (exitCode !== 0 && stderr) {\n\t\t\t\t\t\t// Check for common syntax error patterns\n\t\t\t\t\t\tif (stderr.includes('SyntaxError') ||\n\t\t\t\t\t\t\tstderr.includes('invalid syntax') ||\n\t\t\t\t\t\t\tstderr.includes('Unexpected token') ||\n\t\t\t\t\t\t\tstderr.includes('Unexpected identifier')) {\n\t\t\t\t\t\t\tthrow new Error(`Syntax error: ${stderr.trim()}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Combine stdout and stderr into output\n\t\t\t\t\tconst output = stderr ? `${stdout}\\n${stderr}`.trim() : stdout;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\toutput,\n\t\t\t\t\t\texitCode,\n\t\t\t\t\t\tlanguage: effectiveRuntime\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Re-throw syntax errors\n\t\t\t\t\tif (error instanceof Error && error.message.includes('Syntax error')) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For runtime errors, return a result instead of throwing\n\t\t\t\t\treturn {\n\t\t\t\t\t\toutput: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\texitCode: 1,\n\t\t\t\t\t\tlanguage: runtime || 'node'\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\n\t\t\trunCommand: async (sandbox: SandboxInstance, command: string, args: string[] = []): Promise<CommandResult> => {\n\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\ttry {\n\t\t\t\t\t// Construct full command with arguments, properly quoting each arg\n\t\t\t\t\tconst quotedArgs = args.map((arg: string) => {\n\t\t\t\t\t\tif (arg.includes(' ') || arg.includes('\"') || arg.includes(\"'\") || arg.includes('$') || arg.includes('`')) {\n\t\t\t\t\t\t\treturn `\"${arg.replace(/\"/g, '\\\\\"')}\"`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn arg;\n\t\t\t\t\t});\n\t\t\t\t\tconst fullCommand = quotedArgs.length > 0 ? `${command} ${quotedArgs.join(' ')}` : command;\n\n\t\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, fullCommand);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t\texitCode,\n\t\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout: '',\n\t\t\t\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\texitCode: 127,\n\t\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t\t};\n\t\t\t\t}\n\t\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\tpath: `${path}/${file.name}`,\n\t\t\t\t\t\t\tisDirectory: false,\n\t\t\t\t\t\t\tsize: file.size || 0,\n\t\t\t\t\t\t\tlastModified: 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\tpath: `${path}/${directory.name}`,\n\t\t\t\t\t\t\tisDirectory: true,\n\t\t\t\t\t\t\tsize: 0,\n\t\t\t\t\t\t\tlastModified: 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\t}\n});\n\nasync function handleBlaxelAuth(config: BlaxelConfig) {\n\t// Check if auth is already set in the SDK\n\ttry {\n\t\tawait settings.authenticate();\n\t} catch (error) {\n\t\t// If not, set the auth from the config\n\t\tif (config.workspace || process.env.BLAXEL_WORKSPACE && typeof process !== 'undefined') {\n\t\t\tprocess.env.BL_WORKSPACE = config.workspace || process.env.BLAXEL_WORKSPACE;\n\t\t}\n\t\tif (config.apiKey || process.env.BLAXEL_API_KEY && typeof process !== 'undefined') {\n\t\t\tprocess.env.BL_API_KEY = config.apiKey || process.env.BLAXEL_API_KEY;\n\t\t}\n\t\ttry {\n\t\t\tawait settings.authenticate();\n\t\t} catch (error) {\n\t\t\tthrow new Error('Blaxel authentication failed. Please check the following documents for more information: https://docs.blaxel.ai/Security/Access-tokens#using-api-keys');\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\nfunction convertSandboxStatus(status: string | undefined): SandboxStatus {\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 result = await sandbox.process.exec({ command });\n\n\t// Wait for process completion\n\tawait sandbox.process.wait(result.name);\n\n\t// Get final process result for exit code\n\tconst processResult = await sandbox.process.get(result.name);\n\n\treturn {\n\t\tstdout: processResult.logs,\n\t\tstderr: processResult.logs,\n\t\texitCode: processResult.exitCode || 0\n\t};\n}\n\n// Export the Blaxel SandboxInstance type for explicit typing\nexport type { SandboxInstance as BlaxelSandbox } from '@blaxel/core';\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,kBAA0C;AAC1C,wBAA+B;AAgCxB,IAAM,aAAS,kCAA8C;AAAA,EACnE,MAAM;AAAA,EACN,SAAS;AAAA,IACR,SAAS;AAAA;AAAA,MAER,QAAQ,OAAO,QAAsB,YAAmC;AACvE,cAAM,iBAAiB,MAAM;AAG7B,YAAI,QAAQ,OAAO,SAAS;AAG5B,YAAI,CAAC,OAAO,SAAS,SAAS,SAAS;AACtC,kBAAQ,QAAQ,SAAS;AAAA,YACxB,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,OAAO,SAAS;AACtB,cAAM,MAAM,SAAS,UAAU,GAAG,KAAK,KAAK,QAAQ,UAAU,GAAI,CAAC,MAAM;AAEzE,YAAI;AACH,cAAI;AAGJ,oBA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;AACD;AAMA,eAAe,qBACd,SACA,SACgE;AAEhE,QAAM,SAAS,MAAM,QAAQ,QAAQ,KAAK,EAAE,QAAQ,CAAC;AAGrD,QAAM,QAAQ,QAAQ,KAAK,OAAO,IAAI;AAGtC,QAAM,gBAAgB,MAAM,QAAQ,QAAQ,IAAI,OAAO,IAAI;AAE3D,SAAO;AAAA,IACN,QAAQ,cAAc;AAAA,IACtB,QAAQ,cAAc;AAAA,IACtB,UAAU,cAAc,YAAY;AAAA,EACrC;AACD;","names":["error"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { SandboxInstance, settings } from "@blaxel/core";
|
|
3
|
-
import { createProvider
|
|
3
|
+
import { createProvider } from "computesdk";
|
|
4
4
|
var blaxel = createProvider({
|
|
5
5
|
name: "blaxel",
|
|
6
6
|
methods: {
|
|
@@ -112,65 +112,53 @@ var blaxel = createProvider({
|
|
|
112
112
|
}
|
|
113
113
|
const escapedCode = code.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\$/g, "\\$").replace(/`/g, "\\`");
|
|
114
114
|
const command = effectiveRuntime === "python" ? `python3 -c "${escapedCode}"` : `node -e "${escapedCode}"`;
|
|
115
|
-
const { stdout, stderr, exitCode } = await executeWithStreaming(sandbox,
|
|
115
|
+
const { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, command);
|
|
116
116
|
if (exitCode !== 0 && stderr) {
|
|
117
117
|
if (stderr.includes("SyntaxError") || stderr.includes("invalid syntax") || stderr.includes("Unexpected token") || stderr.includes("Unexpected identifier")) {
|
|
118
118
|
throw new Error(`Syntax error: ${stderr.trim()}`);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
+
const output = stderr ? `${stdout}
|
|
122
|
+
${stderr}`.trim() : stdout;
|
|
121
123
|
return {
|
|
122
|
-
|
|
123
|
-
stderr,
|
|
124
|
+
output,
|
|
124
125
|
exitCode,
|
|
125
|
-
|
|
126
|
-
sandboxId: sandbox.metadata?.name || "blaxel-unknown",
|
|
127
|
-
provider: "blaxel"
|
|
126
|
+
language: effectiveRuntime
|
|
128
127
|
};
|
|
129
128
|
} catch (error) {
|
|
130
129
|
if (error instanceof Error && error.message.includes("Syntax error")) {
|
|
131
130
|
throw error;
|
|
132
131
|
}
|
|
133
132
|
return {
|
|
134
|
-
|
|
135
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
133
|
+
output: error instanceof Error ? error.message : String(error),
|
|
136
134
|
exitCode: 1,
|
|
137
|
-
|
|
138
|
-
sandboxId: sandbox.metadata?.name || "blaxel-unknown",
|
|
139
|
-
provider: "blaxel"
|
|
135
|
+
language: runtime || "node"
|
|
140
136
|
};
|
|
141
137
|
}
|
|
142
138
|
},
|
|
143
|
-
runCommand: async (sandbox, command, args = []
|
|
139
|
+
runCommand: async (sandbox, command, args = []) => {
|
|
144
140
|
const startTime = Date.now();
|
|
145
141
|
try {
|
|
146
|
-
const
|
|
147
|
-
const quotedArgs = finalArgs.map((arg) => {
|
|
142
|
+
const quotedArgs = args.map((arg) => {
|
|
148
143
|
if (arg.includes(" ") || arg.includes('"') || arg.includes("'") || arg.includes("$") || arg.includes("`")) {
|
|
149
144
|
return `"${arg.replace(/"/g, '\\"')}"`;
|
|
150
145
|
}
|
|
151
146
|
return arg;
|
|
152
147
|
});
|
|
153
|
-
const fullCommand = quotedArgs.length > 0 ? `${
|
|
154
|
-
const { stdout, stderr, exitCode } = await executeWithStreaming(sandbox,
|
|
148
|
+
const fullCommand = quotedArgs.length > 0 ? `${command} ${quotedArgs.join(" ")}` : command;
|
|
149
|
+
const { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, fullCommand);
|
|
155
150
|
return {
|
|
156
151
|
stdout,
|
|
157
152
|
stderr,
|
|
158
153
|
exitCode,
|
|
159
|
-
|
|
160
|
-
sandboxId: sandbox.metadata?.name || "blaxel-unknown",
|
|
161
|
-
provider: "blaxel",
|
|
162
|
-
isBackground,
|
|
163
|
-
...isBackground && { pid: -1 }
|
|
154
|
+
durationMs: Date.now() - startTime
|
|
164
155
|
};
|
|
165
156
|
} catch (error) {
|
|
166
157
|
return {
|
|
167
158
|
stdout: "",
|
|
168
159
|
stderr: error instanceof Error ? error.message : String(error),
|
|
169
160
|
exitCode: 127,
|
|
170
|
-
|
|
171
|
-
executionTime: Date.now() - startTime,
|
|
172
|
-
sandboxId: sandbox.metadata?.name || "blaxel-unknown",
|
|
173
|
-
provider: "blaxel"
|
|
161
|
+
durationMs: Date.now() - startTime
|
|
174
162
|
};
|
|
175
163
|
}
|
|
176
164
|
},
|
|
@@ -293,22 +281,6 @@ var blaxel = createProvider({
|
|
|
293
281
|
}
|
|
294
282
|
}
|
|
295
283
|
});
|
|
296
|
-
function createBlaxelCompute(config) {
|
|
297
|
-
const provider = blaxel(config);
|
|
298
|
-
return {
|
|
299
|
-
sandbox: {
|
|
300
|
-
create: async () => {
|
|
301
|
-
const sandbox = await provider.sandbox.create();
|
|
302
|
-
return {
|
|
303
|
-
...sandbox,
|
|
304
|
-
getInstance: () => {
|
|
305
|
-
return sandbox.getInstance();
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
284
|
async function handleBlaxelAuth(config) {
|
|
313
285
|
try {
|
|
314
286
|
await settings.authenticate();
|
|
@@ -364,11 +336,9 @@ function convertSandboxStatus(status) {
|
|
|
364
336
|
return "running";
|
|
365
337
|
}
|
|
366
338
|
}
|
|
367
|
-
async function executeWithStreaming(sandbox,
|
|
339
|
+
async function executeWithStreaming(sandbox, command) {
|
|
368
340
|
const result = await sandbox.process.exec({ command });
|
|
369
|
-
|
|
370
|
-
await sandbox.process.wait(result.name);
|
|
371
|
-
}
|
|
341
|
+
await sandbox.process.wait(result.name);
|
|
372
342
|
const processResult = await sandbox.process.get(result.name);
|
|
373
343
|
return {
|
|
374
344
|
stdout: processResult.logs,
|
|
@@ -377,7 +347,6 @@ async function executeWithStreaming(sandbox, isBackground, command) {
|
|
|
377
347
|
};
|
|
378
348
|
}
|
|
379
349
|
export {
|
|
380
|
-
blaxel
|
|
381
|
-
createBlaxelCompute
|
|
350
|
+
blaxel
|
|
382
351
|
};
|
|
383
352
|
//# sourceMappingURL=index.mjs.map
|
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, settings } from '@blaxel/core';\nimport { createProvider, createBackgroundCommand } from 'computesdk';\nimport type {\n\tExecutionResult,\n\tSandboxInfo,\n\tRuntime,\n\tCreateSandboxOptions,\n\tFileEntry,\n\tRunCommandOptions,\n\tSandboxStatus\n} from 'computesdk';\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 = createProvider<SandboxInstance, BlaxelConfig>({\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\tawait handleBlaxelAuth(config);\n\n\t\t\t\t// Determine the image to use\n\t\t\t\tlet image = config.image || 'blaxel/prod-base: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 && options?.runtime) {\n\t\t\t\t\tswitch (options.runtime) {\n\t\t\t\t\t\tcase 'python':\n\t\t\t\t\t\t\timage = 'blaxel/prod-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/prod-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/prod-base: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 envs = options?.envs;\n\t\t\t\tconst ttl = options?.timeout ? `${Math.ceil(options.timeout / 1000)}s` : undefined;\n\n\t\t\t\ttry {\n\t\t\t\t\tlet sandbox: SandboxInstance;\n\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\tname: options?.sandboxId || `blaxel-${Date.now()}`,\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 })),\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\t\t...options?.metadata?.labels,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\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});\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsandbox,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown'\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof Error) {\n\t\t\t\t\t\tif (error.message.includes('unauthorized') || error.message.includes('API key')) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Blaxel authentication failed. Please check your BLAXEL_API_KEY environment variable.`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (error.message.includes('quota') || error.message.includes('limit')) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Blaxel quota exceeded. Please check your usage limits.`\n\t\t\t\t\t\t\t);\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: ${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\tgetById: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\tawait handleBlaxelAuth(config);\n\n\t\t\t\ttry {\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\tawait handleBlaxelAuth(config);\n\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\tawait handleBlaxelAuth(config);\n\n\t\t\t\ttry {\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\t\trunCode: async (sandbox: SandboxInstance, code: string, runtime?: Runtime): Promise<ExecutionResult> => {\n\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\ttry {\n\t\t\t\t\t// Determine runtime: \n\t\t\t\t\t// 1. Use explicitly passed runtime if provided\n\t\t\t\t\t// 2. Check sandbox's actual runtime based on its image\n\t\t\t\t\t// 3. Fall back to auto-detection from code content\n\t\t\t\t\tlet effectiveRuntime = runtime;\n\n\t\t\t\t\tif (!effectiveRuntime) {\n\t\t\t\t\t\t// Check sandbox's image to determine its runtime\n\t\t\t\t\t\tconst sandboxImage = sandbox.spec?.runtime?.image || '';\n\t\t\t\t\t\tif (sandboxImage.includes('py')) {\n\t\t\t\t\t\t\teffectiveRuntime = 'python';\n\t\t\t\t\t\t} else if (sandboxImage.includes('ts') || sandboxImage.includes('node') || sandboxImage.includes('base')) {\n\t\t\t\t\t\t\t// prod-base, prod-ts-app are both Node/TypeScript environments\n\t\t\t\t\t\t\teffectiveRuntime = 'node';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Fall back to auto-detection with improved patterns for unknown images\n\t\t\t\t\t\t\teffectiveRuntime = (\n\t\t\t\t\t\t\t\t// Strong Python indicators\n\t\t\t\t\t\t\t\tcode.includes('print(') ||\n\t\t\t\t\t\t\t\t\tcode.includes('import ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('from ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('def ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('class ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('raise ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('except ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('elif ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('lambda ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('True') ||\n\t\t\t\t\t\t\t\t\tcode.includes('False') ||\n\t\t\t\t\t\t\t\t\tcode.includes('None') ||\n\t\t\t\t\t\t\t\t\tcode.includes('sys.') ||\n\t\t\t\t\t\t\t\t\tcode.includes('json.') ||\n\t\t\t\t\t\t\t\t\tcode.includes('__') ||\n\t\t\t\t\t\t\t\t\tcode.includes('f\"') ||\n\t\t\t\t\t\t\t\t\tcode.includes(\"f'\") ||\n\t\t\t\t\t\t\t\t\tcode.includes('\"\"\"') ||\n\t\t\t\t\t\t\t\t\tcode.includes(\"'''\")\n\t\t\t\t\t\t\t\t\t? 'python'\n\t\t\t\t\t\t\t\t\t// Default to Node.js for all other cases (including ambiguous)\n\t\t\t\t\t\t\t\t\t: 'node'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Execute code using Blaxel's process execution\n\t\t\t\t\t// Escape the code properly for shell execution\n\t\t\t\t\tconst escapedCode = code.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\$/g, '\\\\$').replace(/`/g, '\\\\`');\n\n\t\t\t\t\tconst command = effectiveRuntime === 'python'\n\t\t\t\t\t\t? `python3 -c \"${escapedCode}\"`\n\t\t\t\t\t\t: `node -e \"${escapedCode}\"`;\n\n\t\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, false, command);\n\n\t\t\t\t\t// Check for syntax errors and throw them\n\t\t\t\t\tif (exitCode !== 0 && stderr) {\n\t\t\t\t\t\t// Check for common syntax error patterns\n\t\t\t\t\t\tif (stderr.includes('SyntaxError') ||\n\t\t\t\t\t\t\tstderr.includes('invalid syntax') ||\n\t\t\t\t\t\t\tstderr.includes('Unexpected token') ||\n\t\t\t\t\t\t\tstderr.includes('Unexpected identifier')) {\n\t\t\t\t\t\t\tthrow new Error(`Syntax error: ${stderr.trim()}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t\texitCode,\n\t\t\t\t\t\texecutionTime: Date.now() - startTime,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\t\tprovider: 'blaxel'\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Re-throw syntax errors\n\t\t\t\t\tif (error instanceof Error && error.message.includes('Syntax error')) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For runtime errors, return a result instead of throwing\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout: '',\n\t\t\t\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\texitCode: 1,\n\t\t\t\t\t\texecutionTime: Date.now() - startTime,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\t\tprovider: 'blaxel'\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\n\t\t\trunCommand: async (sandbox: SandboxInstance, command: string, args: string[] = [], options?: RunCommandOptions): Promise<ExecutionResult> => {\n\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\ttry {\n\t\t\t\t\t// Handle background command execution\n\t\t\t\t\tconst { command: finalCommand, args: finalArgs, isBackground } = createBackgroundCommand(command, args, options);\n\n\t\t\t\t\t// Construct full command with arguments, properly quoting each arg\n\t\t\t\t\tconst quotedArgs = finalArgs.map(arg => {\n\t\t\t\t\t\t// Quote arguments that contain spaces or special characters\n\t\t\t\t\t\tif (arg.includes(' ') || arg.includes('\"') || arg.includes(\"'\") || arg.includes('$') || arg.includes('`')) {\n\t\t\t\t\t\t\t// Escape any double quotes in the argument and wrap in double quotes\n\t\t\t\t\t\t\treturn `\"${arg.replace(/\"/g, '\\\\\"')}\"`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn arg;\n\t\t\t\t\t});\n\t\t\t\t\tconst fullCommand = quotedArgs.length > 0 ? `${finalCommand} ${quotedArgs.join(' ')}` : finalCommand;\n\n\t\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, isBackground, fullCommand);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t\texitCode,\n\t\t\t\t\t\texecutionTime: Date.now() - startTime,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\t\tprovider: 'blaxel',\n\t\t\t\t\t\tisBackground,\n\t\t\t\t\t\t...(isBackground && { pid: -1 })\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// For command failures, return error info instead of throwing\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout: '',\n\t\t\t\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\texitCode: 127, // Command not found exit code\n\t\t\t\t\t\texecutionTime: Date.now() - startTime,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown',\n\t\t\t\t\t\tprovider: 'blaxel'\n\t\t\t\t\t};\n\t\t\t\t}\n\t\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\tpath: `${path}/${file.name}`,\n\t\t\t\t\t\t\tisDirectory: false,\n\t\t\t\t\t\t\tsize: file.size || 0,\n\t\t\t\t\t\t\tlastModified: 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\tpath: `${path}/${directory.name}`,\n\t\t\t\t\t\t\tisDirectory: true,\n\t\t\t\t\t\t\tsize: 0,\n\t\t\t\t\t\t\tlastModified: 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\t}\n});\n\n/**\n * Create a properly typed compute instance for Blaxel\n * This version provides full type safety for getInstance() calls\n * \n * @example\n * ```typescript\n * import { createBlaxelCompute } from '@computesdk/blaxel'\n * \n * const compute = createBlaxelCompute({ workspace: 'your-workspace', apiKey: 'your-key' });\n * const sandbox = await compute.sandbox.create();\n * const instance = sandbox.getInstance(); // ✅ Properly typed as SandboxInstance!\n * ```\n */\nexport function createBlaxelCompute(config: BlaxelConfig): {\n\tsandbox: {\n\t\tcreate(): Promise<{\n\t\t\tsandboxId: string;\n\t\t\tprovider: string;\n\t\t\trunCode(code: string, runtime?: import('computesdk').Runtime): Promise<import('computesdk').ExecutionResult>;\n\t\t\trunCommand(command: string, args?: string[]): Promise<import('computesdk').ExecutionResult>;\n\t\t\tgetInfo(): Promise<import('computesdk').SandboxInfo>;\n\t\t\tgetUrl(options: { port: number; protocol?: string }): Promise<string>;\n\t\t\tgetProvider(): ReturnType<typeof blaxel>;\n\t\t\tgetInstance(): SandboxInstance; // ✅ Properly typed!\n\t\t\tkill(): Promise<void>;\n\t\t\tdestroy(): Promise<void>;\n\t\t\tfilesystem: import('computesdk').SandboxFileSystem;\n\t\t}>;\n\t};\n} {\n\tconst provider = blaxel(config);\n\n\treturn {\n\t\tsandbox: {\n\t\t\tcreate: async () => {\n\t\t\t\tconst sandbox = await provider.sandbox.create();\n\t\t\t\treturn {\n\t\t\t\t\t...sandbox,\n\t\t\t\t\tgetInstance: (): SandboxInstance => {\n\t\t\t\t\t\treturn sandbox.getInstance() as SandboxInstance;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t};\n}\n\nasync function handleBlaxelAuth(config: BlaxelConfig) {\n\t// Check if auth is already set in the SDK\n\ttry {\n\t\tawait settings.authenticate();\n\t} catch (error) {\n\t\t// If not, set the auth from the config\n\t\tif (config.workspace || process.env.BLAXEL_WORKSPACE && typeof process !== 'undefined') {\n\t\t\tprocess.env.BL_WORKSPACE = config.workspace || process.env.BLAXEL_WORKSPACE;\n\t\t}\n\t\tif (config.apiKey || process.env.BLAXEL_API_KEY && typeof process !== 'undefined') {\n\t\t\tprocess.env.BL_API_KEY = config.apiKey || process.env.BLAXEL_API_KEY;\n\t\t}\n\t\ttry {\n\t\t\tawait settings.authenticate();\n\t\t} catch (error) {\n\t\t\tthrow new Error('Blaxel authentication failed. Please check the following documents for more information: https://docs.blaxel.ai/Security/Access-tokens#using-api-keys');\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\nfunction convertSandboxStatus(status: string | undefined): SandboxStatus {\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\tisBackground: boolean,\n\tcommand: string\n): Promise<{ stdout: string; stderr: string; exitCode: number }> {\n\t// Execute the command\n\tconst result = await sandbox.process.exec({ command });\n\n\tif (!isBackground) {\n\t\t// Wait for process completion\n\t\tawait sandbox.process.wait(result.name);\n\t}\n\n\t// Get final process result for exit code\n\tconst processResult = await sandbox.process.get(result.name);\n\n\t// TODO: Handle proper stdout/stderr streaming\n\treturn {\n\t\tstdout: processResult.logs,\n\t\tstderr: processResult.logs,\n\t\texitCode: processResult.exitCode || 0\n\t};\n}\n\n// Export the Blaxel SandboxInstance type for explicit typing\nexport type { SandboxInstance as BlaxelSandbox } from '@blaxel/core';\n\n"],"mappings":";AAMA,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,gBAAgB,+BAA+B;AAgCjD,IAAM,SAAS,eAA8C;AAAA,EACnE,MAAM;AAAA,EACN,SAAS;AAAA,IACR,SAAS;AAAA;AAAA,MAER,QAAQ,OAAO,QAAsB,YAAmC;AACvE,cAAM,iBAAiB,MAAM;AAG7B,YAAI,QAAQ,OAAO,SAAS;AAG5B,YAAI,CAAC,OAAO,SAAS,SAAS,SAAS;AACtC,kBAAQ,QAAQ,SAAS;AAAA,YACxB,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,OAAO,SAAS;AACtB,cAAM,MAAM,SAAS,UAAU,GAAG,KAAK,KAAK,QAAQ,UAAU,GAAI,CAAC,MAAM;AAEzE,YAAI;AACH,cAAI;AAGJ,oBAAU,MAAM,gBAAgB,kBAAkB;AAAA,YACjD,MAAM,SAAS,aAAa,UAAU,KAAK,IAAI,CAAC;AAAA,YAChD;AAAA,YACA;AAAA,YACA,MAAM,OAAO,QAAQ,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,EAAE,MAAM,MAAM,EAAE;AAAA,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AAAA,IACb,KAAK;AAAK,aAAO,QAAQ;AAAA;AAAA,IACzB,KAAK;AAAK,aAAO,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;AAEA,SAAS,qBAAqB,QAA2C;AACxE,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,cACA,SACgE;AAEhE,QAAM,SAAS,MAAM,QAAQ,QAAQ,KAAK,EAAE,QAAQ,CAAC;AAErD,MAAI,CAAC,cAAc;AAElB,UAAM,QAAQ,QAAQ,KAAK,OAAO,IAAI;AAAA,EACvC;AAGA,QAAM,gBAAgB,MAAM,QAAQ,QAAQ,IAAI,OAAO,IAAI;AAG3D,SAAO;AAAA,IACN,QAAQ,cAAc;AAAA,IACtB,QAAQ,cAAc;AAAA,IACtB,UAAU,cAAc,YAAY;AAAA,EACrC;AACD;","names":["error"]}
|
|
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, settings } from '@blaxel/core';\nimport { createProvider } from 'computesdk';\nimport type {\n\tCodeResult,\n\tCommandResult,\n\tSandboxInfo,\n\tRuntime,\n\tCreateSandboxOptions,\n\tFileEntry,\n\tSandboxStatus\n} from 'computesdk';\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 = createProvider<SandboxInstance, BlaxelConfig>({\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\tawait handleBlaxelAuth(config);\n\n\t\t\t\t// Determine the image to use\n\t\t\t\tlet image = config.image || 'blaxel/prod-base: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 && options?.runtime) {\n\t\t\t\t\tswitch (options.runtime) {\n\t\t\t\t\t\tcase 'python':\n\t\t\t\t\t\t\timage = 'blaxel/prod-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/prod-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/prod-base: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 envs = options?.envs;\n\t\t\t\tconst ttl = options?.timeout ? `${Math.ceil(options.timeout / 1000)}s` : undefined;\n\n\t\t\t\ttry {\n\t\t\t\t\tlet sandbox: SandboxInstance;\n\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\tname: options?.sandboxId || `blaxel-${Date.now()}`,\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 })),\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\t\t...options?.metadata?.labels,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\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});\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsandbox,\n\t\t\t\t\t\tsandboxId: sandbox.metadata?.name || 'blaxel-unknown'\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof Error) {\n\t\t\t\t\t\tif (error.message.includes('unauthorized') || error.message.includes('API key')) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Blaxel authentication failed. Please check your BLAXEL_API_KEY environment variable.`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (error.message.includes('quota') || error.message.includes('limit')) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Blaxel quota exceeded. Please check your usage limits.`\n\t\t\t\t\t\t\t);\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: ${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\tgetById: async (config: BlaxelConfig, sandboxId: string) => {\n\t\t\t\tawait handleBlaxelAuth(config);\n\n\t\t\t\ttry {\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\tawait handleBlaxelAuth(config);\n\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\tawait handleBlaxelAuth(config);\n\n\t\t\t\ttry {\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\t\trunCode: async (sandbox: SandboxInstance, code: string, runtime?: Runtime): Promise<CodeResult> => {\n\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\ttry {\n\t\t\t\t\t// Determine runtime: \n\t\t\t\t\t// 1. Use explicitly passed runtime if provided\n\t\t\t\t\t// 2. Check sandbox's actual runtime based on its image\n\t\t\t\t\t// 3. Fall back to auto-detection from code content\n\t\t\t\t\tlet effectiveRuntime = runtime;\n\n\t\t\t\t\tif (!effectiveRuntime) {\n\t\t\t\t\t\t// Check sandbox's image to determine its runtime\n\t\t\t\t\t\tconst sandboxImage = sandbox.spec?.runtime?.image || '';\n\t\t\t\t\t\tif (sandboxImage.includes('py')) {\n\t\t\t\t\t\t\teffectiveRuntime = 'python';\n\t\t\t\t\t\t} else if (sandboxImage.includes('ts') || sandboxImage.includes('node') || sandboxImage.includes('base')) {\n\t\t\t\t\t\t\t// prod-base, prod-ts-app are both Node/TypeScript environments\n\t\t\t\t\t\t\teffectiveRuntime = 'node';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Fall back to auto-detection with improved patterns for unknown images\n\t\t\t\t\t\t\teffectiveRuntime = (\n\t\t\t\t\t\t\t\t// Strong Python indicators\n\t\t\t\t\t\t\t\tcode.includes('print(') ||\n\t\t\t\t\t\t\t\t\tcode.includes('import ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('from ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('def ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('class ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('raise ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('except ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('elif ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('lambda ') ||\n\t\t\t\t\t\t\t\t\tcode.includes('True') ||\n\t\t\t\t\t\t\t\t\tcode.includes('False') ||\n\t\t\t\t\t\t\t\t\tcode.includes('None') ||\n\t\t\t\t\t\t\t\t\tcode.includes('sys.') ||\n\t\t\t\t\t\t\t\t\tcode.includes('json.') ||\n\t\t\t\t\t\t\t\t\tcode.includes('__') ||\n\t\t\t\t\t\t\t\t\tcode.includes('f\"') ||\n\t\t\t\t\t\t\t\t\tcode.includes(\"f'\") ||\n\t\t\t\t\t\t\t\t\tcode.includes('\"\"\"') ||\n\t\t\t\t\t\t\t\t\tcode.includes(\"'''\")\n\t\t\t\t\t\t\t\t\t? 'python'\n\t\t\t\t\t\t\t\t\t// Default to Node.js for all other cases (including ambiguous)\n\t\t\t\t\t\t\t\t\t: 'node'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Execute code using Blaxel's process execution\n\t\t\t\t\t// Escape the code properly for shell execution\n\t\t\t\t\tconst escapedCode = code.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\$/g, '\\\\$').replace(/`/g, '\\\\`');\n\n\t\t\t\t\tconst command = effectiveRuntime === 'python'\n\t\t\t\t\t\t? `python3 -c \"${escapedCode}\"`\n\t\t\t\t\t\t: `node -e \"${escapedCode}\"`;\n\n\t\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, command);\n\n\t\t\t\t\t// Check for syntax errors and throw them\n\t\t\t\t\tif (exitCode !== 0 && stderr) {\n\t\t\t\t\t\t// Check for common syntax error patterns\n\t\t\t\t\t\tif (stderr.includes('SyntaxError') ||\n\t\t\t\t\t\t\tstderr.includes('invalid syntax') ||\n\t\t\t\t\t\t\tstderr.includes('Unexpected token') ||\n\t\t\t\t\t\t\tstderr.includes('Unexpected identifier')) {\n\t\t\t\t\t\t\tthrow new Error(`Syntax error: ${stderr.trim()}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Combine stdout and stderr into output\n\t\t\t\t\tconst output = stderr ? `${stdout}\\n${stderr}`.trim() : stdout;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\toutput,\n\t\t\t\t\t\texitCode,\n\t\t\t\t\t\tlanguage: effectiveRuntime\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Re-throw syntax errors\n\t\t\t\t\tif (error instanceof Error && error.message.includes('Syntax error')) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For runtime errors, return a result instead of throwing\n\t\t\t\t\treturn {\n\t\t\t\t\t\toutput: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\texitCode: 1,\n\t\t\t\t\t\tlanguage: runtime || 'node'\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\n\t\t\trunCommand: async (sandbox: SandboxInstance, command: string, args: string[] = []): Promise<CommandResult> => {\n\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\ttry {\n\t\t\t\t\t// Construct full command with arguments, properly quoting each arg\n\t\t\t\t\tconst quotedArgs = args.map((arg: string) => {\n\t\t\t\t\t\tif (arg.includes(' ') || arg.includes('\"') || arg.includes(\"'\") || arg.includes('$') || arg.includes('`')) {\n\t\t\t\t\t\t\treturn `\"${arg.replace(/\"/g, '\\\\\"')}\"`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn arg;\n\t\t\t\t\t});\n\t\t\t\t\tconst fullCommand = quotedArgs.length > 0 ? `${command} ${quotedArgs.join(' ')}` : command;\n\n\t\t\t\t\tconst { stdout, stderr, exitCode } = await executeWithStreaming(sandbox, fullCommand);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t\texitCode,\n\t\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstdout: '',\n\t\t\t\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\texitCode: 127,\n\t\t\t\t\t\tdurationMs: Date.now() - startTime\n\t\t\t\t\t};\n\t\t\t\t}\n\t\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\tpath: `${path}/${file.name}`,\n\t\t\t\t\t\t\tisDirectory: false,\n\t\t\t\t\t\t\tsize: file.size || 0,\n\t\t\t\t\t\t\tlastModified: 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\tpath: `${path}/${directory.name}`,\n\t\t\t\t\t\t\tisDirectory: true,\n\t\t\t\t\t\t\tsize: 0,\n\t\t\t\t\t\t\tlastModified: 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\t}\n});\n\nasync function handleBlaxelAuth(config: BlaxelConfig) {\n\t// Check if auth is already set in the SDK\n\ttry {\n\t\tawait settings.authenticate();\n\t} catch (error) {\n\t\t// If not, set the auth from the config\n\t\tif (config.workspace || process.env.BLAXEL_WORKSPACE && typeof process !== 'undefined') {\n\t\t\tprocess.env.BL_WORKSPACE = config.workspace || process.env.BLAXEL_WORKSPACE;\n\t\t}\n\t\tif (config.apiKey || process.env.BLAXEL_API_KEY && typeof process !== 'undefined') {\n\t\t\tprocess.env.BL_API_KEY = config.apiKey || process.env.BLAXEL_API_KEY;\n\t\t}\n\t\ttry {\n\t\t\tawait settings.authenticate();\n\t\t} catch (error) {\n\t\t\tthrow new Error('Blaxel authentication failed. Please check the following documents for more information: https://docs.blaxel.ai/Security/Access-tokens#using-api-keys');\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\nfunction convertSandboxStatus(status: string | undefined): SandboxStatus {\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 result = await sandbox.process.exec({ command });\n\n\t// Wait for process completion\n\tawait sandbox.process.wait(result.name);\n\n\t// Get final process result for exit code\n\tconst processResult = await sandbox.process.get(result.name);\n\n\treturn {\n\t\tstdout: processResult.logs,\n\t\tstderr: processResult.logs,\n\t\texitCode: processResult.exitCode || 0\n\t};\n}\n\n// Export the Blaxel SandboxInstance type for explicit typing\nexport type { SandboxInstance as BlaxelSandbox } from '@blaxel/core';\n\n"],"mappings":";AAMA,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,sBAAsB;AAgCxB,IAAM,SAAS,eAA8C;AAAA,EACnE,MAAM;AAAA,EACN,SAAS;AAAA,IACR,SAAS;AAAA;AAAA,MAER,QAAQ,OAAO,QAAsB,YAAmC;AACvE,cAAM,iBAAiB,MAAM;AAG7B,YAAI,QAAQ,OAAO,SAAS;AAG5B,YAAI,CAAC,OAAO,SAAS,SAAS,SAAS;AACtC,kBAAQ,QAAQ,SAAS;AAAA,YACxB,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,OAAO,SAAS;AACtB,cAAM,MAAM,SAAS,UAAU,GAAG,KAAK,KAAK,QAAQ,UAAU,GAAI,CAAC,MAAM;AAEzE,YAAI;AACH,cAAI;AAGJ,oBAAU,MAAM,gBAAgB,kBAAkB;AAAA,YACjD,MAAM,SAAS,aAAa,UAAU,KAAK,IAAI,CAAC;AAAA,YAChD;AAAA,YACA;AAAA,YACA,MAAM,OAAO,Q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AK,OAAO,IAAI;AAGtC,QAAM,gBAAgB,MAAM,QAAQ,QAAQ,IAAI,OAAO,IAAI;AAE3D,SAAO;AAAA,IACN,QAAQ,cAAc;AAAA,IACtB,QAAQ,cAAc;AAAA,IACtB,UAAU,cAAc,YAAY;AAAA,EACrC;AACD;","names":["error"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/blaxel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Blaxel provider for ComputeSDK",
|
|
5
5
|
"author": "ComputeSDK",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@blaxel/core": "^0.2.42",
|
|
22
|
-
"computesdk": "1.
|
|
22
|
+
"computesdk": "1.9.0"
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"blaxel",
|