@computesdk/createos-sandbox 0.1.21 → 0.1.23

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
@@ -138,7 +138,7 @@ function toCreateRequest(opts, shape, rootfs) {
138
138
  if (ssh) req.ssh_pubkeys = ssh;
139
139
  const egress = strArray(opts.egress);
140
140
  if (egress) req.egress = egress;
141
- if (Array.isArray(opts.volumes) && opts.volumes.length > 0) {
141
+ if (provider.isUnifiedVolumeMounts(opts.volumes)) {
142
142
  req.disks = opts.volumes.map((m) => {
143
143
  const ref = provider.resolveVolumeRef(m.volume);
144
144
  const subPath = m.subPath;
@@ -147,6 +147,23 @@ function toCreateRequest(opts, shape, rootfs) {
147
147
  }
148
148
  return req;
149
149
  }
150
+ async function waitForDiskMounted(sandbox, mountPath, deadlineMs = 9e4) {
151
+ const deadline = Date.now() + deadlineMs;
152
+ for (; ; ) {
153
+ const disks = await sandbox.listDisks();
154
+ const att = disks.find((d) => d.mount_path === mountPath);
155
+ if (att?.mount_status === "mounted") return;
156
+ if (att?.mount_status === "error") {
157
+ throw new Error(`createos disk mount failed at ${mountPath}: ${att.mount_error ?? "unknown"}`);
158
+ }
159
+ if (Date.now() >= deadline) {
160
+ throw new Error(
161
+ `createos disk mount at ${mountPath} still ${att?.mount_status ?? "absent"} after ${deadlineMs}ms`
162
+ );
163
+ }
164
+ await new Promise((r) => setTimeout(r, 2e3));
165
+ }
166
+ }
150
167
  function buildScript(command, options) {
151
168
  let script = command;
152
169
  if (options?.cwd) script = `cd ${shellQuote(options.cwd)} && ${script}`;
@@ -194,12 +211,13 @@ var createosSandbox = provider.defineProvider({
194
211
  const forked = await source.fork(toForkRequest(opts));
195
212
  await forked.waitUntilRunning();
196
213
  sandboxConfig.set(forked, config);
197
- if (Array.isArray(opts.volumes) && opts.volumes.length > 0) {
214
+ if (provider.isUnifiedVolumeMounts(opts.volumes)) {
198
215
  try {
199
216
  for (const m of opts.volumes) {
200
217
  const ref = provider.resolveVolumeRef(m.volume);
201
218
  const subPath = m.subPath;
202
219
  await forked.attachDisk({ diskId: ref.id ?? ref.name, mountPath: m.mountPath, ...subPath ? { subPath } : {} });
220
+ await waitForDiskMounted(forked, m.mountPath);
203
221
  }
204
222
  } catch (err) {
205
223
  await forked.destroy().catch(() => {
@@ -213,6 +231,15 @@ var createosSandbox = provider.defineProvider({
213
231
  const rootfs = opts.image ?? opts.runtime ?? config.rootfs ?? "devbox:1";
214
232
  const sandbox = await client.createSandbox(toCreateRequest(opts, shape, rootfs));
215
233
  sandboxConfig.set(sandbox, config);
234
+ if (Array.isArray(opts.volumes)) {
235
+ try {
236
+ for (const m of opts.volumes) await waitForDiskMounted(sandbox, m.mountPath);
237
+ } catch (err) {
238
+ await sandbox.destroy().catch(() => {
239
+ });
240
+ throw err;
241
+ }
242
+ }
216
243
  return { instance: sandbox, instanceId: sandbox.id };
217
244
  },
218
245
  getById: async (config, sandboxId) => {
@@ -290,6 +317,7 @@ var createosSandbox = provider.defineProvider({
290
317
  const ref = provider.resolveVolumeRef(volume);
291
318
  const subPath = volume.subPath;
292
319
  await sandbox.attachDisk({ diskId: ref.id ?? ref.name, mountPath, ...subPath ? { subPath } : {} });
320
+ await waitForDiskMounted(sandbox, mountPath);
293
321
  },
294
322
  detachVolume: async (sandbox, volume, mountPath) => {
295
323
  const ref = provider.resolveVolumeRef(volume);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["CreateosSandboxClient","CreateosSandboxNotFoundError","resolveVolumeRef","defineProvider","withVolumeSettle"],"mappings":";;;;;;AAiDA,IAAM,aAAA,GAAgB,kBAAA;AAOtB,IAAM,aAAA,uBAAoB,OAAA,EAAiC;AAG3D,IAAM,WAAA,uBAAkB,GAAA,EAAmC;AAO3D,SAAS,WAAW,GAAA,EAAqB;AACvC,EAAA,OAAO,CAAA,CAAA,EAAI,GAAA,CAAI,OAAA,CAAQ,IAAA,EA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AA,CAAW,CAAC,CAAA,EAAG,OAAO,IAAA;AAC1B,UAAA,MAAM,CAAA;AAAA,QACR;AAAA,MACF,CAAA;AAAA,MACA,IAAA,EAAM,OAAO,MAAA,KAA2B;AACtC,QAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,QAAA,MAAM,QAA8D,EAAC;AACrE,QAAA,WAAA,MAAiB,KAAK,MAAA,CAAO,KAAA,CAAM,OAAA,EAAQ,QAAS,IAAA,CAAK,EAAE,EAAA,EAAI,CAAA,CAAE,IAAI,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,MAAA,EAAQ,GAAG,CAAA;AAC9F,QAAA,OAAO,KAAA;AAAA,MACT,CAAA;AAAA,MACA,MAAA,EAAQ,OAAO,MAAA,EAAwB,cAAA,KAA2B;AAChE,QAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,QAAA,IAAI;AACF,UAAA,MAAME,0BAAiB,MAAM,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,cAAc,CAAC,CAAA;AAAA,QAClE,SAAS,CAAA,EAAG;AACV,UAAA,IAAI,UAAA,CAAW,CAAC,CAAA,EAAG;AACnB,UAAA,MAAM,CAAA;AAAA,QACR;AAAA,MACF;AAAA;AACF;AAEJ,CAAC","file":"index.js","sourcesContent":["/**\n * CreateOS Sandbox Provider for ComputeSDK\n *\n * VM sandboxes backed by the NodeOps createos-sandbox control plane.\n * Thin adapter over the official `@nodeops-createos/sandbox` npm package — the same\n * SDK used across the CreateOS tooling.\n *\n * Design notes:\n * - `TInstance` is the native `@nodeops-createos/sandbox` `Sandbox` handle, so\n * `getInstance()` hands callers the full stateful API (pause / resume / fork /\n * disks / networks / bandwidth) that ComputeSDK's core surface does not model.\n * The resolving config is associated with each handle via a `WeakMap`\n * side-channel (`sandboxConfig`), so `getInfo` can honour `config` (e.g.\n * `timeout`) and its error policy without wrapping or mutating the handle.\n * - createos-sandbox sizes VMs from a fixed *shape* catalog rather than free-form\n * cpu/mem, so create() maps ComputeSDK's `cpus`/`memoryMb` onto the nearest\n * shape and honours an explicit provider-specific `shape` override.\n * - The control plane drops per-exec env server-side (env is sandbox-level,\n * set at create time), so per-command `env`/`cwd` are synthesised by\n * wrapping the command in an inline `sh -c` script.\n * - Snapshot semantics differ from running-snapshot providers (e2b/tensorlake):\n * `snapshot.create` *pauses* the sandbox (the source VM stops), and the\n * paused sandbox id IS the snapshot id. `create({ snapshotId })` forks that\n * paused bundle into a fresh sandbox.\n *\n * Error policy: provider operations fail loudly when the provider boundary is\n * broken. Only a genuine 404 (`CreateosSandboxNotFoundError`) is mapped to the\n * idempotent \"absent\" outcome (`getById` → null, `destroy`/`delete` → no-op).\n * Auth, network, validation, and server errors propagate.\n */\n\nimport { CreateosSandboxClient, CreateosSandboxNotFoundError, Sandbox } from \"@nodeops-createos/sandbox\";\nimport type {\n CreateSandboxRequest,\n ForkSandboxRequest,\n SandboxStatus,\n Shape,\n} from \"@nodeops-createos/sandbox\";\nimport { defineProvider, resolveVolumeRef, withVolumeSettle } from \"@computesdk/provider\";\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateSnapshotOptions,\n FileEntry,\n ListSnapshotsOptions,\n RunCommandOptions,\n InstanceInfo,\n} from \"@computesdk/provider\";\n\nconst PROVIDER_NAME = \"createos-sandbox\";\n\n/** Per-sandbox config side-channel: associates the resolving config with each\n * native handle without mutating it or wrapping `TInstance` — so `getInstance()`\n * still returns the bare native handle (the escape hatch other providers honour),\n * while `getInfo` can still reach `config` (e.g. `timeout`). Keyed weakly, so an\n * entry is collected with its sandbox. */\nconst sandboxConfig = new WeakMap<Sandbox, CreateosConfig>();\n\n/** Reuse clients for the same apiKey+baseUrl pair. */\nconst clientCache = new Map<string, CreateosSandboxClient>();\n\n/** Quote a value into one complete, self-contained shell token. Unlike the\n * framework's `escapeShellArg` (which only neutralises metacharacters *inside*\n * surrounding double quotes), this wraps in single quotes so the token is safe\n * to splice unquoted — spaces, `;`, `&`, `|`, globs and the rest cannot split\n * the command or inject syntax. Embedded single quotes are closed/escaped/reopened. */\nfunction shellQuote(arg: string): string {\n return `'${arg.replace(/'/g, \"'\\\\''\")}'`;\n}\n\n/** The framework-supplied command runner handed to filesystem callbacks. */\ntype CommandRunner = (\n sandbox: Sandbox,\n command: string,\n options?: RunCommandOptions,\n) => Promise<CommandResult>;\n\nconst FALLBACK_WORKDIR = \"/\";\n\n/** Cached `pwd` probes: the `files.*` API demands absolute paths, so relative\n * filesystem paths resolve against the cwd a `runCommand` exec would use —\n * `writeFile('a.txt')` and `cat a.txt` then agree. */\nconst workdirs = new WeakMap<Sandbox, Promise<string>>();\n\nfunction workdirOf(sandbox: Sandbox, runCommand: CommandRunner): Promise<string> {\n let probe = workdirs.get(sandbox);\n if (!probe) {\n probe = runCommand(sandbox, \"pwd\").then((r) => {\n const dir = r.stdout.trim();\n if (r.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 `workdir`. Absolute paths pass through; relative paths\n * anchor at the sandbox workdir. Empty and `.` segments are dropped; `..`\n * segments are preserved for the sandbox filesystem to resolve physically —\n * collapsing them lexically would mis-resolve when a preceding component is\n * a symlink. */\nexport function resolveSandboxPath(path: string, workdir: string): string {\n const combined = path.startsWith(\"/\") ? path : `${workdir}/${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\n/** Resolve `path` without forcing a workdir probe for absolute paths. */\nasync function resolveFsPath(\n sandbox: Sandbox,\n path: string,\n runCommand: CommandRunner,\n): Promise<string> {\n return resolveSandboxPath(\n path,\n path.startsWith(\"/\") ? \"/\" : await workdirOf(sandbox, runCommand),\n );\n}\n\n/** Memory floor (MiB) for the default shape when a create() pins no size. The\n * control plane names no default shape and `CreateSandboxRequest` requires\n * one, so the default is a client policy — the smallest *live* catalog shape\n * with at least this much RAM. Override per-create with `shape`/`config.shape`. */\nconst DEFAULT_SHAPE_MIN_MIB = 1024;\n\n/** POSIX environment variable name. Keys are spliced into a shell `export`, so\n * anything outside this grammar is rejected rather than emitted (injection). */\nconst ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nexport interface CreateosConfig {\n /** createos-sandbox API key. Falls back to the CREATEOS_SANDBOX_API_KEY env var. */\n apiKey?: string;\n /** Control-plane base URL. Falls back to the CREATEOS_SANDBOX_BASE_URL env\n * var, then the production control plane. */\n baseUrl?: string;\n /** Default shape when create options pin neither `shape` nor cpus/memoryMb. */\n shape?: string;\n /** Default rootfs catalog name or template id. Empty = host default. */\n rootfs?: string;\n /** Reported `getInfo().timeout` in ms. Informational only. */\n timeout?: number;\n}\n\n/** ComputeSDK create options plus the createos-specific fields this provider\n * reads off the (otherwise open) options bag. Declaring them turns the cast-\n * heavy decode into a typed contract and makes unsupported fields obvious. */\nexport interface CreateosCreateOptions extends CreateInstanceOptions {\n /** Explicit shape id. Overrides cpus/memoryMb selection and skips the catalog fetch. */\n shape?: string;\n /** Rootfs catalog name or template id (alias of `runtime`). */\n image?: string;\n /** Rootfs catalog name or template id (alias of `image`). */\n runtime?: string;\n /** Requested RAM; mapped onto the smallest fitting shape. */\n memoryMb?: number;\n /** Requested vCPUs; mapped onto the smallest fitting shape. */\n cpus?: number;\n /** Overlay disk size (MiB). 0 / omitted = the shape's default disk. */\n ephemeralDiskMb?: number;\n /** Enable public ingress. Defaults to false. */\n ingressEnabled?: boolean;\n /** SSH public keys to inject at boot. */\n sshPubkeys?: string[];\n /** Egress allow-list. */\n egress?: string[];\n /** Env vars set at sandbox creation. */\n envs?: Record<string, string>;\n /** Explicit sandbox name (control mints one if omitted). */\n name?: string;\n /** Snapshot id (paused sandbox) to fork from — bypasses cold create. */\n snapshotId?: string;\n}\n\n/** Production control-plane base URL, used when neither `config.baseUrl` nor\n * the CREATEOS_SANDBOX_BASE_URL env var is set. */\nconst DEFAULT_BASE_URL = \"https://api.sb.createos.sh\";\n\nfunction env(key: string): string | undefined {\n return typeof process !== \"undefined\" ? process.env?.[key] : undefined;\n}\n\nfunction resolveClient(config: CreateosConfig): CreateosSandboxClient {\n const apiKey = config.apiKey ?? env(\"CREATEOS_SANDBOX_API_KEY\");\n if (!apiKey) {\n throw new Error(\n \"Missing CreateOS API key. Provide 'apiKey' in config or set the \" +\n \"CREATEOS_SANDBOX_API_KEY environment variable.\",\n );\n }\n // Precedence: explicit config > env var > production default. A blank value\n // is treated as unset so the next source applies.\n const baseUrl =\n config.baseUrl?.trim() || env(\"CREATEOS_SANDBOX_BASE_URL\")?.trim() || DEFAULT_BASE_URL;\n const cacheKey = `${apiKey}\\0${baseUrl}`;\n let client = clientCache.get(cacheKey);\n if (!client) {\n client = new CreateosSandboxClient({ apiKey, baseUrl });\n clientCache.set(cacheKey, client);\n }\n return client;\n}\n\n/** True only for a genuine \"resource does not exist\" (404). Everything else —\n * auth, network, validation, server, rate-limit — is a broken boundary. */\nfunction isNotFound(e: unknown): boolean {\n return e instanceof CreateosSandboxNotFoundError;\n}\n\n/** Sort a catalog by ascending RAM then vCPU. Selection relies on this order;\n * the control plane gives no ordering guarantee for `listShapes()`. */\nfunction sortShapes(shapes: Shape[]): Shape[] {\n return shapes.toSorted((a, b) => a.mem_mib - b.mem_mib || a.vcpu - b.vcpu);\n}\n\n/** Pick the smallest live catalog shape that satisfies the requested cpu/mem.\n * Returns undefined when neither is given (caller applies the default). */\nexport function pickShape(shapes: Shape[], memoryMb?: number, cpus?: number): string | undefined {\n if (memoryMb == null && cpus == null) return undefined;\n const sorted = sortShapes(shapes);\n const fit = sorted.find(\n (s) => (memoryMb == null || s.mem_mib >= memoryMb) && (cpus == null || s.vcpu >= cpus),\n );\n return (fit ?? sorted[sorted.length - 1])?.id;\n}\n\n/** Default shape when create() pins neither `shape` nor cpus/memoryMb: the\n * smallest live shape meeting the RAM floor, else the smallest available. */\nexport function defaultShape(shapes: Shape[]): string | undefined {\n const sorted = sortShapes(shapes);\n const fit = sorted.find((s) => s.mem_mib >= DEFAULT_SHAPE_MIN_MIB);\n return (fit ?? sorted[0])?.id;\n}\n\n/** Cache shapes per client with a 5-minute TTL. */\nconst shapesCache = new WeakMap<CreateosSandboxClient, { shapes: Shape[]; expires: number }>();\nconst SHAPES_CACHE_TTL_MS = 5 * 60 * 1_000;\nconst FALLBACK_SHAPE = \"s-1vcpu-1gb\";\n\n/** Resolve the shape for a create() call. Fetches the live catalog only when\n * no explicit `shape` is pinned, so the explicit path never depends on\n * `/v1/shapes` being reachable. */\nasync function resolveShape(\n client: CreateosSandboxClient,\n opts: CreateosCreateOptions,\n config: CreateosConfig,\n): Promise<string> {\n const explicit = opts.shape ?? config.shape;\n if (explicit) return explicit;\n if (opts.memoryMb == null && opts.cpus == null) return FALLBACK_SHAPE;\n const now = Date.now();\n let entry = shapesCache.get(client);\n if (!entry || entry.expires < now) {\n entry = { shapes: await client.listShapes(), expires: now + SHAPES_CACHE_TTL_MS };\n shapesCache.set(client, entry);\n }\n const picked = pickShape(entry.shapes, opts.memoryMb, opts.cpus) ?? defaultShape(entry.shapes) ?? FALLBACK_SHAPE;\n return picked;\n}\n\n/** Map an createos-sandbox lifecycle state onto ComputeSDK's running|stopped|error. */\nexport function mapStatus(status: SandboxStatus): InstanceInfo[\"status\"] {\n if (status === \"running\") return \"running\";\n if (status === \"error\" || status === \"failed\") return \"error\";\n return \"stopped\";\n}\n\n/** A non-empty env record from `envs` (preferred) or the legacy `env` alias. */\nfunction envsOf(opts: CreateosCreateOptions): Record<string, string> | undefined {\n const envs = opts.envs ?? (opts as { env?: Record<string, string> }).env;\n return envs && Object.keys(envs).length > 0 ? envs : undefined;\n}\n\n/** A string[] when the value is an array, else undefined. */\nfunction strArray(v: unknown): string[] | undefined {\n return Array.isArray(v) ? (v as string[]) : undefined;\n}\n\n/** Pure map: ComputeSDK create options → createos-sandbox fork request body. */\nexport function toForkRequest(opts: CreateosCreateOptions): ForkSandboxRequest {\n const req: ForkSandboxRequest = {\n ingress_enabled: opts.ingressEnabled !== undefined ? Boolean(opts.ingressEnabled) : false,\n };\n const ssh = strArray(opts.sshPubkeys);\n if (ssh) req.ssh_pubkeys = ssh;\n const egress = strArray(opts.egress);\n if (egress) req.egress = egress;\n const envs = envsOf(opts);\n if (envs) req.envs = envs;\n return req;\n}\n\n/** Pure map: ComputeSDK create options (+ resolved shape/rootfs) → create request. */\nexport function toCreateRequest(\n opts: CreateosCreateOptions,\n shape: string,\n rootfs?: string,\n): CreateSandboxRequest {\n const req: CreateSandboxRequest = {\n shape,\n ingress_enabled: opts.ingressEnabled !== undefined ? Boolean(opts.ingressEnabled) : false,\n };\n if (rootfs) req.rootfs = rootfs;\n if (opts.name) req.name = String(opts.name);\n // Pass the requested overlay-disk size straight through; the control plane\n // validates it (0 / omitted = shape default). No client-side menu.\n if (typeof opts.ephemeralDiskMb === \"number\" && opts.ephemeralDiskMb > 0) {\n req.disk_mib = opts.ephemeralDiskMb;\n }\n const envs = envsOf(opts);\n if (envs) req.envs = envs;\n const ssh = strArray(opts.sshPubkeys);\n if (ssh) req.ssh_pubkeys = ssh;\n const egress = strArray(opts.egress);\n if (egress) req.egress = egress;\n\n // Unified mounts → createos disk attachments {disk_id, mount_path, sub_path}.\n if (Array.isArray(opts.volumes) && opts.volumes.length > 0) {\n req.disks = opts.volumes.map((m) => {\n const ref = resolveVolumeRef(m.volume);\n const subPath = (m as { subPath?: string }).subPath;\n return { disk_id: ref.id ?? ref.name!, mount_path: m.mountPath, ...(subPath ? { sub_path: subPath } : {}) };\n });\n }\n return req;\n}\n\n/** Wrap a command so per-call cwd/env/background work despite the server dropping\n * exec env. Env *keys* are validated before being spliced into `export` —\n * values are shell-quoted, but a malformed key would otherwise be raw shell. */\nexport function buildScript(command: string, options?: RunCommandOptions): string {\n let script = command;\n if (options?.cwd) script = `cd ${shellQuote(options.cwd)} && ${script}`;\n if (options?.env && Object.keys(options.env).length > 0) {\n const exports = Object.entries(options.env)\n .map(([k, v]) => {\n if (!ENV_KEY_RE.test(k)) {\n throw new Error(\n `Invalid environment variable name ${JSON.stringify(k)}: ` +\n `must match ${ENV_KEY_RE.source}.`,\n );\n }\n return `export ${k}=${shellQuote(String(v))}`;\n })\n .join(\"; \");\n script = `${exports}; ${script}`;\n }\n if (options?.background) {\n script = `nohup sh -c ${shellQuote(script)} > /dev/null 2>&1 &`;\n }\n return script;\n}\n\n/** Parse `ls -lA --time-style=+%s` output into ComputeSDK FileEntry rows. */\nexport function parseLsOutput(stdout: string): FileEntry[] {\n const entries: FileEntry[] = [];\n for (const line of stdout.split(\"\\n\")) {\n if (!line || line.startsWith(\"total \")) continue;\n const m = line.match(/^(\\S+)\\s+\\d+\\s+\\S+\\s+\\S+\\s+(\\d+)\\s+(\\d+)\\s+(.+)$/);\n if (!m) continue;\n const name = m[4]!.replace(/ -> .*$/, \"\"); // strip symlink target\n entries.push({\n name,\n type: m[1]!.startsWith(\"d\") ? \"directory\" : \"file\",\n size: Number(m[2]),\n modified: new Date(Number(m[3]) * 1000),\n });\n }\n return entries;\n}\n\nexport const createosSandbox = defineProvider<Sandbox, CreateosConfig>({\n name: PROVIDER_NAME,\n methods: {\n instances: {\n create: async (config: CreateosConfig, options?: CreateInstanceOptions) => {\n const client = resolveClient(config);\n const opts = (options ?? {}) as CreateosCreateOptions;\n\n // A snapshot id is a paused sandbox: fork it into a fresh sandbox.\n if (opts.snapshotId) {\n const source = await client.getSandbox(opts.snapshotId);\n const forked = await source.fork(toForkRequest(opts));\n // Surface lifecycle failures: a fork that never reaches \"running\"\n // (or hits a terminal state) must not be reported as success.\n await forked.waitUntilRunning();\n sandboxConfig.set(forked, config);\n // ForkSandboxRequest carries no `disks` field — attach requested\n // volumes post-fork through the runtime disk API instead. Destroy\n // the fork on failure — it is already running, and the caller gets\n // no instance handle to clean up with.\n if (Array.isArray(opts.volumes) && opts.volumes.length > 0) {\n try {\n for (const m of opts.volumes) {\n const ref = resolveVolumeRef(m.volume);\n const subPath = (m as { subPath?: string }).subPath;\n await forked.attachDisk({ diskId: ref.id ?? ref.name!, mountPath: m.mountPath, ...(subPath ? { subPath } : {}) });\n }\n } catch (err) {\n await forked.destroy().catch(() => {});\n throw err;\n }\n }\n return { instance: forked, instanceId: forked.id };\n }\n\n const shape = await resolveShape(client, opts, config);\n const rootfs = opts.image ?? opts.runtime ?? config.rootfs ?? \"devbox:1\";\n const sandbox = await client.createSandbox(toCreateRequest(opts, shape, rootfs));\n sandboxConfig.set(sandbox, config);\n return { instance: sandbox, instanceId: sandbox.id };\n },\n\n getById: async (config: CreateosConfig, sandboxId: string) => {\n const client = resolveClient(config);\n try {\n const sandbox = await client.getSandbox(sandboxId);\n sandboxConfig.set(sandbox, config);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch (e) {\n if (isNotFound(e)) return null;\n throw e;\n }\n },\n\n list: async (config: CreateosConfig) => {\n const client = resolveClient(config);\n // No catch: a failed list is a broken boundary, not an empty account.\n const sandboxes = await client.listSandboxes({ limit: 100 });\n return sandboxes.map((sandbox) => {\n sandboxConfig.set(sandbox, config);\n return { instance: sandbox, instanceId: sandbox.id };\n });\n },\n\n destroy: async (config: CreateosConfig, sandboxId: string) => {\n const client = resolveClient(config);\n try {\n await client.http.request(\n \"DELETE\",\n `/v1/sandboxes/${encodeURIComponent(sandboxId)}`,\n );\n } catch (e) {\n if (isNotFound(e)) return; // already gone; destroy is idempotent\n throw e;\n }\n },\n\n runCommand: async (\n sandbox: Sandbox,\n command: string,\n options?: RunCommandOptions,\n ): Promise<CommandResult> => {\n // `sh -c` (not `bash -lc`): POSIX-portable so bare rootfses without\n // bash still run. buildScript only emits POSIX constructs. Transport /\n // auth errors propagate; a command that ran reports its own exit code.\n const execOpts = options?.timeout ? { timeoutMs: options.timeout } : undefined;\n const { result, exec_ms } = await sandbox.runCommand(\"sh\", [\n \"-c\",\n buildScript(command, options),\n ], execOpts);\n const stderr = result.error ? `${result.stderr}${result.error}` : result.stderr;\n return {\n stdout: result.stdout,\n stderr,\n exitCode: result.exit_code,\n durationMs: exec_ms,\n };\n },\n\n getInfo: async (sandbox: Sandbox): Promise<InstanceInfo> => {\n // Refresh failures propagate (no swallow): a getInfo that cannot reach\n // the control plane must surface that rather than return stale data.\n await sandbox.refresh();\n const v = sandbox.data;\n return {\n id: v.id,\n provider: PROVIDER_NAME,\n status: mapStatus(v.status),\n createdAt: new Date(v.created_at),\n timeout: sandboxConfig.get(sandbox)?.timeout ?? 0,\n metadata: {\n createosStatus: v.status,\n shape: v.shape,\n rootfs: v.rootfs,\n region: v.region,\n ip: v.ip,\n ingressEnabled: v.ingress_enabled,\n },\n };\n },\n\n getUrl: async (sandbox: Sandbox, options: { port: number; protocol?: string }) => {\n const scheme = options.protocol === \"http\" ? \"http\" : \"https\";\n return sandbox.previewUrl(options.port, { scheme });\n },\n\n // Escape hatch: the bare native @nodeops-createos/sandbox handle\n // (pause/resume/fork/disks/...).\n getInstance: (sandbox: Sandbox): Sandbox => sandbox,\n\n attachVolume: async (sandbox: Sandbox, volume, mountPath) => {\n const ref = resolveVolumeRef(volume);\n const subPath = (volume as { subPath?: string }).subPath;\n await sandbox.attachDisk({ diskId: ref.id ?? ref.name!, mountPath, ...(subPath ? { subPath } : {}) });\n },\n detachVolume: async (sandbox: Sandbox, volume, mountPath) => {\n const ref = resolveVolumeRef(volume);\n await sandbox.detachDisk({ diskId: ref.id ?? ref.name!, mountPath: mountPath! });\n },\n\n filesystem: {\n readFile: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n const buf = await sandbox.files.download(\n await resolveFsPath(sandbox, path, runCommand),\n );\n return new TextDecoder().decode(buf);\n },\n writeFile: async (sandbox: Sandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n await sandbox.files.upload(\n await resolveFsPath(sandbox, path, runCommand),\n content,\n );\n },\n mkdir: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `mkdir -p ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`mkdir ${path} failed: ${r.stderr}`);\n },\n readdir: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `ls -lA --time-style=+%s ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`readdir ${path} failed: ${r.stderr}`);\n return parseLsOutput(r.stdout);\n },\n exists: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `test -e ${shellQuote(resolved)}`);\n return r.exitCode === 0;\n },\n remove: async (sandbox: Sandbox, 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 resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `rm -rf ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`remove ${path} failed: ${r.stderr}`);\n },\n },\n },\n\n snapshot: {\n create: async (\n config: CreateosConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions,\n ) => {\n const client = resolveClient(config);\n const sandbox = await client.getSandbox(sandboxId);\n // createos-sandbox has no decoupled snapshot object: pausing IS the snapshot,\n // and the paused sandbox id is the snapshot id. This stops the source VM.\n await sandbox.pause();\n // The success claim is \"it paused\" — surface a pause that timed out or\n // entered a terminal state rather than returning a phantom snapshot.\n await sandbox.waitUntilPaused();\n return {\n id: sandboxId,\n provider: PROVIDER_NAME,\n createdAt: new Date(),\n metadata: { name: options?.name, ...options?.metadata },\n };\n },\n list: async (config: CreateosConfig, _options?: ListSnapshotsOptions) => {\n const client = resolveClient(config);\n // The typed status filter excludes \"paused\", so list all and filter.\n const all = await client.listSandboxes({ limit: 500 });\n return all\n .filter((s) => s.status === \"paused\")\n .map((s) => ({\n id: s.id,\n provider: PROVIDER_NAME,\n createdAt: new Date(s.data.paused_at ?? s.data.created_at),\n }));\n },\n delete: async (config: CreateosConfig, snapshotId: string) => {\n const client = resolveClient(config);\n try {\n const sandbox = await client.getSandbox(snapshotId);\n await sandbox.destroy();\n } catch (e) {\n if (isNotFound(e)) return; // already gone\n throw e;\n }\n },\n },\n\n volume: {\n // Createos disks are registered S3 buckets: \"creating\" a volume means\n // registering bucket config + credentials server-side. The S3 details\n // don't fit the universal CreateVolumeOptions shape, so they come from\n // options.s3 ({bucket, endpoint, region?, accessKey, secretKey,\n // pathStyle?}) or the CREATEOS_S3_* env vars.\n create: async (config: CreateosConfig, options) => {\n const client = resolveClient(config);\n const s3 = (options as { s3?: Record<string, unknown> }).s3 ?? {};\n const pick = (k: string, ...envs: string[]) =>\n (s3 as Record<string, unknown>)[k] ?? envs.map((e) => env(e)).find((v) => v);\n const bucket = pick(\"bucket\", \"CREATEOS_S3_BUCKET\");\n const endpoint = pick(\"endpoint\", \"CREATEOS_S3_ENDPOINT\");\n const accessKey = pick(\"accessKey\", \"CREATEOS_S3_ACCESS_KEY\", \"CREATEOS_S3_ACCESS_KEY_ID\");\n const secretKey = pick(\"secretKey\", \"CREATEOS_S3_SECRET_KEY\", \"CREATEOS_S3_SECRET_ACCESS_KEY\");\n if (!bucket || !endpoint || !accessKey || !secretKey) {\n throw new Error(\n \"Createos volumes are registered S3 buckets: pass options.s3 = \" +\n \"{bucket, endpoint, accessKey, secretKey} or set CREATEOS_S3_BUCKET/\" +\n \"ENDPOINT/ACCESS_KEY/SECRET_KEY.\",\n );\n }\n const disk = await client.disks.create({\n name: options.name,\n kind: \"s3\",\n config: {\n bucket: String(bucket),\n endpoint: String(endpoint),\n ...(pick(\"region\", \"CREATEOS_S3_REGION\") ? { region: String(pick(\"region\", \"CREATEOS_S3_REGION\")) } : {}),\n ...(pick(\"pathStyle\", \"CREATEOS_S3_PATH_STYLE\") ? { use_path_style: true } : {}),\n },\n credentials: { access_key: String(accessKey), secret_key: String(secretKey) },\n });\n return { id: disk.id, name: disk.name, native: disk };\n },\n get: async (config: CreateosConfig, volumeIdOrName: string) => {\n const client = resolveClient(config);\n try {\n const disk = await client.disks.get(volumeIdOrName);\n return disk ? { id: disk.id, name: disk.name, native: disk } : null;\n } catch (e) {\n if (isNotFound(e)) return null;\n throw e;\n }\n },\n list: async (config: CreateosConfig) => {\n const client = resolveClient(config);\n const disks: Array<{ id: string; name: string; native: unknown }> = [];\n for await (const d of client.disks.iterate()) disks.push({ id: d.id, name: d.name, native: d });\n return disks;\n },\n delete: async (config: CreateosConfig, volumeIdOrName: string) => {\n const client = resolveClient(config);\n try {\n await withVolumeSettle(() => client.disks.delete(volumeIdOrName));\n } catch (e) {\n if (isNotFound(e)) return;\n throw e;\n }\n },\n }\n },\n});\n\nexport type { Sandbox as CreateosSandbox } from \"@nodeops-createos/sandbox\";\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["CreateosSandboxClient","CreateosSandboxNotFoundError","isUnifiedVolumeMounts","resolveVolumeRef","defineProvider","withVolumeSettle"],"mappings":";;;;;;AAiDA,IAAM,aAAA,GAAgB,kBAAA;AAOtB,IAAM,aAAA,uBAAoB,OAAA,EAAiC;AAG3D,IAAM,WAAA,uBAAkB,GAAA,EAAmC;AAO3D,SAAS,WAAW,GAAA,EAAqB;AACvC,EAAA,OAAO,CAAA,CAAA,EAAI,GAAA,CAAI,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAC,CAAA,CAAA,CAAA;AACvC;AASA,IAAM,gBAAA,GAAmB,GAAA;AAKzB,IAAM,QAAA,uBAAe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AA,QACR;AAAA,MACF,CAAA;AAAA,MACA,IAAA,EAAM,OAAO,MAAA,KAA2B;AACtC,QAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,QAAA,MAAM,QAA8D,EAAC;AACrE,QAAA,WAAA,MAAiB,KAAK,MAAA,CAAO,KAAA,CAAM,OAAA,EAAQ,QAAS,IAAA,CAAK,EAAE,EAAA,EAAI,CAAA,CAAE,IAAI,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,MAAA,EAAQ,GAAG,CAAA;AAC9F,QAAA,OAAO,KAAA;AAAA,MACT,CAAA;AAAA,MACA,MAAA,EAAQ,OAAO,MAAA,EAAwB,cAAA,KAA2B;AAChE,QAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,QAAA,IAAI;AACF,UAAA,MAAME,0BAAiB,MAAM,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,cAAc,CAAC,CAAA;AAAA,QAClE,SAAS,CAAA,EAAG;AACV,UAAA,IAAI,UAAA,CAAW,CAAC,CAAA,EAAG;AACnB,UAAA,MAAM,CAAA;AAAA,QACR;AAAA,MACF;AAAA;AACF;AAEJ,CAAC","file":"index.js","sourcesContent":["/**\n * CreateOS Sandbox Provider for ComputeSDK\n *\n * VM sandboxes backed by the NodeOps createos-sandbox control plane.\n * Thin adapter over the official `@nodeops-createos/sandbox` npm package — the same\n * SDK used across the CreateOS tooling.\n *\n * Design notes:\n * - `TInstance` is the native `@nodeops-createos/sandbox` `Sandbox` handle, so\n * `getInstance()` hands callers the full stateful API (pause / resume / fork /\n * disks / networks / bandwidth) that ComputeSDK's core surface does not model.\n * The resolving config is associated with each handle via a `WeakMap`\n * side-channel (`sandboxConfig`), so `getInfo` can honour `config` (e.g.\n * `timeout`) and its error policy without wrapping or mutating the handle.\n * - createos-sandbox sizes VMs from a fixed *shape* catalog rather than free-form\n * cpu/mem, so create() maps ComputeSDK's `cpus`/`memoryMb` onto the nearest\n * shape and honours an explicit provider-specific `shape` override.\n * - The control plane drops per-exec env server-side (env is sandbox-level,\n * set at create time), so per-command `env`/`cwd` are synthesised by\n * wrapping the command in an inline `sh -c` script.\n * - Snapshot semantics differ from running-snapshot providers (e2b/tensorlake):\n * `snapshot.create` *pauses* the sandbox (the source VM stops), and the\n * paused sandbox id IS the snapshot id. `create({ snapshotId })` forks that\n * paused bundle into a fresh sandbox.\n *\n * Error policy: provider operations fail loudly when the provider boundary is\n * broken. Only a genuine 404 (`CreateosSandboxNotFoundError`) is mapped to the\n * idempotent \"absent\" outcome (`getById` → null, `destroy`/`delete` → no-op).\n * Auth, network, validation, and server errors propagate.\n */\n\nimport { CreateosSandboxClient, CreateosSandboxNotFoundError, Sandbox } from \"@nodeops-createos/sandbox\";\nimport type {\n CreateSandboxRequest,\n ForkSandboxRequest,\n SandboxStatus,\n Shape,\n} from \"@nodeops-createos/sandbox\";\nimport { defineProvider, resolveVolumeRef, isUnifiedVolumeMounts, withVolumeSettle } from \"@computesdk/provider\";\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateSnapshotOptions,\n FileEntry,\n ListSnapshotsOptions,\n RunCommandOptions,\n InstanceInfo,\n} from \"@computesdk/provider\";\n\nconst PROVIDER_NAME = \"createos-sandbox\";\n\n/** Per-sandbox config side-channel: associates the resolving config with each\n * native handle without mutating it or wrapping `TInstance` — so `getInstance()`\n * still returns the bare native handle (the escape hatch other providers honour),\n * while `getInfo` can still reach `config` (e.g. `timeout`). Keyed weakly, so an\n * entry is collected with its sandbox. */\nconst sandboxConfig = new WeakMap<Sandbox, CreateosConfig>();\n\n/** Reuse clients for the same apiKey+baseUrl pair. */\nconst clientCache = new Map<string, CreateosSandboxClient>();\n\n/** Quote a value into one complete, self-contained shell token. Unlike the\n * framework's `escapeShellArg` (which only neutralises metacharacters *inside*\n * surrounding double quotes), this wraps in single quotes so the token is safe\n * to splice unquoted — spaces, `;`, `&`, `|`, globs and the rest cannot split\n * the command or inject syntax. Embedded single quotes are closed/escaped/reopened. */\nfunction shellQuote(arg: string): string {\n return `'${arg.replace(/'/g, \"'\\\\''\")}'`;\n}\n\n/** The framework-supplied command runner handed to filesystem callbacks. */\ntype CommandRunner = (\n sandbox: Sandbox,\n command: string,\n options?: RunCommandOptions,\n) => Promise<CommandResult>;\n\nconst FALLBACK_WORKDIR = \"/\";\n\n/** Cached `pwd` probes: the `files.*` API demands absolute paths, so relative\n * filesystem paths resolve against the cwd a `runCommand` exec would use —\n * `writeFile('a.txt')` and `cat a.txt` then agree. */\nconst workdirs = new WeakMap<Sandbox, Promise<string>>();\n\nfunction workdirOf(sandbox: Sandbox, runCommand: CommandRunner): Promise<string> {\n let probe = workdirs.get(sandbox);\n if (!probe) {\n probe = runCommand(sandbox, \"pwd\").then((r) => {\n const dir = r.stdout.trim();\n if (r.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 `workdir`. Absolute paths pass through; relative paths\n * anchor at the sandbox workdir. Empty and `.` segments are dropped; `..`\n * segments are preserved for the sandbox filesystem to resolve physically —\n * collapsing them lexically would mis-resolve when a preceding component is\n * a symlink. */\nexport function resolveSandboxPath(path: string, workdir: string): string {\n const combined = path.startsWith(\"/\") ? path : `${workdir}/${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\n/** Resolve `path` without forcing a workdir probe for absolute paths. */\nasync function resolveFsPath(\n sandbox: Sandbox,\n path: string,\n runCommand: CommandRunner,\n): Promise<string> {\n return resolveSandboxPath(\n path,\n path.startsWith(\"/\") ? \"/\" : await workdirOf(sandbox, runCommand),\n );\n}\n\n/** Memory floor (MiB) for the default shape when a create() pins no size. The\n * control plane names no default shape and `CreateSandboxRequest` requires\n * one, so the default is a client policy — the smallest *live* catalog shape\n * with at least this much RAM. Override per-create with `shape`/`config.shape`. */\nconst DEFAULT_SHAPE_MIN_MIB = 1024;\n\n/** POSIX environment variable name. Keys are spliced into a shell `export`, so\n * anything outside this grammar is rejected rather than emitted (injection). */\nconst ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nexport interface CreateosConfig {\n /** createos-sandbox API key. Falls back to the CREATEOS_SANDBOX_API_KEY env var. */\n apiKey?: string;\n /** Control-plane base URL. Falls back to the CREATEOS_SANDBOX_BASE_URL env\n * var, then the production control plane. */\n baseUrl?: string;\n /** Default shape when create options pin neither `shape` nor cpus/memoryMb. */\n shape?: string;\n /** Default rootfs catalog name or template id. Empty = host default. */\n rootfs?: string;\n /** Reported `getInfo().timeout` in ms. Informational only. */\n timeout?: number;\n}\n\n/** ComputeSDK create options plus the createos-specific fields this provider\n * reads off the (otherwise open) options bag. Declaring them turns the cast-\n * heavy decode into a typed contract and makes unsupported fields obvious. */\nexport interface CreateosCreateOptions extends CreateInstanceOptions {\n /** Explicit shape id. Overrides cpus/memoryMb selection and skips the catalog fetch. */\n shape?: string;\n /** Rootfs catalog name or template id (alias of `runtime`). */\n image?: string;\n /** Rootfs catalog name or template id (alias of `image`). */\n runtime?: string;\n /** Requested RAM; mapped onto the smallest fitting shape. */\n memoryMb?: number;\n /** Requested vCPUs; mapped onto the smallest fitting shape. */\n cpus?: number;\n /** Overlay disk size (MiB). 0 / omitted = the shape's default disk. */\n ephemeralDiskMb?: number;\n /** Enable public ingress. Defaults to false. */\n ingressEnabled?: boolean;\n /** SSH public keys to inject at boot. */\n sshPubkeys?: string[];\n /** Egress allow-list. */\n egress?: string[];\n /** Env vars set at sandbox creation. */\n envs?: Record<string, string>;\n /** Explicit sandbox name (control mints one if omitted). */\n name?: string;\n /** Snapshot id (paused sandbox) to fork from — bypasses cold create. */\n snapshotId?: string;\n}\n\n/** Production control-plane base URL, used when neither `config.baseUrl` nor\n * the CREATEOS_SANDBOX_BASE_URL env var is set. */\nconst DEFAULT_BASE_URL = \"https://api.sb.createos.sh\";\n\nfunction env(key: string): string | undefined {\n return typeof process !== \"undefined\" ? process.env?.[key] : undefined;\n}\n\nfunction resolveClient(config: CreateosConfig): CreateosSandboxClient {\n const apiKey = config.apiKey ?? env(\"CREATEOS_SANDBOX_API_KEY\");\n if (!apiKey) {\n throw new Error(\n \"Missing CreateOS API key. Provide 'apiKey' in config or set the \" +\n \"CREATEOS_SANDBOX_API_KEY environment variable.\",\n );\n }\n // Precedence: explicit config > env var > production default. A blank value\n // is treated as unset so the next source applies.\n const baseUrl =\n config.baseUrl?.trim() || env(\"CREATEOS_SANDBOX_BASE_URL\")?.trim() || DEFAULT_BASE_URL;\n const cacheKey = `${apiKey}\\0${baseUrl}`;\n let client = clientCache.get(cacheKey);\n if (!client) {\n client = new CreateosSandboxClient({ apiKey, baseUrl });\n clientCache.set(cacheKey, client);\n }\n return client;\n}\n\n/** True only for a genuine \"resource does not exist\" (404). Everything else —\n * auth, network, validation, server, rate-limit — is a broken boundary. */\nfunction isNotFound(e: unknown): boolean {\n return e instanceof CreateosSandboxNotFoundError;\n}\n\n/** Sort a catalog by ascending RAM then vCPU. Selection relies on this order;\n * the control plane gives no ordering guarantee for `listShapes()`. */\nfunction sortShapes(shapes: Shape[]): Shape[] {\n return shapes.toSorted((a, b) => a.mem_mib - b.mem_mib || a.vcpu - b.vcpu);\n}\n\n/** Pick the smallest live catalog shape that satisfies the requested cpu/mem.\n * Returns undefined when neither is given (caller applies the default). */\nexport function pickShape(shapes: Shape[], memoryMb?: number, cpus?: number): string | undefined {\n if (memoryMb == null && cpus == null) return undefined;\n const sorted = sortShapes(shapes);\n const fit = sorted.find(\n (s) => (memoryMb == null || s.mem_mib >= memoryMb) && (cpus == null || s.vcpu >= cpus),\n );\n return (fit ?? sorted[sorted.length - 1])?.id;\n}\n\n/** Default shape when create() pins neither `shape` nor cpus/memoryMb: the\n * smallest live shape meeting the RAM floor, else the smallest available. */\nexport function defaultShape(shapes: Shape[]): string | undefined {\n const sorted = sortShapes(shapes);\n const fit = sorted.find((s) => s.mem_mib >= DEFAULT_SHAPE_MIN_MIB);\n return (fit ?? sorted[0])?.id;\n}\n\n/** Cache shapes per client with a 5-minute TTL. */\nconst shapesCache = new WeakMap<CreateosSandboxClient, { shapes: Shape[]; expires: number }>();\nconst SHAPES_CACHE_TTL_MS = 5 * 60 * 1_000;\nconst FALLBACK_SHAPE = \"s-1vcpu-1gb\";\n\n/** Resolve the shape for a create() call. Fetches the live catalog only when\n * no explicit `shape` is pinned, so the explicit path never depends on\n * `/v1/shapes` being reachable. */\nasync function resolveShape(\n client: CreateosSandboxClient,\n opts: CreateosCreateOptions,\n config: CreateosConfig,\n): Promise<string> {\n const explicit = opts.shape ?? config.shape;\n if (explicit) return explicit;\n if (opts.memoryMb == null && opts.cpus == null) return FALLBACK_SHAPE;\n const now = Date.now();\n let entry = shapesCache.get(client);\n if (!entry || entry.expires < now) {\n entry = { shapes: await client.listShapes(), expires: now + SHAPES_CACHE_TTL_MS };\n shapesCache.set(client, entry);\n }\n const picked = pickShape(entry.shapes, opts.memoryMb, opts.cpus) ?? defaultShape(entry.shapes) ?? FALLBACK_SHAPE;\n return picked;\n}\n\n/** Map an createos-sandbox lifecycle state onto ComputeSDK's running|stopped|error. */\nexport function mapStatus(status: SandboxStatus): InstanceInfo[\"status\"] {\n if (status === \"running\") return \"running\";\n if (status === \"error\" || status === \"failed\") return \"error\";\n return \"stopped\";\n}\n\n/** A non-empty env record from `envs` (preferred) or the legacy `env` alias. */\nfunction envsOf(opts: CreateosCreateOptions): Record<string, string> | undefined {\n const envs = opts.envs ?? (opts as { env?: Record<string, string> }).env;\n return envs && Object.keys(envs).length > 0 ? envs : undefined;\n}\n\n/** A string[] when the value is an array, else undefined. */\nfunction strArray(v: unknown): string[] | undefined {\n return Array.isArray(v) ? (v as string[]) : undefined;\n}\n\n/** Pure map: ComputeSDK create options → createos-sandbox fork request body. */\nexport function toForkRequest(opts: CreateosCreateOptions): ForkSandboxRequest {\n const req: ForkSandboxRequest = {\n ingress_enabled: opts.ingressEnabled !== undefined ? Boolean(opts.ingressEnabled) : false,\n };\n const ssh = strArray(opts.sshPubkeys);\n if (ssh) req.ssh_pubkeys = ssh;\n const egress = strArray(opts.egress);\n if (egress) req.egress = egress;\n const envs = envsOf(opts);\n if (envs) req.envs = envs;\n return req;\n}\n\n/** Pure map: ComputeSDK create options (+ resolved shape/rootfs) → create request. */\nexport function toCreateRequest(\n opts: CreateosCreateOptions,\n shape: string,\n rootfs?: string,\n): CreateSandboxRequest {\n const req: CreateSandboxRequest = {\n shape,\n ingress_enabled: opts.ingressEnabled !== undefined ? Boolean(opts.ingressEnabled) : false,\n };\n if (rootfs) req.rootfs = rootfs;\n if (opts.name) req.name = String(opts.name);\n // Pass the requested overlay-disk size straight through; the control plane\n // validates it (0 / omitted = shape default). No client-side menu.\n if (typeof opts.ephemeralDiskMb === \"number\" && opts.ephemeralDiskMb > 0) {\n req.disk_mib = opts.ephemeralDiskMb;\n }\n const envs = envsOf(opts);\n if (envs) req.envs = envs;\n const ssh = strArray(opts.sshPubkeys);\n if (ssh) req.ssh_pubkeys = ssh;\n const egress = strArray(opts.egress);\n if (egress) req.egress = egress;\n\n // Unified mounts → createos disk attachments {disk_id, mount_path, sub_path}.\n if (isUnifiedVolumeMounts(opts.volumes)) {\n req.disks = opts.volumes.map((m) => {\n const ref = resolveVolumeRef(m.volume);\n const subPath = (m as { subPath?: string }).subPath;\n return { disk_id: ref.id ?? ref.name!, mount_path: m.mountPath, ...(subPath ? { sub_path: subPath } : {}) };\n });\n }\n return req;\n}\n\n/**\n * Disks mount asynchronously — an in-VM agent transitions each attachment\n * pending → mounted|error. Returning before \"mounted\" hands callers a dir\n * that isn't the disk yet, so every attach path polls `listDisks()` until\n * the attachment settles (bounded, ~90s). `mount_error` surfaces on failure.\n */\nasync function waitForDiskMounted(sandbox: Sandbox, mountPath: string, deadlineMs = 90_000): Promise<void> {\n const deadline = Date.now() + deadlineMs;\n for (;;) {\n const disks = await sandbox.listDisks();\n const att = disks.find((d) => d.mount_path === mountPath);\n if (att?.mount_status === \"mounted\") return;\n if (att?.mount_status === \"error\") {\n throw new Error(`createos disk mount failed at ${mountPath}: ${att.mount_error ?? \"unknown\"}`);\n }\n if (Date.now() >= deadline) {\n throw new Error(\n `createos disk mount at ${mountPath} still ${att?.mount_status ?? \"absent\"} after ${deadlineMs}ms`,\n );\n }\n await new Promise((r) => setTimeout(r, 2000));\n }\n}\n\n/** Wrap a command so per-call cwd/env/background work despite the server dropping\n * exec env. Env *keys* are validated before being spliced into `export` —\n * values are shell-quoted, but a malformed key would otherwise be raw shell. */\nexport function buildScript(command: string, options?: RunCommandOptions): string {\n let script = command;\n if (options?.cwd) script = `cd ${shellQuote(options.cwd)} && ${script}`;\n if (options?.env && Object.keys(options.env).length > 0) {\n const exports = Object.entries(options.env)\n .map(([k, v]) => {\n if (!ENV_KEY_RE.test(k)) {\n throw new Error(\n `Invalid environment variable name ${JSON.stringify(k)}: ` +\n `must match ${ENV_KEY_RE.source}.`,\n );\n }\n return `export ${k}=${shellQuote(String(v))}`;\n })\n .join(\"; \");\n script = `${exports}; ${script}`;\n }\n if (options?.background) {\n script = `nohup sh -c ${shellQuote(script)} > /dev/null 2>&1 &`;\n }\n return script;\n}\n\n/** Parse `ls -lA --time-style=+%s` output into ComputeSDK FileEntry rows. */\nexport function parseLsOutput(stdout: string): FileEntry[] {\n const entries: FileEntry[] = [];\n for (const line of stdout.split(\"\\n\")) {\n if (!line || line.startsWith(\"total \")) continue;\n const m = line.match(/^(\\S+)\\s+\\d+\\s+\\S+\\s+\\S+\\s+(\\d+)\\s+(\\d+)\\s+(.+)$/);\n if (!m) continue;\n const name = m[4]!.replace(/ -> .*$/, \"\"); // strip symlink target\n entries.push({\n name,\n type: m[1]!.startsWith(\"d\") ? \"directory\" : \"file\",\n size: Number(m[2]),\n modified: new Date(Number(m[3]) * 1000),\n });\n }\n return entries;\n}\n\nexport const createosSandbox = defineProvider<Sandbox, CreateosConfig>({\n name: PROVIDER_NAME,\n methods: {\n instances: {\n create: async (config: CreateosConfig, options?: CreateInstanceOptions) => {\n const client = resolveClient(config);\n const opts = (options ?? {}) as CreateosCreateOptions;\n\n // A snapshot id is a paused sandbox: fork it into a fresh sandbox.\n if (opts.snapshotId) {\n const source = await client.getSandbox(opts.snapshotId);\n const forked = await source.fork(toForkRequest(opts));\n // Surface lifecycle failures: a fork that never reaches \"running\"\n // (or hits a terminal state) must not be reported as success.\n await forked.waitUntilRunning();\n sandboxConfig.set(forked, config);\n // ForkSandboxRequest carries no `disks` field — attach requested\n // volumes post-fork through the runtime disk API instead. Destroy\n // the fork on failure — it is already running, and the caller gets\n // no instance handle to clean up with.\n if (isUnifiedVolumeMounts(opts.volumes)) {\n try {\n for (const m of opts.volumes) {\n const ref = resolveVolumeRef(m.volume);\n const subPath = (m as { subPath?: string }).subPath;\n await forked.attachDisk({ diskId: ref.id ?? ref.name!, mountPath: m.mountPath, ...(subPath ? { subPath } : {}) });\n await waitForDiskMounted(forked, m.mountPath);\n }\n } catch (err) {\n await forked.destroy().catch(() => {});\n throw err;\n }\n }\n return { instance: forked, instanceId: forked.id };\n }\n\n const shape = await resolveShape(client, opts, config);\n const rootfs = opts.image ?? opts.runtime ?? config.rootfs ?? \"devbox:1\";\n const sandbox = await client.createSandbox(toCreateRequest(opts, shape, rootfs));\n sandboxConfig.set(sandbox, config);\n // Disks attach at create but mount asynchronously in the guest —\n // wait for every requested mount before handing back the instance.\n // Destroy the sandbox on failure — the caller gets no handle to\n // clean it up with (same contract as the fork path above).\n if (Array.isArray(opts.volumes)) {\n try {\n for (const m of opts.volumes) await waitForDiskMounted(sandbox, m.mountPath);\n } catch (err) {\n await sandbox.destroy().catch(() => {});\n throw err;\n }\n }\n return { instance: sandbox, instanceId: sandbox.id };\n },\n\n getById: async (config: CreateosConfig, sandboxId: string) => {\n const client = resolveClient(config);\n try {\n const sandbox = await client.getSandbox(sandboxId);\n sandboxConfig.set(sandbox, config);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch (e) {\n if (isNotFound(e)) return null;\n throw e;\n }\n },\n\n list: async (config: CreateosConfig) => {\n const client = resolveClient(config);\n // No catch: a failed list is a broken boundary, not an empty account.\n const sandboxes = await client.listSandboxes({ limit: 100 });\n return sandboxes.map((sandbox) => {\n sandboxConfig.set(sandbox, config);\n return { instance: sandbox, instanceId: sandbox.id };\n });\n },\n\n destroy: async (config: CreateosConfig, sandboxId: string) => {\n const client = resolveClient(config);\n try {\n await client.http.request(\n \"DELETE\",\n `/v1/sandboxes/${encodeURIComponent(sandboxId)}`,\n );\n } catch (e) {\n if (isNotFound(e)) return; // already gone; destroy is idempotent\n throw e;\n }\n },\n\n runCommand: async (\n sandbox: Sandbox,\n command: string,\n options?: RunCommandOptions,\n ): Promise<CommandResult> => {\n // `sh -c` (not `bash -lc`): POSIX-portable so bare rootfses without\n // bash still run. buildScript only emits POSIX constructs. Transport /\n // auth errors propagate; a command that ran reports its own exit code.\n const execOpts = options?.timeout ? { timeoutMs: options.timeout } : undefined;\n const { result, exec_ms } = await sandbox.runCommand(\"sh\", [\n \"-c\",\n buildScript(command, options),\n ], execOpts);\n const stderr = result.error ? `${result.stderr}${result.error}` : result.stderr;\n return {\n stdout: result.stdout,\n stderr,\n exitCode: result.exit_code,\n durationMs: exec_ms,\n };\n },\n\n getInfo: async (sandbox: Sandbox): Promise<InstanceInfo> => {\n // Refresh failures propagate (no swallow): a getInfo that cannot reach\n // the control plane must surface that rather than return stale data.\n await sandbox.refresh();\n const v = sandbox.data;\n return {\n id: v.id,\n provider: PROVIDER_NAME,\n status: mapStatus(v.status),\n createdAt: new Date(v.created_at),\n timeout: sandboxConfig.get(sandbox)?.timeout ?? 0,\n metadata: {\n createosStatus: v.status,\n shape: v.shape,\n rootfs: v.rootfs,\n region: v.region,\n ip: v.ip,\n ingressEnabled: v.ingress_enabled,\n },\n };\n },\n\n getUrl: async (sandbox: Sandbox, options: { port: number; protocol?: string }) => {\n const scheme = options.protocol === \"http\" ? \"http\" : \"https\";\n return sandbox.previewUrl(options.port, { scheme });\n },\n\n // Escape hatch: the bare native @nodeops-createos/sandbox handle\n // (pause/resume/fork/disks/...).\n getInstance: (sandbox: Sandbox): Sandbox => sandbox,\n\n attachVolume: async (sandbox: Sandbox, volume, mountPath) => {\n const ref = resolveVolumeRef(volume);\n const subPath = (volume as { subPath?: string }).subPath;\n await sandbox.attachDisk({ diskId: ref.id ?? ref.name!, mountPath, ...(subPath ? { subPath } : {}) });\n await waitForDiskMounted(sandbox, mountPath);\n },\n detachVolume: async (sandbox: Sandbox, volume, mountPath) => {\n const ref = resolveVolumeRef(volume);\n await sandbox.detachDisk({ diskId: ref.id ?? ref.name!, mountPath: mountPath! });\n },\n\n filesystem: {\n readFile: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n const buf = await sandbox.files.download(\n await resolveFsPath(sandbox, path, runCommand),\n );\n return new TextDecoder().decode(buf);\n },\n writeFile: async (sandbox: Sandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n await sandbox.files.upload(\n await resolveFsPath(sandbox, path, runCommand),\n content,\n );\n },\n mkdir: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `mkdir -p ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`mkdir ${path} failed: ${r.stderr}`);\n },\n readdir: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `ls -lA --time-style=+%s ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`readdir ${path} failed: ${r.stderr}`);\n return parseLsOutput(r.stdout);\n },\n exists: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `test -e ${shellQuote(resolved)}`);\n return r.exitCode === 0;\n },\n remove: async (sandbox: Sandbox, 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 resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `rm -rf ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`remove ${path} failed: ${r.stderr}`);\n },\n },\n },\n\n snapshot: {\n create: async (\n config: CreateosConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions,\n ) => {\n const client = resolveClient(config);\n const sandbox = await client.getSandbox(sandboxId);\n // createos-sandbox has no decoupled snapshot object: pausing IS the snapshot,\n // and the paused sandbox id is the snapshot id. This stops the source VM.\n await sandbox.pause();\n // The success claim is \"it paused\" — surface a pause that timed out or\n // entered a terminal state rather than returning a phantom snapshot.\n await sandbox.waitUntilPaused();\n return {\n id: sandboxId,\n provider: PROVIDER_NAME,\n createdAt: new Date(),\n metadata: { name: options?.name, ...options?.metadata },\n };\n },\n list: async (config: CreateosConfig, _options?: ListSnapshotsOptions) => {\n const client = resolveClient(config);\n // The typed status filter excludes \"paused\", so list all and filter.\n const all = await client.listSandboxes({ limit: 500 });\n return all\n .filter((s) => s.status === \"paused\")\n .map((s) => ({\n id: s.id,\n provider: PROVIDER_NAME,\n createdAt: new Date(s.data.paused_at ?? s.data.created_at),\n }));\n },\n delete: async (config: CreateosConfig, snapshotId: string) => {\n const client = resolveClient(config);\n try {\n const sandbox = await client.getSandbox(snapshotId);\n await sandbox.destroy();\n } catch (e) {\n if (isNotFound(e)) return; // already gone\n throw e;\n }\n },\n },\n\n volume: {\n // Createos disks are registered S3 buckets: \"creating\" a volume means\n // registering bucket config + credentials server-side. The S3 details\n // don't fit the universal CreateVolumeOptions shape, so they come from\n // options.s3 ({bucket, endpoint, region?, accessKey, secretKey,\n // pathStyle?}) or the CREATEOS_S3_* env vars.\n create: async (config: CreateosConfig, options) => {\n const client = resolveClient(config);\n const s3 = (options as { s3?: Record<string, unknown> }).s3 ?? {};\n const pick = (k: string, ...envs: string[]) =>\n (s3 as Record<string, unknown>)[k] ?? envs.map((e) => env(e)).find((v) => v);\n const bucket = pick(\"bucket\", \"CREATEOS_S3_BUCKET\");\n const endpoint = pick(\"endpoint\", \"CREATEOS_S3_ENDPOINT\");\n const accessKey = pick(\"accessKey\", \"CREATEOS_S3_ACCESS_KEY\", \"CREATEOS_S3_ACCESS_KEY_ID\");\n const secretKey = pick(\"secretKey\", \"CREATEOS_S3_SECRET_KEY\", \"CREATEOS_S3_SECRET_ACCESS_KEY\");\n if (!bucket || !endpoint || !accessKey || !secretKey) {\n throw new Error(\n \"Createos volumes are registered S3 buckets: pass options.s3 = \" +\n \"{bucket, endpoint, accessKey, secretKey} or set CREATEOS_S3_BUCKET/\" +\n \"ENDPOINT/ACCESS_KEY/SECRET_KEY.\",\n );\n }\n const disk = await client.disks.create({\n name: options.name,\n kind: \"s3\",\n config: {\n bucket: String(bucket),\n endpoint: String(endpoint),\n ...(pick(\"region\", \"CREATEOS_S3_REGION\") ? { region: String(pick(\"region\", \"CREATEOS_S3_REGION\")) } : {}),\n ...(pick(\"pathStyle\", \"CREATEOS_S3_PATH_STYLE\") ? { use_path_style: true } : {}),\n },\n credentials: { access_key: String(accessKey), secret_key: String(secretKey) },\n });\n return { id: disk.id, name: disk.name, native: disk };\n },\n get: async (config: CreateosConfig, volumeIdOrName: string) => {\n const client = resolveClient(config);\n try {\n const disk = await client.disks.get(volumeIdOrName);\n return disk ? { id: disk.id, name: disk.name, native: disk } : null;\n } catch (e) {\n if (isNotFound(e)) return null;\n throw e;\n }\n },\n list: async (config: CreateosConfig) => {\n const client = resolveClient(config);\n const disks: Array<{ id: string; name: string; native: unknown }> = [];\n for await (const d of client.disks.iterate()) disks.push({ id: d.id, name: d.name, native: d });\n return disks;\n },\n delete: async (config: CreateosConfig, volumeIdOrName: string) => {\n const client = resolveClient(config);\n try {\n await withVolumeSettle(() => client.disks.delete(volumeIdOrName));\n } catch (e) {\n if (isNotFound(e)) return;\n throw e;\n }\n },\n }\n },\n});\n\nexport type { Sandbox as CreateosSandbox } from \"@nodeops-createos/sandbox\";\n"]}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CreateosSandboxClient, CreateosSandboxNotFoundError } from '@nodeops-createos/sandbox';
2
- import { defineProvider, withVolumeSettle, resolveVolumeRef } from '@computesdk/provider';
2
+ import { defineProvider, withVolumeSettle, resolveVolumeRef, isUnifiedVolumeMounts } from '@computesdk/provider';
3
3
 
4
4
  // src/index.ts
5
5
  var PROVIDER_NAME = "createos-sandbox";
@@ -136,7 +136,7 @@ function toCreateRequest(opts, shape, rootfs) {
136
136
  if (ssh) req.ssh_pubkeys = ssh;
137
137
  const egress = strArray(opts.egress);
138
138
  if (egress) req.egress = egress;
139
- if (Array.isArray(opts.volumes) && opts.volumes.length > 0) {
139
+ if (isUnifiedVolumeMounts(opts.volumes)) {
140
140
  req.disks = opts.volumes.map((m) => {
141
141
  const ref = resolveVolumeRef(m.volume);
142
142
  const subPath = m.subPath;
@@ -145,6 +145,23 @@ function toCreateRequest(opts, shape, rootfs) {
145
145
  }
146
146
  return req;
147
147
  }
148
+ async function waitForDiskMounted(sandbox, mountPath, deadlineMs = 9e4) {
149
+ const deadline = Date.now() + deadlineMs;
150
+ for (; ; ) {
151
+ const disks = await sandbox.listDisks();
152
+ const att = disks.find((d) => d.mount_path === mountPath);
153
+ if (att?.mount_status === "mounted") return;
154
+ if (att?.mount_status === "error") {
155
+ throw new Error(`createos disk mount failed at ${mountPath}: ${att.mount_error ?? "unknown"}`);
156
+ }
157
+ if (Date.now() >= deadline) {
158
+ throw new Error(
159
+ `createos disk mount at ${mountPath} still ${att?.mount_status ?? "absent"} after ${deadlineMs}ms`
160
+ );
161
+ }
162
+ await new Promise((r) => setTimeout(r, 2e3));
163
+ }
164
+ }
148
165
  function buildScript(command, options) {
149
166
  let script = command;
150
167
  if (options?.cwd) script = `cd ${shellQuote(options.cwd)} && ${script}`;
@@ -192,12 +209,13 @@ var createosSandbox = defineProvider({
192
209
  const forked = await source.fork(toForkRequest(opts));
193
210
  await forked.waitUntilRunning();
194
211
  sandboxConfig.set(forked, config);
195
- if (Array.isArray(opts.volumes) && opts.volumes.length > 0) {
212
+ if (isUnifiedVolumeMounts(opts.volumes)) {
196
213
  try {
197
214
  for (const m of opts.volumes) {
198
215
  const ref = resolveVolumeRef(m.volume);
199
216
  const subPath = m.subPath;
200
217
  await forked.attachDisk({ diskId: ref.id ?? ref.name, mountPath: m.mountPath, ...subPath ? { subPath } : {} });
218
+ await waitForDiskMounted(forked, m.mountPath);
201
219
  }
202
220
  } catch (err) {
203
221
  await forked.destroy().catch(() => {
@@ -211,6 +229,15 @@ var createosSandbox = defineProvider({
211
229
  const rootfs = opts.image ?? opts.runtime ?? config.rootfs ?? "devbox:1";
212
230
  const sandbox = await client.createSandbox(toCreateRequest(opts, shape, rootfs));
213
231
  sandboxConfig.set(sandbox, config);
232
+ if (Array.isArray(opts.volumes)) {
233
+ try {
234
+ for (const m of opts.volumes) await waitForDiskMounted(sandbox, m.mountPath);
235
+ } catch (err) {
236
+ await sandbox.destroy().catch(() => {
237
+ });
238
+ throw err;
239
+ }
240
+ }
214
241
  return { instance: sandbox, instanceId: sandbox.id };
215
242
  },
216
243
  getById: async (config, sandboxId) => {
@@ -288,6 +315,7 @@ var createosSandbox = defineProvider({
288
315
  const ref = resolveVolumeRef(volume);
289
316
  const subPath = volume.subPath;
290
317
  await sandbox.attachDisk({ diskId: ref.id ?? ref.name, mountPath, ...subPath ? { subPath } : {} });
318
+ await waitForDiskMounted(sandbox, mountPath);
291
319
  },
292
320
  detachVolume: async (sandbox, volume, mountPath) => {
293
321
  const ref = resolveVolumeRef(volume);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAiDA,IAAM,aAAA,GAAgB,kBAAA;AAOtB,IAAM,aAAA,uBAAoB,OAAA,EAAiC;AAG3D,IAAM,WAAA,uBAAkB,GAAA,EAAmC;AAO3D,SAAS,WAAW,GAAA,EAAqB;AACvC,EAAA,OAAO,CAAA,CAAA,EAAI,GAAA,CAAI,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAC,CAAA,CAAA,CAAA;AACvC;AASA,IAAM,gBAAA,GAAmB,GAAA;AAKzB,IAAM,QAAA,uBAAe,OAAA,EAAkC;AAEvD,SAAS,SAAA,CAAU,SAAkB,UAAA,EAA4C;AAC/E,EAAA,IAAI,KAAA,GAAQ,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAChC,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,KAAA,GAAQ,WAAW,OAAA,EAAS,KAAK,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,KAAM;AAC7C,MAAA,MAAM,GAAA,GAAM,CAAA,CAAE,MAAA,CAAO,IAAA,EAAK;AAC1B,MAAA,IAAI,EAAE,QAAA,KAAa,CAAA,IAAK,IAAI,UAAA,CAAW,GAAG,GAAG,OAAO,GAAA;AAIpD,MAAA,QAAA,CAAS,OAAO,OAAO,CAAA;AACvB,MAAA,OAAO,gBAAA;AAAA,IACT,CAAC,CAAA;AACD,IAAA,QAAA,CAAS,GAAA,CAAI,SAAS,KAAK,CAAA;AAC3B,IAAA,KAAA,CAAM,KAAA,CAAM,MAAM,QAAA,CAAS,MAAA,CAAO,OAAO,CAAC,CAAA;AAAA,EAC5C;AACA,EAAA,OAAO,KAAA;AACT;AAOO,SAAS,kBAAA,CAAmB,MAAc,OAAA,EAAyB;AACxE,EAAA,MAAM,QAAA,GAAW,KAAK,UAAA,CAAW,GAAG,IAAI,IAA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AC7D,QAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,QAAA,IAAI;AACF,UAAA,MAAM,IAAA,GAAO,MAAM,MAAA,CAAO,KAAA,CAAM,IAAI,cAAc,CAAA;AAClD,UAAA,OAAO,IAAA,GAAO,EAAE,EAAA,EAAI,IAAA,CAAK,EAAA,EAAI,MAAM,IAAA,CAAK,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAK,GAAI,IAAA;AAAA,QACjE,SAAS,CAAA,EAAG;AACV,UAAA,IAAI,UAAA,CAAW,CAAC,CAAA,EAAG,OAAO,IAAA;AAC1B,UAAA,MAAM,CAAA;AAAA,QACR;AAAA,MACF,CAAA;AAAA,MACA,IAAA,EAAM,OAAO,MAAA,KAA2B;AACtC,QAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,QAAA,MAAM,QAA8D,EAAC;AACrE,QAAA,WAAA,MAAiB,KAAK,MAAA,CAAO,KAAA,CAAM,OAAA,EAAQ,QAAS,IAAA,CAAK,EAAE,EAAA,EAAI,CAAA,CAAE,IAAI,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,MAAA,EAAQ,GAAG,CAAA;AAC9F,QAAA,OAAO,KAAA;AAAA,MACT,CAAA;AAAA,MACA,MAAA,EAAQ,OAAO,MAAA,EAAwB,cAAA,KAA2B;AAChE,QAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,QAAA,IAAI;AACF,UAAA,MAAM,iBAAiB,MAAM,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,cAAc,CAAC,CAAA;AAAA,QAClE,SAAS,CAAA,EAAG;AACV,UAAA,IAAI,UAAA,CAAW,CAAC,CAAA,EAAG;AACnB,UAAA,MAAM,CAAA;AAAA,QACR;AAAA,MACF;AAAA;AACF;AAEJ,CAAC","file":"index.mjs","sourcesContent":["/**\n * CreateOS Sandbox Provider for ComputeSDK\n *\n * VM sandboxes backed by the NodeOps createos-sandbox control plane.\n * Thin adapter over the official `@nodeops-createos/sandbox` npm package — the same\n * SDK used across the CreateOS tooling.\n *\n * Design notes:\n * - `TInstance` is the native `@nodeops-createos/sandbox` `Sandbox` handle, so\n * `getInstance()` hands callers the full stateful API (pause / resume / fork /\n * disks / networks / bandwidth) that ComputeSDK's core surface does not model.\n * The resolving config is associated with each handle via a `WeakMap`\n * side-channel (`sandboxConfig`), so `getInfo` can honour `config` (e.g.\n * `timeout`) and its error policy without wrapping or mutating the handle.\n * - createos-sandbox sizes VMs from a fixed *shape* catalog rather than free-form\n * cpu/mem, so create() maps ComputeSDK's `cpus`/`memoryMb` onto the nearest\n * shape and honours an explicit provider-specific `shape` override.\n * - The control plane drops per-exec env server-side (env is sandbox-level,\n * set at create time), so per-command `env`/`cwd` are synthesised by\n * wrapping the command in an inline `sh -c` script.\n * - Snapshot semantics differ from running-snapshot providers (e2b/tensorlake):\n * `snapshot.create` *pauses* the sandbox (the source VM stops), and the\n * paused sandbox id IS the snapshot id. `create({ snapshotId })` forks that\n * paused bundle into a fresh sandbox.\n *\n * Error policy: provider operations fail loudly when the provider boundary is\n * broken. Only a genuine 404 (`CreateosSandboxNotFoundError`) is mapped to the\n * idempotent \"absent\" outcome (`getById` → null, `destroy`/`delete` → no-op).\n * Auth, network, validation, and server errors propagate.\n */\n\nimport { CreateosSandboxClient, CreateosSandboxNotFoundError, Sandbox } from \"@nodeops-createos/sandbox\";\nimport type {\n CreateSandboxRequest,\n ForkSandboxRequest,\n SandboxStatus,\n Shape,\n} from \"@nodeops-createos/sandbox\";\nimport { defineProvider, resolveVolumeRef, withVolumeSettle } from \"@computesdk/provider\";\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateSnapshotOptions,\n FileEntry,\n ListSnapshotsOptions,\n RunCommandOptions,\n InstanceInfo,\n} from \"@computesdk/provider\";\n\nconst PROVIDER_NAME = \"createos-sandbox\";\n\n/** Per-sandbox config side-channel: associates the resolving config with each\n * native handle without mutating it or wrapping `TInstance` — so `getInstance()`\n * still returns the bare native handle (the escape hatch other providers honour),\n * while `getInfo` can still reach `config` (e.g. `timeout`). Keyed weakly, so an\n * entry is collected with its sandbox. */\nconst sandboxConfig = new WeakMap<Sandbox, CreateosConfig>();\n\n/** Reuse clients for the same apiKey+baseUrl pair. */\nconst clientCache = new Map<string, CreateosSandboxClient>();\n\n/** Quote a value into one complete, self-contained shell token. Unlike the\n * framework's `escapeShellArg` (which only neutralises metacharacters *inside*\n * surrounding double quotes), this wraps in single quotes so the token is safe\n * to splice unquoted — spaces, `;`, `&`, `|`, globs and the rest cannot split\n * the command or inject syntax. Embedded single quotes are closed/escaped/reopened. */\nfunction shellQuote(arg: string): string {\n return `'${arg.replace(/'/g, \"'\\\\''\")}'`;\n}\n\n/** The framework-supplied command runner handed to filesystem callbacks. */\ntype CommandRunner = (\n sandbox: Sandbox,\n command: string,\n options?: RunCommandOptions,\n) => Promise<CommandResult>;\n\nconst FALLBACK_WORKDIR = \"/\";\n\n/** Cached `pwd` probes: the `files.*` API demands absolute paths, so relative\n * filesystem paths resolve against the cwd a `runCommand` exec would use —\n * `writeFile('a.txt')` and `cat a.txt` then agree. */\nconst workdirs = new WeakMap<Sandbox, Promise<string>>();\n\nfunction workdirOf(sandbox: Sandbox, runCommand: CommandRunner): Promise<string> {\n let probe = workdirs.get(sandbox);\n if (!probe) {\n probe = runCommand(sandbox, \"pwd\").then((r) => {\n const dir = r.stdout.trim();\n if (r.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 `workdir`. Absolute paths pass through; relative paths\n * anchor at the sandbox workdir. Empty and `.` segments are dropped; `..`\n * segments are preserved for the sandbox filesystem to resolve physically —\n * collapsing them lexically would mis-resolve when a preceding component is\n * a symlink. */\nexport function resolveSandboxPath(path: string, workdir: string): string {\n const combined = path.startsWith(\"/\") ? path : `${workdir}/${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\n/** Resolve `path` without forcing a workdir probe for absolute paths. */\nasync function resolveFsPath(\n sandbox: Sandbox,\n path: string,\n runCommand: CommandRunner,\n): Promise<string> {\n return resolveSandboxPath(\n path,\n path.startsWith(\"/\") ? \"/\" : await workdirOf(sandbox, runCommand),\n );\n}\n\n/** Memory floor (MiB) for the default shape when a create() pins no size. The\n * control plane names no default shape and `CreateSandboxRequest` requires\n * one, so the default is a client policy — the smallest *live* catalog shape\n * with at least this much RAM. Override per-create with `shape`/`config.shape`. */\nconst DEFAULT_SHAPE_MIN_MIB = 1024;\n\n/** POSIX environment variable name. Keys are spliced into a shell `export`, so\n * anything outside this grammar is rejected rather than emitted (injection). */\nconst ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nexport interface CreateosConfig {\n /** createos-sandbox API key. Falls back to the CREATEOS_SANDBOX_API_KEY env var. */\n apiKey?: string;\n /** Control-plane base URL. Falls back to the CREATEOS_SANDBOX_BASE_URL env\n * var, then the production control plane. */\n baseUrl?: string;\n /** Default shape when create options pin neither `shape` nor cpus/memoryMb. */\n shape?: string;\n /** Default rootfs catalog name or template id. Empty = host default. */\n rootfs?: string;\n /** Reported `getInfo().timeout` in ms. Informational only. */\n timeout?: number;\n}\n\n/** ComputeSDK create options plus the createos-specific fields this provider\n * reads off the (otherwise open) options bag. Declaring them turns the cast-\n * heavy decode into a typed contract and makes unsupported fields obvious. */\nexport interface CreateosCreateOptions extends CreateInstanceOptions {\n /** Explicit shape id. Overrides cpus/memoryMb selection and skips the catalog fetch. */\n shape?: string;\n /** Rootfs catalog name or template id (alias of `runtime`). */\n image?: string;\n /** Rootfs catalog name or template id (alias of `image`). */\n runtime?: string;\n /** Requested RAM; mapped onto the smallest fitting shape. */\n memoryMb?: number;\n /** Requested vCPUs; mapped onto the smallest fitting shape. */\n cpus?: number;\n /** Overlay disk size (MiB). 0 / omitted = the shape's default disk. */\n ephemeralDiskMb?: number;\n /** Enable public ingress. Defaults to false. */\n ingressEnabled?: boolean;\n /** SSH public keys to inject at boot. */\n sshPubkeys?: string[];\n /** Egress allow-list. */\n egress?: string[];\n /** Env vars set at sandbox creation. */\n envs?: Record<string, string>;\n /** Explicit sandbox name (control mints one if omitted). */\n name?: string;\n /** Snapshot id (paused sandbox) to fork from — bypasses cold create. */\n snapshotId?: string;\n}\n\n/** Production control-plane base URL, used when neither `config.baseUrl` nor\n * the CREATEOS_SANDBOX_BASE_URL env var is set. */\nconst DEFAULT_BASE_URL = \"https://api.sb.createos.sh\";\n\nfunction env(key: string): string | undefined {\n return typeof process !== \"undefined\" ? process.env?.[key] : undefined;\n}\n\nfunction resolveClient(config: CreateosConfig): CreateosSandboxClient {\n const apiKey = config.apiKey ?? env(\"CREATEOS_SANDBOX_API_KEY\");\n if (!apiKey) {\n throw new Error(\n \"Missing CreateOS API key. Provide 'apiKey' in config or set the \" +\n \"CREATEOS_SANDBOX_API_KEY environment variable.\",\n );\n }\n // Precedence: explicit config > env var > production default. A blank value\n // is treated as unset so the next source applies.\n const baseUrl =\n config.baseUrl?.trim() || env(\"CREATEOS_SANDBOX_BASE_URL\")?.trim() || DEFAULT_BASE_URL;\n const cacheKey = `${apiKey}\\0${baseUrl}`;\n let client = clientCache.get(cacheKey);\n if (!client) {\n client = new CreateosSandboxClient({ apiKey, baseUrl });\n clientCache.set(cacheKey, client);\n }\n return client;\n}\n\n/** True only for a genuine \"resource does not exist\" (404). Everything else —\n * auth, network, validation, server, rate-limit — is a broken boundary. */\nfunction isNotFound(e: unknown): boolean {\n return e instanceof CreateosSandboxNotFoundError;\n}\n\n/** Sort a catalog by ascending RAM then vCPU. Selection relies on this order;\n * the control plane gives no ordering guarantee for `listShapes()`. */\nfunction sortShapes(shapes: Shape[]): Shape[] {\n return shapes.toSorted((a, b) => a.mem_mib - b.mem_mib || a.vcpu - b.vcpu);\n}\n\n/** Pick the smallest live catalog shape that satisfies the requested cpu/mem.\n * Returns undefined when neither is given (caller applies the default). */\nexport function pickShape(shapes: Shape[], memoryMb?: number, cpus?: number): string | undefined {\n if (memoryMb == null && cpus == null) return undefined;\n const sorted = sortShapes(shapes);\n const fit = sorted.find(\n (s) => (memoryMb == null || s.mem_mib >= memoryMb) && (cpus == null || s.vcpu >= cpus),\n );\n return (fit ?? sorted[sorted.length - 1])?.id;\n}\n\n/** Default shape when create() pins neither `shape` nor cpus/memoryMb: the\n * smallest live shape meeting the RAM floor, else the smallest available. */\nexport function defaultShape(shapes: Shape[]): string | undefined {\n const sorted = sortShapes(shapes);\n const fit = sorted.find((s) => s.mem_mib >= DEFAULT_SHAPE_MIN_MIB);\n return (fit ?? sorted[0])?.id;\n}\n\n/** Cache shapes per client with a 5-minute TTL. */\nconst shapesCache = new WeakMap<CreateosSandboxClient, { shapes: Shape[]; expires: number }>();\nconst SHAPES_CACHE_TTL_MS = 5 * 60 * 1_000;\nconst FALLBACK_SHAPE = \"s-1vcpu-1gb\";\n\n/** Resolve the shape for a create() call. Fetches the live catalog only when\n * no explicit `shape` is pinned, so the explicit path never depends on\n * `/v1/shapes` being reachable. */\nasync function resolveShape(\n client: CreateosSandboxClient,\n opts: CreateosCreateOptions,\n config: CreateosConfig,\n): Promise<string> {\n const explicit = opts.shape ?? config.shape;\n if (explicit) return explicit;\n if (opts.memoryMb == null && opts.cpus == null) return FALLBACK_SHAPE;\n const now = Date.now();\n let entry = shapesCache.get(client);\n if (!entry || entry.expires < now) {\n entry = { shapes: await client.listShapes(), expires: now + SHAPES_CACHE_TTL_MS };\n shapesCache.set(client, entry);\n }\n const picked = pickShape(entry.shapes, opts.memoryMb, opts.cpus) ?? defaultShape(entry.shapes) ?? FALLBACK_SHAPE;\n return picked;\n}\n\n/** Map an createos-sandbox lifecycle state onto ComputeSDK's running|stopped|error. */\nexport function mapStatus(status: SandboxStatus): InstanceInfo[\"status\"] {\n if (status === \"running\") return \"running\";\n if (status === \"error\" || status === \"failed\") return \"error\";\n return \"stopped\";\n}\n\n/** A non-empty env record from `envs` (preferred) or the legacy `env` alias. */\nfunction envsOf(opts: CreateosCreateOptions): Record<string, string> | undefined {\n const envs = opts.envs ?? (opts as { env?: Record<string, string> }).env;\n return envs && Object.keys(envs).length > 0 ? envs : undefined;\n}\n\n/** A string[] when the value is an array, else undefined. */\nfunction strArray(v: unknown): string[] | undefined {\n return Array.isArray(v) ? (v as string[]) : undefined;\n}\n\n/** Pure map: ComputeSDK create options → createos-sandbox fork request body. */\nexport function toForkRequest(opts: CreateosCreateOptions): ForkSandboxRequest {\n const req: ForkSandboxRequest = {\n ingress_enabled: opts.ingressEnabled !== undefined ? Boolean(opts.ingressEnabled) : false,\n };\n const ssh = strArray(opts.sshPubkeys);\n if (ssh) req.ssh_pubkeys = ssh;\n const egress = strArray(opts.egress);\n if (egress) req.egress = egress;\n const envs = envsOf(opts);\n if (envs) req.envs = envs;\n return req;\n}\n\n/** Pure map: ComputeSDK create options (+ resolved shape/rootfs) → create request. */\nexport function toCreateRequest(\n opts: CreateosCreateOptions,\n shape: string,\n rootfs?: string,\n): CreateSandboxRequest {\n const req: CreateSandboxRequest = {\n shape,\n ingress_enabled: opts.ingressEnabled !== undefined ? Boolean(opts.ingressEnabled) : false,\n };\n if (rootfs) req.rootfs = rootfs;\n if (opts.name) req.name = String(opts.name);\n // Pass the requested overlay-disk size straight through; the control plane\n // validates it (0 / omitted = shape default). No client-side menu.\n if (typeof opts.ephemeralDiskMb === \"number\" && opts.ephemeralDiskMb > 0) {\n req.disk_mib = opts.ephemeralDiskMb;\n }\n const envs = envsOf(opts);\n if (envs) req.envs = envs;\n const ssh = strArray(opts.sshPubkeys);\n if (ssh) req.ssh_pubkeys = ssh;\n const egress = strArray(opts.egress);\n if (egress) req.egress = egress;\n\n // Unified mounts → createos disk attachments {disk_id, mount_path, sub_path}.\n if (Array.isArray(opts.volumes) && opts.volumes.length > 0) {\n req.disks = opts.volumes.map((m) => {\n const ref = resolveVolumeRef(m.volume);\n const subPath = (m as { subPath?: string }).subPath;\n return { disk_id: ref.id ?? ref.name!, mount_path: m.mountPath, ...(subPath ? { sub_path: subPath } : {}) };\n });\n }\n return req;\n}\n\n/** Wrap a command so per-call cwd/env/background work despite the server dropping\n * exec env. Env *keys* are validated before being spliced into `export` —\n * values are shell-quoted, but a malformed key would otherwise be raw shell. */\nexport function buildScript(command: string, options?: RunCommandOptions): string {\n let script = command;\n if (options?.cwd) script = `cd ${shellQuote(options.cwd)} && ${script}`;\n if (options?.env && Object.keys(options.env).length > 0) {\n const exports = Object.entries(options.env)\n .map(([k, v]) => {\n if (!ENV_KEY_RE.test(k)) {\n throw new Error(\n `Invalid environment variable name ${JSON.stringify(k)}: ` +\n `must match ${ENV_KEY_RE.source}.`,\n );\n }\n return `export ${k}=${shellQuote(String(v))}`;\n })\n .join(\"; \");\n script = `${exports}; ${script}`;\n }\n if (options?.background) {\n script = `nohup sh -c ${shellQuote(script)} > /dev/null 2>&1 &`;\n }\n return script;\n}\n\n/** Parse `ls -lA --time-style=+%s` output into ComputeSDK FileEntry rows. */\nexport function parseLsOutput(stdout: string): FileEntry[] {\n const entries: FileEntry[] = [];\n for (const line of stdout.split(\"\\n\")) {\n if (!line || line.startsWith(\"total \")) continue;\n const m = line.match(/^(\\S+)\\s+\\d+\\s+\\S+\\s+\\S+\\s+(\\d+)\\s+(\\d+)\\s+(.+)$/);\n if (!m) continue;\n const name = m[4]!.replace(/ -> .*$/, \"\"); // strip symlink target\n entries.push({\n name,\n type: m[1]!.startsWith(\"d\") ? \"directory\" : \"file\",\n size: Number(m[2]),\n modified: new Date(Number(m[3]) * 1000),\n });\n }\n return entries;\n}\n\nexport const createosSandbox = defineProvider<Sandbox, CreateosConfig>({\n name: PROVIDER_NAME,\n methods: {\n instances: {\n create: async (config: CreateosConfig, options?: CreateInstanceOptions) => {\n const client = resolveClient(config);\n const opts = (options ?? {}) as CreateosCreateOptions;\n\n // A snapshot id is a paused sandbox: fork it into a fresh sandbox.\n if (opts.snapshotId) {\n const source = await client.getSandbox(opts.snapshotId);\n const forked = await source.fork(toForkRequest(opts));\n // Surface lifecycle failures: a fork that never reaches \"running\"\n // (or hits a terminal state) must not be reported as success.\n await forked.waitUntilRunning();\n sandboxConfig.set(forked, config);\n // ForkSandboxRequest carries no `disks` field — attach requested\n // volumes post-fork through the runtime disk API instead. Destroy\n // the fork on failure — it is already running, and the caller gets\n // no instance handle to clean up with.\n if (Array.isArray(opts.volumes) && opts.volumes.length > 0) {\n try {\n for (const m of opts.volumes) {\n const ref = resolveVolumeRef(m.volume);\n const subPath = (m as { subPath?: string }).subPath;\n await forked.attachDisk({ diskId: ref.id ?? ref.name!, mountPath: m.mountPath, ...(subPath ? { subPath } : {}) });\n }\n } catch (err) {\n await forked.destroy().catch(() => {});\n throw err;\n }\n }\n return { instance: forked, instanceId: forked.id };\n }\n\n const shape = await resolveShape(client, opts, config);\n const rootfs = opts.image ?? opts.runtime ?? config.rootfs ?? \"devbox:1\";\n const sandbox = await client.createSandbox(toCreateRequest(opts, shape, rootfs));\n sandboxConfig.set(sandbox, config);\n return { instance: sandbox, instanceId: sandbox.id };\n },\n\n getById: async (config: CreateosConfig, sandboxId: string) => {\n const client = resolveClient(config);\n try {\n const sandbox = await client.getSandbox(sandboxId);\n sandboxConfig.set(sandbox, config);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch (e) {\n if (isNotFound(e)) return null;\n throw e;\n }\n },\n\n list: async (config: CreateosConfig) => {\n const client = resolveClient(config);\n // No catch: a failed list is a broken boundary, not an empty account.\n const sandboxes = await client.listSandboxes({ limit: 100 });\n return sandboxes.map((sandbox) => {\n sandboxConfig.set(sandbox, config);\n return { instance: sandbox, instanceId: sandbox.id };\n });\n },\n\n destroy: async (config: CreateosConfig, sandboxId: string) => {\n const client = resolveClient(config);\n try {\n await client.http.request(\n \"DELETE\",\n `/v1/sandboxes/${encodeURIComponent(sandboxId)}`,\n );\n } catch (e) {\n if (isNotFound(e)) return; // already gone; destroy is idempotent\n throw e;\n }\n },\n\n runCommand: async (\n sandbox: Sandbox,\n command: string,\n options?: RunCommandOptions,\n ): Promise<CommandResult> => {\n // `sh -c` (not `bash -lc`): POSIX-portable so bare rootfses without\n // bash still run. buildScript only emits POSIX constructs. Transport /\n // auth errors propagate; a command that ran reports its own exit code.\n const execOpts = options?.timeout ? { timeoutMs: options.timeout } : undefined;\n const { result, exec_ms } = await sandbox.runCommand(\"sh\", [\n \"-c\",\n buildScript(command, options),\n ], execOpts);\n const stderr = result.error ? `${result.stderr}${result.error}` : result.stderr;\n return {\n stdout: result.stdout,\n stderr,\n exitCode: result.exit_code,\n durationMs: exec_ms,\n };\n },\n\n getInfo: async (sandbox: Sandbox): Promise<InstanceInfo> => {\n // Refresh failures propagate (no swallow): a getInfo that cannot reach\n // the control plane must surface that rather than return stale data.\n await sandbox.refresh();\n const v = sandbox.data;\n return {\n id: v.id,\n provider: PROVIDER_NAME,\n status: mapStatus(v.status),\n createdAt: new Date(v.created_at),\n timeout: sandboxConfig.get(sandbox)?.timeout ?? 0,\n metadata: {\n createosStatus: v.status,\n shape: v.shape,\n rootfs: v.rootfs,\n region: v.region,\n ip: v.ip,\n ingressEnabled: v.ingress_enabled,\n },\n };\n },\n\n getUrl: async (sandbox: Sandbox, options: { port: number; protocol?: string }) => {\n const scheme = options.protocol === \"http\" ? \"http\" : \"https\";\n return sandbox.previewUrl(options.port, { scheme });\n },\n\n // Escape hatch: the bare native @nodeops-createos/sandbox handle\n // (pause/resume/fork/disks/...).\n getInstance: (sandbox: Sandbox): Sandbox => sandbox,\n\n attachVolume: async (sandbox: Sandbox, volume, mountPath) => {\n const ref = resolveVolumeRef(volume);\n const subPath = (volume as { subPath?: string }).subPath;\n await sandbox.attachDisk({ diskId: ref.id ?? ref.name!, mountPath, ...(subPath ? { subPath } : {}) });\n },\n detachVolume: async (sandbox: Sandbox, volume, mountPath) => {\n const ref = resolveVolumeRef(volume);\n await sandbox.detachDisk({ diskId: ref.id ?? ref.name!, mountPath: mountPath! });\n },\n\n filesystem: {\n readFile: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n const buf = await sandbox.files.download(\n await resolveFsPath(sandbox, path, runCommand),\n );\n return new TextDecoder().decode(buf);\n },\n writeFile: async (sandbox: Sandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n await sandbox.files.upload(\n await resolveFsPath(sandbox, path, runCommand),\n content,\n );\n },\n mkdir: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `mkdir -p ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`mkdir ${path} failed: ${r.stderr}`);\n },\n readdir: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `ls -lA --time-style=+%s ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`readdir ${path} failed: ${r.stderr}`);\n return parseLsOutput(r.stdout);\n },\n exists: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `test -e ${shellQuote(resolved)}`);\n return r.exitCode === 0;\n },\n remove: async (sandbox: Sandbox, 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 resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `rm -rf ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`remove ${path} failed: ${r.stderr}`);\n },\n },\n },\n\n snapshot: {\n create: async (\n config: CreateosConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions,\n ) => {\n const client = resolveClient(config);\n const sandbox = await client.getSandbox(sandboxId);\n // createos-sandbox has no decoupled snapshot object: pausing IS the snapshot,\n // and the paused sandbox id is the snapshot id. This stops the source VM.\n await sandbox.pause();\n // The success claim is \"it paused\" — surface a pause that timed out or\n // entered a terminal state rather than returning a phantom snapshot.\n await sandbox.waitUntilPaused();\n return {\n id: sandboxId,\n provider: PROVIDER_NAME,\n createdAt: new Date(),\n metadata: { name: options?.name, ...options?.metadata },\n };\n },\n list: async (config: CreateosConfig, _options?: ListSnapshotsOptions) => {\n const client = resolveClient(config);\n // The typed status filter excludes \"paused\", so list all and filter.\n const all = await client.listSandboxes({ limit: 500 });\n return all\n .filter((s) => s.status === \"paused\")\n .map((s) => ({\n id: s.id,\n provider: PROVIDER_NAME,\n createdAt: new Date(s.data.paused_at ?? s.data.created_at),\n }));\n },\n delete: async (config: CreateosConfig, snapshotId: string) => {\n const client = resolveClient(config);\n try {\n const sandbox = await client.getSandbox(snapshotId);\n await sandbox.destroy();\n } catch (e) {\n if (isNotFound(e)) return; // already gone\n throw e;\n }\n },\n },\n\n volume: {\n // Createos disks are registered S3 buckets: \"creating\" a volume means\n // registering bucket config + credentials server-side. The S3 details\n // don't fit the universal CreateVolumeOptions shape, so they come from\n // options.s3 ({bucket, endpoint, region?, accessKey, secretKey,\n // pathStyle?}) or the CREATEOS_S3_* env vars.\n create: async (config: CreateosConfig, options) => {\n const client = resolveClient(config);\n const s3 = (options as { s3?: Record<string, unknown> }).s3 ?? {};\n const pick = (k: string, ...envs: string[]) =>\n (s3 as Record<string, unknown>)[k] ?? envs.map((e) => env(e)).find((v) => v);\n const bucket = pick(\"bucket\", \"CREATEOS_S3_BUCKET\");\n const endpoint = pick(\"endpoint\", \"CREATEOS_S3_ENDPOINT\");\n const accessKey = pick(\"accessKey\", \"CREATEOS_S3_ACCESS_KEY\", \"CREATEOS_S3_ACCESS_KEY_ID\");\n const secretKey = pick(\"secretKey\", \"CREATEOS_S3_SECRET_KEY\", \"CREATEOS_S3_SECRET_ACCESS_KEY\");\n if (!bucket || !endpoint || !accessKey || !secretKey) {\n throw new Error(\n \"Createos volumes are registered S3 buckets: pass options.s3 = \" +\n \"{bucket, endpoint, accessKey, secretKey} or set CREATEOS_S3_BUCKET/\" +\n \"ENDPOINT/ACCESS_KEY/SECRET_KEY.\",\n );\n }\n const disk = await client.disks.create({\n name: options.name,\n kind: \"s3\",\n config: {\n bucket: String(bucket),\n endpoint: String(endpoint),\n ...(pick(\"region\", \"CREATEOS_S3_REGION\") ? { region: String(pick(\"region\", \"CREATEOS_S3_REGION\")) } : {}),\n ...(pick(\"pathStyle\", \"CREATEOS_S3_PATH_STYLE\") ? { use_path_style: true } : {}),\n },\n credentials: { access_key: String(accessKey), secret_key: String(secretKey) },\n });\n return { id: disk.id, name: disk.name, native: disk };\n },\n get: async (config: CreateosConfig, volumeIdOrName: string) => {\n const client = resolveClient(config);\n try {\n const disk = await client.disks.get(volumeIdOrName);\n return disk ? { id: disk.id, name: disk.name, native: disk } : null;\n } catch (e) {\n if (isNotFound(e)) return null;\n throw e;\n }\n },\n list: async (config: CreateosConfig) => {\n const client = resolveClient(config);\n const disks: Array<{ id: string; name: string; native: unknown }> = [];\n for await (const d of client.disks.iterate()) disks.push({ id: d.id, name: d.name, native: d });\n return disks;\n },\n delete: async (config: CreateosConfig, volumeIdOrName: string) => {\n const client = resolveClient(config);\n try {\n await withVolumeSettle(() => client.disks.delete(volumeIdOrName));\n } catch (e) {\n if (isNotFound(e)) return;\n throw e;\n }\n },\n }\n },\n});\n\nexport type { Sandbox as CreateosSandbox } from \"@nodeops-createos/sandbox\";\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAiDA,IAAM,aAAA,GAAgB,kBAAA;AAOtB,IAAM,aAAA,uBAAoB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AO,IAAA,GAAO,EAAE,EAAA,EAAI,IAAA,CAAK,EAAA,EAAI,MAAM,IAAA,CAAK,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAK,GAAI,IAAA;AAAA,QACjE,SAAS,CAAA,EAAG;AACV,UAAA,IAAI,UAAA,CAAW,CAAC,CAAA,EAAG,OAAO,IAAA;AAC1B,UAAA,MAAM,CAAA;AAAA,QACR;AAAA,MACF,CAAA;AAAA,MACA,IAAA,EAAM,OAAO,MAAA,KAA2B;AACtC,QAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,QAAA,MAAM,QAA8D,EAAC;AACrE,QAAA,WAAA,MAAiB,KAAK,MAAA,CAAO,KAAA,CAAM,OAAA,EAAQ,QAAS,IAAA,CAAK,EAAE,EAAA,EAAI,CAAA,CAAE,IAAI,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,MAAA,EAAQ,GAAG,CAAA;AAC9F,QAAA,OAAO,KAAA;AAAA,MACT,CAAA;AAAA,MACA,MAAA,EAAQ,OAAO,MAAA,EAAwB,cAAA,KAA2B;AAChE,QAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,QAAA,IAAI;AACF,UAAA,MAAM,iBAAiB,MAAM,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,cAAc,CAAC,CAAA;AAAA,QAClE,SAAS,CAAA,EAAG;AACV,UAAA,IAAI,UAAA,CAAW,CAAC,CAAA,EAAG;AACnB,UAAA,MAAM,CAAA;AAAA,QACR;AAAA,MACF;AAAA;AACF;AAEJ,CAAC","file":"index.mjs","sourcesContent":["/**\n * CreateOS Sandbox Provider for ComputeSDK\n *\n * VM sandboxes backed by the NodeOps createos-sandbox control plane.\n * Thin adapter over the official `@nodeops-createos/sandbox` npm package — the same\n * SDK used across the CreateOS tooling.\n *\n * Design notes:\n * - `TInstance` is the native `@nodeops-createos/sandbox` `Sandbox` handle, so\n * `getInstance()` hands callers the full stateful API (pause / resume / fork /\n * disks / networks / bandwidth) that ComputeSDK's core surface does not model.\n * The resolving config is associated with each handle via a `WeakMap`\n * side-channel (`sandboxConfig`), so `getInfo` can honour `config` (e.g.\n * `timeout`) and its error policy without wrapping or mutating the handle.\n * - createos-sandbox sizes VMs from a fixed *shape* catalog rather than free-form\n * cpu/mem, so create() maps ComputeSDK's `cpus`/`memoryMb` onto the nearest\n * shape and honours an explicit provider-specific `shape` override.\n * - The control plane drops per-exec env server-side (env is sandbox-level,\n * set at create time), so per-command `env`/`cwd` are synthesised by\n * wrapping the command in an inline `sh -c` script.\n * - Snapshot semantics differ from running-snapshot providers (e2b/tensorlake):\n * `snapshot.create` *pauses* the sandbox (the source VM stops), and the\n * paused sandbox id IS the snapshot id. `create({ snapshotId })` forks that\n * paused bundle into a fresh sandbox.\n *\n * Error policy: provider operations fail loudly when the provider boundary is\n * broken. Only a genuine 404 (`CreateosSandboxNotFoundError`) is mapped to the\n * idempotent \"absent\" outcome (`getById` → null, `destroy`/`delete` → no-op).\n * Auth, network, validation, and server errors propagate.\n */\n\nimport { CreateosSandboxClient, CreateosSandboxNotFoundError, Sandbox } from \"@nodeops-createos/sandbox\";\nimport type {\n CreateSandboxRequest,\n ForkSandboxRequest,\n SandboxStatus,\n Shape,\n} from \"@nodeops-createos/sandbox\";\nimport { defineProvider, resolveVolumeRef, isUnifiedVolumeMounts, withVolumeSettle } from \"@computesdk/provider\";\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateSnapshotOptions,\n FileEntry,\n ListSnapshotsOptions,\n RunCommandOptions,\n InstanceInfo,\n} from \"@computesdk/provider\";\n\nconst PROVIDER_NAME = \"createos-sandbox\";\n\n/** Per-sandbox config side-channel: associates the resolving config with each\n * native handle without mutating it or wrapping `TInstance` — so `getInstance()`\n * still returns the bare native handle (the escape hatch other providers honour),\n * while `getInfo` can still reach `config` (e.g. `timeout`). Keyed weakly, so an\n * entry is collected with its sandbox. */\nconst sandboxConfig = new WeakMap<Sandbox, CreateosConfig>();\n\n/** Reuse clients for the same apiKey+baseUrl pair. */\nconst clientCache = new Map<string, CreateosSandboxClient>();\n\n/** Quote a value into one complete, self-contained shell token. Unlike the\n * framework's `escapeShellArg` (which only neutralises metacharacters *inside*\n * surrounding double quotes), this wraps in single quotes so the token is safe\n * to splice unquoted — spaces, `;`, `&`, `|`, globs and the rest cannot split\n * the command or inject syntax. Embedded single quotes are closed/escaped/reopened. */\nfunction shellQuote(arg: string): string {\n return `'${arg.replace(/'/g, \"'\\\\''\")}'`;\n}\n\n/** The framework-supplied command runner handed to filesystem callbacks. */\ntype CommandRunner = (\n sandbox: Sandbox,\n command: string,\n options?: RunCommandOptions,\n) => Promise<CommandResult>;\n\nconst FALLBACK_WORKDIR = \"/\";\n\n/** Cached `pwd` probes: the `files.*` API demands absolute paths, so relative\n * filesystem paths resolve against the cwd a `runCommand` exec would use —\n * `writeFile('a.txt')` and `cat a.txt` then agree. */\nconst workdirs = new WeakMap<Sandbox, Promise<string>>();\n\nfunction workdirOf(sandbox: Sandbox, runCommand: CommandRunner): Promise<string> {\n let probe = workdirs.get(sandbox);\n if (!probe) {\n probe = runCommand(sandbox, \"pwd\").then((r) => {\n const dir = r.stdout.trim();\n if (r.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 `workdir`. Absolute paths pass through; relative paths\n * anchor at the sandbox workdir. Empty and `.` segments are dropped; `..`\n * segments are preserved for the sandbox filesystem to resolve physically —\n * collapsing them lexically would mis-resolve when a preceding component is\n * a symlink. */\nexport function resolveSandboxPath(path: string, workdir: string): string {\n const combined = path.startsWith(\"/\") ? path : `${workdir}/${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\n/** Resolve `path` without forcing a workdir probe for absolute paths. */\nasync function resolveFsPath(\n sandbox: Sandbox,\n path: string,\n runCommand: CommandRunner,\n): Promise<string> {\n return resolveSandboxPath(\n path,\n path.startsWith(\"/\") ? \"/\" : await workdirOf(sandbox, runCommand),\n );\n}\n\n/** Memory floor (MiB) for the default shape when a create() pins no size. The\n * control plane names no default shape and `CreateSandboxRequest` requires\n * one, so the default is a client policy — the smallest *live* catalog shape\n * with at least this much RAM. Override per-create with `shape`/`config.shape`. */\nconst DEFAULT_SHAPE_MIN_MIB = 1024;\n\n/** POSIX environment variable name. Keys are spliced into a shell `export`, so\n * anything outside this grammar is rejected rather than emitted (injection). */\nconst ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nexport interface CreateosConfig {\n /** createos-sandbox API key. Falls back to the CREATEOS_SANDBOX_API_KEY env var. */\n apiKey?: string;\n /** Control-plane base URL. Falls back to the CREATEOS_SANDBOX_BASE_URL env\n * var, then the production control plane. */\n baseUrl?: string;\n /** Default shape when create options pin neither `shape` nor cpus/memoryMb. */\n shape?: string;\n /** Default rootfs catalog name or template id. Empty = host default. */\n rootfs?: string;\n /** Reported `getInfo().timeout` in ms. Informational only. */\n timeout?: number;\n}\n\n/** ComputeSDK create options plus the createos-specific fields this provider\n * reads off the (otherwise open) options bag. Declaring them turns the cast-\n * heavy decode into a typed contract and makes unsupported fields obvious. */\nexport interface CreateosCreateOptions extends CreateInstanceOptions {\n /** Explicit shape id. Overrides cpus/memoryMb selection and skips the catalog fetch. */\n shape?: string;\n /** Rootfs catalog name or template id (alias of `runtime`). */\n image?: string;\n /** Rootfs catalog name or template id (alias of `image`). */\n runtime?: string;\n /** Requested RAM; mapped onto the smallest fitting shape. */\n memoryMb?: number;\n /** Requested vCPUs; mapped onto the smallest fitting shape. */\n cpus?: number;\n /** Overlay disk size (MiB). 0 / omitted = the shape's default disk. */\n ephemeralDiskMb?: number;\n /** Enable public ingress. Defaults to false. */\n ingressEnabled?: boolean;\n /** SSH public keys to inject at boot. */\n sshPubkeys?: string[];\n /** Egress allow-list. */\n egress?: string[];\n /** Env vars set at sandbox creation. */\n envs?: Record<string, string>;\n /** Explicit sandbox name (control mints one if omitted). */\n name?: string;\n /** Snapshot id (paused sandbox) to fork from — bypasses cold create. */\n snapshotId?: string;\n}\n\n/** Production control-plane base URL, used when neither `config.baseUrl` nor\n * the CREATEOS_SANDBOX_BASE_URL env var is set. */\nconst DEFAULT_BASE_URL = \"https://api.sb.createos.sh\";\n\nfunction env(key: string): string | undefined {\n return typeof process !== \"undefined\" ? process.env?.[key] : undefined;\n}\n\nfunction resolveClient(config: CreateosConfig): CreateosSandboxClient {\n const apiKey = config.apiKey ?? env(\"CREATEOS_SANDBOX_API_KEY\");\n if (!apiKey) {\n throw new Error(\n \"Missing CreateOS API key. Provide 'apiKey' in config or set the \" +\n \"CREATEOS_SANDBOX_API_KEY environment variable.\",\n );\n }\n // Precedence: explicit config > env var > production default. A blank value\n // is treated as unset so the next source applies.\n const baseUrl =\n config.baseUrl?.trim() || env(\"CREATEOS_SANDBOX_BASE_URL\")?.trim() || DEFAULT_BASE_URL;\n const cacheKey = `${apiKey}\\0${baseUrl}`;\n let client = clientCache.get(cacheKey);\n if (!client) {\n client = new CreateosSandboxClient({ apiKey, baseUrl });\n clientCache.set(cacheKey, client);\n }\n return client;\n}\n\n/** True only for a genuine \"resource does not exist\" (404). Everything else —\n * auth, network, validation, server, rate-limit — is a broken boundary. */\nfunction isNotFound(e: unknown): boolean {\n return e instanceof CreateosSandboxNotFoundError;\n}\n\n/** Sort a catalog by ascending RAM then vCPU. Selection relies on this order;\n * the control plane gives no ordering guarantee for `listShapes()`. */\nfunction sortShapes(shapes: Shape[]): Shape[] {\n return shapes.toSorted((a, b) => a.mem_mib - b.mem_mib || a.vcpu - b.vcpu);\n}\n\n/** Pick the smallest live catalog shape that satisfies the requested cpu/mem.\n * Returns undefined when neither is given (caller applies the default). */\nexport function pickShape(shapes: Shape[], memoryMb?: number, cpus?: number): string | undefined {\n if (memoryMb == null && cpus == null) return undefined;\n const sorted = sortShapes(shapes);\n const fit = sorted.find(\n (s) => (memoryMb == null || s.mem_mib >= memoryMb) && (cpus == null || s.vcpu >= cpus),\n );\n return (fit ?? sorted[sorted.length - 1])?.id;\n}\n\n/** Default shape when create() pins neither `shape` nor cpus/memoryMb: the\n * smallest live shape meeting the RAM floor, else the smallest available. */\nexport function defaultShape(shapes: Shape[]): string | undefined {\n const sorted = sortShapes(shapes);\n const fit = sorted.find((s) => s.mem_mib >= DEFAULT_SHAPE_MIN_MIB);\n return (fit ?? sorted[0])?.id;\n}\n\n/** Cache shapes per client with a 5-minute TTL. */\nconst shapesCache = new WeakMap<CreateosSandboxClient, { shapes: Shape[]; expires: number }>();\nconst SHAPES_CACHE_TTL_MS = 5 * 60 * 1_000;\nconst FALLBACK_SHAPE = \"s-1vcpu-1gb\";\n\n/** Resolve the shape for a create() call. Fetches the live catalog only when\n * no explicit `shape` is pinned, so the explicit path never depends on\n * `/v1/shapes` being reachable. */\nasync function resolveShape(\n client: CreateosSandboxClient,\n opts: CreateosCreateOptions,\n config: CreateosConfig,\n): Promise<string> {\n const explicit = opts.shape ?? config.shape;\n if (explicit) return explicit;\n if (opts.memoryMb == null && opts.cpus == null) return FALLBACK_SHAPE;\n const now = Date.now();\n let entry = shapesCache.get(client);\n if (!entry || entry.expires < now) {\n entry = { shapes: await client.listShapes(), expires: now + SHAPES_CACHE_TTL_MS };\n shapesCache.set(client, entry);\n }\n const picked = pickShape(entry.shapes, opts.memoryMb, opts.cpus) ?? defaultShape(entry.shapes) ?? FALLBACK_SHAPE;\n return picked;\n}\n\n/** Map an createos-sandbox lifecycle state onto ComputeSDK's running|stopped|error. */\nexport function mapStatus(status: SandboxStatus): InstanceInfo[\"status\"] {\n if (status === \"running\") return \"running\";\n if (status === \"error\" || status === \"failed\") return \"error\";\n return \"stopped\";\n}\n\n/** A non-empty env record from `envs` (preferred) or the legacy `env` alias. */\nfunction envsOf(opts: CreateosCreateOptions): Record<string, string> | undefined {\n const envs = opts.envs ?? (opts as { env?: Record<string, string> }).env;\n return envs && Object.keys(envs).length > 0 ? envs : undefined;\n}\n\n/** A string[] when the value is an array, else undefined. */\nfunction strArray(v: unknown): string[] | undefined {\n return Array.isArray(v) ? (v as string[]) : undefined;\n}\n\n/** Pure map: ComputeSDK create options → createos-sandbox fork request body. */\nexport function toForkRequest(opts: CreateosCreateOptions): ForkSandboxRequest {\n const req: ForkSandboxRequest = {\n ingress_enabled: opts.ingressEnabled !== undefined ? Boolean(opts.ingressEnabled) : false,\n };\n const ssh = strArray(opts.sshPubkeys);\n if (ssh) req.ssh_pubkeys = ssh;\n const egress = strArray(opts.egress);\n if (egress) req.egress = egress;\n const envs = envsOf(opts);\n if (envs) req.envs = envs;\n return req;\n}\n\n/** Pure map: ComputeSDK create options (+ resolved shape/rootfs) → create request. */\nexport function toCreateRequest(\n opts: CreateosCreateOptions,\n shape: string,\n rootfs?: string,\n): CreateSandboxRequest {\n const req: CreateSandboxRequest = {\n shape,\n ingress_enabled: opts.ingressEnabled !== undefined ? Boolean(opts.ingressEnabled) : false,\n };\n if (rootfs) req.rootfs = rootfs;\n if (opts.name) req.name = String(opts.name);\n // Pass the requested overlay-disk size straight through; the control plane\n // validates it (0 / omitted = shape default). No client-side menu.\n if (typeof opts.ephemeralDiskMb === \"number\" && opts.ephemeralDiskMb > 0) {\n req.disk_mib = opts.ephemeralDiskMb;\n }\n const envs = envsOf(opts);\n if (envs) req.envs = envs;\n const ssh = strArray(opts.sshPubkeys);\n if (ssh) req.ssh_pubkeys = ssh;\n const egress = strArray(opts.egress);\n if (egress) req.egress = egress;\n\n // Unified mounts → createos disk attachments {disk_id, mount_path, sub_path}.\n if (isUnifiedVolumeMounts(opts.volumes)) {\n req.disks = opts.volumes.map((m) => {\n const ref = resolveVolumeRef(m.volume);\n const subPath = (m as { subPath?: string }).subPath;\n return { disk_id: ref.id ?? ref.name!, mount_path: m.mountPath, ...(subPath ? { sub_path: subPath } : {}) };\n });\n }\n return req;\n}\n\n/**\n * Disks mount asynchronously — an in-VM agent transitions each attachment\n * pending → mounted|error. Returning before \"mounted\" hands callers a dir\n * that isn't the disk yet, so every attach path polls `listDisks()` until\n * the attachment settles (bounded, ~90s). `mount_error` surfaces on failure.\n */\nasync function waitForDiskMounted(sandbox: Sandbox, mountPath: string, deadlineMs = 90_000): Promise<void> {\n const deadline = Date.now() + deadlineMs;\n for (;;) {\n const disks = await sandbox.listDisks();\n const att = disks.find((d) => d.mount_path === mountPath);\n if (att?.mount_status === \"mounted\") return;\n if (att?.mount_status === \"error\") {\n throw new Error(`createos disk mount failed at ${mountPath}: ${att.mount_error ?? \"unknown\"}`);\n }\n if (Date.now() >= deadline) {\n throw new Error(\n `createos disk mount at ${mountPath} still ${att?.mount_status ?? \"absent\"} after ${deadlineMs}ms`,\n );\n }\n await new Promise((r) => setTimeout(r, 2000));\n }\n}\n\n/** Wrap a command so per-call cwd/env/background work despite the server dropping\n * exec env. Env *keys* are validated before being spliced into `export` —\n * values are shell-quoted, but a malformed key would otherwise be raw shell. */\nexport function buildScript(command: string, options?: RunCommandOptions): string {\n let script = command;\n if (options?.cwd) script = `cd ${shellQuote(options.cwd)} && ${script}`;\n if (options?.env && Object.keys(options.env).length > 0) {\n const exports = Object.entries(options.env)\n .map(([k, v]) => {\n if (!ENV_KEY_RE.test(k)) {\n throw new Error(\n `Invalid environment variable name ${JSON.stringify(k)}: ` +\n `must match ${ENV_KEY_RE.source}.`,\n );\n }\n return `export ${k}=${shellQuote(String(v))}`;\n })\n .join(\"; \");\n script = `${exports}; ${script}`;\n }\n if (options?.background) {\n script = `nohup sh -c ${shellQuote(script)} > /dev/null 2>&1 &`;\n }\n return script;\n}\n\n/** Parse `ls -lA --time-style=+%s` output into ComputeSDK FileEntry rows. */\nexport function parseLsOutput(stdout: string): FileEntry[] {\n const entries: FileEntry[] = [];\n for (const line of stdout.split(\"\\n\")) {\n if (!line || line.startsWith(\"total \")) continue;\n const m = line.match(/^(\\S+)\\s+\\d+\\s+\\S+\\s+\\S+\\s+(\\d+)\\s+(\\d+)\\s+(.+)$/);\n if (!m) continue;\n const name = m[4]!.replace(/ -> .*$/, \"\"); // strip symlink target\n entries.push({\n name,\n type: m[1]!.startsWith(\"d\") ? \"directory\" : \"file\",\n size: Number(m[2]),\n modified: new Date(Number(m[3]) * 1000),\n });\n }\n return entries;\n}\n\nexport const createosSandbox = defineProvider<Sandbox, CreateosConfig>({\n name: PROVIDER_NAME,\n methods: {\n instances: {\n create: async (config: CreateosConfig, options?: CreateInstanceOptions) => {\n const client = resolveClient(config);\n const opts = (options ?? {}) as CreateosCreateOptions;\n\n // A snapshot id is a paused sandbox: fork it into a fresh sandbox.\n if (opts.snapshotId) {\n const source = await client.getSandbox(opts.snapshotId);\n const forked = await source.fork(toForkRequest(opts));\n // Surface lifecycle failures: a fork that never reaches \"running\"\n // (or hits a terminal state) must not be reported as success.\n await forked.waitUntilRunning();\n sandboxConfig.set(forked, config);\n // ForkSandboxRequest carries no `disks` field — attach requested\n // volumes post-fork through the runtime disk API instead. Destroy\n // the fork on failure — it is already running, and the caller gets\n // no instance handle to clean up with.\n if (isUnifiedVolumeMounts(opts.volumes)) {\n try {\n for (const m of opts.volumes) {\n const ref = resolveVolumeRef(m.volume);\n const subPath = (m as { subPath?: string }).subPath;\n await forked.attachDisk({ diskId: ref.id ?? ref.name!, mountPath: m.mountPath, ...(subPath ? { subPath } : {}) });\n await waitForDiskMounted(forked, m.mountPath);\n }\n } catch (err) {\n await forked.destroy().catch(() => {});\n throw err;\n }\n }\n return { instance: forked, instanceId: forked.id };\n }\n\n const shape = await resolveShape(client, opts, config);\n const rootfs = opts.image ?? opts.runtime ?? config.rootfs ?? \"devbox:1\";\n const sandbox = await client.createSandbox(toCreateRequest(opts, shape, rootfs));\n sandboxConfig.set(sandbox, config);\n // Disks attach at create but mount asynchronously in the guest —\n // wait for every requested mount before handing back the instance.\n // Destroy the sandbox on failure — the caller gets no handle to\n // clean it up with (same contract as the fork path above).\n if (Array.isArray(opts.volumes)) {\n try {\n for (const m of opts.volumes) await waitForDiskMounted(sandbox, m.mountPath);\n } catch (err) {\n await sandbox.destroy().catch(() => {});\n throw err;\n }\n }\n return { instance: sandbox, instanceId: sandbox.id };\n },\n\n getById: async (config: CreateosConfig, sandboxId: string) => {\n const client = resolveClient(config);\n try {\n const sandbox = await client.getSandbox(sandboxId);\n sandboxConfig.set(sandbox, config);\n return { instance: sandbox, instanceId: sandbox.id };\n } catch (e) {\n if (isNotFound(e)) return null;\n throw e;\n }\n },\n\n list: async (config: CreateosConfig) => {\n const client = resolveClient(config);\n // No catch: a failed list is a broken boundary, not an empty account.\n const sandboxes = await client.listSandboxes({ limit: 100 });\n return sandboxes.map((sandbox) => {\n sandboxConfig.set(sandbox, config);\n return { instance: sandbox, instanceId: sandbox.id };\n });\n },\n\n destroy: async (config: CreateosConfig, sandboxId: string) => {\n const client = resolveClient(config);\n try {\n await client.http.request(\n \"DELETE\",\n `/v1/sandboxes/${encodeURIComponent(sandboxId)}`,\n );\n } catch (e) {\n if (isNotFound(e)) return; // already gone; destroy is idempotent\n throw e;\n }\n },\n\n runCommand: async (\n sandbox: Sandbox,\n command: string,\n options?: RunCommandOptions,\n ): Promise<CommandResult> => {\n // `sh -c` (not `bash -lc`): POSIX-portable so bare rootfses without\n // bash still run. buildScript only emits POSIX constructs. Transport /\n // auth errors propagate; a command that ran reports its own exit code.\n const execOpts = options?.timeout ? { timeoutMs: options.timeout } : undefined;\n const { result, exec_ms } = await sandbox.runCommand(\"sh\", [\n \"-c\",\n buildScript(command, options),\n ], execOpts);\n const stderr = result.error ? `${result.stderr}${result.error}` : result.stderr;\n return {\n stdout: result.stdout,\n stderr,\n exitCode: result.exit_code,\n durationMs: exec_ms,\n };\n },\n\n getInfo: async (sandbox: Sandbox): Promise<InstanceInfo> => {\n // Refresh failures propagate (no swallow): a getInfo that cannot reach\n // the control plane must surface that rather than return stale data.\n await sandbox.refresh();\n const v = sandbox.data;\n return {\n id: v.id,\n provider: PROVIDER_NAME,\n status: mapStatus(v.status),\n createdAt: new Date(v.created_at),\n timeout: sandboxConfig.get(sandbox)?.timeout ?? 0,\n metadata: {\n createosStatus: v.status,\n shape: v.shape,\n rootfs: v.rootfs,\n region: v.region,\n ip: v.ip,\n ingressEnabled: v.ingress_enabled,\n },\n };\n },\n\n getUrl: async (sandbox: Sandbox, options: { port: number; protocol?: string }) => {\n const scheme = options.protocol === \"http\" ? \"http\" : \"https\";\n return sandbox.previewUrl(options.port, { scheme });\n },\n\n // Escape hatch: the bare native @nodeops-createos/sandbox handle\n // (pause/resume/fork/disks/...).\n getInstance: (sandbox: Sandbox): Sandbox => sandbox,\n\n attachVolume: async (sandbox: Sandbox, volume, mountPath) => {\n const ref = resolveVolumeRef(volume);\n const subPath = (volume as { subPath?: string }).subPath;\n await sandbox.attachDisk({ diskId: ref.id ?? ref.name!, mountPath, ...(subPath ? { subPath } : {}) });\n await waitForDiskMounted(sandbox, mountPath);\n },\n detachVolume: async (sandbox: Sandbox, volume, mountPath) => {\n const ref = resolveVolumeRef(volume);\n await sandbox.detachDisk({ diskId: ref.id ?? ref.name!, mountPath: mountPath! });\n },\n\n filesystem: {\n readFile: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n const buf = await sandbox.files.download(\n await resolveFsPath(sandbox, path, runCommand),\n );\n return new TextDecoder().decode(buf);\n },\n writeFile: async (sandbox: Sandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n await sandbox.files.upload(\n await resolveFsPath(sandbox, path, runCommand),\n content,\n );\n },\n mkdir: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `mkdir -p ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`mkdir ${path} failed: ${r.stderr}`);\n },\n readdir: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `ls -lA --time-style=+%s ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`readdir ${path} failed: ${r.stderr}`);\n return parseLsOutput(r.stdout);\n },\n exists: async (sandbox: Sandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const resolved = await resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `test -e ${shellQuote(resolved)}`);\n return r.exitCode === 0;\n },\n remove: async (sandbox: Sandbox, 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 resolveFsPath(sandbox, path, runCommand);\n const r = await runCommand(sandbox, `rm -rf ${shellQuote(resolved)}`);\n if (r.exitCode !== 0) throw new Error(`remove ${path} failed: ${r.stderr}`);\n },\n },\n },\n\n snapshot: {\n create: async (\n config: CreateosConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions,\n ) => {\n const client = resolveClient(config);\n const sandbox = await client.getSandbox(sandboxId);\n // createos-sandbox has no decoupled snapshot object: pausing IS the snapshot,\n // and the paused sandbox id is the snapshot id. This stops the source VM.\n await sandbox.pause();\n // The success claim is \"it paused\" — surface a pause that timed out or\n // entered a terminal state rather than returning a phantom snapshot.\n await sandbox.waitUntilPaused();\n return {\n id: sandboxId,\n provider: PROVIDER_NAME,\n createdAt: new Date(),\n metadata: { name: options?.name, ...options?.metadata },\n };\n },\n list: async (config: CreateosConfig, _options?: ListSnapshotsOptions) => {\n const client = resolveClient(config);\n // The typed status filter excludes \"paused\", so list all and filter.\n const all = await client.listSandboxes({ limit: 500 });\n return all\n .filter((s) => s.status === \"paused\")\n .map((s) => ({\n id: s.id,\n provider: PROVIDER_NAME,\n createdAt: new Date(s.data.paused_at ?? s.data.created_at),\n }));\n },\n delete: async (config: CreateosConfig, snapshotId: string) => {\n const client = resolveClient(config);\n try {\n const sandbox = await client.getSandbox(snapshotId);\n await sandbox.destroy();\n } catch (e) {\n if (isNotFound(e)) return; // already gone\n throw e;\n }\n },\n },\n\n volume: {\n // Createos disks are registered S3 buckets: \"creating\" a volume means\n // registering bucket config + credentials server-side. The S3 details\n // don't fit the universal CreateVolumeOptions shape, so they come from\n // options.s3 ({bucket, endpoint, region?, accessKey, secretKey,\n // pathStyle?}) or the CREATEOS_S3_* env vars.\n create: async (config: CreateosConfig, options) => {\n const client = resolveClient(config);\n const s3 = (options as { s3?: Record<string, unknown> }).s3 ?? {};\n const pick = (k: string, ...envs: string[]) =>\n (s3 as Record<string, unknown>)[k] ?? envs.map((e) => env(e)).find((v) => v);\n const bucket = pick(\"bucket\", \"CREATEOS_S3_BUCKET\");\n const endpoint = pick(\"endpoint\", \"CREATEOS_S3_ENDPOINT\");\n const accessKey = pick(\"accessKey\", \"CREATEOS_S3_ACCESS_KEY\", \"CREATEOS_S3_ACCESS_KEY_ID\");\n const secretKey = pick(\"secretKey\", \"CREATEOS_S3_SECRET_KEY\", \"CREATEOS_S3_SECRET_ACCESS_KEY\");\n if (!bucket || !endpoint || !accessKey || !secretKey) {\n throw new Error(\n \"Createos volumes are registered S3 buckets: pass options.s3 = \" +\n \"{bucket, endpoint, accessKey, secretKey} or set CREATEOS_S3_BUCKET/\" +\n \"ENDPOINT/ACCESS_KEY/SECRET_KEY.\",\n );\n }\n const disk = await client.disks.create({\n name: options.name,\n kind: \"s3\",\n config: {\n bucket: String(bucket),\n endpoint: String(endpoint),\n ...(pick(\"region\", \"CREATEOS_S3_REGION\") ? { region: String(pick(\"region\", \"CREATEOS_S3_REGION\")) } : {}),\n ...(pick(\"pathStyle\", \"CREATEOS_S3_PATH_STYLE\") ? { use_path_style: true } : {}),\n },\n credentials: { access_key: String(accessKey), secret_key: String(secretKey) },\n });\n return { id: disk.id, name: disk.name, native: disk };\n },\n get: async (config: CreateosConfig, volumeIdOrName: string) => {\n const client = resolveClient(config);\n try {\n const disk = await client.disks.get(volumeIdOrName);\n return disk ? { id: disk.id, name: disk.name, native: disk } : null;\n } catch (e) {\n if (isNotFound(e)) return null;\n throw e;\n }\n },\n list: async (config: CreateosConfig) => {\n const client = resolveClient(config);\n const disks: Array<{ id: string; name: string; native: unknown }> = [];\n for await (const d of client.disks.iterate()) disks.push({ id: d.id, name: d.name, native: d });\n return disks;\n },\n delete: async (config: CreateosConfig, volumeIdOrName: string) => {\n const client = resolveClient(config);\n try {\n await withVolumeSettle(() => client.disks.delete(volumeIdOrName));\n } catch (e) {\n if (isNotFound(e)) return;\n throw e;\n }\n },\n }\n },\n});\n\nexport type { Sandbox as CreateosSandbox } from \"@nodeops-createos/sandbox\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@computesdk/createos-sandbox",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "CreateOS provider for ComputeSDK — NodeOps VM sandboxes with pause/resume/fork snapshots",
5
5
  "author": "NodeOps Inc.",
6
6
  "license": "MIT",
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@nodeops-createos/sandbox": "^0.8.1",
25
- "@computesdk/provider": "2.1.18"
25
+ "@computesdk/provider": "2.1.19"
26
26
  },
27
27
  "keywords": [
28
28
  "code-execution",