@computesdk/superserve 0.2.29 → 0.2.30

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
@@ -106,23 +106,49 @@ async function deleteVolume(connection, idOrName) {
106
106
  throw error;
107
107
  }
108
108
  const deadline = Date.now() + 12e4;
109
- for (; ; ) {
110
- try {
111
- await import_sdk.Volume.deleteById(volume.id, connection);
112
- return;
113
- } catch (error) {
114
- if (!(error instanceof import_sdk.ConflictError) || error.code !== "volume_conflict") throw error;
115
- let attachments;
109
+ const controller = new AbortController();
110
+ const timer = setTimeout(() => controller.abort(), 12e4);
111
+ let lastError;
112
+ const requireTime = () => {
113
+ const remaining = deadline - Date.now();
114
+ if (controller.signal.aborted || remaining <= 0) {
115
+ throw lastError ?? new Error("Timed out waiting for Superserve volume deletion.");
116
+ }
117
+ return remaining;
118
+ };
119
+ try {
120
+ for (; ; ) {
121
+ requireTime();
116
122
  try {
117
- attachments = await volume.listAttachments();
118
- } catch (lookupError) {
119
- if (lookupError instanceof import_sdk.NotFoundError) return;
120
- throw lookupError;
123
+ await volume.delete({ signal: controller.signal, timeoutMs: requireTime() });
124
+ return;
125
+ } catch (error) {
126
+ requireTime();
127
+ lastError = error;
128
+ try {
129
+ if (error instanceof import_sdk.ConflictError && error.code === "volume_conflict") {
130
+ const attachments = await volume.listAttachments({ signal: controller.signal, timeoutMs: requireTime() });
131
+ const closing = attachments.filter((attachment) => attachment.status !== "revoked");
132
+ if (!closing.length || closing.some((attachment) => attachment.status !== "detaching" && attachment.status !== "revoking")) throw error;
133
+ } else if (error instanceof import_sdk.ServerError && error.statusCode === 503 && error.code === "volume_unavailable") {
134
+ const current = await volume.getInfo({ signal: controller.signal, timeoutMs: requireTime() });
135
+ if (current.status !== "deleting") throw error;
136
+ } else {
137
+ throw error;
138
+ }
139
+ } catch (lookupError) {
140
+ if (lookupError instanceof import_sdk.NotFoundError) return;
141
+ throw lookupError;
142
+ }
143
+ requireTime();
144
+ await new Promise((resolve) => setTimeout(resolve, Math.min(3e3, deadline - Date.now())));
121
145
  }
122
- const closing = attachments.filter((attachment) => attachment.status !== "revoked");
123
- if (!closing.length || closing.some((attachment) => attachment.status !== "detaching" && attachment.status !== "revoking") || Date.now() >= deadline) throw error;
124
- await new Promise((resolve) => setTimeout(resolve, 3e3));
125
146
  }
147
+ } catch (error) {
148
+ if (controller.signal.aborted || Date.now() >= deadline) throw lastError ?? error;
149
+ throw error;
150
+ } finally {
151
+ clearTimeout(timer);
126
152
  }
127
153
  }
128
154
  function workdirOf(sandbox, runCommand2) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Superserve Provider - Factory-based Implementation\n *\n * Wraps `@superserve/sdk` to expose the ComputeSDK provider interface.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n AuthenticationError,\n ConflictError,\n NotFoundError,\n Sandbox as SuperserveSandbox,\n Snapshot as SuperserveSnapshot,\n Template as SuperserveTemplate,\n Volume as SuperserveVolume,\n resolveConfig,\n} from '@superserve/sdk';\nimport type {\n ResolvedConfig,\n SnapshotInfo,\n TemplateCreateOptions,\n TemplateInfo,\n VolumeCreateOptions,\n VolumeInfo,\n} from '@superserve/sdk';\nimport { defineProvider, escapeShellArg, InstanceSizeError, INSTANCE_SIZE_PROFILES } from '@computesdk/provider';\n\nconst DEFAULT_TIMEOUT_MS = 300_000;\n\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateTemplateOptions,\n CreateVolumeOptions,\n FileEntry,\n InstanceSizeClass,\n RunCommandOptions,\n InstanceInfo,\n Volume,\n} from '@computesdk/provider';\n\nexport interface SuperserveConfig {\n /** Superserve API key. Falls back to `SUPERSERVE_API_KEY` env var. */\n apiKey?: string;\n /** API base URL. Falls back to `SUPERSERVE_BASE_URL` env var, then the `@superserve/sdk` default. */\n baseUrl?: string;\n /** Default auto-pause timeout in milliseconds. */\n timeout?: number;\n /** Template to boot per standard `sizeClass`; defaults to {@link SUPERSERVE_SIZE_TEMPLATES}. */\n sizeTemplates?: Partial<Record<InstanceSizeClass, string>>;\n}\n\n/**\n * Superserve fixes vCPU, memory and disk when a template is built, so each\n * standard size boots its own template. `superserve/base` (2 vCPU / 4 GiB /\n * 8 GiB disk) is built in to every team; the others are team templates\n * built by `scripts/provider-setup.mjs superserve`. The largest listed plan\n * (Pro) caps a sandbox at 16 vCPU / 64 GiB, so `3xl` has no default.\n */\nexport const SUPERSERVE_SIZE_TEMPLATES: Readonly<Partial<Record<InstanceSizeClass, string>>> = Object.freeze({\n xs: 'csdk-node22-1cpu-1gb',\n sm: 'csdk-node22-1cpu-2gb',\n md: 'superserve/base',\n lg: 'csdk-node22-4cpu-8gb',\n xl: 'csdk-node22-8cpu-16gb',\n '2xl': 'csdk-node22-16cpu-32gb',\n});\n\n/** Disk the built-in templates fix; team templates take theirs from the build. */\nconst BUILT_IN_TEMPLATE_DISK_MIB: Readonly<Record<string, number>> = Object.freeze({ 'superserve/base': 8192 });\n\n/** Native selectors that pick or size the VM; `Sandbox.create` drops the sizing ones silently. */\nconst SOURCE_OPTIONS = ['templateId', 'snapshotId', 'sandboxId', 'fromTemplate', 'fromSnapshot'] as const;\nconst NATIVE_SIZE_OPTIONS = ['vcpu', 'vcpuCount', 'memoryMib', 'memoryMaxMib', 'diskMib'] as const;\n\nfunction sizeTemplateOf(config: SuperserveConfig, sizeClass: InstanceSizeClass): string | undefined {\n const name = config.sizeTemplates?.[sizeClass] ?? SUPERSERVE_SIZE_TEMPLATES[sizeClass];\n return typeof name === 'string' && name.trim() ? name : undefined;\n}\n\n/** A create that failed because a standard-size template was never built on this team. */\nfunction missingSizeTemplate(config: SuperserveConfig, templateId: unknown, error: unknown): string | undefined {\n if (typeof templateId !== 'string' || !(error instanceof NotFoundError)) return undefined;\n const sizeClass = (Object.keys(INSTANCE_SIZE_PROFILES) as InstanceSizeClass[]).find(c => sizeTemplateOf(config, c) === templateId);\n if (!sizeClass) return undefined;\n return `Superserve size template '${templateId}' (sizeClass ${sizeClass}) is not built on this Superserve team; run \\`node scripts/provider-setup.mjs superserve\\` (provider-setup.yml) or point \\`sizeTemplates.${sizeClass}\\` at an existing template`;\n}\n\nfunction resolveApiKey(config: SuperserveConfig): string {\n const apiKey = config.apiKey || process.env.SUPERSERVE_API_KEY;\n if (!apiKey) {\n throw new Error(\n `Missing Superserve API key. Provide 'apiKey' in config or set SUPERSERVE_API_KEY environment variable.`,\n );\n }\n return apiKey;\n}\n\nfunction resolveBaseUrl(config: SuperserveConfig): string | undefined {\n // Returns undefined when unset on purpose: the SDK then applies its own\n // resolution (SUPERSERVE_BASE_URL env var, then its default endpoint), so\n // we don't duplicate that default and risk it drifting.\n return config.baseUrl || process.env.SUPERSERVE_BASE_URL || undefined;\n}\n\nfunction generateSandboxName(): string {\n return `cs-${randomUUID().slice(0, 8)}`;\n}\n\ntype CommandRunner = (\n sandbox: SuperserveSandbox,\n command: string,\n options?: RunCommandOptions,\n) => Promise<CommandResult>;\n\nconst FALLBACK_WORKDIR = '/';\n\n/** Cached `pwd` probes: relative filesystem paths resolve against the cwd a\n * `runCommand` exec would use, so `writeFile('a.txt')` and `cat a.txt` agree. */\nconst workdirs = new WeakMap<SuperserveSandbox, Promise<string>>();\nconst volumeConnections = new WeakMap<SuperserveSandbox, ResolvedConfig>();\n\nfunction volumeReference(volume: string | Volume): string {\n const reference = typeof volume === 'string' ? volume : volume?.id || volume?.name;\n if (typeof reference !== 'string' || !reference.trim()) {\n throw new Error('A Superserve volume reference must contain an id or name.');\n }\n return reference;\n}\n\nfunction volumeConnection(sandbox: SuperserveSandbox): ResolvedConfig {\n const connection = volumeConnections.get(sandbox);\n if (!connection) throw new Error('The Superserve sandbox has no captured volume connection.');\n return connection;\n}\n\nfunction sameSandboxId(left: string, right: string): boolean {\n const pattern = /^(?:sb-([A-Za-z0-9]+)-)?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;\n const a = pattern.exec(left);\n const b = pattern.exec(right);\n if (!a || !b) return left === right;\n return a[2].toLowerCase() === b[2].toLowerCase() &&\n (a[1] === undefined || b[1] === undefined || a[1] === b[1]);\n}\n\nfunction toVolume(info: VolumeInfo): Volume {\n return {\n id: info.id,\n name: info.name,\n sizeBytes: info.capacityBytes,\n usedBytes: info.usedBytes,\n region: info.region,\n status: info.status,\n createdAt: info.createdAt,\n };\n}\n\nasync function deleteVolume(connection: ResolvedConfig, idOrName: string): Promise<void> {\n let volume: SuperserveVolume;\n try {\n volume = await SuperserveVolume.connect(idOrName, connection);\n } catch (error) {\n if (error instanceof NotFoundError) return;\n throw error;\n }\n // Names can be reused while closing leases settle. Resolve once so retries\n // and attachment checks stay bound to the original volume.\n const deadline = Date.now() + 120_000;\n for (;;) {\n try {\n await SuperserveVolume.deleteById(volume.id, connection);\n return;\n } catch (error) {\n if (!(error instanceof ConflictError) || error.code !== 'volume_conflict') throw error;\n let attachments;\n try {\n attachments = await volume.listAttachments();\n } catch (lookupError) {\n if (lookupError instanceof NotFoundError) return;\n throw lookupError;\n }\n const closing = attachments.filter((attachment) => attachment.status !== 'revoked');\n // A destroyed sandbox can leave a closing lease briefly. Never wait on\n // an active mount, or turn another kind of conflict into successful cleanup.\n if (!closing.length || closing.some((attachment) =>\n attachment.status !== 'detaching' && attachment.status !== 'revoking') ||\n Date.now() >= deadline) throw error;\n await new Promise((resolve) => setTimeout(resolve, 3_000));\n }\n }\n}\n\nfunction workdirOf(sandbox: SuperserveSandbox, runCommand: CommandRunner): Promise<string> {\n let probe = workdirs.get(sandbox);\n if (!probe) {\n probe = runCommand(sandbox, 'pwd').then((result) => {\n const dir = result.stdout.trim();\n if (result.exitCode === 0 && dir.startsWith('/')) return dir;\n // runCommand reports exec failures as results, not rejections, so a\n // transient failure must not pin the workdir to the fallback forever —\n // evict and let the next filesystem op probe again.\n workdirs.delete(sandbox);\n return FALLBACK_WORKDIR;\n });\n workdirs.set(sandbox, probe);\n probe.catch(() => workdirs.delete(sandbox));\n }\n return probe;\n}\n\n/** Join `path` onto the sandbox workdir. Absolute paths pass through and skip\n * the probe; empty and `.` segments are dropped; `..` segments are preserved\n * for the sandbox filesystem to resolve physically — collapsing them\n * lexically would mis-resolve when a preceding component is a symlink. */\nasync function resolveSandboxPath(\n sandbox: SuperserveSandbox,\n path: string,\n runCommand: CommandRunner,\n): Promise<string> {\n const combined = path.startsWith('/')\n ? path\n : `${await workdirOf(sandbox, runCommand)}/${path}`;\n const segments: string[] = [];\n for (const segment of combined.split('/')) {\n if (segment === '' || segment === '.') continue;\n segments.push(segment);\n }\n return `/${segments.join('/')}`;\n}\n\nfunction rethrowFriendly(error: unknown, fallbackPrefix: string): never {\n if (error instanceof AuthenticationError) {\n throw new Error(\n `Superserve authentication failed. Please check your SUPERSERVE_API_KEY environment variable.`,\n );\n }\n const message = error instanceof Error ? error.message : String(error);\n const lower = message.toLowerCase();\n if (lower.includes('unauthorized') || lower.includes('401') || lower.includes('api key')) {\n throw new Error(\n `Superserve authentication failed. Please check your SUPERSERVE_API_KEY environment variable.`,\n );\n }\n if (lower.includes('quota') || lower.includes('limit') || lower.includes('429')) {\n throw new Error(`Superserve quota or rate limit reached: ${message}`);\n }\n throw new Error(`${fallbackPrefix}: ${message}`);\n}\n\n// Also serves as `streamCommand`: the SDK streams output over its own exec API\n// when callbacks are passed, so no daemon or routable port is needed.\nconst runCommand: CommandRunner = async (sandbox, command, options) => {\n const startTime = Date.now();\n try {\n let fullCommand = command;\n if (options?.background) {\n // Run the whole command under `sh -c` so the trailing `&` backgrounds\n // the entire command (not just its last statement), and escape it so\n // the user's command can't break out of the nohup wrapper.\n fullCommand = `nohup sh -c \"${escapeShellArg(fullCommand)}\" > /dev/null 2>&1 &`;\n }\n const result = await sandbox.commands.run(fullCommand, {\n cwd: options?.cwd,\n env: options?.env,\n timeoutMs: options?.timeout,\n onStdout: options?.onStdout,\n onStderr: options?.onStderr,\n });\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n durationMs: Date.now() - startTime,\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\nfunction toSnapshot(info: SnapshotInfo) {\n return {\n id: info.id,\n provider: 'superserve',\n createdAt: info.createdAt,\n metadata: {\n name: info.name,\n sandboxId: info.sandboxId,\n status: info.status,\n sizeBytes: info.sizeBytes,\n },\n };\n}\n\n/** Superserve sizes sandboxes at the template: vCPU, memory and disk are set\n * here and every sandbox created from it inherits them. */\nexport type SuperserveTemplateCreateOptions = CreateTemplateOptions & Partial<Omit<TemplateCreateOptions, 'apiKey' | 'baseUrl' | 'name'>>;\nexport type SuperserveVolumeCreateOptions = CreateVolumeOptions &\n Pick<VolumeCreateOptions, 'idempotencyKey' | 'timeoutMs' | 'signal'>;\n\nfunction toTemplate(info: TemplateInfo) {\n return {\n id: info.id,\n name: info.name,\n createdAt: info.createdAt,\n metadata: { status: info.status, vcpu: info.vcpu, memoryMib: info.memoryMib, diskMib: info.diskMib, errorMessage: info.errorMessage },\n };\n}\n\nexport const superserve = defineProvider<SuperserveSandbox, SuperserveConfig>({\n name: 'superserve',\n sizes: (config, profile, options) => {\n const opts = options as Record<string, unknown> | undefined;\n const nativeSize = NATIVE_SIZE_OPTIONS.find(key => opts?.[key] !== undefined);\n if (nativeSize) {\n throw new InstanceSizeError('conflict', `cannot combine sizeClass with native Superserve ${nativeSize}; Superserve sizes sandboxes by template`);\n }\n const source = SOURCE_OPTIONS.find(key => opts?.[key] !== undefined);\n if (source) {\n return { status: 'unsupported', reason: `A Superserve template or snapshot fixes CPU and memory; drop ${source} to boot the standard size template.` };\n }\n const templateId = sizeTemplateOf(config, profile.sizeClass);\n if (!templateId) {\n return {\n status: 'unsupported',\n reason: `Superserve lists at most 16 vCPU / 64 GiB per sandbox (Pro plan); ${profile.sizeClass} needs ${profile.vcpus} vCPU / ${profile.memoryMiB / 1024} GiB. Set sizeTemplates.${profile.sizeClass} to a custom-size template to use it.`,\n };\n }\n const diskMiB = BUILT_IN_TEMPLATE_DISK_MIB[templateId];\n return {\n status: 'supported',\n nativeOptions: { templateId },\n ...(diskMiB === undefined ? {} : { resolved: { vcpus: profile.vcpus, memoryMiB: profile.memoryMiB, diskMiB } }),\n };\n },\n methods: {\n instances: {\n create: async (config: SuperserveConfig, options?: CreateInstanceOptions) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n\n const {\n timeout: requestedTimeoutMs,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n volumes,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n const ttMs = requestedTimeoutMs ?? config.timeout;\n const timeoutSeconds = ttMs !== undefined ? Math.max(1, Math.ceil(ttMs / 1000)) : undefined;\n\n try {\n const createOptions = {\n apiKey,\n baseUrl,\n name: name ?? generateSandboxName(),\n ...(templateId ? { fromTemplate: templateId } : {}),\n ...(snapshotId ? { fromSnapshot: snapshotId } : {}),\n ...(timeoutSeconds !== undefined ? { timeoutSeconds } : {}),\n ...(metadata ? { metadata: metadata as Record<string, string> } : {}),\n ...(envs ? { envVars: envs } : {}),\n ...providerOptions,\n ...(volumes !== undefined ? {\n volumes: volumes.map((mount) => ({\n ...mount,\n volume: mount.volume instanceof SuperserveVolume\n ? mount.volume\n : volumeReference(mount.volume),\n })),\n } : {}),\n };\n const connection = resolveConfig(createOptions);\n const sandbox = await SuperserveSandbox.create(createOptions);\n volumeConnections.set(sandbox, connection);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch (error) {\n const notBuilt = missingSizeTemplate(config, templateId, error);\n if (notBuilt) throw Object.assign(new Error(notBuilt), { status: 404, cause: error });\n rethrowFriendly(error, 'Failed to create Superserve sandbox');\n }\n },\n\n getById: async (config: SuperserveConfig, sandboxId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const connection = resolveConfig({ apiKey, baseUrl });\n const sandbox = await SuperserveSandbox.connect(sandboxId, connection);\n volumeConnections.set(sandbox, connection);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch {\n return null;\n }\n },\n\n list: async (config: SuperserveConfig) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const connection = resolveConfig({ apiKey, baseUrl });\n const infos = await SuperserveSandbox.list(connection);\n // No per-item connect() — that would POST /activate and resume paused sandboxes.\n return infos.map((info) => {\n const instance = info as unknown as SuperserveSandbox;\n volumeConnections.set(instance, connection);\n return { instance, instanceId: info.id };\n });\n } catch {\n return [];\n }\n },\n\n destroy: async (config: SuperserveConfig, sandboxId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n // The SDK handles already-deleted sandboxes and retries transient failures.\n await SuperserveSandbox.killById(sandboxId, { apiKey, baseUrl });\n },\n\n runCommand,\n streamCommand: runCommand,\n\n attachVolume: async (sandbox, volume, mountPath) => {\n const native = await SuperserveVolume.connect(volumeReference(volume), volumeConnection(sandbox));\n await native.attach(sandbox.id, { mountPath });\n },\n\n detachVolume: async (sandbox, volume, mountPath) => {\n const native = await SuperserveVolume.connect(volumeReference(volume), volumeConnection(sandbox));\n const attachments = (await native.listAttachments()).filter((attachment) =>\n attachment.volumeId === native.id &&\n sameSandboxId(attachment.sandboxId, sandbox.id) &&\n attachment.status !== 'revoked' &&\n (mountPath === undefined || attachment.mountPath === mountPath));\n if (attachments.length > 1) {\n throw new Error('Multiple matching Superserve attachments; provide their mount path to detach one.');\n }\n if (attachments[0]) await native.detach(attachments[0].id);\n },\n\n getInfo: async (sandbox: SuperserveSandbox): Promise<InstanceInfo> => {\n const info = await sandbox.getInfo();\n const status: InstanceInfo['status'] =\n info.status === 'paused' || info.status === 'deleted' ? 'stopped' :\n info.status === 'failed' ? 'error' :\n 'running';\n return {\n id: info.id,\n provider: 'superserve',\n status,\n createdAt: info.createdAt,\n timeout: info.timeoutSeconds ? info.timeoutSeconds * 1000 : DEFAULT_TIMEOUT_MS,\n metadata: info.metadata,\n };\n },\n\n getUrl: async (sandbox: SuperserveSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n // A preview URL only routes once its port is published. A new port takes\n // the sandbox's `previewAccess` default; a published one keeps its mode.\n await sandbox.publishPreviewPort(options.port);\n const url = sandbox.getPreviewUrl(options.port);\n return options.protocol ? url.replace(/^https/, options.protocol) : url;\n },\n\n filesystem: {\n readFile: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n return sandbox.files.readText(await resolveSandboxPath(sandbox, path, runCommand));\n },\n\n writeFile: async (sandbox: SuperserveSandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n await sandbox.files.write(await resolveSandboxPath(sandbox, path, runCommand), content);\n },\n\n mkdir: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`mkdir -p \"${escapeShellArg(resolved)}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`mkdir failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n },\n\n readdir: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n // find -printf format: <type>\\t<size>\\t<mtime-epoch>\\t<name>\n const cmd = [\n `cd \"${escapeShellArg(resolved)}\" || exit 2`,\n `find . -mindepth 1 -maxdepth 1 -printf '%y\\\\t%s\\\\t%T@\\\\t%f\\\\n' 2>/dev/null`,\n ].join(' && ');\n const result = await sandbox.commands.run(cmd);\n if (result.exitCode === 2) {\n throw new Error(`readdir: directory not found: ${path}`);\n }\n if (result.exitCode !== 0) {\n throw new Error(`readdir failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n const entries: FileEntry[] = [];\n for (const line of result.stdout.split('\\n')) {\n if (!line) continue;\n const [type, sizeStr, mtimeStr, ...nameParts] = line.split('\\t');\n const name = nameParts.join('\\t');\n if (!name) continue;\n const size = Number.parseInt(sizeStr, 10);\n const mtime = Number.parseFloat(mtimeStr);\n entries.push({\n name,\n type: type === 'd' ? 'directory' : 'file',\n size: Number.isFinite(size) ? size : 0,\n modified: Number.isFinite(mtime) ? new Date(mtime * 1000) : new Date(),\n });\n }\n return entries;\n },\n\n exists: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`test -e \"${escapeShellArg(resolved)}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n // An empty or dot-only path would resolve to the workdir itself —\n // refuse it rather than `rm -rf` the sandbox's whole cwd.\n if (path.split('/').every((s) => s === '' || s === '.')) {\n throw new Error(`remove: refusing ambiguous path: ${JSON.stringify(path)}`);\n }\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`rm -rf \"${escapeShellArg(resolved)}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`remove failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n },\n },\n\n getInstance: (sandbox: SuperserveSandbox): SuperserveSandbox => sandbox,\n\n pause: async (sandbox: SuperserveSandbox): Promise<void> => {\n try {\n await sandbox.pause({ wait: true });\n } catch (error) {\n rethrowFriendly(error, 'Failed to pause Superserve sandbox');\n }\n },\n\n resume: async (sandbox: SuperserveSandbox): Promise<void> => {\n try {\n // The access token rotates on resume; the SDK refreshes the handle in place.\n await sandbox.resume();\n } catch (error) {\n rethrowFriendly(error, 'Failed to resume Superserve sandbox');\n }\n },\n\n pauseCapabilities: { memory: true },\n },\n\n snapshot: {\n // Snapshots hold memory and disk: restores keep the whole filesystem,\n // tmpfs /tmp included, and running processes. The source keeps running.\n capabilities: { scope: 'rootfs', memory: true, destroysSource: false },\n create: async (config: SuperserveConfig, sandboxId: string, options?: { name?: string }) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n // connect() activates the sandbox, so a paused one is resumed first.\n const sandbox = await SuperserveSandbox.connect(sandboxId, { apiKey, baseUrl });\n return toSnapshot(await sandbox.snapshot({ name: options?.name }));\n } catch (error) {\n rethrowFriendly(error, 'Failed to create Superserve snapshot');\n }\n },\n list: async (config: SuperserveConfig, options?: { sandboxId?: string; limit?: number }) => {\n // Snapshots are listed per sandbox. Callers that aggregate across\n // providers pass no options, so an unscoped call returns nothing\n // instead of throwing and failing their whole listing.\n if (!options?.sandboxId) return [];\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n const infos = await SuperserveSnapshot.list(options.sandboxId, { apiKey, baseUrl, limit: options.limit });\n return infos.map(toSnapshot);\n },\n delete: async (config: SuperserveConfig, snapshotId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n await SuperserveSnapshot.deleteById(snapshotId, { apiKey, baseUrl });\n },\n },\n\n volume: {\n create: async (config: SuperserveConfig, options: SuperserveVolumeCreateOptions) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n const volume = await SuperserveVolume.create({\n ...connection,\n name: options.name,\n ...(options.sizeBytes !== undefined ? { capacityBytes: options.sizeBytes } : {}),\n idempotencyKey: options.idempotencyKey,\n timeoutMs: options.timeoutMs,\n signal: options.signal,\n });\n return toVolume(volume);\n },\n get: async (config: SuperserveConfig, idOrName: string) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n try {\n return toVolume(await SuperserveVolume.connect(idOrName, connection));\n } catch (error) {\n if (error instanceof NotFoundError) return null;\n throw error;\n }\n },\n list: async (config: SuperserveConfig, options?: { limit?: number }) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n const volumes = await SuperserveVolume.list({ ...connection, limit: options?.limit });\n return volumes.map(toVolume);\n },\n delete: async (config: SuperserveConfig, idOrName: string) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n await deleteVolume(connection, idOrName);\n },\n },\n\n template: {\n create: async (config: SuperserveConfig, options: SuperserveTemplateCreateOptions) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n const { name, from, vcpu, memoryMib, diskMib, steps, startCmd, readyCmd } = options;\n if (!from) {\n throw new Error('Superserve templates are built from an image: pass `from` (e.g. \"node:22\").');\n }\n try {\n const template = await SuperserveTemplate.create({\n apiKey, baseUrl, name, from, vcpu, memoryMib, diskMib, steps, startCmd, readyCmd,\n });\n return toTemplate(await template.waitUntilReady());\n } catch (error) {\n rethrowFriendly(error, 'Failed to create Superserve template');\n }\n },\n list: async (config: SuperserveConfig) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const infos = await SuperserveTemplate.list({ apiKey, baseUrl });\n return infos.map(toTemplate);\n } catch {\n return [];\n }\n },\n delete: async (config: SuperserveConfig, templateId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n await SuperserveTemplate.deleteById(templateId, { apiKey, baseUrl });\n } catch {\n /* already deleted */\n }\n },\n },\n },\n});\n\nexport type { Sandbox as SuperserveSandbox } from '@superserve/sdk';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,yBAA2B;AAC3B,iBASO;AASP,sBAA0F;AAE1F,IAAM,qBAAqB;AAgCpB,IAAM,4BAAkF,OAAO,OAAO;AAAA,EAC3G,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT,CAAC;AAGD,IAAM,6BAA+D,OAAO,OAAO,EAAE,mBAAmB,KAAK,CAAC;AAG9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AAA,YAAW;AAAA,YAAS;AAAA,YAAO;AAAA,YAAU;AAAA,UAC1E,CAAC;AACD,iBAAO,WAAW,MAAM,SAAS,eAAe,CAAC;AAAA,QACnD,SAAS,OAAO;AACd,0BAAgB,OAAO,sCAAsC;AAAA,QAC/D;AAAA,MACF;AAAA,MACA,MAAM,OAAO,WAA6B;AACxC,cAAM,SAAS,cAAc,MAAM;AACnC,cAAM,UAAU,eAAe,MAAM;AACrC,YAAI;AACF,gBAAM,QAAQ,MAAM,WAAAA,SAAmB,KAAK,EAAE,QAAQ,QAAQ,CAAC;AAC/D,iBAAO,MAAM,IAAI,UAAU;AAAA,QAC7B,QAAQ;AACN,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,MACA,QAAQ,OAAO,QAA0B,eAAuB;AAC9D,cAAM,SAAS,cAAc,MAAM;AACnC,cAAM,UAAU,eAAe,MAAM;AACrC,YAAI;AACF,gBAAM,WAAAA,SAAmB,WAAW,YAAY,EAAE,QAAQ,QAAQ,CAAC;AAAA,QACrE,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["SuperserveVolume","runCommand","SuperserveSandbox","SuperserveSnapshot","SuperserveTemplate"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Superserve Provider - Factory-based Implementation\n *\n * Wraps `@superserve/sdk` to expose the ComputeSDK provider interface.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n AuthenticationError,\n ConflictError,\n NotFoundError,\n ServerError,\n Sandbox as SuperserveSandbox,\n Snapshot as SuperserveSnapshot,\n Template as SuperserveTemplate,\n Volume as SuperserveVolume,\n resolveConfig,\n} from '@superserve/sdk';\nimport type {\n ResolvedConfig,\n SnapshotInfo,\n TemplateCreateOptions,\n TemplateInfo,\n VolumeCreateOptions,\n VolumeInfo,\n} from '@superserve/sdk';\nimport { defineProvider, escapeShellArg, InstanceSizeError, INSTANCE_SIZE_PROFILES } from '@computesdk/provider';\n\nconst DEFAULT_TIMEOUT_MS = 300_000;\n\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateTemplateOptions,\n CreateVolumeOptions,\n FileEntry,\n InstanceSizeClass,\n RunCommandOptions,\n InstanceInfo,\n Volume,\n} from '@computesdk/provider';\n\nexport interface SuperserveConfig {\n /** Superserve API key. Falls back to `SUPERSERVE_API_KEY` env var. */\n apiKey?: string;\n /** API base URL. Falls back to `SUPERSERVE_BASE_URL` env var, then the `@superserve/sdk` default. */\n baseUrl?: string;\n /** Default auto-pause timeout in milliseconds. */\n timeout?: number;\n /** Template to boot per standard `sizeClass`; defaults to {@link SUPERSERVE_SIZE_TEMPLATES}. */\n sizeTemplates?: Partial<Record<InstanceSizeClass, string>>;\n}\n\n/**\n * Superserve fixes vCPU, memory and disk when a template is built, so each\n * standard size boots its own template. `superserve/base` (2 vCPU / 4 GiB /\n * 8 GiB disk) is built in to every team; the others are team templates\n * built by `scripts/provider-setup.mjs superserve`. The largest listed plan\n * (Pro) caps a sandbox at 16 vCPU / 64 GiB, so `3xl` has no default.\n */\nexport const SUPERSERVE_SIZE_TEMPLATES: Readonly<Partial<Record<InstanceSizeClass, string>>> = Object.freeze({\n xs: 'csdk-node22-1cpu-1gb',\n sm: 'csdk-node22-1cpu-2gb',\n md: 'superserve/base',\n lg: 'csdk-node22-4cpu-8gb',\n xl: 'csdk-node22-8cpu-16gb',\n '2xl': 'csdk-node22-16cpu-32gb',\n});\n\n/** Disk the built-in templates fix; team templates take theirs from the build. */\nconst BUILT_IN_TEMPLATE_DISK_MIB: Readonly<Record<string, number>> = Object.freeze({ 'superserve/base': 8192 });\n\n/** Native selectors that pick or size the VM; `Sandbox.create` drops the sizing ones silently. */\nconst SOURCE_OPTIONS = ['templateId', 'snapshotId', 'sandboxId', 'fromTemplate', 'fromSnapshot'] as const;\nconst NATIVE_SIZE_OPTIONS = ['vcpu', 'vcpuCount', 'memoryMib', 'memoryMaxMib', 'diskMib'] as const;\n\nfunction sizeTemplateOf(config: SuperserveConfig, sizeClass: InstanceSizeClass): string | undefined {\n const name = config.sizeTemplates?.[sizeClass] ?? SUPERSERVE_SIZE_TEMPLATES[sizeClass];\n return typeof name === 'string' && name.trim() ? name : undefined;\n}\n\n/** A create that failed because a standard-size template was never built on this team. */\nfunction missingSizeTemplate(config: SuperserveConfig, templateId: unknown, error: unknown): string | undefined {\n if (typeof templateId !== 'string' || !(error instanceof NotFoundError)) return undefined;\n const sizeClass = (Object.keys(INSTANCE_SIZE_PROFILES) as InstanceSizeClass[]).find(c => sizeTemplateOf(config, c) === templateId);\n if (!sizeClass) return undefined;\n return `Superserve size template '${templateId}' (sizeClass ${sizeClass}) is not built on this Superserve team; run \\`node scripts/provider-setup.mjs superserve\\` (provider-setup.yml) or point \\`sizeTemplates.${sizeClass}\\` at an existing template`;\n}\n\nfunction resolveApiKey(config: SuperserveConfig): string {\n const apiKey = config.apiKey || process.env.SUPERSERVE_API_KEY;\n if (!apiKey) {\n throw new Error(\n `Missing Superserve API key. Provide 'apiKey' in config or set SUPERSERVE_API_KEY environment variable.`,\n );\n }\n return apiKey;\n}\n\nfunction resolveBaseUrl(config: SuperserveConfig): string | undefined {\n // Returns undefined when unset on purpose: the SDK then applies its own\n // resolution (SUPERSERVE_BASE_URL env var, then its default endpoint), so\n // we don't duplicate that default and risk it drifting.\n return config.baseUrl || process.env.SUPERSERVE_BASE_URL || undefined;\n}\n\nfunction generateSandboxName(): string {\n return `cs-${randomUUID().slice(0, 8)}`;\n}\n\ntype CommandRunner = (\n sandbox: SuperserveSandbox,\n command: string,\n options?: RunCommandOptions,\n) => Promise<CommandResult>;\n\nconst FALLBACK_WORKDIR = '/';\n\n/** Cached `pwd` probes: relative filesystem paths resolve against the cwd a\n * `runCommand` exec would use, so `writeFile('a.txt')` and `cat a.txt` agree. */\nconst workdirs = new WeakMap<SuperserveSandbox, Promise<string>>();\nconst volumeConnections = new WeakMap<SuperserveSandbox, ResolvedConfig>();\n\nfunction volumeReference(volume: string | Volume): string {\n const reference = typeof volume === 'string' ? volume : volume?.id || volume?.name;\n if (typeof reference !== 'string' || !reference.trim()) {\n throw new Error('A Superserve volume reference must contain an id or name.');\n }\n return reference;\n}\n\nfunction volumeConnection(sandbox: SuperserveSandbox): ResolvedConfig {\n const connection = volumeConnections.get(sandbox);\n if (!connection) throw new Error('The Superserve sandbox has no captured volume connection.');\n return connection;\n}\n\nfunction sameSandboxId(left: string, right: string): boolean {\n const pattern = /^(?:sb-([A-Za-z0-9]+)-)?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;\n const a = pattern.exec(left);\n const b = pattern.exec(right);\n if (!a || !b) return left === right;\n return a[2].toLowerCase() === b[2].toLowerCase() &&\n (a[1] === undefined || b[1] === undefined || a[1] === b[1]);\n}\n\nfunction toVolume(info: VolumeInfo): Volume {\n return {\n id: info.id,\n name: info.name,\n sizeBytes: info.capacityBytes,\n usedBytes: info.usedBytes,\n region: info.region,\n status: info.status,\n createdAt: info.createdAt,\n };\n}\n\nasync function deleteVolume(connection: ResolvedConfig, idOrName: string): Promise<void> {\n let volume: SuperserveVolume;\n try {\n volume = await SuperserveVolume.connect(idOrName, connection);\n } catch (error) {\n if (error instanceof NotFoundError) return;\n throw error;\n }\n // Names can be reused while closing leases settle. Resolve once so retries\n // and attachment checks stay bound to the original volume.\n const deadline = Date.now() + 120_000;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), 120_000);\n let lastError: unknown;\n const requireTime = () => {\n const remaining = deadline - Date.now();\n if (controller.signal.aborted || remaining <= 0) {\n throw lastError ?? new Error('Timed out waiting for Superserve volume deletion.');\n }\n return remaining;\n };\n try {\n for (;;) {\n requireTime();\n try {\n // The instance method forwards request timeouts; the static shortcut does not.\n await volume.delete({ signal: controller.signal, timeoutMs: requireTime() });\n return;\n } catch (error) {\n requireTime();\n lastError = error;\n try {\n if (error instanceof ConflictError && error.code === 'volume_conflict') {\n const attachments = await volume.listAttachments({ signal: controller.signal, timeoutMs: requireTime() });\n const closing = attachments.filter((attachment) => attachment.status !== 'revoked');\n // Never wait for an active mount or hide an unrelated conflict.\n if (!closing.length || closing.some((attachment) =>\n attachment.status !== 'detaching' && attachment.status !== 'revoking')) throw error;\n } else if (error instanceof ServerError && error.statusCode === 503 && error.code === 'volume_unavailable') {\n // Cleanup advances in batches; a fresh deleting state is retryable,\n // but it is not confirmation that the original volume is gone.\n const current = await volume.getInfo({ signal: controller.signal, timeoutMs: requireTime() });\n if (current.status !== 'deleting') throw error;\n } else {\n throw error;\n }\n } catch (lookupError) {\n if (lookupError instanceof NotFoundError) return;\n throw lookupError;\n }\n requireTime();\n await new Promise((resolve) => setTimeout(resolve, Math.min(3_000, deadline - Date.now())));\n }\n }\n } catch (error) {\n if (controller.signal.aborted || Date.now() >= deadline) throw lastError ?? error;\n throw error;\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction workdirOf(sandbox: SuperserveSandbox, runCommand: CommandRunner): Promise<string> {\n let probe = workdirs.get(sandbox);\n if (!probe) {\n probe = runCommand(sandbox, 'pwd').then((result) => {\n const dir = result.stdout.trim();\n if (result.exitCode === 0 && dir.startsWith('/')) return dir;\n // runCommand reports exec failures as results, not rejections, so a\n // transient failure must not pin the workdir to the fallback forever —\n // evict and let the next filesystem op probe again.\n workdirs.delete(sandbox);\n return FALLBACK_WORKDIR;\n });\n workdirs.set(sandbox, probe);\n probe.catch(() => workdirs.delete(sandbox));\n }\n return probe;\n}\n\n/** Join `path` onto the sandbox workdir. Absolute paths pass through and skip\n * the probe; empty and `.` segments are dropped; `..` segments are preserved\n * for the sandbox filesystem to resolve physically — collapsing them\n * lexically would mis-resolve when a preceding component is a symlink. */\nasync function resolveSandboxPath(\n sandbox: SuperserveSandbox,\n path: string,\n runCommand: CommandRunner,\n): Promise<string> {\n const combined = path.startsWith('/')\n ? path\n : `${await workdirOf(sandbox, runCommand)}/${path}`;\n const segments: string[] = [];\n for (const segment of combined.split('/')) {\n if (segment === '' || segment === '.') continue;\n segments.push(segment);\n }\n return `/${segments.join('/')}`;\n}\n\nfunction rethrowFriendly(error: unknown, fallbackPrefix: string): never {\n if (error instanceof AuthenticationError) {\n throw new Error(\n `Superserve authentication failed. Please check your SUPERSERVE_API_KEY environment variable.`,\n );\n }\n const message = error instanceof Error ? error.message : String(error);\n const lower = message.toLowerCase();\n if (lower.includes('unauthorized') || lower.includes('401') || lower.includes('api key')) {\n throw new Error(\n `Superserve authentication failed. Please check your SUPERSERVE_API_KEY environment variable.`,\n );\n }\n if (lower.includes('quota') || lower.includes('limit') || lower.includes('429')) {\n throw new Error(`Superserve quota or rate limit reached: ${message}`);\n }\n throw new Error(`${fallbackPrefix}: ${message}`);\n}\n\n// Also serves as `streamCommand`: the SDK streams output over its own exec API\n// when callbacks are passed, so no daemon or routable port is needed.\nconst runCommand: CommandRunner = async (sandbox, command, options) => {\n const startTime = Date.now();\n try {\n let fullCommand = command;\n if (options?.background) {\n // Run the whole command under `sh -c` so the trailing `&` backgrounds\n // the entire command (not just its last statement), and escape it so\n // the user's command can't break out of the nohup wrapper.\n fullCommand = `nohup sh -c \"${escapeShellArg(fullCommand)}\" > /dev/null 2>&1 &`;\n }\n const result = await sandbox.commands.run(fullCommand, {\n cwd: options?.cwd,\n env: options?.env,\n timeoutMs: options?.timeout,\n onStdout: options?.onStdout,\n onStderr: options?.onStderr,\n });\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n durationMs: Date.now() - startTime,\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\nfunction toSnapshot(info: SnapshotInfo) {\n return {\n id: info.id,\n provider: 'superserve',\n createdAt: info.createdAt,\n metadata: {\n name: info.name,\n sandboxId: info.sandboxId,\n status: info.status,\n sizeBytes: info.sizeBytes,\n },\n };\n}\n\n/** Superserve sizes sandboxes at the template: vCPU, memory and disk are set\n * here and every sandbox created from it inherits them. */\nexport type SuperserveTemplateCreateOptions = CreateTemplateOptions & Partial<Omit<TemplateCreateOptions, 'apiKey' | 'baseUrl' | 'name'>>;\nexport type SuperserveVolumeCreateOptions = CreateVolumeOptions &\n Pick<VolumeCreateOptions, 'idempotencyKey' | 'timeoutMs' | 'signal'>;\n\nfunction toTemplate(info: TemplateInfo) {\n return {\n id: info.id,\n name: info.name,\n createdAt: info.createdAt,\n metadata: { status: info.status, vcpu: info.vcpu, memoryMib: info.memoryMib, diskMib: info.diskMib, errorMessage: info.errorMessage },\n };\n}\n\nexport const superserve = defineProvider<SuperserveSandbox, SuperserveConfig>({\n name: 'superserve',\n sizes: (config, profile, options) => {\n const opts = options as Record<string, unknown> | undefined;\n const nativeSize = NATIVE_SIZE_OPTIONS.find(key => opts?.[key] !== undefined);\n if (nativeSize) {\n throw new InstanceSizeError('conflict', `cannot combine sizeClass with native Superserve ${nativeSize}; Superserve sizes sandboxes by template`);\n }\n const source = SOURCE_OPTIONS.find(key => opts?.[key] !== undefined);\n if (source) {\n return { status: 'unsupported', reason: `A Superserve template or snapshot fixes CPU and memory; drop ${source} to boot the standard size template.` };\n }\n const templateId = sizeTemplateOf(config, profile.sizeClass);\n if (!templateId) {\n return {\n status: 'unsupported',\n reason: `Superserve lists at most 16 vCPU / 64 GiB per sandbox (Pro plan); ${profile.sizeClass} needs ${profile.vcpus} vCPU / ${profile.memoryMiB / 1024} GiB. Set sizeTemplates.${profile.sizeClass} to a custom-size template to use it.`,\n };\n }\n const diskMiB = BUILT_IN_TEMPLATE_DISK_MIB[templateId];\n return {\n status: 'supported',\n nativeOptions: { templateId },\n ...(diskMiB === undefined ? {} : { resolved: { vcpus: profile.vcpus, memoryMiB: profile.memoryMiB, diskMiB } }),\n };\n },\n methods: {\n instances: {\n create: async (config: SuperserveConfig, options?: CreateInstanceOptions) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n\n const {\n timeout: requestedTimeoutMs,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n volumes,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n const ttMs = requestedTimeoutMs ?? config.timeout;\n const timeoutSeconds = ttMs !== undefined ? Math.max(1, Math.ceil(ttMs / 1000)) : undefined;\n\n try {\n const createOptions = {\n apiKey,\n baseUrl,\n name: name ?? generateSandboxName(),\n ...(templateId ? { fromTemplate: templateId } : {}),\n ...(snapshotId ? { fromSnapshot: snapshotId } : {}),\n ...(timeoutSeconds !== undefined ? { timeoutSeconds } : {}),\n ...(metadata ? { metadata: metadata as Record<string, string> } : {}),\n ...(envs ? { envVars: envs } : {}),\n ...providerOptions,\n ...(volumes !== undefined ? {\n volumes: volumes.map((mount) => ({\n ...mount,\n volume: mount.volume instanceof SuperserveVolume\n ? mount.volume\n : volumeReference(mount.volume),\n })),\n } : {}),\n };\n const connection = resolveConfig(createOptions);\n const sandbox = await SuperserveSandbox.create(createOptions);\n volumeConnections.set(sandbox, connection);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch (error) {\n const notBuilt = missingSizeTemplate(config, templateId, error);\n if (notBuilt) throw Object.assign(new Error(notBuilt), { status: 404, cause: error });\n rethrowFriendly(error, 'Failed to create Superserve sandbox');\n }\n },\n\n getById: async (config: SuperserveConfig, sandboxId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const connection = resolveConfig({ apiKey, baseUrl });\n const sandbox = await SuperserveSandbox.connect(sandboxId, connection);\n volumeConnections.set(sandbox, connection);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch {\n return null;\n }\n },\n\n list: async (config: SuperserveConfig) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const connection = resolveConfig({ apiKey, baseUrl });\n const infos = await SuperserveSandbox.list(connection);\n // No per-item connect() — that would POST /activate and resume paused sandboxes.\n return infos.map((info) => {\n const instance = info as unknown as SuperserveSandbox;\n volumeConnections.set(instance, connection);\n return { instance, instanceId: info.id };\n });\n } catch {\n return [];\n }\n },\n\n destroy: async (config: SuperserveConfig, sandboxId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n // The SDK handles already-deleted sandboxes and retries transient failures.\n await SuperserveSandbox.killById(sandboxId, { apiKey, baseUrl });\n },\n\n runCommand,\n streamCommand: runCommand,\n\n attachVolume: async (sandbox, volume, mountPath) => {\n const native = await SuperserveVolume.connect(volumeReference(volume), volumeConnection(sandbox));\n await native.attach(sandbox.id, { mountPath });\n },\n\n detachVolume: async (sandbox, volume, mountPath) => {\n const native = await SuperserveVolume.connect(volumeReference(volume), volumeConnection(sandbox));\n const attachments = (await native.listAttachments()).filter((attachment) =>\n attachment.volumeId === native.id &&\n sameSandboxId(attachment.sandboxId, sandbox.id) &&\n attachment.status !== 'revoked' &&\n (mountPath === undefined || attachment.mountPath === mountPath));\n if (attachments.length > 1) {\n throw new Error('Multiple matching Superserve attachments; provide their mount path to detach one.');\n }\n if (attachments[0]) await native.detach(attachments[0].id);\n },\n\n getInfo: async (sandbox: SuperserveSandbox): Promise<InstanceInfo> => {\n const info = await sandbox.getInfo();\n const status: InstanceInfo['status'] =\n info.status === 'paused' || info.status === 'deleted' ? 'stopped' :\n info.status === 'failed' ? 'error' :\n 'running';\n return {\n id: info.id,\n provider: 'superserve',\n status,\n createdAt: info.createdAt,\n timeout: info.timeoutSeconds ? info.timeoutSeconds * 1000 : DEFAULT_TIMEOUT_MS,\n metadata: info.metadata,\n };\n },\n\n getUrl: async (sandbox: SuperserveSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n // A preview URL only routes once its port is published. A new port takes\n // the sandbox's `previewAccess` default; a published one keeps its mode.\n await sandbox.publishPreviewPort(options.port);\n const url = sandbox.getPreviewUrl(options.port);\n return options.protocol ? url.replace(/^https/, options.protocol) : url;\n },\n\n filesystem: {\n readFile: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n return sandbox.files.readText(await resolveSandboxPath(sandbox, path, runCommand));\n },\n\n writeFile: async (sandbox: SuperserveSandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n await sandbox.files.write(await resolveSandboxPath(sandbox, path, runCommand), content);\n },\n\n mkdir: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`mkdir -p \"${escapeShellArg(resolved)}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`mkdir failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n },\n\n readdir: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n // find -printf format: <type>\\t<size>\\t<mtime-epoch>\\t<name>\n const cmd = [\n `cd \"${escapeShellArg(resolved)}\" || exit 2`,\n `find . -mindepth 1 -maxdepth 1 -printf '%y\\\\t%s\\\\t%T@\\\\t%f\\\\n' 2>/dev/null`,\n ].join(' && ');\n const result = await sandbox.commands.run(cmd);\n if (result.exitCode === 2) {\n throw new Error(`readdir: directory not found: ${path}`);\n }\n if (result.exitCode !== 0) {\n throw new Error(`readdir failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n const entries: FileEntry[] = [];\n for (const line of result.stdout.split('\\n')) {\n if (!line) continue;\n const [type, sizeStr, mtimeStr, ...nameParts] = line.split('\\t');\n const name = nameParts.join('\\t');\n if (!name) continue;\n const size = Number.parseInt(sizeStr, 10);\n const mtime = Number.parseFloat(mtimeStr);\n entries.push({\n name,\n type: type === 'd' ? 'directory' : 'file',\n size: Number.isFinite(size) ? size : 0,\n modified: Number.isFinite(mtime) ? new Date(mtime * 1000) : new Date(),\n });\n }\n return entries;\n },\n\n exists: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`test -e \"${escapeShellArg(resolved)}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n // An empty or dot-only path would resolve to the workdir itself —\n // refuse it rather than `rm -rf` the sandbox's whole cwd.\n if (path.split('/').every((s) => s === '' || s === '.')) {\n throw new Error(`remove: refusing ambiguous path: ${JSON.stringify(path)}`);\n }\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`rm -rf \"${escapeShellArg(resolved)}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`remove failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n },\n },\n\n getInstance: (sandbox: SuperserveSandbox): SuperserveSandbox => sandbox,\n\n pause: async (sandbox: SuperserveSandbox): Promise<void> => {\n try {\n await sandbox.pause({ wait: true });\n } catch (error) {\n rethrowFriendly(error, 'Failed to pause Superserve sandbox');\n }\n },\n\n resume: async (sandbox: SuperserveSandbox): Promise<void> => {\n try {\n // The access token rotates on resume; the SDK refreshes the handle in place.\n await sandbox.resume();\n } catch (error) {\n rethrowFriendly(error, 'Failed to resume Superserve sandbox');\n }\n },\n\n pauseCapabilities: { memory: true },\n },\n\n snapshot: {\n // Snapshots hold memory and disk: restores keep the whole filesystem,\n // tmpfs /tmp included, and running processes. The source keeps running.\n capabilities: { scope: 'rootfs', memory: true, destroysSource: false },\n create: async (config: SuperserveConfig, sandboxId: string, options?: { name?: string }) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n // connect() activates the sandbox, so a paused one is resumed first.\n const sandbox = await SuperserveSandbox.connect(sandboxId, { apiKey, baseUrl });\n return toSnapshot(await sandbox.snapshot({ name: options?.name }));\n } catch (error) {\n rethrowFriendly(error, 'Failed to create Superserve snapshot');\n }\n },\n list: async (config: SuperserveConfig, options?: { sandboxId?: string; limit?: number }) => {\n // Snapshots are listed per sandbox. Callers that aggregate across\n // providers pass no options, so an unscoped call returns nothing\n // instead of throwing and failing their whole listing.\n if (!options?.sandboxId) return [];\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n const infos = await SuperserveSnapshot.list(options.sandboxId, { apiKey, baseUrl, limit: options.limit });\n return infos.map(toSnapshot);\n },\n delete: async (config: SuperserveConfig, snapshotId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n await SuperserveSnapshot.deleteById(snapshotId, { apiKey, baseUrl });\n },\n },\n\n volume: {\n create: async (config: SuperserveConfig, options: SuperserveVolumeCreateOptions) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n const volume = await SuperserveVolume.create({\n ...connection,\n name: options.name,\n ...(options.sizeBytes !== undefined ? { capacityBytes: options.sizeBytes } : {}),\n idempotencyKey: options.idempotencyKey,\n timeoutMs: options.timeoutMs,\n signal: options.signal,\n });\n return toVolume(volume);\n },\n get: async (config: SuperserveConfig, idOrName: string) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n try {\n return toVolume(await SuperserveVolume.connect(idOrName, connection));\n } catch (error) {\n if (error instanceof NotFoundError) return null;\n throw error;\n }\n },\n list: async (config: SuperserveConfig, options?: { limit?: number }) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n const volumes = await SuperserveVolume.list({ ...connection, limit: options?.limit });\n return volumes.map(toVolume);\n },\n delete: async (config: SuperserveConfig, idOrName: string) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n await deleteVolume(connection, idOrName);\n },\n },\n\n template: {\n create: async (config: SuperserveConfig, options: SuperserveTemplateCreateOptions) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n const { name, from, vcpu, memoryMib, diskMib, steps, startCmd, readyCmd } = options;\n if (!from) {\n throw new Error('Superserve templates are built from an image: pass `from` (e.g. \"node:22\").');\n }\n try {\n const template = await SuperserveTemplate.create({\n apiKey, baseUrl, name, from, vcpu, memoryMib, diskMib, steps, startCmd, readyCmd,\n });\n return toTemplate(await template.waitUntilReady());\n } catch (error) {\n rethrowFriendly(error, 'Failed to create Superserve template');\n }\n },\n list: async (config: SuperserveConfig) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const infos = await SuperserveTemplate.list({ apiKey, baseUrl });\n return infos.map(toTemplate);\n } catch {\n return [];\n }\n },\n delete: async (config: SuperserveConfig, templateId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n await SuperserveTemplate.deleteById(templateId, { apiKey, baseUrl });\n } catch {\n /* already deleted */\n }\n },\n },\n },\n});\n\nexport type { Sandbox as SuperserveSandbox } from '@superserve/sdk';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,yBAA2B;AAC3B,iBAUO;AASP,sBAA0F;AAE1F,IAAM,qBAAqB;AAgCpB,IAAM,4BAAkF,OAAO,OAAO;AAAA,EAC3G,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT,CAAC;AAGD,IAAM,6BAA+D,OAAO,OAAO,EAAE,mBAAmB,KAAK,CAAC;AAG9G,IAAM,iBAAiB,CAAC,cAAc,cAAc,aAAa,gBAAgB,cAAc;AAC/F,IAAM,sBAAsB,CAAC,QAAQ,aAAa,aAAa,gBAAgB,SAAS;AAExF,SAAS,eAAe,QAA0B,WAAkD;AAClG,QAAM,OAAO,OAAO,gBAAgB,SAAS,KAAK,0BAA0B,SAAS;AACrF,SAAO,OAAO,SAAS,YAAY,KAAK,KAAK,IAAI,OAAO;AAC1D;AAGA,SAAS,oBAAoB,QAA0B,YAAqB,OAAoC;AAC9G,MAAI,OAAO,eAAe,YAAY,EAAE,iBAAiB,0BAAgB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4,6 +4,7 @@ import {
4
4
  AuthenticationError,
5
5
  ConflictError,
6
6
  NotFoundError,
7
+ ServerError,
7
8
  Sandbox as SuperserveSandbox,
8
9
  Snapshot as SuperserveSnapshot,
9
10
  Template as SuperserveTemplate,
@@ -90,23 +91,49 @@ async function deleteVolume(connection, idOrName) {
90
91
  throw error;
91
92
  }
92
93
  const deadline = Date.now() + 12e4;
93
- for (; ; ) {
94
- try {
95
- await SuperserveVolume.deleteById(volume.id, connection);
96
- return;
97
- } catch (error) {
98
- if (!(error instanceof ConflictError) || error.code !== "volume_conflict") throw error;
99
- let attachments;
94
+ const controller = new AbortController();
95
+ const timer = setTimeout(() => controller.abort(), 12e4);
96
+ let lastError;
97
+ const requireTime = () => {
98
+ const remaining = deadline - Date.now();
99
+ if (controller.signal.aborted || remaining <= 0) {
100
+ throw lastError ?? new Error("Timed out waiting for Superserve volume deletion.");
101
+ }
102
+ return remaining;
103
+ };
104
+ try {
105
+ for (; ; ) {
106
+ requireTime();
100
107
  try {
101
- attachments = await volume.listAttachments();
102
- } catch (lookupError) {
103
- if (lookupError instanceof NotFoundError) return;
104
- throw lookupError;
108
+ await volume.delete({ signal: controller.signal, timeoutMs: requireTime() });
109
+ return;
110
+ } catch (error) {
111
+ requireTime();
112
+ lastError = error;
113
+ try {
114
+ if (error instanceof ConflictError && error.code === "volume_conflict") {
115
+ const attachments = await volume.listAttachments({ signal: controller.signal, timeoutMs: requireTime() });
116
+ const closing = attachments.filter((attachment) => attachment.status !== "revoked");
117
+ if (!closing.length || closing.some((attachment) => attachment.status !== "detaching" && attachment.status !== "revoking")) throw error;
118
+ } else if (error instanceof ServerError && error.statusCode === 503 && error.code === "volume_unavailable") {
119
+ const current = await volume.getInfo({ signal: controller.signal, timeoutMs: requireTime() });
120
+ if (current.status !== "deleting") throw error;
121
+ } else {
122
+ throw error;
123
+ }
124
+ } catch (lookupError) {
125
+ if (lookupError instanceof NotFoundError) return;
126
+ throw lookupError;
127
+ }
128
+ requireTime();
129
+ await new Promise((resolve) => setTimeout(resolve, Math.min(3e3, deadline - Date.now())));
105
130
  }
106
- const closing = attachments.filter((attachment) => attachment.status !== "revoked");
107
- if (!closing.length || closing.some((attachment) => attachment.status !== "detaching" && attachment.status !== "revoking") || Date.now() >= deadline) throw error;
108
- await new Promise((resolve) => setTimeout(resolve, 3e3));
109
131
  }
132
+ } catch (error) {
133
+ if (controller.signal.aborted || Date.now() >= deadline) throw lastError ?? error;
134
+ throw error;
135
+ } finally {
136
+ clearTimeout(timer);
110
137
  }
111
138
  }
112
139
  function workdirOf(sandbox, runCommand2) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Superserve Provider - Factory-based Implementation\n *\n * Wraps `@superserve/sdk` to expose the ComputeSDK provider interface.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n AuthenticationError,\n ConflictError,\n NotFoundError,\n Sandbox as SuperserveSandbox,\n Snapshot as SuperserveSnapshot,\n Template as SuperserveTemplate,\n Volume as SuperserveVolume,\n resolveConfig,\n} from '@superserve/sdk';\nimport type {\n ResolvedConfig,\n SnapshotInfo,\n TemplateCreateOptions,\n TemplateInfo,\n VolumeCreateOptions,\n VolumeInfo,\n} from '@superserve/sdk';\nimport { defineProvider, escapeShellArg, InstanceSizeError, INSTANCE_SIZE_PROFILES } from '@computesdk/provider';\n\nconst DEFAULT_TIMEOUT_MS = 300_000;\n\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateTemplateOptions,\n CreateVolumeOptions,\n FileEntry,\n InstanceSizeClass,\n RunCommandOptions,\n InstanceInfo,\n Volume,\n} from '@computesdk/provider';\n\nexport interface SuperserveConfig {\n /** Superserve API key. Falls back to `SUPERSERVE_API_KEY` env var. */\n apiKey?: string;\n /** API base URL. Falls back to `SUPERSERVE_BASE_URL` env var, then the `@superserve/sdk` default. */\n baseUrl?: string;\n /** Default auto-pause timeout in milliseconds. */\n timeout?: number;\n /** Template to boot per standard `sizeClass`; defaults to {@link SUPERSERVE_SIZE_TEMPLATES}. */\n sizeTemplates?: Partial<Record<InstanceSizeClass, string>>;\n}\n\n/**\n * Superserve fixes vCPU, memory and disk when a template is built, so each\n * standard size boots its own template. `superserve/base` (2 vCPU / 4 GiB /\n * 8 GiB disk) is built in to every team; the others are team templates\n * built by `scripts/provider-setup.mjs superserve`. The largest listed plan\n * (Pro) caps a sandbox at 16 vCPU / 64 GiB, so `3xl` has no default.\n */\nexport const SUPERSERVE_SIZE_TEMPLATES: Readonly<Partial<Record<InstanceSizeClass, string>>> = Object.freeze({\n xs: 'csdk-node22-1cpu-1gb',\n sm: 'csdk-node22-1cpu-2gb',\n md: 'superserve/base',\n lg: 'csdk-node22-4cpu-8gb',\n xl: 'csdk-node22-8cpu-16gb',\n '2xl': 'csdk-node22-16cpu-32gb',\n});\n\n/** Disk the built-in templates fix; team templates take theirs from the build. */\nconst BUILT_IN_TEMPLATE_DISK_MIB: Readonly<Record<string, number>> = Object.freeze({ 'superserve/base': 8192 });\n\n/** Native selectors that pick or size the VM; `Sandbox.create` drops the sizing ones silently. */\nconst SOURCE_OPTIONS = ['templateId', 'snapshotId', 'sandboxId', 'fromTemplate', 'fromSnapshot'] as const;\nconst NATIVE_SIZE_OPTIONS = ['vcpu', 'vcpuCount', 'memoryMib', 'memoryMaxMib', 'diskMib'] as const;\n\nfunction sizeTemplateOf(config: SuperserveConfig, sizeClass: InstanceSizeClass): string | undefined {\n const name = config.sizeTemplates?.[sizeClass] ?? SUPERSERVE_SIZE_TEMPLATES[sizeClass];\n return typeof name === 'string' && name.trim() ? name : undefined;\n}\n\n/** A create that failed because a standard-size template was never built on this team. */\nfunction missingSizeTemplate(config: SuperserveConfig, templateId: unknown, error: unknown): string | undefined {\n if (typeof templateId !== 'string' || !(error instanceof NotFoundError)) return undefined;\n const sizeClass = (Object.keys(INSTANCE_SIZE_PROFILES) as InstanceSizeClass[]).find(c => sizeTemplateOf(config, c) === templateId);\n if (!sizeClass) return undefined;\n return `Superserve size template '${templateId}' (sizeClass ${sizeClass}) is not built on this Superserve team; run \\`node scripts/provider-setup.mjs superserve\\` (provider-setup.yml) or point \\`sizeTemplates.${sizeClass}\\` at an existing template`;\n}\n\nfunction resolveApiKey(config: SuperserveConfig): string {\n const apiKey = config.apiKey || process.env.SUPERSERVE_API_KEY;\n if (!apiKey) {\n throw new Error(\n `Missing Superserve API key. Provide 'apiKey' in config or set SUPERSERVE_API_KEY environment variable.`,\n );\n }\n return apiKey;\n}\n\nfunction resolveBaseUrl(config: SuperserveConfig): string | undefined {\n // Returns undefined when unset on purpose: the SDK then applies its own\n // resolution (SUPERSERVE_BASE_URL env var, then its default endpoint), so\n // we don't duplicate that default and risk it drifting.\n return config.baseUrl || process.env.SUPERSERVE_BASE_URL || undefined;\n}\n\nfunction generateSandboxName(): string {\n return `cs-${randomUUID().slice(0, 8)}`;\n}\n\ntype CommandRunner = (\n sandbox: SuperserveSandbox,\n command: string,\n options?: RunCommandOptions,\n) => Promise<CommandResult>;\n\nconst FALLBACK_WORKDIR = '/';\n\n/** Cached `pwd` probes: relative filesystem paths resolve against the cwd a\n * `runCommand` exec would use, so `writeFile('a.txt')` and `cat a.txt` agree. */\nconst workdirs = new WeakMap<SuperserveSandbox, Promise<string>>();\nconst volumeConnections = new WeakMap<SuperserveSandbox, ResolvedConfig>();\n\nfunction volumeReference(volume: string | Volume): string {\n const reference = typeof volume === 'string' ? volume : volume?.id || volume?.name;\n if (typeof reference !== 'string' || !reference.trim()) {\n throw new Error('A Superserve volume reference must contain an id or name.');\n }\n return reference;\n}\n\nfunction volumeConnection(sandbox: SuperserveSandbox): ResolvedConfig {\n const connection = volumeConnections.get(sandbox);\n if (!connection) throw new Error('The Superserve sandbox has no captured volume connection.');\n return connection;\n}\n\nfunction sameSandboxId(left: string, right: string): boolean {\n const pattern = /^(?:sb-([A-Za-z0-9]+)-)?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;\n const a = pattern.exec(left);\n const b = pattern.exec(right);\n if (!a || !b) return left === right;\n return a[2].toLowerCase() === b[2].toLowerCase() &&\n (a[1] === undefined || b[1] === undefined || a[1] === b[1]);\n}\n\nfunction toVolume(info: VolumeInfo): Volume {\n return {\n id: info.id,\n name: info.name,\n sizeBytes: info.capacityBytes,\n usedBytes: info.usedBytes,\n region: info.region,\n status: info.status,\n createdAt: info.createdAt,\n };\n}\n\nasync function deleteVolume(connection: ResolvedConfig, idOrName: string): Promise<void> {\n let volume: SuperserveVolume;\n try {\n volume = await SuperserveVolume.connect(idOrName, connection);\n } catch (error) {\n if (error instanceof NotFoundError) return;\n throw error;\n }\n // Names can be reused while closing leases settle. Resolve once so retries\n // and attachment checks stay bound to the original volume.\n const deadline = Date.now() + 120_000;\n for (;;) {\n try {\n await SuperserveVolume.deleteById(volume.id, connection);\n return;\n } catch (error) {\n if (!(error instanceof ConflictError) || error.code !== 'volume_conflict') throw error;\n let attachments;\n try {\n attachments = await volume.listAttachments();\n } catch (lookupError) {\n if (lookupError instanceof NotFoundError) return;\n throw lookupError;\n }\n const closing = attachments.filter((attachment) => attachment.status !== 'revoked');\n // A destroyed sandbox can leave a closing lease briefly. Never wait on\n // an active mount, or turn another kind of conflict into successful cleanup.\n if (!closing.length || closing.some((attachment) =>\n attachment.status !== 'detaching' && attachment.status !== 'revoking') ||\n Date.now() >= deadline) throw error;\n await new Promise((resolve) => setTimeout(resolve, 3_000));\n }\n }\n}\n\nfunction workdirOf(sandbox: SuperserveSandbox, runCommand: CommandRunner): Promise<string> {\n let probe = workdirs.get(sandbox);\n if (!probe) {\n probe = runCommand(sandbox, 'pwd').then((result) => {\n const dir = result.stdout.trim();\n if (result.exitCode === 0 && dir.startsWith('/')) return dir;\n // runCommand reports exec failures as results, not rejections, so a\n // transient failure must not pin the workdir to the fallback forever —\n // evict and let the next filesystem op probe again.\n workdirs.delete(sandbox);\n return FALLBACK_WORKDIR;\n });\n workdirs.set(sandbox, probe);\n probe.catch(() => workdirs.delete(sandbox));\n }\n return probe;\n}\n\n/** Join `path` onto the sandbox workdir. Absolute paths pass through and skip\n * the probe; empty and `.` segments are dropped; `..` segments are preserved\n * for the sandbox filesystem to resolve physically — collapsing them\n * lexically would mis-resolve when a preceding component is a symlink. */\nasync function resolveSandboxPath(\n sandbox: SuperserveSandbox,\n path: string,\n runCommand: CommandRunner,\n): Promise<string> {\n const combined = path.startsWith('/')\n ? path\n : `${await workdirOf(sandbox, runCommand)}/${path}`;\n const segments: string[] = [];\n for (const segment of combined.split('/')) {\n if (segment === '' || segment === '.') continue;\n segments.push(segment);\n }\n return `/${segments.join('/')}`;\n}\n\nfunction rethrowFriendly(error: unknown, fallbackPrefix: string): never {\n if (error instanceof AuthenticationError) {\n throw new Error(\n `Superserve authentication failed. Please check your SUPERSERVE_API_KEY environment variable.`,\n );\n }\n const message = error instanceof Error ? error.message : String(error);\n const lower = message.toLowerCase();\n if (lower.includes('unauthorized') || lower.includes('401') || lower.includes('api key')) {\n throw new Error(\n `Superserve authentication failed. Please check your SUPERSERVE_API_KEY environment variable.`,\n );\n }\n if (lower.includes('quota') || lower.includes('limit') || lower.includes('429')) {\n throw new Error(`Superserve quota or rate limit reached: ${message}`);\n }\n throw new Error(`${fallbackPrefix}: ${message}`);\n}\n\n// Also serves as `streamCommand`: the SDK streams output over its own exec API\n// when callbacks are passed, so no daemon or routable port is needed.\nconst runCommand: CommandRunner = async (sandbox, command, options) => {\n const startTime = Date.now();\n try {\n let fullCommand = command;\n if (options?.background) {\n // Run the whole command under `sh -c` so the trailing `&` backgrounds\n // the entire command (not just its last statement), and escape it so\n // the user's command can't break out of the nohup wrapper.\n fullCommand = `nohup sh -c \"${escapeShellArg(fullCommand)}\" > /dev/null 2>&1 &`;\n }\n const result = await sandbox.commands.run(fullCommand, {\n cwd: options?.cwd,\n env: options?.env,\n timeoutMs: options?.timeout,\n onStdout: options?.onStdout,\n onStderr: options?.onStderr,\n });\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n durationMs: Date.now() - startTime,\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\nfunction toSnapshot(info: SnapshotInfo) {\n return {\n id: info.id,\n provider: 'superserve',\n createdAt: info.createdAt,\n metadata: {\n name: info.name,\n sandboxId: info.sandboxId,\n status: info.status,\n sizeBytes: info.sizeBytes,\n },\n };\n}\n\n/** Superserve sizes sandboxes at the template: vCPU, memory and disk are set\n * here and every sandbox created from it inherits them. */\nexport type SuperserveTemplateCreateOptions = CreateTemplateOptions & Partial<Omit<TemplateCreateOptions, 'apiKey' | 'baseUrl' | 'name'>>;\nexport type SuperserveVolumeCreateOptions = CreateVolumeOptions &\n Pick<VolumeCreateOptions, 'idempotencyKey' | 'timeoutMs' | 'signal'>;\n\nfunction toTemplate(info: TemplateInfo) {\n return {\n id: info.id,\n name: info.name,\n createdAt: info.createdAt,\n metadata: { status: info.status, vcpu: info.vcpu, memoryMib: info.memoryMib, diskMib: info.diskMib, errorMessage: info.errorMessage },\n };\n}\n\nexport const superserve = defineProvider<SuperserveSandbox, SuperserveConfig>({\n name: 'superserve',\n sizes: (config, profile, options) => {\n const opts = options as Record<string, unknown> | undefined;\n const nativeSize = NATIVE_SIZE_OPTIONS.find(key => opts?.[key] !== undefined);\n if (nativeSize) {\n throw new InstanceSizeError('conflict', `cannot combine sizeClass with native Superserve ${nativeSize}; Superserve sizes sandboxes by template`);\n }\n const source = SOURCE_OPTIONS.find(key => opts?.[key] !== undefined);\n if (source) {\n return { status: 'unsupported', reason: `A Superserve template or snapshot fixes CPU and memory; drop ${source} to boot the standard size template.` };\n }\n const templateId = sizeTemplateOf(config, profile.sizeClass);\n if (!templateId) {\n return {\n status: 'unsupported',\n reason: `Superserve lists at most 16 vCPU / 64 GiB per sandbox (Pro plan); ${profile.sizeClass} needs ${profile.vcpus} vCPU / ${profile.memoryMiB / 1024} GiB. Set sizeTemplates.${profile.sizeClass} to a custom-size template to use it.`,\n };\n }\n const diskMiB = BUILT_IN_TEMPLATE_DISK_MIB[templateId];\n return {\n status: 'supported',\n nativeOptions: { templateId },\n ...(diskMiB === undefined ? {} : { resolved: { vcpus: profile.vcpus, memoryMiB: profile.memoryMiB, diskMiB } }),\n };\n },\n methods: {\n instances: {\n create: async (config: SuperserveConfig, options?: CreateInstanceOptions) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n\n const {\n timeout: requestedTimeoutMs,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n volumes,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n const ttMs = requestedTimeoutMs ?? config.timeout;\n const timeoutSeconds = ttMs !== undefined ? Math.max(1, Math.ceil(ttMs / 1000)) : undefined;\n\n try {\n const createOptions = {\n apiKey,\n baseUrl,\n name: name ?? generateSandboxName(),\n ...(templateId ? { fromTemplate: templateId } : {}),\n ...(snapshotId ? { fromSnapshot: snapshotId } : {}),\n ...(timeoutSeconds !== undefined ? { timeoutSeconds } : {}),\n ...(metadata ? { metadata: metadata as Record<string, string> } : {}),\n ...(envs ? { envVars: envs } : {}),\n ...providerOptions,\n ...(volumes !== undefined ? {\n volumes: volumes.map((mount) => ({\n ...mount,\n volume: mount.volume instanceof SuperserveVolume\n ? mount.volume\n : volumeReference(mount.volume),\n })),\n } : {}),\n };\n const connection = resolveConfig(createOptions);\n const sandbox = await SuperserveSandbox.create(createOptions);\n volumeConnections.set(sandbox, connection);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch (error) {\n const notBuilt = missingSizeTemplate(config, templateId, error);\n if (notBuilt) throw Object.assign(new Error(notBuilt), { status: 404, cause: error });\n rethrowFriendly(error, 'Failed to create Superserve sandbox');\n }\n },\n\n getById: async (config: SuperserveConfig, sandboxId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const connection = resolveConfig({ apiKey, baseUrl });\n const sandbox = await SuperserveSandbox.connect(sandboxId, connection);\n volumeConnections.set(sandbox, connection);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch {\n return null;\n }\n },\n\n list: async (config: SuperserveConfig) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const connection = resolveConfig({ apiKey, baseUrl });\n const infos = await SuperserveSandbox.list(connection);\n // No per-item connect() — that would POST /activate and resume paused sandboxes.\n return infos.map((info) => {\n const instance = info as unknown as SuperserveSandbox;\n volumeConnections.set(instance, connection);\n return { instance, instanceId: info.id };\n });\n } catch {\n return [];\n }\n },\n\n destroy: async (config: SuperserveConfig, sandboxId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n // The SDK handles already-deleted sandboxes and retries transient failures.\n await SuperserveSandbox.killById(sandboxId, { apiKey, baseUrl });\n },\n\n runCommand,\n streamCommand: runCommand,\n\n attachVolume: async (sandbox, volume, mountPath) => {\n const native = await SuperserveVolume.connect(volumeReference(volume), volumeConnection(sandbox));\n await native.attach(sandbox.id, { mountPath });\n },\n\n detachVolume: async (sandbox, volume, mountPath) => {\n const native = await SuperserveVolume.connect(volumeReference(volume), volumeConnection(sandbox));\n const attachments = (await native.listAttachments()).filter((attachment) =>\n attachment.volumeId === native.id &&\n sameSandboxId(attachment.sandboxId, sandbox.id) &&\n attachment.status !== 'revoked' &&\n (mountPath === undefined || attachment.mountPath === mountPath));\n if (attachments.length > 1) {\n throw new Error('Multiple matching Superserve attachments; provide their mount path to detach one.');\n }\n if (attachments[0]) await native.detach(attachments[0].id);\n },\n\n getInfo: async (sandbox: SuperserveSandbox): Promise<InstanceInfo> => {\n const info = await sandbox.getInfo();\n const status: InstanceInfo['status'] =\n info.status === 'paused' || info.status === 'deleted' ? 'stopped' :\n info.status === 'failed' ? 'error' :\n 'running';\n return {\n id: info.id,\n provider: 'superserve',\n status,\n createdAt: info.createdAt,\n timeout: info.timeoutSeconds ? info.timeoutSeconds * 1000 : DEFAULT_TIMEOUT_MS,\n metadata: info.metadata,\n };\n },\n\n getUrl: async (sandbox: SuperserveSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n // A preview URL only routes once its port is published. A new port takes\n // the sandbox's `previewAccess` default; a published one keeps its mode.\n await sandbox.publishPreviewPort(options.port);\n const url = sandbox.getPreviewUrl(options.port);\n return options.protocol ? url.replace(/^https/, options.protocol) : url;\n },\n\n filesystem: {\n readFile: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n return sandbox.files.readText(await resolveSandboxPath(sandbox, path, runCommand));\n },\n\n writeFile: async (sandbox: SuperserveSandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n await sandbox.files.write(await resolveSandboxPath(sandbox, path, runCommand), content);\n },\n\n mkdir: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`mkdir -p \"${escapeShellArg(resolved)}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`mkdir failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n },\n\n readdir: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n // find -printf format: <type>\\t<size>\\t<mtime-epoch>\\t<name>\n const cmd = [\n `cd \"${escapeShellArg(resolved)}\" || exit 2`,\n `find . -mindepth 1 -maxdepth 1 -printf '%y\\\\t%s\\\\t%T@\\\\t%f\\\\n' 2>/dev/null`,\n ].join(' && ');\n const result = await sandbox.commands.run(cmd);\n if (result.exitCode === 2) {\n throw new Error(`readdir: directory not found: ${path}`);\n }\n if (result.exitCode !== 0) {\n throw new Error(`readdir failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n const entries: FileEntry[] = [];\n for (const line of result.stdout.split('\\n')) {\n if (!line) continue;\n const [type, sizeStr, mtimeStr, ...nameParts] = line.split('\\t');\n const name = nameParts.join('\\t');\n if (!name) continue;\n const size = Number.parseInt(sizeStr, 10);\n const mtime = Number.parseFloat(mtimeStr);\n entries.push({\n name,\n type: type === 'd' ? 'directory' : 'file',\n size: Number.isFinite(size) ? size : 0,\n modified: Number.isFinite(mtime) ? new Date(mtime * 1000) : new Date(),\n });\n }\n return entries;\n },\n\n exists: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`test -e \"${escapeShellArg(resolved)}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n // An empty or dot-only path would resolve to the workdir itself —\n // refuse it rather than `rm -rf` the sandbox's whole cwd.\n if (path.split('/').every((s) => s === '' || s === '.')) {\n throw new Error(`remove: refusing ambiguous path: ${JSON.stringify(path)}`);\n }\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`rm -rf \"${escapeShellArg(resolved)}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`remove failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n },\n },\n\n getInstance: (sandbox: SuperserveSandbox): SuperserveSandbox => sandbox,\n\n pause: async (sandbox: SuperserveSandbox): Promise<void> => {\n try {\n await sandbox.pause({ wait: true });\n } catch (error) {\n rethrowFriendly(error, 'Failed to pause Superserve sandbox');\n }\n },\n\n resume: async (sandbox: SuperserveSandbox): Promise<void> => {\n try {\n // The access token rotates on resume; the SDK refreshes the handle in place.\n await sandbox.resume();\n } catch (error) {\n rethrowFriendly(error, 'Failed to resume Superserve sandbox');\n }\n },\n\n pauseCapabilities: { memory: true },\n },\n\n snapshot: {\n // Snapshots hold memory and disk: restores keep the whole filesystem,\n // tmpfs /tmp included, and running processes. The source keeps running.\n capabilities: { scope: 'rootfs', memory: true, destroysSource: false },\n create: async (config: SuperserveConfig, sandboxId: string, options?: { name?: string }) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n // connect() activates the sandbox, so a paused one is resumed first.\n const sandbox = await SuperserveSandbox.connect(sandboxId, { apiKey, baseUrl });\n return toSnapshot(await sandbox.snapshot({ name: options?.name }));\n } catch (error) {\n rethrowFriendly(error, 'Failed to create Superserve snapshot');\n }\n },\n list: async (config: SuperserveConfig, options?: { sandboxId?: string; limit?: number }) => {\n // Snapshots are listed per sandbox. Callers that aggregate across\n // providers pass no options, so an unscoped call returns nothing\n // instead of throwing and failing their whole listing.\n if (!options?.sandboxId) return [];\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n const infos = await SuperserveSnapshot.list(options.sandboxId, { apiKey, baseUrl, limit: options.limit });\n return infos.map(toSnapshot);\n },\n delete: async (config: SuperserveConfig, snapshotId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n await SuperserveSnapshot.deleteById(snapshotId, { apiKey, baseUrl });\n },\n },\n\n volume: {\n create: async (config: SuperserveConfig, options: SuperserveVolumeCreateOptions) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n const volume = await SuperserveVolume.create({\n ...connection,\n name: options.name,\n ...(options.sizeBytes !== undefined ? { capacityBytes: options.sizeBytes } : {}),\n idempotencyKey: options.idempotencyKey,\n timeoutMs: options.timeoutMs,\n signal: options.signal,\n });\n return toVolume(volume);\n },\n get: async (config: SuperserveConfig, idOrName: string) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n try {\n return toVolume(await SuperserveVolume.connect(idOrName, connection));\n } catch (error) {\n if (error instanceof NotFoundError) return null;\n throw error;\n }\n },\n list: async (config: SuperserveConfig, options?: { limit?: number }) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n const volumes = await SuperserveVolume.list({ ...connection, limit: options?.limit });\n return volumes.map(toVolume);\n },\n delete: async (config: SuperserveConfig, idOrName: string) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n await deleteVolume(connection, idOrName);\n },\n },\n\n template: {\n create: async (config: SuperserveConfig, options: SuperserveTemplateCreateOptions) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n const { name, from, vcpu, memoryMib, diskMib, steps, startCmd, readyCmd } = options;\n if (!from) {\n throw new Error('Superserve templates are built from an image: pass `from` (e.g. \"node:22\").');\n }\n try {\n const template = await SuperserveTemplate.create({\n apiKey, baseUrl, name, from, vcpu, memoryMib, diskMib, steps, startCmd, readyCmd,\n });\n return toTemplate(await template.waitUntilReady());\n } catch (error) {\n rethrowFriendly(error, 'Failed to create Superserve template');\n }\n },\n list: async (config: SuperserveConfig) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const infos = await SuperserveTemplate.list({ apiKey, baseUrl });\n return infos.map(toTemplate);\n } catch {\n return [];\n }\n },\n delete: async (config: SuperserveConfig, templateId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n await SuperserveTemplate.deleteById(templateId, { apiKey, baseUrl });\n } catch {\n /* already deleted */\n }\n },\n },\n },\n});\n\nexport type { Sandbox as SuperserveSandbox } from '@superserve/sdk';\n"],"mappings":";AAMA,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV;AAAA,OACK;AASP,SAAS,gBAAgB,gBAAgB,mBAAmB,8BAA8B;AAE1F,IAAM,qBAAqB;AAgCpB,IAAM,4BAAkF,OAAO,OAAO;AAAA,EAC3G,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT,CAAC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;AACD,iBAAO,WAAW,MAAM,SAAS,eAAe,CAAC;AAAA,QACnD,SAAS,OAAO;AACd,0BAAgB,OAAO,sCAAsC;AAAA,QAC/D;AAAA,MACF;AAAA,MACA,MAAM,OAAO,WAA6B;AACxC,cAAM,SAAS,cAAc,MAAM;AACnC,cAAM,UAAU,eAAe,MAAM;AACrC,YAAI;AACF,gBAAM,QAAQ,MAAM,mBAAmB,KAAK,EAAE,QAAQ,QAAQ,CAAC;AAC/D,iBAAO,MAAM,IAAI,UAAU;AAAA,QAC7B,QAAQ;AACN,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,MACA,QAAQ,OAAO,QAA0B,eAAuB;AAC9D,cAAM,SAAS,cAAc,MAAM;AACnC,cAAM,UAAU,eAAe,MAAM;AACrC,YAAI;AACF,gBAAM,mBAAmB,WAAW,YAAY,EAAE,QAAQ,QAAQ,CAAC;AAAA,QACrE,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["runCommand"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Superserve Provider - Factory-based Implementation\n *\n * Wraps `@superserve/sdk` to expose the ComputeSDK provider interface.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n AuthenticationError,\n ConflictError,\n NotFoundError,\n ServerError,\n Sandbox as SuperserveSandbox,\n Snapshot as SuperserveSnapshot,\n Template as SuperserveTemplate,\n Volume as SuperserveVolume,\n resolveConfig,\n} from '@superserve/sdk';\nimport type {\n ResolvedConfig,\n SnapshotInfo,\n TemplateCreateOptions,\n TemplateInfo,\n VolumeCreateOptions,\n VolumeInfo,\n} from '@superserve/sdk';\nimport { defineProvider, escapeShellArg, InstanceSizeError, INSTANCE_SIZE_PROFILES } from '@computesdk/provider';\n\nconst DEFAULT_TIMEOUT_MS = 300_000;\n\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateTemplateOptions,\n CreateVolumeOptions,\n FileEntry,\n InstanceSizeClass,\n RunCommandOptions,\n InstanceInfo,\n Volume,\n} from '@computesdk/provider';\n\nexport interface SuperserveConfig {\n /** Superserve API key. Falls back to `SUPERSERVE_API_KEY` env var. */\n apiKey?: string;\n /** API base URL. Falls back to `SUPERSERVE_BASE_URL` env var, then the `@superserve/sdk` default. */\n baseUrl?: string;\n /** Default auto-pause timeout in milliseconds. */\n timeout?: number;\n /** Template to boot per standard `sizeClass`; defaults to {@link SUPERSERVE_SIZE_TEMPLATES}. */\n sizeTemplates?: Partial<Record<InstanceSizeClass, string>>;\n}\n\n/**\n * Superserve fixes vCPU, memory and disk when a template is built, so each\n * standard size boots its own template. `superserve/base` (2 vCPU / 4 GiB /\n * 8 GiB disk) is built in to every team; the others are team templates\n * built by `scripts/provider-setup.mjs superserve`. The largest listed plan\n * (Pro) caps a sandbox at 16 vCPU / 64 GiB, so `3xl` has no default.\n */\nexport const SUPERSERVE_SIZE_TEMPLATES: Readonly<Partial<Record<InstanceSizeClass, string>>> = Object.freeze({\n xs: 'csdk-node22-1cpu-1gb',\n sm: 'csdk-node22-1cpu-2gb',\n md: 'superserve/base',\n lg: 'csdk-node22-4cpu-8gb',\n xl: 'csdk-node22-8cpu-16gb',\n '2xl': 'csdk-node22-16cpu-32gb',\n});\n\n/** Disk the built-in templates fix; team templates take theirs from the build. */\nconst BUILT_IN_TEMPLATE_DISK_MIB: Readonly<Record<string, number>> = Object.freeze({ 'superserve/base': 8192 });\n\n/** Native selectors that pick or size the VM; `Sandbox.create` drops the sizing ones silently. */\nconst SOURCE_OPTIONS = ['templateId', 'snapshotId', 'sandboxId', 'fromTemplate', 'fromSnapshot'] as const;\nconst NATIVE_SIZE_OPTIONS = ['vcpu', 'vcpuCount', 'memoryMib', 'memoryMaxMib', 'diskMib'] as const;\n\nfunction sizeTemplateOf(config: SuperserveConfig, sizeClass: InstanceSizeClass): string | undefined {\n const name = config.sizeTemplates?.[sizeClass] ?? SUPERSERVE_SIZE_TEMPLATES[sizeClass];\n return typeof name === 'string' && name.trim() ? name : undefined;\n}\n\n/** A create that failed because a standard-size template was never built on this team. */\nfunction missingSizeTemplate(config: SuperserveConfig, templateId: unknown, error: unknown): string | undefined {\n if (typeof templateId !== 'string' || !(error instanceof NotFoundError)) return undefined;\n const sizeClass = (Object.keys(INSTANCE_SIZE_PROFILES) as InstanceSizeClass[]).find(c => sizeTemplateOf(config, c) === templateId);\n if (!sizeClass) return undefined;\n return `Superserve size template '${templateId}' (sizeClass ${sizeClass}) is not built on this Superserve team; run \\`node scripts/provider-setup.mjs superserve\\` (provider-setup.yml) or point \\`sizeTemplates.${sizeClass}\\` at an existing template`;\n}\n\nfunction resolveApiKey(config: SuperserveConfig): string {\n const apiKey = config.apiKey || process.env.SUPERSERVE_API_KEY;\n if (!apiKey) {\n throw new Error(\n `Missing Superserve API key. Provide 'apiKey' in config or set SUPERSERVE_API_KEY environment variable.`,\n );\n }\n return apiKey;\n}\n\nfunction resolveBaseUrl(config: SuperserveConfig): string | undefined {\n // Returns undefined when unset on purpose: the SDK then applies its own\n // resolution (SUPERSERVE_BASE_URL env var, then its default endpoint), so\n // we don't duplicate that default and risk it drifting.\n return config.baseUrl || process.env.SUPERSERVE_BASE_URL || undefined;\n}\n\nfunction generateSandboxName(): string {\n return `cs-${randomUUID().slice(0, 8)}`;\n}\n\ntype CommandRunner = (\n sandbox: SuperserveSandbox,\n command: string,\n options?: RunCommandOptions,\n) => Promise<CommandResult>;\n\nconst FALLBACK_WORKDIR = '/';\n\n/** Cached `pwd` probes: relative filesystem paths resolve against the cwd a\n * `runCommand` exec would use, so `writeFile('a.txt')` and `cat a.txt` agree. */\nconst workdirs = new WeakMap<SuperserveSandbox, Promise<string>>();\nconst volumeConnections = new WeakMap<SuperserveSandbox, ResolvedConfig>();\n\nfunction volumeReference(volume: string | Volume): string {\n const reference = typeof volume === 'string' ? volume : volume?.id || volume?.name;\n if (typeof reference !== 'string' || !reference.trim()) {\n throw new Error('A Superserve volume reference must contain an id or name.');\n }\n return reference;\n}\n\nfunction volumeConnection(sandbox: SuperserveSandbox): ResolvedConfig {\n const connection = volumeConnections.get(sandbox);\n if (!connection) throw new Error('The Superserve sandbox has no captured volume connection.');\n return connection;\n}\n\nfunction sameSandboxId(left: string, right: string): boolean {\n const pattern = /^(?:sb-([A-Za-z0-9]+)-)?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;\n const a = pattern.exec(left);\n const b = pattern.exec(right);\n if (!a || !b) return left === right;\n return a[2].toLowerCase() === b[2].toLowerCase() &&\n (a[1] === undefined || b[1] === undefined || a[1] === b[1]);\n}\n\nfunction toVolume(info: VolumeInfo): Volume {\n return {\n id: info.id,\n name: info.name,\n sizeBytes: info.capacityBytes,\n usedBytes: info.usedBytes,\n region: info.region,\n status: info.status,\n createdAt: info.createdAt,\n };\n}\n\nasync function deleteVolume(connection: ResolvedConfig, idOrName: string): Promise<void> {\n let volume: SuperserveVolume;\n try {\n volume = await SuperserveVolume.connect(idOrName, connection);\n } catch (error) {\n if (error instanceof NotFoundError) return;\n throw error;\n }\n // Names can be reused while closing leases settle. Resolve once so retries\n // and attachment checks stay bound to the original volume.\n const deadline = Date.now() + 120_000;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), 120_000);\n let lastError: unknown;\n const requireTime = () => {\n const remaining = deadline - Date.now();\n if (controller.signal.aborted || remaining <= 0) {\n throw lastError ?? new Error('Timed out waiting for Superserve volume deletion.');\n }\n return remaining;\n };\n try {\n for (;;) {\n requireTime();\n try {\n // The instance method forwards request timeouts; the static shortcut does not.\n await volume.delete({ signal: controller.signal, timeoutMs: requireTime() });\n return;\n } catch (error) {\n requireTime();\n lastError = error;\n try {\n if (error instanceof ConflictError && error.code === 'volume_conflict') {\n const attachments = await volume.listAttachments({ signal: controller.signal, timeoutMs: requireTime() });\n const closing = attachments.filter((attachment) => attachment.status !== 'revoked');\n // Never wait for an active mount or hide an unrelated conflict.\n if (!closing.length || closing.some((attachment) =>\n attachment.status !== 'detaching' && attachment.status !== 'revoking')) throw error;\n } else if (error instanceof ServerError && error.statusCode === 503 && error.code === 'volume_unavailable') {\n // Cleanup advances in batches; a fresh deleting state is retryable,\n // but it is not confirmation that the original volume is gone.\n const current = await volume.getInfo({ signal: controller.signal, timeoutMs: requireTime() });\n if (current.status !== 'deleting') throw error;\n } else {\n throw error;\n }\n } catch (lookupError) {\n if (lookupError instanceof NotFoundError) return;\n throw lookupError;\n }\n requireTime();\n await new Promise((resolve) => setTimeout(resolve, Math.min(3_000, deadline - Date.now())));\n }\n }\n } catch (error) {\n if (controller.signal.aborted || Date.now() >= deadline) throw lastError ?? error;\n throw error;\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction workdirOf(sandbox: SuperserveSandbox, runCommand: CommandRunner): Promise<string> {\n let probe = workdirs.get(sandbox);\n if (!probe) {\n probe = runCommand(sandbox, 'pwd').then((result) => {\n const dir = result.stdout.trim();\n if (result.exitCode === 0 && dir.startsWith('/')) return dir;\n // runCommand reports exec failures as results, not rejections, so a\n // transient failure must not pin the workdir to the fallback forever —\n // evict and let the next filesystem op probe again.\n workdirs.delete(sandbox);\n return FALLBACK_WORKDIR;\n });\n workdirs.set(sandbox, probe);\n probe.catch(() => workdirs.delete(sandbox));\n }\n return probe;\n}\n\n/** Join `path` onto the sandbox workdir. Absolute paths pass through and skip\n * the probe; empty and `.` segments are dropped; `..` segments are preserved\n * for the sandbox filesystem to resolve physically — collapsing them\n * lexically would mis-resolve when a preceding component is a symlink. */\nasync function resolveSandboxPath(\n sandbox: SuperserveSandbox,\n path: string,\n runCommand: CommandRunner,\n): Promise<string> {\n const combined = path.startsWith('/')\n ? path\n : `${await workdirOf(sandbox, runCommand)}/${path}`;\n const segments: string[] = [];\n for (const segment of combined.split('/')) {\n if (segment === '' || segment === '.') continue;\n segments.push(segment);\n }\n return `/${segments.join('/')}`;\n}\n\nfunction rethrowFriendly(error: unknown, fallbackPrefix: string): never {\n if (error instanceof AuthenticationError) {\n throw new Error(\n `Superserve authentication failed. Please check your SUPERSERVE_API_KEY environment variable.`,\n );\n }\n const message = error instanceof Error ? error.message : String(error);\n const lower = message.toLowerCase();\n if (lower.includes('unauthorized') || lower.includes('401') || lower.includes('api key')) {\n throw new Error(\n `Superserve authentication failed. Please check your SUPERSERVE_API_KEY environment variable.`,\n );\n }\n if (lower.includes('quota') || lower.includes('limit') || lower.includes('429')) {\n throw new Error(`Superserve quota or rate limit reached: ${message}`);\n }\n throw new Error(`${fallbackPrefix}: ${message}`);\n}\n\n// Also serves as `streamCommand`: the SDK streams output over its own exec API\n// when callbacks are passed, so no daemon or routable port is needed.\nconst runCommand: CommandRunner = async (sandbox, command, options) => {\n const startTime = Date.now();\n try {\n let fullCommand = command;\n if (options?.background) {\n // Run the whole command under `sh -c` so the trailing `&` backgrounds\n // the entire command (not just its last statement), and escape it so\n // the user's command can't break out of the nohup wrapper.\n fullCommand = `nohup sh -c \"${escapeShellArg(fullCommand)}\" > /dev/null 2>&1 &`;\n }\n const result = await sandbox.commands.run(fullCommand, {\n cwd: options?.cwd,\n env: options?.env,\n timeoutMs: options?.timeout,\n onStdout: options?.onStdout,\n onStderr: options?.onStderr,\n });\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n durationMs: Date.now() - startTime,\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\nfunction toSnapshot(info: SnapshotInfo) {\n return {\n id: info.id,\n provider: 'superserve',\n createdAt: info.createdAt,\n metadata: {\n name: info.name,\n sandboxId: info.sandboxId,\n status: info.status,\n sizeBytes: info.sizeBytes,\n },\n };\n}\n\n/** Superserve sizes sandboxes at the template: vCPU, memory and disk are set\n * here and every sandbox created from it inherits them. */\nexport type SuperserveTemplateCreateOptions = CreateTemplateOptions & Partial<Omit<TemplateCreateOptions, 'apiKey' | 'baseUrl' | 'name'>>;\nexport type SuperserveVolumeCreateOptions = CreateVolumeOptions &\n Pick<VolumeCreateOptions, 'idempotencyKey' | 'timeoutMs' | 'signal'>;\n\nfunction toTemplate(info: TemplateInfo) {\n return {\n id: info.id,\n name: info.name,\n createdAt: info.createdAt,\n metadata: { status: info.status, vcpu: info.vcpu, memoryMib: info.memoryMib, diskMib: info.diskMib, errorMessage: info.errorMessage },\n };\n}\n\nexport const superserve = defineProvider<SuperserveSandbox, SuperserveConfig>({\n name: 'superserve',\n sizes: (config, profile, options) => {\n const opts = options as Record<string, unknown> | undefined;\n const nativeSize = NATIVE_SIZE_OPTIONS.find(key => opts?.[key] !== undefined);\n if (nativeSize) {\n throw new InstanceSizeError('conflict', `cannot combine sizeClass with native Superserve ${nativeSize}; Superserve sizes sandboxes by template`);\n }\n const source = SOURCE_OPTIONS.find(key => opts?.[key] !== undefined);\n if (source) {\n return { status: 'unsupported', reason: `A Superserve template or snapshot fixes CPU and memory; drop ${source} to boot the standard size template.` };\n }\n const templateId = sizeTemplateOf(config, profile.sizeClass);\n if (!templateId) {\n return {\n status: 'unsupported',\n reason: `Superserve lists at most 16 vCPU / 64 GiB per sandbox (Pro plan); ${profile.sizeClass} needs ${profile.vcpus} vCPU / ${profile.memoryMiB / 1024} GiB. Set sizeTemplates.${profile.sizeClass} to a custom-size template to use it.`,\n };\n }\n const diskMiB = BUILT_IN_TEMPLATE_DISK_MIB[templateId];\n return {\n status: 'supported',\n nativeOptions: { templateId },\n ...(diskMiB === undefined ? {} : { resolved: { vcpus: profile.vcpus, memoryMiB: profile.memoryMiB, diskMiB } }),\n };\n },\n methods: {\n instances: {\n create: async (config: SuperserveConfig, options?: CreateInstanceOptions) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n\n const {\n timeout: requestedTimeoutMs,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n volumes,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n const ttMs = requestedTimeoutMs ?? config.timeout;\n const timeoutSeconds = ttMs !== undefined ? Math.max(1, Math.ceil(ttMs / 1000)) : undefined;\n\n try {\n const createOptions = {\n apiKey,\n baseUrl,\n name: name ?? generateSandboxName(),\n ...(templateId ? { fromTemplate: templateId } : {}),\n ...(snapshotId ? { fromSnapshot: snapshotId } : {}),\n ...(timeoutSeconds !== undefined ? { timeoutSeconds } : {}),\n ...(metadata ? { metadata: metadata as Record<string, string> } : {}),\n ...(envs ? { envVars: envs } : {}),\n ...providerOptions,\n ...(volumes !== undefined ? {\n volumes: volumes.map((mount) => ({\n ...mount,\n volume: mount.volume instanceof SuperserveVolume\n ? mount.volume\n : volumeReference(mount.volume),\n })),\n } : {}),\n };\n const connection = resolveConfig(createOptions);\n const sandbox = await SuperserveSandbox.create(createOptions);\n volumeConnections.set(sandbox, connection);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch (error) {\n const notBuilt = missingSizeTemplate(config, templateId, error);\n if (notBuilt) throw Object.assign(new Error(notBuilt), { status: 404, cause: error });\n rethrowFriendly(error, 'Failed to create Superserve sandbox');\n }\n },\n\n getById: async (config: SuperserveConfig, sandboxId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const connection = resolveConfig({ apiKey, baseUrl });\n const sandbox = await SuperserveSandbox.connect(sandboxId, connection);\n volumeConnections.set(sandbox, connection);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch {\n return null;\n }\n },\n\n list: async (config: SuperserveConfig) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const connection = resolveConfig({ apiKey, baseUrl });\n const infos = await SuperserveSandbox.list(connection);\n // No per-item connect() — that would POST /activate and resume paused sandboxes.\n return infos.map((info) => {\n const instance = info as unknown as SuperserveSandbox;\n volumeConnections.set(instance, connection);\n return { instance, instanceId: info.id };\n });\n } catch {\n return [];\n }\n },\n\n destroy: async (config: SuperserveConfig, sandboxId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n // The SDK handles already-deleted sandboxes and retries transient failures.\n await SuperserveSandbox.killById(sandboxId, { apiKey, baseUrl });\n },\n\n runCommand,\n streamCommand: runCommand,\n\n attachVolume: async (sandbox, volume, mountPath) => {\n const native = await SuperserveVolume.connect(volumeReference(volume), volumeConnection(sandbox));\n await native.attach(sandbox.id, { mountPath });\n },\n\n detachVolume: async (sandbox, volume, mountPath) => {\n const native = await SuperserveVolume.connect(volumeReference(volume), volumeConnection(sandbox));\n const attachments = (await native.listAttachments()).filter((attachment) =>\n attachment.volumeId === native.id &&\n sameSandboxId(attachment.sandboxId, sandbox.id) &&\n attachment.status !== 'revoked' &&\n (mountPath === undefined || attachment.mountPath === mountPath));\n if (attachments.length > 1) {\n throw new Error('Multiple matching Superserve attachments; provide their mount path to detach one.');\n }\n if (attachments[0]) await native.detach(attachments[0].id);\n },\n\n getInfo: async (sandbox: SuperserveSandbox): Promise<InstanceInfo> => {\n const info = await sandbox.getInfo();\n const status: InstanceInfo['status'] =\n info.status === 'paused' || info.status === 'deleted' ? 'stopped' :\n info.status === 'failed' ? 'error' :\n 'running';\n return {\n id: info.id,\n provider: 'superserve',\n status,\n createdAt: info.createdAt,\n timeout: info.timeoutSeconds ? info.timeoutSeconds * 1000 : DEFAULT_TIMEOUT_MS,\n metadata: info.metadata,\n };\n },\n\n getUrl: async (sandbox: SuperserveSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n // A preview URL only routes once its port is published. A new port takes\n // the sandbox's `previewAccess` default; a published one keeps its mode.\n await sandbox.publishPreviewPort(options.port);\n const url = sandbox.getPreviewUrl(options.port);\n return options.protocol ? url.replace(/^https/, options.protocol) : url;\n },\n\n filesystem: {\n readFile: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n return sandbox.files.readText(await resolveSandboxPath(sandbox, path, runCommand));\n },\n\n writeFile: async (sandbox: SuperserveSandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n await sandbox.files.write(await resolveSandboxPath(sandbox, path, runCommand), content);\n },\n\n mkdir: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`mkdir -p \"${escapeShellArg(resolved)}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`mkdir failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n },\n\n readdir: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n // find -printf format: <type>\\t<size>\\t<mtime-epoch>\\t<name>\n const cmd = [\n `cd \"${escapeShellArg(resolved)}\" || exit 2`,\n `find . -mindepth 1 -maxdepth 1 -printf '%y\\\\t%s\\\\t%T@\\\\t%f\\\\n' 2>/dev/null`,\n ].join(' && ');\n const result = await sandbox.commands.run(cmd);\n if (result.exitCode === 2) {\n throw new Error(`readdir: directory not found: ${path}`);\n }\n if (result.exitCode !== 0) {\n throw new Error(`readdir failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n const entries: FileEntry[] = [];\n for (const line of result.stdout.split('\\n')) {\n if (!line) continue;\n const [type, sizeStr, mtimeStr, ...nameParts] = line.split('\\t');\n const name = nameParts.join('\\t');\n if (!name) continue;\n const size = Number.parseInt(sizeStr, 10);\n const mtime = Number.parseFloat(mtimeStr);\n entries.push({\n name,\n type: type === 'd' ? 'directory' : 'file',\n size: Number.isFinite(size) ? size : 0,\n modified: Number.isFinite(mtime) ? new Date(mtime * 1000) : new Date(),\n });\n }\n return entries;\n },\n\n exists: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`test -e \"${escapeShellArg(resolved)}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: SuperserveSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n // An empty or dot-only path would resolve to the workdir itself —\n // refuse it rather than `rm -rf` the sandbox's whole cwd.\n if (path.split('/').every((s) => s === '' || s === '.')) {\n throw new Error(`remove: refusing ambiguous path: ${JSON.stringify(path)}`);\n }\n const resolved = await resolveSandboxPath(sandbox, path, runCommand);\n const result = await sandbox.commands.run(`rm -rf \"${escapeShellArg(resolved)}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`remove failed: ${result.stderr || `exit code ${result.exitCode}`}`);\n }\n },\n },\n\n getInstance: (sandbox: SuperserveSandbox): SuperserveSandbox => sandbox,\n\n pause: async (sandbox: SuperserveSandbox): Promise<void> => {\n try {\n await sandbox.pause({ wait: true });\n } catch (error) {\n rethrowFriendly(error, 'Failed to pause Superserve sandbox');\n }\n },\n\n resume: async (sandbox: SuperserveSandbox): Promise<void> => {\n try {\n // The access token rotates on resume; the SDK refreshes the handle in place.\n await sandbox.resume();\n } catch (error) {\n rethrowFriendly(error, 'Failed to resume Superserve sandbox');\n }\n },\n\n pauseCapabilities: { memory: true },\n },\n\n snapshot: {\n // Snapshots hold memory and disk: restores keep the whole filesystem,\n // tmpfs /tmp included, and running processes. The source keeps running.\n capabilities: { scope: 'rootfs', memory: true, destroysSource: false },\n create: async (config: SuperserveConfig, sandboxId: string, options?: { name?: string }) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n // connect() activates the sandbox, so a paused one is resumed first.\n const sandbox = await SuperserveSandbox.connect(sandboxId, { apiKey, baseUrl });\n return toSnapshot(await sandbox.snapshot({ name: options?.name }));\n } catch (error) {\n rethrowFriendly(error, 'Failed to create Superserve snapshot');\n }\n },\n list: async (config: SuperserveConfig, options?: { sandboxId?: string; limit?: number }) => {\n // Snapshots are listed per sandbox. Callers that aggregate across\n // providers pass no options, so an unscoped call returns nothing\n // instead of throwing and failing their whole listing.\n if (!options?.sandboxId) return [];\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n const infos = await SuperserveSnapshot.list(options.sandboxId, { apiKey, baseUrl, limit: options.limit });\n return infos.map(toSnapshot);\n },\n delete: async (config: SuperserveConfig, snapshotId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n await SuperserveSnapshot.deleteById(snapshotId, { apiKey, baseUrl });\n },\n },\n\n volume: {\n create: async (config: SuperserveConfig, options: SuperserveVolumeCreateOptions) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n const volume = await SuperserveVolume.create({\n ...connection,\n name: options.name,\n ...(options.sizeBytes !== undefined ? { capacityBytes: options.sizeBytes } : {}),\n idempotencyKey: options.idempotencyKey,\n timeoutMs: options.timeoutMs,\n signal: options.signal,\n });\n return toVolume(volume);\n },\n get: async (config: SuperserveConfig, idOrName: string) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n try {\n return toVolume(await SuperserveVolume.connect(idOrName, connection));\n } catch (error) {\n if (error instanceof NotFoundError) return null;\n throw error;\n }\n },\n list: async (config: SuperserveConfig, options?: { limit?: number }) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n const volumes = await SuperserveVolume.list({ ...connection, limit: options?.limit });\n return volumes.map(toVolume);\n },\n delete: async (config: SuperserveConfig, idOrName: string) => {\n const connection = resolveConfig({ apiKey: resolveApiKey(config), baseUrl: resolveBaseUrl(config) });\n await deleteVolume(connection, idOrName);\n },\n },\n\n template: {\n create: async (config: SuperserveConfig, options: SuperserveTemplateCreateOptions) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n const { name, from, vcpu, memoryMib, diskMib, steps, startCmd, readyCmd } = options;\n if (!from) {\n throw new Error('Superserve templates are built from an image: pass `from` (e.g. \"node:22\").');\n }\n try {\n const template = await SuperserveTemplate.create({\n apiKey, baseUrl, name, from, vcpu, memoryMib, diskMib, steps, startCmd, readyCmd,\n });\n return toTemplate(await template.waitUntilReady());\n } catch (error) {\n rethrowFriendly(error, 'Failed to create Superserve template');\n }\n },\n list: async (config: SuperserveConfig) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n const infos = await SuperserveTemplate.list({ apiKey, baseUrl });\n return infos.map(toTemplate);\n } catch {\n return [];\n }\n },\n delete: async (config: SuperserveConfig, templateId: string) => {\n const apiKey = resolveApiKey(config);\n const baseUrl = resolveBaseUrl(config);\n try {\n await SuperserveTemplate.deleteById(templateId, { apiKey, baseUrl });\n } catch {\n /* already deleted */\n }\n },\n },\n },\n});\n\nexport type { Sandbox as SuperserveSandbox } from '@superserve/sdk';\n"],"mappings":";AAMA,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV;AAAA,OACK;AASP,SAAS,gBAAgB,gBAAgB,mBAAmB,8BAA8B;AAE1F,IAAM,qBAAqB;AAgCpB,IAAM,4BAAkF,OAAO,OAAO;AAAA,EAC3G,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT,CAAC;AAGD,IAAM,6BAA+D,OAAO,OAAO,EAAE,mBAAmB,KAAK,CAAC;AAG9G,IAAM,iBAAiB,CAAC,cAAc,cAAc,aAAa,gBAAgB,cAAc;AAC/F,IAAM,sBAAsB,CAAC,QAAQ,aAAa,aAAa,gBAAgB,SAAS;AAExF,SAAS,eAAe,QAA0B,WAAkD;AAClG,QAAM,OAAO,OAAO,gBAAgB,SAAS,KAAK,0BAA0B,SAAS;AACrF,SAAO,OAAO,SAAS,YAAY,KAAK,KAAK,IAAI,OAAO;AAC1D;AAGA,SAAS,oBAAoB,QAA0B,YAAqB,OAAoC;AAC9G,MAAI,OAAO,eAAe,YAAY,EAAE,iBAAiB,eAAgB,QAAO;AAChF,QAAM,Y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;AACnC,cAAM,UAAU,eAAe,MAAM;AACrC,cAAM,EAAE,MAAM,MAAM,MAAM,WAAW,SAAS,OAAO,UAAU,SAAS,IAAI;AAC5E,YAAI,CAAC,MAAM;AACT,gBAAM,IAAI,MAAM,6EAA6E;AAAA,QAC/F;AACA,YAAI;AACF,gBAAM,WAAW,MAAM,mBAAmB,OAAO;AAAA,YAC/C;AAAA,YAAQ;AAAA,YAAS;AAAA,YAAM;AAAA,YAAM;AAAA,YAAM;AAAA,YAAW;AAAA,YAAS;AAAA,YAAO;AAAA,YAAU;AAAA,UAC1E,CAAC;AACD,iBAAO,WAAW,MAAM,SAAS,eAAe,CAAC;AAAA,QACnD,SAAS,OAAO;AACd,0BAAgB,OAAO,sCAAsC;AAAA,QAC/D;AAAA,MACF;AAAA,MACA,MAAM,OAAO,WAA6B;AACxC,cAAM,SAAS,cAAc,MAAM;AACnC,cAAM,UAAU,eAAe,MAAM;AACrC,YAAI;AACF,gBAAM,QAAQ,MAAM,mBAAmB,KAAK,EAAE,QAAQ,QAAQ,CAAC;AAC/D,iBAAO,MAAM,IAAI,UAAU;AAAA,QAC7B,QAAQ;AACN,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,MACA,QAAQ,OAAO,QAA0B,eAAuB;AAC9D,cAAM,SAAS,cAAc,MAAM;AACnC,cAAM,UAAU,eAAe,MAAM;AACrC,YAAI;AACF,gBAAM,mBAAmB,WAAW,YAAY,EAAE,QAAQ,QAAQ,CAAC;AAAA,QACrE,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["runCommand"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@computesdk/superserve",
3
- "version": "0.2.29",
3
+ "version": "0.2.30",
4
4
  "description": "Superserve sandbox adapter for ComputeSDK. Run code in Firecracker microVMs.",
5
5
  "author": "Superserve",
6
6
  "license": "MIT",