@computesdk/tensorlake 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -25,7 +25,6 @@ __export(index_exports, {
25
25
  module.exports = __toCommonJS(index_exports);
26
26
  var import_tensorlake = require("tensorlake");
27
27
  var import_provider = require("@computesdk/provider");
28
- var DEFAULT_IMAGE = "ubuntu-minimal";
29
28
  function resolveAuth(config) {
30
29
  const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.TENSORLAKE_API_KEY || "";
31
30
  if (!apiKey) {
@@ -42,23 +41,26 @@ var tensorlake = (0, import_provider.defineProvider)({
42
41
  sandbox: {
43
42
  create: async (config, options) => {
44
43
  const { apiKey, apiUrl } = resolveAuth(config);
45
- const image = options?.image || config.image || DEFAULT_IMAGE;
44
+ const image = options?.image || config.image;
46
45
  const timeoutMs = options?.timeout ?? config.timeout;
47
46
  const timeoutSecs = timeoutMs ? Math.ceil(timeoutMs / 1e3) : void 0;
47
+ const params = {
48
+ ...image && { image },
49
+ ...timeoutSecs && { timeoutSecs },
50
+ ...options?.cpus && { cpus: options.cpus },
51
+ ...options?.memoryMb && { memoryMb: options.memoryMb },
52
+ ...options?.ephemeralDiskMb && {
53
+ ephemeralDiskMb: options.ephemeralDiskMb
54
+ },
55
+ ...options?.name && { name: options.name },
56
+ ...options?.snapshotId && { snapshotId: options.snapshotId },
57
+ proxyUrl: config.proxyUrl,
58
+ apiKey,
59
+ apiUrl
60
+ };
48
61
  try {
49
62
  const startTime = Date.now();
50
- const instance = await import_tensorlake.Sandbox.create({
51
- image,
52
- cpus: 1,
53
- memoryMb: 1024,
54
- ephemeralDiskMb: 2048,
55
- ...timeoutSecs && { timeoutSecs },
56
- ...options?.name && { name: options.name },
57
- ...options?.snapshotId && { snapshotId: options.snapshotId },
58
- proxyUrl: config.proxyUrl,
59
- apiKey,
60
- apiUrl
61
- });
63
+ const instance = await import_tensorlake.Sandbox.create(params);
62
64
  const sandbox = {
63
65
  config,
64
66
  sandbox: instance
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/// <reference types=\"node\" />\n/**\n * Tensorlake Provider - SDK-based Implementation\n *\n * Stateful MicroVM sandboxes for agentic applications and LLM-generated code execution.\n * Uses the official tensorlake npm SDK (0.5.7).\n */\n\nimport { Sandbox, SandboxStatus, OutputMode } from \"tensorlake\";\nimport type { SandboxInfo } from \"tensorlake\";\nimport { defineProvider } from \"@computesdk/provider\";\nimport type {\n CodeResult,\n CommandResult,\n SandboxInfo as ComputeSandboxInfo,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions,\n} from \"@computesdk/provider\";\n\nconst DEFAULT_IMAGE = \"ubuntu-minimal\";\n\nexport interface TensorlakeConfig {\n /** Tensorlake API key — falls back to TENSORLAKE_API_KEY environment variable */\n apiKey?: string;\n /** Override for the management API base URL */\n apiUrl?: string;\n /** Override for the sandbox proxy URL */\n proxyUrl?: string;\n /** Default container image for new sandboxes (default: ubuntu-minimal) */\n image?: string;\n /** Default timeout in milliseconds for sandboxes */\n timeout?: number;\n}\n\nexport interface TensorlakeSandboxContext {\n config: TensorlakeConfig;\n /** Connected SDK Sandbox instance — used for all proxy operations */\n sandbox: InstanceType<typeof Sandbox>;\n}\n\nfunction resolveAuth(config: TensorlakeConfig): {\n apiKey: string;\n apiUrl?: string;\n} {\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_KEY) ||\n \"\";\n if (!apiKey) {\n throw new Error(\n `Missing Tensorlake API key. Provide 'apiKey' in config or set TENSORLAKE_API_KEY environment variable. ` +\n `Get your API key from https://app.tensorlake.ai`\n );\n }\n const apiUrl =\n config.apiUrl ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_URL) ||\n undefined;\n return { apiKey, apiUrl };\n}\n\nexport const tensorlake = defineProvider<\n TensorlakeSandboxContext,\n TensorlakeConfig\n>({\n name: \"tensorlake\",\n methods: {\n sandbox: {\n create: async (\n config: TensorlakeConfig,\n options?: CreateSandboxOptions\n ) => {\n const { apiKey, apiUrl } = resolveAuth(config);\n const image = options?.image || config.image || DEFAULT_IMAGE;\n const timeoutMs = options?.timeout ?? config.timeout;\n const timeoutSecs = timeoutMs ? Math.ceil(timeoutMs / 1000) : undefined;\n\n try {\n const startTime = Date.now();\n const instance = await Sandbox.create({\n image,\n cpus: 1,\n memoryMb: 1024,\n ephemeralDiskMb: 2048,\n ...(timeoutSecs && { timeoutSecs }),\n ...(options?.name && { name: options.name }),\n ...(options?.snapshotId && { snapshotId: options.snapshotId }),\n proxyUrl: config.proxyUrl,\n apiKey,\n apiUrl,\n });\n\n const sandbox: TensorlakeSandboxContext = {\n config,\n sandbox: instance,\n };\n const durationMs = Date.now() - startTime;\n return {\n sandbox,\n sandboxId: instance.sandboxId,\n durationMs,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"401\")) {\n throw new Error(\n `Tensorlake authentication failed. Please check your TENSORLAKE_API_KEY. ` +\n `Get your API key from https://app.tensorlake.ai`\n );\n }\n throw new Error(\n `Failed to create Tensorlake sandbox: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getById: async (config: TensorlakeConfig, sandboxId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n const ctx: TensorlakeSandboxContext = {\n config,\n sandbox,\n };\n return { sandbox: ctx, sandboxId: sandbox.sandboxId };\n } catch {\n return null;\n }\n },\n\n list: async (config: TensorlakeConfig) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandboxes = await Sandbox.list({ apiKey, apiUrl });\n return Promise.all(\n sandboxes.map(async (s) => {\n const sandbox = await Sandbox.connect({\n sandboxId: s.sandboxId,\n proxyUrl: config.proxyUrl,\n routingHint: s.routingHint,\n apiKey,\n apiUrl,\n });\n return {\n sandbox: {\n sandboxId: s.sandboxId,\n config,\n sandbox,\n } as TensorlakeSandboxContext,\n sandboxId: s.sandboxId,\n };\n })\n );\n } catch {\n return [];\n }\n },\n\n destroy: async (config: TensorlakeConfig, sandboxId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n await sandbox.terminate();\n } catch {\n // Sandbox may already be terminated\n }\n },\n\n runCommand: async (\n ctx: TensorlakeSandboxContext,\n command: string,\n options?: RunCommandOptions\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n\n if (options?.background) {\n try {\n await ctx.sandbox.startProcess(\"sh\", {\n args: [\"-c\", command],\n stdoutMode: OutputMode.DISCARD,\n stderrMode: OutputMode.DISCARD,\n ...(options.env &&\n Object.keys(options.env).length > 0 && { env: options.env }),\n ...(options.cwd && { workingDir: options.cwd }),\n });\n } catch (error) {\n return {\n stdout: \"\",\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n }\n\n try {\n const result = await ctx.sandbox.run(\"sh\", {\n args: [\"-c\", command],\n ...(options?.env &&\n Object.keys(options.env).length > 0 && { env: options.env }),\n ...(options?.cwd && { workingDir: options.cwd }),\n });\n\n const durationMs = Date.now() - startTime;\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode ?? 0,\n durationMs,\n };\n } catch (error) {\n return {\n stdout: \"\",\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n },\n\n getInfo: async (\n ctx: TensorlakeSandboxContext\n ): Promise<ComputeSandboxInfo> => {\n try {\n const info = await ctx.sandbox.info();\n return {\n id: ctx.sandbox.sandboxId,\n provider: \"tensorlake\",\n status:\n info.status === SandboxStatus.RUNNING ? \"running\" : \"stopped\",\n createdAt: info.createdAt || new Date(),\n timeout:\n info.timeoutSecs != null ? info.timeoutSecs * 1000 : 300_000,\n metadata: {},\n };\n } catch {\n return {\n id: ctx.sandbox.sandboxId,\n provider: \"tensorlake\",\n status: \"running\",\n createdAt: new Date(),\n timeout: 300_000,\n metadata: {},\n };\n }\n },\n\n getUrl: async (\n ctx: TensorlakeSandboxContext,\n options: { port: number; protocol?: string }\n ): Promise<string> => {\n const { port, protocol: optionsProtocol } = options;\n const protocol = optionsProtocol || \"https\";\n\n const apiUrl =\n ctx.config.apiUrl ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_URL) ||\n \"https://api.tensorlake.ai\";\n\n const proxyDomain = new URL(apiUrl).hostname;\n const subdomain =\n port === 443 || port === 80\n ? ctx.sandbox.sandboxId\n : `${port}-${ctx.sandbox.sandboxId}`;\n\n return `${protocol}://${subdomain}.${proxyDomain}`;\n },\n\n filesystem: {\n readFile: async (\n ctx: TensorlakeSandboxContext,\n path: string\n ): Promise<string> => {\n const bytes = await ctx.sandbox.readFile(path);\n return Buffer.from(bytes).toString(\"utf-8\");\n },\n\n writeFile: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n content: string\n ): Promise<void> => {\n await ctx.sandbox.writeFile(path, Buffer.from(content, \"utf-8\"));\n },\n\n mkdir: async (\n ctx: TensorlakeSandboxContext,\n path: string\n ): Promise<void> => {\n const result = await ctx.sandbox.run(\"mkdir\", { args: [\"-p\", path] });\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`\n );\n }\n },\n\n readdir: async (\n ctx: TensorlakeSandboxContext,\n path: string\n ): Promise<FileEntry[]> => {\n const response = await ctx.sandbox.listDirectory(path);\n return response.entries.map((e) => ({\n name: e.name,\n type: e.isDir ? (\"directory\" as const) : (\"file\" as const),\n size: e.size || 0,\n modified: e.modifiedAt ?? new Date(),\n }));\n },\n\n exists: async (\n ctx: TensorlakeSandboxContext,\n path: string\n ): Promise<boolean> => {\n try {\n await ctx.sandbox.readFile(path);\n return true;\n } catch {}\n try {\n await ctx.sandbox.listDirectory(path);\n return true;\n } catch {}\n return false;\n },\n\n remove: async (\n ctx: TensorlakeSandboxContext,\n path: string\n ): Promise<void> => {\n try {\n await ctx.sandbox.deleteFile(path);\n } catch {\n // May be a directory — fall back to rm -rf\n const result = await ctx.sandbox.run(\"rm\", { args: [\"-rf\", path] });\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n }\n },\n },\n\n getInstance: (ctx: TensorlakeSandboxContext): TensorlakeSandboxContext =>\n ctx,\n },\n\n snapshot: {\n create: async (\n config: TensorlakeConfig,\n sandboxId: string,\n options?: { name?: string }\n ) => {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n const result = await sandbox.checkpoint();\n\n if (!result) {\n throw new Error(\n `Failed to create snapshot for sandbox '${sandboxId}': checkpoint() did not return a snapshot result.`\n );\n }\n\n return {\n id: result.snapshotId,\n provider: \"tensorlake\",\n createdAt: new Date(),\n metadata: { name: options?.name },\n };\n },\n\n list: async (config: TensorlakeConfig) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n return await Sandbox.listSnapshots({ apiKey, apiUrl });\n } catch {\n return [];\n }\n },\n\n delete: async (config: TensorlakeConfig, snapshotId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n await Sandbox.deleteSnapshot(snapshotId, { apiKey, apiUrl });\n } catch {\n // Ignore\n }\n },\n },\n },\n});\n\nexport type { TensorlakeSandboxContext as TensorlakeSandbox };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,wBAAmD;AAEnD,sBAA+B;AAU/B,IAAM,gBAAgB;AAqBtB,SAAS,YAAY,QAGnB;AACA,QAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,sBAChD;AACF,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,QAAM,SACJ,OAAO,UACN,OAA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C,SAAS;AAAA,UACrD;AAAA,QACF;AAEA,eAAO;AAAA,UACL,IAAI,OAAO;AAAA,UACX,UAAU;AAAA,UACV,WAAW,oBAAI,KAAK;AAAA,UACpB,UAAU,EAAE,MAAM,SAAS,KAAK;AAAA,QAClC;AAAA,MACF;AAAA,MAEA,MAAM,OAAO,WAA6B;AACxC,YAAI;AACF,gBAAM,EAAE,QAAQ,OAAO,IAAI,YAAY,MAAM;AAC7C,iBAAO,MAAM,0BAAQ,cAAc,EAAE,QAAQ,OAAO,CAAC;AAAA,QACvD,QAAQ;AACN,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,MAEA,QAAQ,OAAO,QAA0B,eAAuB;AAC9D,YAAI;AACF,gBAAM,EAAE,QAAQ,OAAO,IAAI,YAAY,MAAM;AAC7C,gBAAM,0BAAQ,eAAe,YAAY,EAAE,QAAQ,OAAO,CAAC;AAAA,QAC7D,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/// <reference types=\"node\" />\n/**\n * Tensorlake Provider - SDK-based Implementation\n *\n * Stateful MicroVM sandboxes for agentic applications and LLM-generated code execution.\n * Uses the official tensorlake npm SDK (0.5.7).\n */\n\nimport { Sandbox, SandboxStatus, OutputMode } from \"tensorlake\";\nimport type { SandboxInfo } from \"tensorlake\";\nimport { defineProvider } from \"@computesdk/provider\";\nimport type {\n CodeResult,\n CommandResult,\n SandboxInfo as ComputeSandboxInfo,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions,\n} from \"@computesdk/provider\";\n\nexport interface TensorlakeConfig {\n /** Tensorlake API key — falls back to TENSORLAKE_API_KEY environment variable */\n apiKey?: string;\n /** Override for the management API base URL */\n apiUrl?: string;\n /** Override for the sandbox proxy URL */\n proxyUrl?: string;\n /** Default container image for new sandboxes (default: ubuntu-minimal) */\n image?: string;\n /** Default timeout in milliseconds for sandboxes */\n timeout?: number;\n}\n\nexport interface TensorlakeSandboxContext {\n config: TensorlakeConfig;\n /** Connected SDK Sandbox instance — used for all proxy operations */\n sandbox: InstanceType<typeof Sandbox>;\n}\n\nfunction resolveAuth(config: TensorlakeConfig): {\n apiKey: string;\n apiUrl?: string;\n} {\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_KEY) ||\n \"\";\n if (!apiKey) {\n throw new Error(\n `Missing Tensorlake API key. Provide 'apiKey' in config or set TENSORLAKE_API_KEY environment variable. ` +\n `Get your API key from https://app.tensorlake.ai`,\n );\n }\n const apiUrl =\n config.apiUrl ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_URL) ||\n undefined;\n return { apiKey, apiUrl };\n}\n\nexport const tensorlake = defineProvider<\n TensorlakeSandboxContext,\n TensorlakeConfig\n>({\n name: \"tensorlake\",\n methods: {\n sandbox: {\n create: async (\n config: TensorlakeConfig,\n options?: CreateSandboxOptions,\n ) => {\n const { apiKey, apiUrl } = resolveAuth(config);\n const image = options?.image || config.image;\n const timeoutMs = options?.timeout ?? config.timeout;\n const timeoutSecs = timeoutMs ? Math.ceil(timeoutMs / 1000) : undefined;\n\n const params = {\n ...(image && { image }),\n ...(timeoutSecs && { timeoutSecs }),\n ...(options?.cpus && { cpus: options.cpus }),\n ...(options?.memoryMb && { memoryMb: options.memoryMb }),\n ...(options?.ephemeralDiskMb && {\n ephemeralDiskMb: options.ephemeralDiskMb,\n }),\n ...(options?.name && { name: options.name }),\n ...(options?.snapshotId && { snapshotId: options.snapshotId }),\n proxyUrl: config.proxyUrl,\n apiKey,\n apiUrl,\n };\n\n try {\n const startTime = Date.now();\n const instance = await Sandbox.create(params);\n\n const sandbox: TensorlakeSandboxContext = {\n config,\n sandbox: instance,\n };\n const durationMs = Date.now() - startTime;\n return {\n sandbox,\n sandboxId: instance.sandboxId,\n durationMs,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"401\")) {\n throw new Error(\n `Tensorlake authentication failed. Please check your TENSORLAKE_API_KEY. ` +\n `Get your API key from https://app.tensorlake.ai`,\n );\n }\n throw new Error(\n `Failed to create Tensorlake sandbox: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n },\n\n getById: async (config: TensorlakeConfig, sandboxId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n const ctx: TensorlakeSandboxContext = {\n config,\n sandbox,\n };\n return { sandbox: ctx, sandboxId: sandbox.sandboxId };\n } catch {\n return null;\n }\n },\n\n list: async (config: TensorlakeConfig) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandboxes = await Sandbox.list({ apiKey, apiUrl });\n return Promise.all(\n sandboxes.map(async (s) => {\n const sandbox = await Sandbox.connect({\n sandboxId: s.sandboxId,\n proxyUrl: config.proxyUrl,\n routingHint: s.routingHint,\n apiKey,\n apiUrl,\n });\n return {\n sandbox: {\n sandboxId: s.sandboxId,\n config,\n sandbox,\n } as TensorlakeSandboxContext,\n sandboxId: s.sandboxId,\n };\n }),\n );\n } catch {\n return [];\n }\n },\n\n destroy: async (config: TensorlakeConfig, sandboxId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n await sandbox.terminate();\n } catch {\n // Sandbox may already be terminated\n }\n },\n\n runCommand: async (\n ctx: TensorlakeSandboxContext,\n command: string,\n options?: RunCommandOptions,\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n\n if (options?.background) {\n try {\n await ctx.sandbox.startProcess(\"sh\", {\n args: [\"-c\", command],\n stdoutMode: OutputMode.DISCARD,\n stderrMode: OutputMode.DISCARD,\n ...(options.env &&\n Object.keys(options.env).length > 0 && { env: options.env }),\n ...(options.cwd && { workingDir: options.cwd }),\n });\n } catch (error) {\n return {\n stdout: \"\",\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n }\n\n try {\n const result = await ctx.sandbox.run(\"sh\", {\n args: [\"-c\", command],\n ...(options?.env &&\n Object.keys(options.env).length > 0 && { env: options.env }),\n ...(options?.cwd && { workingDir: options.cwd }),\n });\n\n const durationMs = Date.now() - startTime;\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode ?? 0,\n durationMs,\n };\n } catch (error) {\n return {\n stdout: \"\",\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n },\n\n getInfo: async (\n ctx: TensorlakeSandboxContext,\n ): Promise<ComputeSandboxInfo> => {\n try {\n const info = await ctx.sandbox.info();\n return {\n id: ctx.sandbox.sandboxId,\n provider: \"tensorlake\",\n status:\n info.status === SandboxStatus.RUNNING ? \"running\" : \"stopped\",\n createdAt: info.createdAt || new Date(),\n timeout:\n info.timeoutSecs != null ? info.timeoutSecs * 1000 : 300_000,\n metadata: {},\n };\n } catch {\n return {\n id: ctx.sandbox.sandboxId,\n provider: \"tensorlake\",\n status: \"running\",\n createdAt: new Date(),\n timeout: 300_000,\n metadata: {},\n };\n }\n },\n\n getUrl: async (\n ctx: TensorlakeSandboxContext,\n options: { port: number; protocol?: string },\n ): Promise<string> => {\n const { port, protocol: optionsProtocol } = options;\n const protocol = optionsProtocol || \"https\";\n\n const apiUrl =\n ctx.config.apiUrl ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_URL) ||\n \"https://api.tensorlake.ai\";\n\n const proxyDomain = new URL(apiUrl).hostname;\n const subdomain =\n port === 443 || port === 80\n ? ctx.sandbox.sandboxId\n : `${port}-${ctx.sandbox.sandboxId}`;\n\n return `${protocol}://${subdomain}.${proxyDomain}`;\n },\n\n filesystem: {\n readFile: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n ): Promise<string> => {\n const bytes = await ctx.sandbox.readFile(path);\n return Buffer.from(bytes).toString(\"utf-8\");\n },\n\n writeFile: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n content: string,\n ): Promise<void> => {\n await ctx.sandbox.writeFile(path, Buffer.from(content, \"utf-8\"));\n },\n\n mkdir: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n ): Promise<void> => {\n const result = await ctx.sandbox.run(\"mkdir\", { args: [\"-p\", path] });\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`,\n );\n }\n },\n\n readdir: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n ): Promise<FileEntry[]> => {\n const response = await ctx.sandbox.listDirectory(path);\n return response.entries.map((e) => ({\n name: e.name,\n type: e.isDir ? (\"directory\" as const) : (\"file\" as const),\n size: e.size || 0,\n modified: e.modifiedAt ?? new Date(),\n }));\n },\n\n exists: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n ): Promise<boolean> => {\n try {\n await ctx.sandbox.readFile(path);\n return true;\n } catch {}\n try {\n await ctx.sandbox.listDirectory(path);\n return true;\n } catch {}\n return false;\n },\n\n remove: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n ): Promise<void> => {\n try {\n await ctx.sandbox.deleteFile(path);\n } catch {\n // May be a directory — fall back to rm -rf\n const result = await ctx.sandbox.run(\"rm\", { args: [\"-rf\", path] });\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n }\n },\n },\n\n getInstance: (ctx: TensorlakeSandboxContext): TensorlakeSandboxContext =>\n ctx,\n },\n\n snapshot: {\n create: async (\n config: TensorlakeConfig,\n sandboxId: string,\n options?: { name?: string },\n ) => {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n const result = await sandbox.checkpoint();\n\n if (!result) {\n throw new Error(\n `Failed to create snapshot for sandbox '${sandboxId}': checkpoint() did not return a snapshot result.`,\n );\n }\n\n return {\n id: result.snapshotId,\n provider: \"tensorlake\",\n createdAt: new Date(),\n metadata: { name: options?.name },\n };\n },\n\n list: async (config: TensorlakeConfig) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n return await Sandbox.listSnapshots({ apiKey, apiUrl });\n } catch {\n return [];\n }\n },\n\n delete: async (config: TensorlakeConfig, snapshotId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n await Sandbox.deleteSnapshot(snapshotId, { apiKey, apiUrl });\n } catch {\n // Ignore\n }\n },\n },\n },\n});\n\nexport type { TensorlakeSandboxContext as TensorlakeSandbox };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,wBAAmD;AAEnD,sBAA+B;AA6B/B,SAAS,YAAY,QAGnB;AACA,QAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,sBAChD;AACF,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,QAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,sBAChD;AACF,SAAO,EAAE,QAAQ,OAAO;AAC1B;AAEO,IAAM,iBAAa,gCAGxB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA,MACP,QAAQ,OACN,QACA,YACG;AACH,cAAM,EAAE,QAAQ,OAAO,IAAI,YAAY,MAAM;AAC7C,cAAM,QAAQ,SAAS,SAAS,OAAO;AACvC,cAAM,YAAY,SAAS,WAAW,OAAO;AAC7C,cAAM,cAAc,YAAY,KAAK,KAAK,YAAY,GAAI,IAAI;AAE9D,cAAM,SAAS;AAAA,UACb,GAAI,SAAS,EAAE,MAAM;AAAA,UACrB,GAAI,eAAe,EAAE,YAAY;AAAA,UACjC,GAAI,SAAS,QAAQ,EAAE,MAAM,QAAQ,KAAK;AAAA,UAC1C,GAAI,SAAS,YAAY,EAAE,UAAU,QAAQ,SAAS;AAAA,UACtD,GAAI,SAAS,mBAAmB;AAAA,YAC9B,iBAAiB,QAAQ;AAAA,UAC3B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,OAAO,IAAI,YAAY,MAAM;AAC7C,gBAAM,0BAAQ,eAAe,YAAY,EAAE,QAAQ,OAAO,CAAC;AAAA,QAC7D,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
package/dist/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  // src/index.ts
2
2
  import { Sandbox, SandboxStatus, OutputMode } from "tensorlake";
3
3
  import { defineProvider } from "@computesdk/provider";
4
- var DEFAULT_IMAGE = "ubuntu-minimal";
5
4
  function resolveAuth(config) {
6
5
  const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.TENSORLAKE_API_KEY || "";
7
6
  if (!apiKey) {
@@ -18,23 +17,26 @@ var tensorlake = defineProvider({
18
17
  sandbox: {
19
18
  create: async (config, options) => {
20
19
  const { apiKey, apiUrl } = resolveAuth(config);
21
- const image = options?.image || config.image || DEFAULT_IMAGE;
20
+ const image = options?.image || config.image;
22
21
  const timeoutMs = options?.timeout ?? config.timeout;
23
22
  const timeoutSecs = timeoutMs ? Math.ceil(timeoutMs / 1e3) : void 0;
23
+ const params = {
24
+ ...image && { image },
25
+ ...timeoutSecs && { timeoutSecs },
26
+ ...options?.cpus && { cpus: options.cpus },
27
+ ...options?.memoryMb && { memoryMb: options.memoryMb },
28
+ ...options?.ephemeralDiskMb && {
29
+ ephemeralDiskMb: options.ephemeralDiskMb
30
+ },
31
+ ...options?.name && { name: options.name },
32
+ ...options?.snapshotId && { snapshotId: options.snapshotId },
33
+ proxyUrl: config.proxyUrl,
34
+ apiKey,
35
+ apiUrl
36
+ };
24
37
  try {
25
38
  const startTime = Date.now();
26
- const instance = await Sandbox.create({
27
- image,
28
- cpus: 1,
29
- memoryMb: 1024,
30
- ephemeralDiskMb: 2048,
31
- ...timeoutSecs && { timeoutSecs },
32
- ...options?.name && { name: options.name },
33
- ...options?.snapshotId && { snapshotId: options.snapshotId },
34
- proxyUrl: config.proxyUrl,
35
- apiKey,
36
- apiUrl
37
- });
39
+ const instance = await Sandbox.create(params);
38
40
  const sandbox = {
39
41
  config,
40
42
  sandbox: instance
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/// <reference types=\"node\" />\n/**\n * Tensorlake Provider - SDK-based Implementation\n *\n * Stateful MicroVM sandboxes for agentic applications and LLM-generated code execution.\n * Uses the official tensorlake npm SDK (0.5.7).\n */\n\nimport { Sandbox, SandboxStatus, OutputMode } from \"tensorlake\";\nimport type { SandboxInfo } from \"tensorlake\";\nimport { defineProvider } from \"@computesdk/provider\";\nimport type {\n CodeResult,\n CommandResult,\n SandboxInfo as ComputeSandboxInfo,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions,\n} from \"@computesdk/provider\";\n\nconst DEFAULT_IMAGE = \"ubuntu-minimal\";\n\nexport interface TensorlakeConfig {\n /** Tensorlake API key — falls back to TENSORLAKE_API_KEY environment variable */\n apiKey?: string;\n /** Override for the management API base URL */\n apiUrl?: string;\n /** Override for the sandbox proxy URL */\n proxyUrl?: string;\n /** Default container image for new sandboxes (default: ubuntu-minimal) */\n image?: string;\n /** Default timeout in milliseconds for sandboxes */\n timeout?: number;\n}\n\nexport interface TensorlakeSandboxContext {\n config: TensorlakeConfig;\n /** Connected SDK Sandbox instance — used for all proxy operations */\n sandbox: InstanceType<typeof Sandbox>;\n}\n\nfunction resolveAuth(config: TensorlakeConfig): {\n apiKey: string;\n apiUrl?: string;\n} {\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_KEY) ||\n \"\";\n if (!apiKey) {\n throw new Error(\n `Missing Tensorlake API key. Provide 'apiKey' in config or set TENSORLAKE_API_KEY environment variable. ` +\n `Get your API key from https://app.tensorlake.ai`\n );\n }\n const apiUrl =\n config.apiUrl ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_URL) ||\n undefined;\n return { apiKey, apiUrl };\n}\n\nexport const tensorlake = defineProvider<\n TensorlakeSandboxContext,\n TensorlakeConfig\n>({\n name: \"tensorlake\",\n methods: {\n sandbox: {\n create: async (\n config: TensorlakeConfig,\n options?: CreateSandboxOptions\n ) => {\n const { apiKey, apiUrl } = resolveAuth(config);\n const image = options?.image || config.image || DEFAULT_IMAGE;\n const timeoutMs = options?.timeout ?? config.timeout;\n const timeoutSecs = timeoutMs ? Math.ceil(timeoutMs / 1000) : undefined;\n\n try {\n const startTime = Date.now();\n const instance = await Sandbox.create({\n image,\n cpus: 1,\n memoryMb: 1024,\n ephemeralDiskMb: 2048,\n ...(timeoutSecs && { timeoutSecs }),\n ...(options?.name && { name: options.name }),\n ...(options?.snapshotId && { snapshotId: options.snapshotId }),\n proxyUrl: config.proxyUrl,\n apiKey,\n apiUrl,\n });\n\n const sandbox: TensorlakeSandboxContext = {\n config,\n sandbox: instance,\n };\n const durationMs = Date.now() - startTime;\n return {\n sandbox,\n sandboxId: instance.sandboxId,\n durationMs,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"401\")) {\n throw new Error(\n `Tensorlake authentication failed. Please check your TENSORLAKE_API_KEY. ` +\n `Get your API key from https://app.tensorlake.ai`\n );\n }\n throw new Error(\n `Failed to create Tensorlake sandbox: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getById: async (config: TensorlakeConfig, sandboxId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n const ctx: TensorlakeSandboxContext = {\n config,\n sandbox,\n };\n return { sandbox: ctx, sandboxId: sandbox.sandboxId };\n } catch {\n return null;\n }\n },\n\n list: async (config: TensorlakeConfig) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandboxes = await Sandbox.list({ apiKey, apiUrl });\n return Promise.all(\n sandboxes.map(async (s) => {\n const sandbox = await Sandbox.connect({\n sandboxId: s.sandboxId,\n proxyUrl: config.proxyUrl,\n routingHint: s.routingHint,\n apiKey,\n apiUrl,\n });\n return {\n sandbox: {\n sandboxId: s.sandboxId,\n config,\n sandbox,\n } as TensorlakeSandboxContext,\n sandboxId: s.sandboxId,\n };\n })\n );\n } catch {\n return [];\n }\n },\n\n destroy: async (config: TensorlakeConfig, sandboxId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n await sandbox.terminate();\n } catch {\n // Sandbox may already be terminated\n }\n },\n\n runCommand: async (\n ctx: TensorlakeSandboxContext,\n command: string,\n options?: RunCommandOptions\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n\n if (options?.background) {\n try {\n await ctx.sandbox.startProcess(\"sh\", {\n args: [\"-c\", command],\n stdoutMode: OutputMode.DISCARD,\n stderrMode: OutputMode.DISCARD,\n ...(options.env &&\n Object.keys(options.env).length > 0 && { env: options.env }),\n ...(options.cwd && { workingDir: options.cwd }),\n });\n } catch (error) {\n return {\n stdout: \"\",\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n }\n\n try {\n const result = await ctx.sandbox.run(\"sh\", {\n args: [\"-c\", command],\n ...(options?.env &&\n Object.keys(options.env).length > 0 && { env: options.env }),\n ...(options?.cwd && { workingDir: options.cwd }),\n });\n\n const durationMs = Date.now() - startTime;\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode ?? 0,\n durationMs,\n };\n } catch (error) {\n return {\n stdout: \"\",\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n },\n\n getInfo: async (\n ctx: TensorlakeSandboxContext\n ): Promise<ComputeSandboxInfo> => {\n try {\n const info = await ctx.sandbox.info();\n return {\n id: ctx.sandbox.sandboxId,\n provider: \"tensorlake\",\n status:\n info.status === SandboxStatus.RUNNING ? \"running\" : \"stopped\",\n createdAt: info.createdAt || new Date(),\n timeout:\n info.timeoutSecs != null ? info.timeoutSecs * 1000 : 300_000,\n metadata: {},\n };\n } catch {\n return {\n id: ctx.sandbox.sandboxId,\n provider: \"tensorlake\",\n status: \"running\",\n createdAt: new Date(),\n timeout: 300_000,\n metadata: {},\n };\n }\n },\n\n getUrl: async (\n ctx: TensorlakeSandboxContext,\n options: { port: number; protocol?: string }\n ): Promise<string> => {\n const { port, protocol: optionsProtocol } = options;\n const protocol = optionsProtocol || \"https\";\n\n const apiUrl =\n ctx.config.apiUrl ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_URL) ||\n \"https://api.tensorlake.ai\";\n\n const proxyDomain = new URL(apiUrl).hostname;\n const subdomain =\n port === 443 || port === 80\n ? ctx.sandbox.sandboxId\n : `${port}-${ctx.sandbox.sandboxId}`;\n\n return `${protocol}://${subdomain}.${proxyDomain}`;\n },\n\n filesystem: {\n readFile: async (\n ctx: TensorlakeSandboxContext,\n path: string\n ): Promise<string> => {\n const bytes = await ctx.sandbox.readFile(path);\n return Buffer.from(bytes).toString(\"utf-8\");\n },\n\n writeFile: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n content: string\n ): Promise<void> => {\n await ctx.sandbox.writeFile(path, Buffer.from(content, \"utf-8\"));\n },\n\n mkdir: async (\n ctx: TensorlakeSandboxContext,\n path: string\n ): Promise<void> => {\n const result = await ctx.sandbox.run(\"mkdir\", { args: [\"-p\", path] });\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`\n );\n }\n },\n\n readdir: async (\n ctx: TensorlakeSandboxContext,\n path: string\n ): Promise<FileEntry[]> => {\n const response = await ctx.sandbox.listDirectory(path);\n return response.entries.map((e) => ({\n name: e.name,\n type: e.isDir ? (\"directory\" as const) : (\"file\" as const),\n size: e.size || 0,\n modified: e.modifiedAt ?? new Date(),\n }));\n },\n\n exists: async (\n ctx: TensorlakeSandboxContext,\n path: string\n ): Promise<boolean> => {\n try {\n await ctx.sandbox.readFile(path);\n return true;\n } catch {}\n try {\n await ctx.sandbox.listDirectory(path);\n return true;\n } catch {}\n return false;\n },\n\n remove: async (\n ctx: TensorlakeSandboxContext,\n path: string\n ): Promise<void> => {\n try {\n await ctx.sandbox.deleteFile(path);\n } catch {\n // May be a directory — fall back to rm -rf\n const result = await ctx.sandbox.run(\"rm\", { args: [\"-rf\", path] });\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n }\n },\n },\n\n getInstance: (ctx: TensorlakeSandboxContext): TensorlakeSandboxContext =>\n ctx,\n },\n\n snapshot: {\n create: async (\n config: TensorlakeConfig,\n sandboxId: string,\n options?: { name?: string }\n ) => {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n const result = await sandbox.checkpoint();\n\n if (!result) {\n throw new Error(\n `Failed to create snapshot for sandbox '${sandboxId}': checkpoint() did not return a snapshot result.`\n );\n }\n\n return {\n id: result.snapshotId,\n provider: \"tensorlake\",\n createdAt: new Date(),\n metadata: { name: options?.name },\n };\n },\n\n list: async (config: TensorlakeConfig) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n return await Sandbox.listSnapshots({ apiKey, apiUrl });\n } catch {\n return [];\n }\n },\n\n delete: async (config: TensorlakeConfig, snapshotId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n await Sandbox.deleteSnapshot(snapshotId, { apiKey, apiUrl });\n } catch {\n // Ignore\n }\n },\n },\n },\n});\n\nexport type { TensorlakeSandboxContext as TensorlakeSandbox };\n"],"mappings":";AAQA,SAAS,SAAS,eAAe,kBAAkB;AAEnD,SAAS,sBAAsB;AAU/B,IAAM,gBAAgB;AAqBtB,SAAS,YAAY,QAGnB;AACA,QAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,sBAChD;AACF,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,QAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,s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;AAAA,UACL,IAAI,OAAO;AAAA,UACX,UAAU;AAAA,UACV,WAAW,oBAAI,KAAK;AAAA,UACpB,UAAU,EAAE,MAAM,SAAS,KAAK;AAAA,QAClC;AAAA,MACF;AAAA,MAEA,MAAM,OAAO,WAA6B;AACxC,YAAI;AACF,gBAAM,EAAE,QAAQ,OAAO,IAAI,YAAY,MAAM;AAC7C,iBAAO,MAAM,QAAQ,cAAc,EAAE,QAAQ,OAAO,CAAC;AAAA,QACvD,QAAQ;AACN,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,MAEA,QAAQ,OAAO,QAA0B,eAAuB;AAC9D,YAAI;AACF,gBAAM,EAAE,QAAQ,OAAO,IAAI,YAAY,MAAM;AAC7C,gBAAM,QAAQ,eAAe,YAAY,EAAE,QAAQ,OAAO,CAAC;AAAA,QAC7D,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/// <reference types=\"node\" />\n/**\n * Tensorlake Provider - SDK-based Implementation\n *\n * Stateful MicroVM sandboxes for agentic applications and LLM-generated code execution.\n * Uses the official tensorlake npm SDK (0.5.7).\n */\n\nimport { Sandbox, SandboxStatus, OutputMode } from \"tensorlake\";\nimport type { SandboxInfo } from \"tensorlake\";\nimport { defineProvider } from \"@computesdk/provider\";\nimport type {\n CodeResult,\n CommandResult,\n SandboxInfo as ComputeSandboxInfo,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions,\n} from \"@computesdk/provider\";\n\nexport interface TensorlakeConfig {\n /** Tensorlake API key — falls back to TENSORLAKE_API_KEY environment variable */\n apiKey?: string;\n /** Override for the management API base URL */\n apiUrl?: string;\n /** Override for the sandbox proxy URL */\n proxyUrl?: string;\n /** Default container image for new sandboxes (default: ubuntu-minimal) */\n image?: string;\n /** Default timeout in milliseconds for sandboxes */\n timeout?: number;\n}\n\nexport interface TensorlakeSandboxContext {\n config: TensorlakeConfig;\n /** Connected SDK Sandbox instance — used for all proxy operations */\n sandbox: InstanceType<typeof Sandbox>;\n}\n\nfunction resolveAuth(config: TensorlakeConfig): {\n apiKey: string;\n apiUrl?: string;\n} {\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_KEY) ||\n \"\";\n if (!apiKey) {\n throw new Error(\n `Missing Tensorlake API key. Provide 'apiKey' in config or set TENSORLAKE_API_KEY environment variable. ` +\n `Get your API key from https://app.tensorlake.ai`,\n );\n }\n const apiUrl =\n config.apiUrl ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_URL) ||\n undefined;\n return { apiKey, apiUrl };\n}\n\nexport const tensorlake = defineProvider<\n TensorlakeSandboxContext,\n TensorlakeConfig\n>({\n name: \"tensorlake\",\n methods: {\n sandbox: {\n create: async (\n config: TensorlakeConfig,\n options?: CreateSandboxOptions,\n ) => {\n const { apiKey, apiUrl } = resolveAuth(config);\n const image = options?.image || config.image;\n const timeoutMs = options?.timeout ?? config.timeout;\n const timeoutSecs = timeoutMs ? Math.ceil(timeoutMs / 1000) : undefined;\n\n const params = {\n ...(image && { image }),\n ...(timeoutSecs && { timeoutSecs }),\n ...(options?.cpus && { cpus: options.cpus }),\n ...(options?.memoryMb && { memoryMb: options.memoryMb }),\n ...(options?.ephemeralDiskMb && {\n ephemeralDiskMb: options.ephemeralDiskMb,\n }),\n ...(options?.name && { name: options.name }),\n ...(options?.snapshotId && { snapshotId: options.snapshotId }),\n proxyUrl: config.proxyUrl,\n apiKey,\n apiUrl,\n };\n\n try {\n const startTime = Date.now();\n const instance = await Sandbox.create(params);\n\n const sandbox: TensorlakeSandboxContext = {\n config,\n sandbox: instance,\n };\n const durationMs = Date.now() - startTime;\n return {\n sandbox,\n sandboxId: instance.sandboxId,\n durationMs,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"401\")) {\n throw new Error(\n `Tensorlake authentication failed. Please check your TENSORLAKE_API_KEY. ` +\n `Get your API key from https://app.tensorlake.ai`,\n );\n }\n throw new Error(\n `Failed to create Tensorlake sandbox: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n },\n\n getById: async (config: TensorlakeConfig, sandboxId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n const ctx: TensorlakeSandboxContext = {\n config,\n sandbox,\n };\n return { sandbox: ctx, sandboxId: sandbox.sandboxId };\n } catch {\n return null;\n }\n },\n\n list: async (config: TensorlakeConfig) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandboxes = await Sandbox.list({ apiKey, apiUrl });\n return Promise.all(\n sandboxes.map(async (s) => {\n const sandbox = await Sandbox.connect({\n sandboxId: s.sandboxId,\n proxyUrl: config.proxyUrl,\n routingHint: s.routingHint,\n apiKey,\n apiUrl,\n });\n return {\n sandbox: {\n sandboxId: s.sandboxId,\n config,\n sandbox,\n } as TensorlakeSandboxContext,\n sandboxId: s.sandboxId,\n };\n }),\n );\n } catch {\n return [];\n }\n },\n\n destroy: async (config: TensorlakeConfig, sandboxId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n await sandbox.terminate();\n } catch {\n // Sandbox may already be terminated\n }\n },\n\n runCommand: async (\n ctx: TensorlakeSandboxContext,\n command: string,\n options?: RunCommandOptions,\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n\n if (options?.background) {\n try {\n await ctx.sandbox.startProcess(\"sh\", {\n args: [\"-c\", command],\n stdoutMode: OutputMode.DISCARD,\n stderrMode: OutputMode.DISCARD,\n ...(options.env &&\n Object.keys(options.env).length > 0 && { env: options.env }),\n ...(options.cwd && { workingDir: options.cwd }),\n });\n } catch (error) {\n return {\n stdout: \"\",\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n }\n\n try {\n const result = await ctx.sandbox.run(\"sh\", {\n args: [\"-c\", command],\n ...(options?.env &&\n Object.keys(options.env).length > 0 && { env: options.env }),\n ...(options?.cwd && { workingDir: options.cwd }),\n });\n\n const durationMs = Date.now() - startTime;\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode ?? 0,\n durationMs,\n };\n } catch (error) {\n return {\n stdout: \"\",\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime,\n };\n }\n },\n\n getInfo: async (\n ctx: TensorlakeSandboxContext,\n ): Promise<ComputeSandboxInfo> => {\n try {\n const info = await ctx.sandbox.info();\n return {\n id: ctx.sandbox.sandboxId,\n provider: \"tensorlake\",\n status:\n info.status === SandboxStatus.RUNNING ? \"running\" : \"stopped\",\n createdAt: info.createdAt || new Date(),\n timeout:\n info.timeoutSecs != null ? info.timeoutSecs * 1000 : 300_000,\n metadata: {},\n };\n } catch {\n return {\n id: ctx.sandbox.sandboxId,\n provider: \"tensorlake\",\n status: \"running\",\n createdAt: new Date(),\n timeout: 300_000,\n metadata: {},\n };\n }\n },\n\n getUrl: async (\n ctx: TensorlakeSandboxContext,\n options: { port: number; protocol?: string },\n ): Promise<string> => {\n const { port, protocol: optionsProtocol } = options;\n const protocol = optionsProtocol || \"https\";\n\n const apiUrl =\n ctx.config.apiUrl ||\n (typeof process !== \"undefined\" && process.env?.TENSORLAKE_API_URL) ||\n \"https://api.tensorlake.ai\";\n\n const proxyDomain = new URL(apiUrl).hostname;\n const subdomain =\n port === 443 || port === 80\n ? ctx.sandbox.sandboxId\n : `${port}-${ctx.sandbox.sandboxId}`;\n\n return `${protocol}://${subdomain}.${proxyDomain}`;\n },\n\n filesystem: {\n readFile: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n ): Promise<string> => {\n const bytes = await ctx.sandbox.readFile(path);\n return Buffer.from(bytes).toString(\"utf-8\");\n },\n\n writeFile: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n content: string,\n ): Promise<void> => {\n await ctx.sandbox.writeFile(path, Buffer.from(content, \"utf-8\"));\n },\n\n mkdir: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n ): Promise<void> => {\n const result = await ctx.sandbox.run(\"mkdir\", { args: [\"-p\", path] });\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`,\n );\n }\n },\n\n readdir: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n ): Promise<FileEntry[]> => {\n const response = await ctx.sandbox.listDirectory(path);\n return response.entries.map((e) => ({\n name: e.name,\n type: e.isDir ? (\"directory\" as const) : (\"file\" as const),\n size: e.size || 0,\n modified: e.modifiedAt ?? new Date(),\n }));\n },\n\n exists: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n ): Promise<boolean> => {\n try {\n await ctx.sandbox.readFile(path);\n return true;\n } catch {}\n try {\n await ctx.sandbox.listDirectory(path);\n return true;\n } catch {}\n return false;\n },\n\n remove: async (\n ctx: TensorlakeSandboxContext,\n path: string,\n ): Promise<void> => {\n try {\n await ctx.sandbox.deleteFile(path);\n } catch {\n // May be a directory — fall back to rm -rf\n const result = await ctx.sandbox.run(\"rm\", { args: [\"-rf\", path] });\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n }\n },\n },\n\n getInstance: (ctx: TensorlakeSandboxContext): TensorlakeSandboxContext =>\n ctx,\n },\n\n snapshot: {\n create: async (\n config: TensorlakeConfig,\n sandboxId: string,\n options?: { name?: string },\n ) => {\n const { apiKey, apiUrl } = resolveAuth(config);\n const sandbox = await Sandbox.connect({ sandboxId, apiKey, apiUrl });\n const result = await sandbox.checkpoint();\n\n if (!result) {\n throw new Error(\n `Failed to create snapshot for sandbox '${sandboxId}': checkpoint() did not return a snapshot result.`,\n );\n }\n\n return {\n id: result.snapshotId,\n provider: \"tensorlake\",\n createdAt: new Date(),\n metadata: { name: options?.name },\n };\n },\n\n list: async (config: TensorlakeConfig) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n return await Sandbox.listSnapshots({ apiKey, apiUrl });\n } catch {\n return [];\n }\n },\n\n delete: async (config: TensorlakeConfig, snapshotId: string) => {\n try {\n const { apiKey, apiUrl } = resolveAuth(config);\n await Sandbox.deleteSnapshot(snapshotId, { apiKey, apiUrl });\n } catch {\n // Ignore\n }\n },\n },\n },\n});\n\nexport type { TensorlakeSandboxContext as TensorlakeSandbox };\n"],"mappings":";AAQA,SAAS,SAAS,eAAe,kBAAkB;AAEnD,SAAS,sBAAsB;AA6B/B,SAAS,YAAY,QAGnB;AACA,QAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,sBAChD;AACF,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,QAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,sBAChD;AACF,SAAO,EAAE,QAAQ,OAAO;AAC1B;AAEO,IAAM,aAAa,eAGxB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA,MACP,QAAQ,OACN,QACA,YACG;AACH,cAAM,EAAE,QAAQ,OAAO,IAAI,YAAY,MAAM;AAC7C,cAAM,QAAQ,SAAS,SAAS,OAAO;AACvC,cAAM,YAAY,SAAS,WAAW,OAAO;AAC7C,cAAM,cAAc,YAAY,KAAK,KAAK,YAAY,GAAI,IAAI;AAE9D,cAAM,SAAS;AAAA,UACb,GAAI,SAAS,EAAE,MAAM;AAAA,UACrB,GAAI,eAAe,EAAE,YAAY;AAAA,UACjC,GAAI,SAAS,QAAQ,EAAE,MAAM,QAAQ,KAAK;AAAA,UAC1C,GAAI,SAAS,YAAY,EAAE,UAAU,QAAQ,SAAS;AAAA,UACtD,GAAI,SAAS,mBAAmB;AAAA,YAC9B,iBAAiB,QAAQ;AAAA,UAC3B;AAAA,UACA,GAAI,SAAS,QAAQ,EAAE,MAAM,QAAQ,KAAK;AAAA,UAC1C,GAAI,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A,QAC7D,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@computesdk/tensorlake",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Tensorlake provider for ComputeSDK - stateful MicroVM sandboxes for agentic applications and LLM-generated code execution",
5
5
  "author": "Garrison",
6
6
  "license": "MIT",
@@ -19,8 +19,8 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "tensorlake": "0.5.7",
22
- "@computesdk/provider": "2.0.0",
23
- "computesdk": "4.0.0"
22
+ "@computesdk/provider": "2.1.0",
23
+ "computesdk": "4.1.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^20.19.39",