{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Arker Provider - Factory-based Implementation\n *\n * Arker (https://arker.ai) runs sandboxed VMs with persistent per-VM\n * filesystems.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport { Arker, ArkerError, VM } from '@arker-ai/sdk';\nimport { defineProvider, escapeShellArg, InstanceSizeError, isUnifiedVolumeMounts, resolveVolumeRef } from '@computesdk/provider';\n\nimport type { Filesystem, Mount, PatchVmRequest, PolicyDoc, PolicyEntry, ResourcesInput, RunOptions, SyncWriteResponse } from '@arker-ai/sdk';\nimport type {\n  CommandResult,\n  InstanceInfo,\n  CreateInstanceOptions,\n  CreateSnapshotOptions,\n  FileEntry,\n  ListSnapshotsOptions,\n  ListVolumesOptions,\n  RunCommandOptions,\n  Volume,\n} from '@computesdk/provider';\n\n/** Provider used when none is configured. */\nconst DEFAULT_PROVIDER = 'aws';\n/** Region used when none is configured. */\nconst DEFAULT_REGION = 'us-east-1';\n/** Golden forked when none is requested — small Ubuntu VM with node + python. */\nconst DEFAULT_SOURCE = 'ubuntu-small';\n\n/**\n * Catalog bounds of public ArkerHQ goldens (https://arker.ai/docs/vms). A fork\n * takes `resources` per create, but only within its source VM's bounds.\n */\nconst GOLDEN_BOUNDS: Record<string, { maxVcpus: number; minMemoryMiB: number; maxMemoryMiB: number }> = {\n  'ubuntu-coding': { maxVcpus: 4, minMemoryMiB: 1024, maxMemoryMiB: 15360 },\n  'ubuntu-coding-8': { maxVcpus: 8, minMemoryMiB: 2560, maxMemoryMiB: 16384 },\n  'ubuntu-coding-32': { maxVcpus: 32, minMemoryMiB: 2560, maxMemoryMiB: 32768 },\n  'ubuntu-full-8': { maxVcpus: 8, minMemoryMiB: 2560, maxMemoryMiB: 16384 },\n};\n/** Same-toolchain goldens a sized create forks from when no source is pinned, smallest first. */\nconst SIZED_SOURCES = ['ubuntu-coding', 'ubuntu-coding-8', 'ubuntu-coding-32'];\n/**\n * Public goldens, which have no runs for a fork to copy. (A VM of your own\n * with one of these names is taken for the golden.)\n */\nconst PUBLIC_GOLDENS = new Set([DEFAULT_SOURCE, 'ubuntu-full', ...Object.keys(GOLDEN_BOUNDS)]);\n\nconst fitsGolden = (name: string, vcpus: number, memoryMiB: number): boolean => {\n  const b = GOLDEN_BOUNDS[name];\n  return !!b && vcpus <= b.maxVcpus && memoryMiB >= b.minMemoryMiB && memoryMiB <= b.maxMemoryMiB;\n};\n\nexport interface ArkerConfig {\n  /** Arker API key (starts with `ark_`). Falls back to the ARKER_API_KEY environment variable. */\n  apiKey?: string;\n  /** Region, e.g. `us-east-1`. Falls back to ARKER_REGION, then the us-east-1 default.\n   *  A combined `\"<provider>-<region>\"` value (e.g. `aws-us-east-1`) is still accepted. */\n  region?: string;\n  /** Compute provider, e.g. `aws`. Falls back to ARKER_PROVIDER, then `aws`.\n   *  The SDK requires provider and region together. */\n  provider?: string;\n  /** Golden source VM to fork on create(). Falls back to ARKER_SOURCE, then `ubuntu-small`. */\n  source?: string;\n  /** Compute platforms to fork onto, e.g. `['graviton4']`. Falls back to ARKER_PLATFORMS (comma-separated). */\n  platforms?: string[];\n  /**\n   * Keep each sandbox running between commands for its `timeout`\n   * (5 minutes when unset, `0` for no limit) or until it is\n   * destroyed; a pause suspends it and resume carries on (default `true`).\n   * With `false`, Arker pauses the VM whenever no command is running, which\n   * also freezes anything a command left running in the background, and bills\n   * only while commands run. The hold starts in the background once the\n   * sandbox's first command returns, so it adds nothing to the time to that\n   * command, and only in the process that created the sandbox: one commanded\n   * only from another process (through `getById`) is not held. Until it\n   * starts, or if the calling process exits first, the sandbox behaves as with\n   * `false`.\n   */\n  keepAwake?: boolean;\n}\n\nconst env = (key: string): string | undefined => {\n  const value = typeof process !== 'undefined' ? process.env?.[key] : undefined;\n  return value && value.trim() ? value.trim() : undefined;\n};\n\n/** Known compute providers, used to split a combined `<provider>-<region>` value. */\nconst PROVIDER_PREFIXES = ['aws', 'gcp', 'azure', 'arker'] as const;\n\n/**\n * Split a region that still carries a provider prefix (`aws-us-east-1`) into\n * its parts. Returns `[undefined, region]` when there is no prefix.\n */\nfunction splitPlacement(region: string): [string | undefined, string] {\n  for (const p of PROVIDER_PREFIXES) {\n    if (region.startsWith(`${p}-`)) return [p, region.slice(p.length + 1)];\n  }\n  return [undefined, region];\n}\n\n/**\n * Build an Arker SDK client. The SDK requires `provider` and `region`\n * together, so both always resolve to a value: config, then env\n * (ARKER_PROVIDER / ARKER_REGION), then the aws/us-east-1 default. A\n * combined `aws-us-east-1` region is split so older callers keep working.\n */\nfunction makeClient(config: ArkerConfig): Arker {\n  const rawRegion = config.region ?? env('ARKER_REGION') ?? DEFAULT_REGION;\n  const [prefixed, region] = splitPlacement(rawRegion);\n  const provider = config.provider ?? env('ARKER_PROVIDER') ?? prefixed ?? DEFAULT_PROVIDER;\n  return new Arker({\n    apiKey: config.apiKey ?? env('ARKER_API_KEY'),\n    provider,\n    region,\n  });\n}\n\n/** Raw bytes per file-transfer command (a multiple of 3, ~1 MiB of base64). */\nconst WRITE_CHUNK_BYTES = 3 * 256 * 1024;\n\n/** Name prefix marking VMs forked by `snapshot.create`. */\nconst SNAPSHOT_PREFIX = 'computesdk-snapshot-';\n\nexport interface ArkerSnapshot {\n  /** ID of the forked VM; pass it as `snapshotId` to restore. */\n  id: string;\n  provider: 'arker';\n  createdAt: Date;\n  metadata?: Record<string, any>;\n}\n\n/** Id of the schedule rule `pause` writes to suspend a VM. */\nconst PAUSE_RULE = 'computesdk-pause';\n/** How long `pause` waits for the suspend to take effect. */\nconst PAUSE_TIMEOUT_MS = 60_000;\n\n/**\n * Write (or, with `null`, remove) one policy rule by id, keeping the others.\n * The id-keyed `rules` form of `PATCH /v1/vms/{id}` postdates the SDK's\n * `PatchVmRequest` type, which still describes the deprecated list form.\n */\nconst patchRule = (vm: VM, id: string, rule: Record<string, unknown> | null) =>\n  vm.update({ policies: { rules: { [id]: rule } } } as unknown as PatchVmRequest);\n\nconst isNotFound = (err: unknown): boolean => err instanceof ArkerError && err.status === 404;\n\n/** True when an inbound rule already serves `port`. */\nconst exposesPort = (rule: PolicyEntry, port: number): boolean =>\n  rule.type === 'inbound' && rule.action !== 'deny' && !!rule.match?.ports?.includes(port);\n\n/** Single-quote a string for `sh -c`, escaping any embedded single quotes. */\nconst singleQuote = (s: string): string => `'${s.replace(/'/g, `'\\\\''`)}'`;\n\n/** Leads the hold's command, so a restore can find the copy it inherits. */\nconst KEEP_AWAKE_MARK = ': computesdk-keep-awake';\nconst KEEP_AWAKE_COMMAND = `${KEEP_AWAKE_MARK}; while :; do sleep 3600 || exit; done`;\n/** Default keep-awake window when create omits timeout. */\nconst DEFAULT_KEEP_AWAKE_MS = 300_000;\n/** How many times a hold that fails to start is tried, one try after each command. */\nconst MAX_HOLD_ATTEMPTS = 3;\n/** Sandboxes this process created that await their first command to be held awake, by VM id. */\nconst holdsToStart = new Map<string, { createdAt: number; timeoutMs: number; attempts: number }>();\n/** Keep-awake work still under way, by VM id; `pause()` and a new hold wait for it. */\nconst keepAwakeSetup = new Map<string, Promise<void>>();\n/** Sandboxes paused from this process, by VM id: a hold waits for their next command or `resume()`. */\nconst pausedVms = new Set<string>();\n/** The keep-awake window of each sandbox this process created, in ms (`0`: no limit), for `getInfo`. */\nconst keepAwakeMs = new Map<string, number>();\n\n/** Record keep-awake work for a VM, after whatever is already under way for it. */\nfunction queueKeepAwake(vmId: string, work: () => Promise<void>): void {\n  const setup: Promise<void> = (keepAwakeSetup.get(vmId) ?? Promise.resolve())\n    .then(work)\n    .catch(() => {})\n    .finally(() => {\n      if (keepAwakeSetup.get(vmId) === setup) keepAwakeSetup.delete(vmId);\n    });\n  keepAwakeSetup.set(vmId, setup);\n}\n\n/**\n * Start a sandbox's hold after a command, for what is left of its timeout. A\n * hold that fails to start is tried again after the next command, a few times;\n * one for a VM that is gone, or was destroyed meanwhile, is not.\n */\nfunction startHold(vm: VM): void {\n  const pending = holdsToStart.get(vm.id);\n  // A paused sandbox stays paused: its next command or `resume()` starts the hold.\n  if (!pending || pausedVms.has(vm.id)) return;\n  holdsToStart.delete(vm.id);\n  const left = pending.timeoutMs && pending.timeoutMs - (Date.now() - pending.createdAt);\n  if (pending.timeoutMs && left <= 0) return;\n  queueKeepAwake(vm.id, () =>\n    holdAwake(vm, left).catch((err) => {\n      if (!isNotFound(err) && keepAwakeMs.has(vm.id) && pending.attempts + 1 < MAX_HOLD_ATTEMPTS) {\n        holdsToStart.set(vm.id, { ...pending, attempts: pending.attempts + 1 });\n      }\n      throw err;\n    }),\n  );\n}\n\n/** Forget holds whose time ran out before their sandbox ran a command here. */\nfunction pruneHoldsToStart(now: number): void {\n  for (const [id, { createdAt, timeoutMs }] of holdsToStart) {\n    if (timeoutMs && now - createdAt >= timeoutMs) holdsToStart.delete(id);\n  }\n}\n\n/**\n * Keep the VM running between commands. Arker pauses a VM once none of\n * its runs is live, so one run that never finishes holds it awake.\n * A session of its own keeps commands from waiting on the hold. The\n * run dies with the VM, goes `pending` across a pause and carries on at resume,\n * and is killed at `timeoutMs`, after which the VM pauses between commands\n * again.\n */\nasync function holdAwake(vm: VM, timeoutMs: number): Promise<void> {\n  const { session_id } = await vm.createSession();\n  try {\n    await vm.run(KEEP_AWAKE_COMMAND, {\n      session_id,\n      time_to_background: 0,\n      idempotencyKey: randomUUID(),\n      ...(timeoutMs ? { timeout: Math.max(1, Math.ceil(timeoutMs / 1000)) } : {}),\n    });\n  } catch (err) {\n    await vm.deleteSession(session_id).catch(() => {});\n    throw err;\n  }\n}\n\n/**\n * A fork copies its source's live runs, so a sandbox restored from a snapshot\n * inherits the hold its source had. End it: the restore keeps itself awake by\n * its own settings. Pending runs are listed before running ones, so a copy\n * that starts meanwhile is found in the second list.\n */\nasync function endInheritedHold(vm: VM): Promise<void> {\n  const failures: unknown[] = [];\n  for (const state of ['pending', 'running'] as const) {\n    const inherited: string[] = [];\n    let cursor: string | undefined;\n    do {\n      const page = await vm.listRuns({ state, ...(cursor ? { cursor } : {}) });\n      inherited.push(...page.runs.filter((r) => r.command?.startsWith(KEEP_AWAKE_MARK)).map((r) => r.run_id));\n      cursor = page.next_cursor ?? undefined;\n    } while (cursor);\n    for (const outcome of await Promise.allSettled(inherited.map((id) => cancelRun(vm, id)))) {\n      if (outcome.status === 'rejected') failures.push(outcome.reason);\n    }\n  }\n  if (failures.length > 0) throw failures[0];\n}\n\n/** Statuses Arker answers when it can't act right now but may on a retry. */\nconst BRIEFLY_UNAVAILABLE = new Set([429, 502, 503, 504]);\nconst CANCEL_ATTEMPTS = 3;\nconst CANCEL_RETRY_MS = 1_000;\n\n/**\n * Cancel a run, trying again while Arker is briefly unavailable: the SDK does\n * not retry a cancel itself, and cancelling a run twice is harmless.\n */\nasync function cancelRun(vm: VM, runId: string): Promise<void> {\n  for (let attempt = 1; ; attempt++) {\n    try {\n      await vm.cancelRun(runId);\n      return;\n    } catch (err) {\n      if (isNotFound(err)) return;\n      const retryable = err instanceof ArkerError && BRIEFLY_UNAVAILABLE.has(err.status);\n      if (!retryable || attempt >= CANCEL_ATTEMPTS) throw err;\n      await new Promise((resolve) => setTimeout(resolve, CANCEL_RETRY_MS));\n    }\n  }\n}\n\n/** Per VM: commands of this process in its default session, and other sessions free for a command. */\nconst commandSessions = new Map<string, { inDefault: number; idle: string[] }>();\n\n/**\n * Take a session for one command. Arker runs one command at a time per\n * session, so a command that starts while another from this process is still\n * running gets a session of its own, kept for later concurrent commands,\n * instead of queueing behind it. `undefined` is the VM's default session,\n * which a VM that refuses another session falls back to.\n */\nasync function takeSession(vm: VM): Promise<string | undefined> {\n  let sessions = commandSessions.get(vm.id);\n  if (!sessions) commandSessions.set(vm.id, (sessions = { inDefault: 0, idle: [] }));\n  if (sessions.inDefault === 0) {\n    sessions.inDefault++;\n    return undefined;\n  }\n  const idle = sessions.idle.pop();\n  if (idle) return idle;\n  try {\n    return (await vm.createSession()).session_id;\n  } catch {\n    sessions.inDefault++;\n    return undefined;\n  }\n}\n\n/**\n * Give back a session from `takeSession`. A borrowed session whose run failed\n * may still be busy, so it is set aside (`reusable` false) rather than reused;\n * `runCommand` gives back one whose command timed out once Arker has ended the\n * run. None is deleted: deleting a session ends every process started in it,\n * including background ones from earlier commands.\n */\nfunction releaseSession(vmId: string, sessionId: string | undefined, reusable: boolean): void {\n  const sessions = commandSessions.get(vmId);\n  if (!sessions) return;\n  if (sessionId === undefined) sessions.inDefault = Math.max(0, sessions.inDefault - 1);\n  else if (reusable) sessions.idle.push(sessionId);\n}\n\n/** Forget what this process tracks for a VM it destroyed. */\nfunction forgetVm(vmId: string): void {\n  holdsToStart.delete(vmId);\n  pausedVms.delete(vmId);\n  keepAwakeMs.delete(vmId);\n  commandSessions.delete(vmId);\n}\n\n/** Reject once `ms` elapses, so a caller's timeout is a real deadline. */\nasync function withDeadline<T>(promise: Promise<T>, ms: number): Promise<T> {\n  let timer: ReturnType<typeof setTimeout>;\n  try {\n    return await Promise.race([\n      promise,\n      new Promise<never>((_, reject) => {\n        timer = setTimeout(() => reject(new Error(`Arker command timed out after ${ms}ms`)), ms);\n      }),\n    ]);\n  } finally {\n    clearTimeout(timer!);\n    // The losing run keeps going until its server-side kill bound; swallow its\n    // outcome so it cannot surface as an unhandled rejection.\n    promise.catch(() => {});\n  }\n}\n\n/** Ids Arker gives filesystems: `dir_` and 22 base62 characters. */\nconst FILESYSTEM_ID = /^dir_[0-9A-Za-z]{22}$/;\n/** How long a mount may take to reach the guest. */\nconst MOUNT_TIMEOUT_MS = 120_000;\n\nconst toVolume = (fs: Filesystem): Volume => ({ id: fs.filesystem_id, name: fs.name, native: fs });\n\nasync function findFilesystemById(client: Arker, id: string): Promise<Filesystem | null> {\n  try {\n    return await client.getFilesystem(id);\n  } catch (err) {\n    if (isNotFound(err)) return null;\n    throw err;\n  }\n}\n\n/** A filesystem by id or name, or `null` when there is none. Names are unique within an org. */\nasync function findFilesystem(client: Arker, idOrName: string): Promise<Filesystem | null> {\n  if (!idOrName) return null;\n  if (FILESYSTEM_ID.test(idOrName)) {\n    const fs = await findFilesystemById(client, idOrName);\n    if (fs) return fs;\n  }\n  // Names are unique regardless of case, but Arker's prefix filter matches\n  // case, so a name in another case is looked for in the full listing.\n  const wanted = idOrName.toLowerCase();\n  for (const namePrefix of [idOrName, undefined]) {\n    let cursor: string | undefined;\n    do {\n      const page = await client.listFilesystems({ ...(namePrefix ? { namePrefix } : {}), ...(cursor ? { cursor } : {}) });\n      const match = page.filesystems.find((fs) => fs.name.toLowerCase() === wanted);\n      if (match) return match;\n      cursor = page.next_cursor ?? undefined;\n    } while (cursor);\n  }\n  return null;\n}\n\n/**\n * The filesystem id behind a volume handle (its `id`) or a plain id or name.\n * Errors the adapter writes for volumes leave out the caller's names and paths:\n * ComputeSDK retries a create or attach whose error says `attached`, `mounted`\n * or `busy`, so a name or path containing one would retry a lasting failure.\n */\nasync function filesystemId(\n  client: Arker, volume: string | Volume, { allowDeleted = false } = {},\n): Promise<string> {\n  const ref = resolveVolumeRef(volume);\n  const id = typeof volume === 'string' ? undefined : ref.id;\n  if (id && allowDeleted) return id;\n  const fs = id ? await findFilesystemById(client, id) : await findFilesystem(client, ref.id ?? ref.name ?? '');\n  if (!fs) throw new Error('Arker has no filesystem with the volume\\'s id or name');\n  return fs.filesystem_id;\n}\n\n/**\n * Mount a filesystem at `path` and wait until the guest has it. The guest\n * mounts it only while the VM runs, and Arker pauses a VM as soon as its last\n * run ends, so a run waits in the guest for the mount and keeps the VM running\n * that long; the mount's own state then says whether it took. When the wait\n * fails, a mount this call made (or one that had already failed) is removed,\n * so a retry starts afresh and a late mount cannot appear after the caller got\n * an error; a working mount the sandbox already had is kept. Two concurrent\n * attaches of one volume at one path share a mount, so one's failure can\n * remove the other's; attach a volume once per path.\n */\nasync function mountFilesystem(vm: VM, filesystemId: string, path: string): Promise<void> {\n  // Arker answers a repeated mount (same filesystem and path) with the one it\n  // has, so only a new mount, or one that had already failed, is removed.\n  const before = await allMounts(vm);\n  // Arker matches a mount point by its exact path, so one the VM already has\n  // (a restore copies its source's, spelled as made) keeps the spelling it\n  // has: the same volume there is reused, another one is Arker's conflict.\n  const same =\n    before.find((m) => m.filesystem_id === filesystemId && samePath(m.path, path)) ??\n    before.find((m) => samePath(m.path, path));\n  const { mount_id } = await vm.createMount({ filesystemId, path: same?.path ?? mountPoint(path) });\n  const had = before.find((m) => m.mount_id === mount_id);\n  const sessionId = await asideSession(vm);\n  try {\n    await waitUntilMounted(vm, filesystemId, mount_id, path, sessionId, had?.state === 'failed');\n  } catch (err) {\n    if (!had || had.state === 'failed') await vm.deleteMount(mount_id).catch(() => {});\n    throw err;\n  } finally {\n    if (sessionId) vm.deleteSession(sessionId).catch(() => {});\n  }\n}\n\n/** Every mount on a VM, across pages. */\nasync function allMounts(vm: VM): Promise<Mount[]> {\n  const mounts: Mount[] = [];\n  let cursor: string | undefined;\n  do {\n    const page = await vm.listMounts(cursor ? { cursor } : {});\n    mounts.push(...page.mounts);\n    cursor = page.next_cursor ?? undefined;\n  } while (cursor);\n  return mounts;\n}\n\nasync function waitUntilMounted(\n  vm: VM, filesystemId: string, mountId: string, path: string, sessionId: string | undefined, retryingFailed: boolean,\n): Promise<void> {\n  const deadline = Date.now() + MOUNT_TIMEOUT_MS;\n  for (;;) {\n    const waitSecs = Math.max(1, Math.ceil((deadline - Date.now()) / 1000));\n    // A key makes the wait safe for the SDK to retry when Arker is briefly unavailable.\n    await vm.run(waitForMount(path, waitSecs), {\n      timeout: waitSecs + 5,\n      idempotencyKey: randomUUID(),\n      ...(sessionId ? { session_id: sessionId } : {}),\n    });\n    const { mounts } = await vm.listMounts({ filesystemId });\n    const mount = mounts.find((m) => m.mount_id === mountId);\n    if (mount?.state === 'mounted') return;\n    if (!mount) throw new Error(`Arker mount ${mountId} of ${filesystemId} on VM ${vm.id} disappeared`);\n    // A failed mount being tried again keeps its old `failed` record until\n    // the new attempt is recorded, so for it only the deadline is final.\n    if (mount.state === 'failed' && (!retryingFailed || Date.now() > deadline)) {\n      throw new Error(`Arker could not mount ${filesystemId} on VM ${vm.id}: ${mount.state_detail ?? 'failed'}`);\n    }\n    if (Date.now() > deadline) {\n      throw new Error(`Arker mount of ${filesystemId} on VM ${vm.id} still attaching after ${MOUNT_TIMEOUT_MS}ms`);\n    }\n    // The guest can show the mount a moment before Arker records it.\n    await new Promise((resolve) => setTimeout(resolve, 250));\n  }\n}\n\n/**\n * A session for the adapter's own guest commands, so they wait on no caller's\n * command (a restore's default session can hold one copied from its source);\n * the caller deletes it after, since only its commands ran there. `undefined`\n * (the default session) when the VM refuses another session.\n */\nconst asideSession = (vm: VM): Promise<string | undefined> =>\n  vm.createSession().then((s) => s.session_id, () => undefined);\n\n/**\n * A guest command that exits once `path` is a mount point, or after `secs`;\n * in a subshell, so its `exit` ends only the subshell, not a session's shell.\n */\nconst waitForMount = (path: string, secs: number): string =>\n  `(i=0; while [ $i -lt ${secs * 5} ]; do grep -qsF ${singleQuote(` ${mountPoint(path)} `)} /proc/mounts && exit 0; sleep 0.2; i=$((i+1)); done; exit 1)`;\n\n/**\n * A path as the kernel shows a mount point: no empty or `.` segments, no\n * trailing slash. Symlinks are not resolved, so a mount under one (such as\n * `/var/run`) is confirmed by Arker's mount state after the wait's deadline.\n */\nconst mountPoint = (path: string): string => `/${path.split('/').filter((s) => s && s !== '.').join('/')}`;\n\n/**\n * Mount paths must be absolute, not `/`, at most 256 bytes and without `..`,\n * as Arker requires, and Arker does not mount one with whitespace or a\n * backslash (it stays `attaching`); checked up front, with an error that\n * leaves the path out, since Arker's refusal quotes it.\n */\nconst isMountPath = (path: unknown): path is string =>\n  typeof path === 'string' && path.startsWith('/') && !/[\\s\\\\]/.test(path) &&\n  !path.includes('..') && mountPoint(path) !== '/' && Buffer.byteLength(mountPoint(path)) <= 256;\n\nconst MOUNT_PATH_RULE = 'an absolute mount path other than /, of at most 256 bytes, without whitespace, backslashes or `..`';\n\n/** Arker mounts are read-write; refuse a read-only mount rather than grant write access. */\nfunction refuseReadOnly(mounts: { readOnly?: boolean }[]): void {\n  const index = mounts.findIndex((m) => m.readOnly);\n  if (index >= 0) throw new Error(`Arker cannot mount volumes[${index}] read-only: its mounts are read-write`);\n}\n\n/** Paths name the same mount point when they normalise to the same path (symlinks unresolved). */\nconst samePath = (a: string, b: string): boolean => mountPoint(a) === mountPoint(b);\n\nexport const arker = defineProvider<VM, ArkerConfig>({\n  name: 'arker',\n  // Arker sizes per fork with `resources`, bounded by the source VM. Unpinned\n  // creates fork the smallest ubuntu-coding golden that holds the shape.\n  sizes: (config, profile, options) => {\n    // The SDK already rejects sizeClass combined with native `resources`.\n    const { vcpus, memoryMiB } = profile;\n    const sized = { resources: { vcpu: vcpus, memory_mib: memoryMiB } };\n    if (options?.snapshotId) {\n      return { status: 'unknown', reason: 'A snapshot fork keeps its source VM\\'s resource bounds, which this adapter has not verified.' };\n    }\n    if (options?.image) {\n      return { status: 'unknown', reason: 'An OCI image fork does not use a golden source VM, so its resource bounds are not the golden bounds this adapter verifies.' };\n    }\n    const pinned = options?.templateId || config.source || env('ARKER_SOURCE');\n    if (pinned) {\n      if (GOLDEN_BOUNDS[pinned] && !fitsGolden(pinned, vcpus, memoryMiB)) {\n        const b = GOLDEN_BOUNDS[pinned];\n        return { status: 'unsupported', reason: `Arker golden ${pinned} forks at 1-${b.maxVcpus} vCPU / ${b.minMemoryMiB}-${b.maxMemoryMiB} MiB, not ${vcpus} vCPU / ${memoryMiB} MiB.` };\n      }\n      return { status: 'supported', nativeOptions: sized };\n    }\n    const golden = SIZED_SOURCES.find((g) => fitsGolden(g, vcpus, memoryMiB));\n    if (!golden) {\n      return { status: 'unsupported', reason: `No public Arker golden forks at ${vcpus} vCPU / ${memoryMiB} MiB.` };\n    }\n    return { status: 'supported', nativeOptions: { templateId: golden, ...sized } };\n  },\n  methods: {\n    instances: {\n      // --- Collection operations ---\n\n      create: async (config: ArkerConfig, options?: CreateInstanceOptions) => {\n        const client = makeClient(config);\n        const name = options?.name ?? null;\n        \n        const platforms =\n          config.platforms ??\n          env('ARKER_PLATFORMS')?.split(',').map((p) => p.trim()).filter(Boolean);\n        const resources = options?.resources as ResourcesInput | undefined;\n        const source = options?.templateId || config.source || env('ARKER_SOURCE') || DEFAULT_SOURCE;\n\n        // Arker has no native `volumes` shape to pass through, so anything but\n        // unified `{ volume, mountPath }` entries is a mistake worth reporting.\n        const requested: unknown = options?.volumes;\n        const isEmpty = requested === undefined || (Array.isArray(requested) && requested.length === 0);\n        if (!isEmpty && !(isUnifiedVolumeMounts(requested) && requested.every((m) => isMountPath(m.mountPath)))) {\n          throw new Error(`Arker create: each \\`volumes\\` entry needs a \\`volume\\` and, as \\`mountPath\\`, ${MOUNT_PATH_RULE}`);\n        }\n        const volumes = isUnifiedVolumeMounts(requested) ? requested : [];\n        refuseReadOnly(volumes);\n        // Resolved before the fork, so a volume that isn't there costs no VM.\n        const mounts = await Promise.all(\n          volumes.map(async ({ volume, mountPath }) => ({ id: await filesystemId(client, volume), mountPath })),\n        );\n\n        let vm: VM;\n        try {\n          // SDK 1.x takes a single options object keyed by the wire schema\n          // (`source_vm_id` / `source_vm_name` / `image`); the old\n          // `fork(name, opts)` overload is gone.\n          const placed = { name, ...(platforms?.length ? { platforms } : {}), ...(resources ? { resources } : {}) };\n          // An OCI `image` boots a rootfs Arker converts from that image. A\n          // first conversion can outlast a gateway timeout; with a key, the\n          // SDK's retry gets back the VM it built instead of leaving it behind.\n          vm = options?.snapshotId\n            ? await client.fork({ source_vm_id: options.snapshotId, name, ...(resources ? { resources } : {}) })\n            : options?.image\n              ? await client.fork({ image: options.image, ...placed, idempotency: true })\n              : await client.fork({ source_vm_name: source, ...placed });\n        } catch (err) {\n          // The source VM bounds the resources a fork can take; Arker enforces them.\n          if (resources && err instanceof ArkerError && (err.status === 400 || err.status === 422) &&\n              /vcpu|memory|resource/i.test(err.message)) {\n            throw new InstanceSizeError(\n              'unsupported',\n              `Arker cannot fork ${options?.snapshotId ?? options?.image ?? source} at ${JSON.stringify(resources)}: ${err.message}`,\n            );\n          }\n          throw err;\n        }\n\n        if (mounts.length > 0) {\n          try {\n            for (const { id, mountPath } of mounts) await mountFilesystem(vm, id, mountPath);\n          } catch (err) {\n            // The caller never gets this VM, so it must not outlive the failure.\n            await vm.delete().catch(() => {});\n            throw err;\n          }\n        }\n\n        // Both run in the background: a fork of a VM that may carry a hold\n        // (a snapshot, or a VM of yours named as the source) ends the one it\n        // inherited at once, and a new hold starts after the first command\n        // (`startHold`). Images and public goldens carry no runs.\n        const mayInherit = options?.snapshotId || (!options?.image && !PUBLIC_GOLDENS.has(source));\n        if (mayInherit) queueKeepAwake(vm.id, () => endInheritedHold(vm));\n        if (config.keepAwake ?? true) {\n          const now = Date.now();\n          pruneHoldsToStart(now);\n          const requestedMs = options?.timeout;\n          const timeoutMs = typeof requestedMs === 'number' && Number.isFinite(requestedMs) && requestedMs >= 0 ? requestedMs : DEFAULT_KEEP_AWAKE_MS;\n          holdsToStart.set(vm.id, { createdAt: now, timeoutMs, attempts: 0 });\n          keepAwakeMs.set(vm.id, timeoutMs);\n        }\n\n        return { instance: vm, instanceId: vm.id };\n      },\n\n      getById: async (config: ArkerConfig, sandboxId: string) => {\n        const client = makeClient(config);\n        try {\n          const vm = await client.getVm(sandboxId);\n          return { instance: vm, instanceId: sandboxId };\n        } catch (err) {\n          if (err instanceof ArkerError && err.status === 404) return null;\n          throw err;\n        }\n      },\n\n      list: async (config: ArkerConfig) => {\n        const client = makeClient(config);\n        const { vms } = await client.listVms();\n        return vms.map((vm) => ({ instance: vm, instanceId: vm.id }));\n      },\n\n      destroy: async (config: ArkerConfig, sandboxId: string) => {\n        // No hold may start while the delete is under way; one still to start\n        // is kept if the delete fails and the sandbox lives on.\n        const pending = holdsToStart.get(sandboxId);\n        holdsToStart.delete(sandboxId);\n        const client = makeClient(config);\n        try {\n          await client.vm(sandboxId).delete();\n        } catch (err) {\n          if (!(err instanceof ArkerError && err.status === 404)) {\n            if (pending && keepAwakeMs.has(sandboxId)) holdsToStart.set(sandboxId, pending);\n            throw err;\n          }\n        }\n        forgetVm(sandboxId);\n      },\n\n      // --- Instance operations ---\n\n      runCommand: async (sandbox: VM, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n        const startTime = Date.now();\n\n        let fullCommand = command;\n        if (options?.cwd) fullCommand = `cd ${singleQuote(options.cwd)} && { ${fullCommand}\\n}`;\n        if (options?.env && Object.keys(options.env).length > 0) {\n          const assignments = Object.entries(options.env)\n            .map(([k, v]) => {\n              // `export NAME=value` can't quote the name, so reject any name\n              // that isn't a valid identifier.\n              if (!/^[A-Za-z_]\\w*$/.test(k)) {\n                throw new Error(`Arker runCommand: invalid environment variable name: ${JSON.stringify(k)}`);\n              }\n              return `${k}=${singleQuote(String(v))}`;\n            })\n            .join(' ');\n          // `export` (not a `NAME=value cmd` prefix) so every part of a compound\n          // command sees the variables.\n          fullCommand = `export ${assignments}; ${fullCommand}`;\n        }\n        // Wrap in `sh -c` so any cwd/env prefix detaches with the command;\n        // a bare `nohup cd … && …` would run only `cd` under nohup.\n        if (options?.background) fullCommand = `nohup sh -c ${singleQuote(fullCommand)} > /dev/null 2>&1 &`;\n\n        // Leaving `time_to_background` unset selects the SDK's synchronous\n        // overload: the SDK polls the run to completion itself and resolves\n        // `CompletedRunResult`, so there is nothing to poll or narrow here.\n        const runOptions: Omit<RunOptions, 'time_to_background'> = {};\n        // ComputeSDK's timeout is milliseconds; Arker's is seconds (rounded up so a\n        // sub-second timeout stays non-zero — 0 means \"no limit\" to Arker).\n        if (options?.timeout) runOptions.timeout = Math.max(1, Math.ceil(options.timeout / 1000));\n\n        // A command starts a paused VM, so the sandbox is no longer paused.\n        pausedVms.delete(sandbox.id);\n        const session = await takeSession(sandbox);\n        if (session) {\n          runOptions.session_id = session;\n          // Arker keeps a session's working directory and exported variables\n          // between runs. Commands in turn share the default session, so a\n          // `cd` carries into the next one; a command that ran alongside\n          // another runs in a subshell, so the session it borrowed starts the\n          // next concurrent command afresh instead of where this one left it.\n          if (!options?.background) fullCommand = `(\\n${fullCommand}\\n)`;\n        }\n\n        const run = sandbox.run(fullCommand, runOptions);\n        // The run's `timeout` is a server-side kill bound, so an over-running command\n        // comes back as a completed run with a non-zero exit code rather than a\n        // rejection. RunCommandOptions.timeout is documented as a deadline, so reject\n        // once it passes; the kill bound above stops the command server-side.\n        let result: Awaited<typeof run> | undefined;\n        try {\n          result = options?.timeout ? await withDeadline(run, options.timeout) : await run;\n        } finally {\n          // The default session is free for the next command at once: Arker\n          // queues it behind a run still dying, and it keeps the shell's cwd.\n          // A borrowed session whose command did not come back in time is\n          // busy until Arker ends the run at its `timeout`; one whose run\n          // failed is set aside.\n          if (result !== undefined || session === undefined) releaseSession(sandbox.id, session, true);\n          else run.then(() => releaseSession(sandbox.id, session, true), () => releaseSession(sandbox.id, session, false));\n          startHold(sandbox);\n        }\n        return {\n          stdout: result.stdout,\n          stderr: result.stderr,\n          exitCode: result.exitCode,\n          durationMs: Date.now() - startTime,\n        };\n      },\n\n      getInfo: async (sandbox: VM): Promise<InstanceInfo> => ({\n        id: sandbox.id,\n        provider: 'arker',\n        status: 'running',\n        createdAt: sandbox.created_at ? new Date(sandbox.created_at) : new Date(),\n        // How long the sandbox is kept awake (see `keepAwake`); `0` when it\n        // isn't, has no limit, or was created in another process.\n        timeout: keepAwakeMs.get(sandbox.id) ?? 0,\n      }),\n\n      // Arker serves a guest port once an inbound policy rule allows it, at\n      // `<vm>-<port>.<provider>-<region>.arker.app`. Add a public (`auth: open`)\n      // rule for the port, keeping the VM's other rules, and derive the URL from\n      // the hostname the policy endpoint returns.\n      getUrl: async (sandbox: VM, options: { port: number; protocol?: string }): Promise<string> => {\n        const { port } = options;\n        const current = await sandbox.getPolicies();\n        const rules = current.policies ?? [];\n        let doc: PolicyDoc = current;\n        if (!rules.some((rule) => exposesPort(rule, port))) {\n          const rule: PolicyEntry = { type: 'inbound', match: { ports: [port] }, action: 'allow', auth: 'open' };\n          doc = await sandbox.setPolicies({ policies: [...rules, rule], ...(current.secrets ? { secrets: current.secrets } : {}) });\n        }\n        const base = doc.hostname ?? current.hostname;\n        if (!base) throw new Error(`Arker did not return an inbound hostname for VM ${sandbox.id}`);\n        const dot = base.indexOf('.');\n        const host = `${base.slice(0, dot)}-${port}${base.slice(dot)}`;\n        const protocol = options.protocol ?? 'https';\n        return `${protocol}://${host}`;\n      },\n\n      getInstance: (sandbox: VM): VM => sandbox,\n\n      // A filesystem can be mounted on any number of VMs at once, at one path\n      // on each, and stays when they are destroyed. Mounting starts a paused\n      // sandbox, as a command would.\n      attachVolume: async (sandbox: VM, volume: string | Volume, mountPath: string): Promise<void> => {\n        if (!isMountPath(mountPath)) throw new Error(`Arker attachVolume needs ${MOUNT_PATH_RULE}`);\n        await mountFilesystem(sandbox, await filesystemId(sandbox._client, volume), mountPath);\n      },\n\n      // `mountPath`, when given, must be where the volume is mounted.\n      detachVolume: async (sandbox: VM, volume: string | Volume, mountPath?: string): Promise<void> => {\n        // A saved handle can still identify a mount after its filesystem is deleted.\n        const id = await filesystemId(sandbox._client, volume, { allowDeleted: true });\n        const { mounts } = await sandbox.listMounts({ filesystemId: id });\n        const mount = mounts.find((m) => mountPath === undefined || samePath(m.path, mountPath));\n        if (!mount) throw new Error(`Arker volume ${id} has no such mount on VM ${sandbox.id}`);\n        await sandbox.deleteMount(mount.mount_id);\n      },\n\n      // An idle Arker VM is already frozen; pause suspends a running one too\n      // (in-flight runs go `pending`) with a `schedule` rule whose `at` has\n      // passed, which fires at once. The rule is removed once the VM is idle so\n      // it can't outlive the pause. Memory is kept: processes and in-flight\n      // runs carry on when the VM next starts.\n      pause: async (sandbox: VM): Promise<void> => {\n        // A hold that starts after the suspend would wake the VM again: wait\n        // for one under way, and keep a later one back until the sandbox\n        // runs a command or resumes.\n        pausedVms.add(sandbox.id);\n        try {\n          await keepAwakeSetup.get(sandbox.id);\n          await patchRule(sandbox, PAUSE_RULE, {\n            type: 'schedule',\n            at: new Date(Date.now() - 1000).toISOString(),\n            action: 'suspend',\n          });\n          try {\n            const deadline = Date.now() + PAUSE_TIMEOUT_MS;\n            while ((await sandbox.refresh()).state !== 'idle') {\n              if (Date.now() > deadline) throw new Error(`Arker VM ${sandbox.id} did not suspend within ${PAUSE_TIMEOUT_MS}ms`);\n              await new Promise((resolve) => setTimeout(resolve, 500));\n            }\n          } finally {\n            await patchRule(sandbox, PAUSE_RULE, null);\n          }\n        } catch (err) {\n          pausedVms.delete(sandbox.id);\n          throw err;\n        }\n      },\n\n      // Any run starts a suspended VM, and its pending runs resume with it.\n      // The run takes a free session, so it does not wait on a command the\n      // pause interrupted.\n      resume: async (sandbox: VM): Promise<void> => {\n        pausedVms.delete(sandbox.id);\n        const session = await takeSession(sandbox);\n        let returned = false;\n        try {\n          const result = await sandbox.run('true', session ? { session_id: session } : {});\n          returned = true;\n          if (result.exitCode !== 0) throw new Error(`Arker resume failed for VM ${sandbox.id}: exit ${result.exitCode}`);\n        } finally {\n          releaseSession(sandbox.id, session, returned);\n        }\n        startHold(sandbox);\n      },\n      pauseCapabilities: { memory: true },\n\n      // --- Filesystem: file bodies over Arker's native sync API, the rest over runCommand ---\n\n      filesystem: {\n        // Native sync read; large files whose presigned read fails fall back\n        // to base64 chunks over runCommand.\n        readFile: async (sandbox, path, runCommand): Promise<string> => {\n          const fail = (detail: string) => new Error(`Arker readFile failed for ${path}: ${detail}`);\n          let absolutePath = path;\n          if (!absolutePath.startsWith('/')) {\n            const cwd = await runCommand(sandbox, 'pwd -P');\n            if (cwd.exitCode !== 0) throw fail(cwd.stderr || `pwd exited ${cwd.exitCode}`);\n            const dir = cwd.stdout.replace(/\\n$/, '');\n            if (!dir.startsWith('/')) throw fail('pwd did not return an absolute working directory');\n            absolutePath = `${dir}/${path}`;\n          }\n          try {\n            return new TextDecoder('utf-8', { ignoreBOM: true }).decode(await sandbox.sync(absolutePath));\n          } catch (err) {\n            if (!(err instanceof ArkerError) || err.status === 404) {\n              throw fail(err instanceof Error ? err.message : String(err));\n            }\n          }\n          const target = singleQuote(absolutePath);\n          const stat = await runCommand(sandbox, `wc -c < ${target}`);\n          if (stat.exitCode !== 0) throw fail(stat.stderr || `exit ${stat.exitCode}`);\n          const sizeText = stat.stdout.trim();\n          const size = Number(sizeText);\n          if (!/^\\d+$/.test(sizeText) || !Number.isSafeInteger(size)) throw fail('invalid file size');\n          const chunks: Buffer[] = [];\n          for (let start = 0; start < size; start += WRITE_CHUNK_BYTES) {\n            const result = await runCommand(\n              sandbox,\n              `tail -c +${start + 1} ${target} | head -c ${WRITE_CHUNK_BYTES} | base64 | tr -d '\\\\n'`\n            );\n            if (result.exitCode !== 0) throw fail(result.stderr || `exit ${result.exitCode}`);\n            const encoded = result.stdout.trim();\n            const chunk = Buffer.from(encoded, 'base64');\n            if (chunk.toString('base64') !== encoded) throw fail(`invalid base64 at byte ${start}`);\n            if (chunk.length !== Math.min(WRITE_CHUNK_BYTES, size - start)) {\n              throw fail(`incomplete read at byte ${start}`);\n            }\n            chunks.push(chunk);\n          }\n          return Buffer.concat(chunks).toString('utf8');\n        },\n        writeFile: async (sandbox, path, content, runCommand): Promise<void> => {\n          const bytes = Buffer.from(content, 'utf8');\n          try {\n            let target = path;\n            if (!target.startsWith('/')) {\n              const cwd = await runCommand(sandbox, 'pwd -P');\n              if (cwd.exitCode !== 0) throw new Error(cwd.stderr || `pwd exited ${cwd.exitCode}`);\n              const dir = cwd.stdout.replace(/\\n$/, '');\n              if (!dir.startsWith('/')) throw new Error('pwd did not return an absolute working directory');\n              target = `${dir}/${path}`;\n            }\n            try {\n              await sandbox.sync(target, bytes);\n              return;\n            } catch (err) {\n              if (!isNotFound(err)) throw err;\n            }\n\n            // Older regions lack /sync-stream. Use the documented chunk API,\n            // not the persistent shell, whose history retains every payload.\n            const uploadId = randomUUID();\n            let start = 0;\n            do {\n              const end = Math.min(start + WRITE_CHUNK_BYTES, bytes.length);\n              const response = await sandbox._client._request<SyncWriteResponse>(\n                'POST', `/v1/vms/${encodeURIComponent(sandbox.id)}/sync`,\n                { op: 'write', writes: [{ path: target, size: bytes.length, upload_id: uploadId, start, end, content: bytes.subarray(start, end).toString('base64') }] },\n                sandbox.baseUrl,\n              );\n              const result = response.results?.[0];\n              if (!response.ok || !result || result.error) {\n                throw new Error(result?.error?.message ?? 'sync write returned no successful result');\n              }\n              if (end === bytes.length && (!result.complete || !result.written)) {\n                throw new Error('sync write did not commit the complete file');\n              }\n              start = end;\n            } while (start < bytes.length);\n          } catch (err) {\n            throw new Error(`Arker writeFile failed for ${path}: ${err instanceof Error ? err.message : String(err)}`);\n          }\n        },\n        mkdir: async (sandbox, path, runCommand): Promise<void> => {\n          const result = await runCommand(sandbox, `mkdir -p \"${escapeShellArg(path)}\"`);\n          if (result.exitCode !== 0) throw new Error(`Arker mkdir failed for ${path}: ${result.stderr || `exit ${result.exitCode}`}`);\n        },\n        readdir: async (sandbox, path, runCommand): Promise<FileEntry[]> => {\n          const result = await runCommand(sandbox, `ls -la \"${escapeShellArg(path)}\"`);\n          if (result.exitCode !== 0) throw new Error(`Arker readdir failed for ${path}: ${result.stderr || `exit ${result.exitCode}`}`);\n\n          const entries: FileEntry[] = [];\n          for (const line of result.stdout.split('\\n')) {\n            const parts = line.trim().split(/\\s+/);\n            // Skip the \"total\" line, malformed rows, and . / ..\n            if (parts.length < 9 || !/^[-dl]/.test(parts[0])) continue;\n            let name = parts.slice(8).join(' ');\n            if (parts[0].startsWith('l')) name = name.split(' -> ')[0]; // symlink arrow\n            if (name === '.' || name === '..') continue;\n            // ls prints \"Mmm dd HH:MM\" for recent files (no year) and \"Mmm dd YYYY\" otherwise.\n            const [month, day, timeOrYear] = parts.slice(5, 8);\n            const dateStr = timeOrYear.includes(':')\n              ? `${month} ${day} ${new Date().getFullYear()} ${timeOrYear}`\n              : `${month} ${day} ${timeOrYear}`;\n            const modified = new Date(dateStr);\n            entries.push({\n              name,\n              type: parts[0].startsWith('d') ? 'directory' : 'file',\n              size: Number(parts[4]) || 0,\n              modified: isNaN(modified.getTime()) ? new Date(0) : modified,\n            });\n          }\n          return entries;\n        },\n        exists: async (sandbox, path, runCommand): Promise<boolean> => {\n          const result = await runCommand(sandbox, `test -e \"${escapeShellArg(path)}\"`);\n          return result.exitCode === 0;\n        },\n        remove: async (sandbox, path, runCommand): Promise<void> => {\n          const result = await runCommand(sandbox, `rm -rf \"${escapeShellArg(path)}\"`);\n          if (result.exitCode !== 0) throw new Error(`Arker remove failed for ${path}: ${result.stderr || `exit ${result.exitCode}`}`);\n        },\n      },\n    },\n\n    // A snapshot is a warm fork of the VM (disk + memory). Restore by passing\n    // its id as `snapshotId` to create(), which forks from it again.\n    snapshot: {\n      // The whole root disk (including /tmp, which is not a tmpfs) and running\n      // processes; the source keeps running.\n      capabilities: { scope: 'rootfs', memory: true, destroysSource: false },\n\n      create: async (config: ArkerConfig, instanceId: string, options?: CreateSnapshotOptions): Promise<ArkerSnapshot> => {\n        const client = makeClient(config);\n        const name = `${SNAPSHOT_PREFIX}${options?.name ? `${options.name}-` : ''}${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;\n        const vm = await client.vm(instanceId).fork({ name, description: `snapshot of ${instanceId}` });\n        return {\n          id: vm.id,\n          provider: 'arker',\n          createdAt: vm.created_at ? new Date(vm.created_at) : new Date(),\n          metadata: { name: vm.name ?? name, sourceInstanceId: instanceId, ...options?.metadata },\n        };\n      },\n\n      // Arker's VM listing omits names and caps its pages, so snapshot forks\n      // can't be told apart from other VMs; keep the ids create() returns.\n      list: async (_config: ArkerConfig, _options?: ListSnapshotsOptions): Promise<ArkerSnapshot[]> => {\n        throw new Error('Arker cannot list snapshots: its VM listing does not identify snapshot forks');\n      },\n\n      delete: async (config: ArkerConfig, snapshotId: string): Promise<void> => {\n        const client = makeClient(config);\n        try {\n          await client.vm(snapshotId).delete();\n        } catch (err) {\n          if (isNotFound(err)) return;\n          throw err;\n        }\n      },\n    },\n\n    // A volume is an Arker filesystem: org-scoped storage, named uniquely,\n    // that outlives the VMs it is mounted on.\n    volume: {\n      // Arker filesystems grow as they fill, so `sizeBytes` has nothing to set.\n      create: async (config: ArkerConfig, options): Promise<Volume> =>\n        toVolume(await makeClient(config).createFilesystem({ name: options.name })),\n\n      get: async (config: ArkerConfig, volumeIdOrName: string): Promise<Volume | null> => {\n        const fs = await findFilesystem(makeClient(config), volumeIdOrName);\n        return fs && toVolume(fs);\n      },\n\n      list: async (config: ArkerConfig, options?: ListVolumesOptions): Promise<Volume[]> => {\n        if (options?.limit !== undefined && options.limit <= 0) return [];\n        const client = makeClient(config);\n        const volumes: Volume[] = [];\n        let cursor: string | undefined;\n        do {\n          // Arker serves at most 1000 per page.\n          const left = options?.limit === undefined ? undefined : Math.min(options.limit - volumes.length, 1000);\n          const page = await client.listFilesystems({ ...(cursor ? { cursor } : {}), ...(left === undefined ? {} : { limit: left }) });\n          volumes.push(...page.filesystems.map(toVolume));\n          cursor = page.next_cursor ?? undefined;\n        } while (cursor && (options?.limit === undefined || volumes.length < options.limit));\n        return options?.limit === undefined ? volumes : volumes.slice(0, options.limit);\n      },\n\n      // Arker expects a filesystem to be detached from every VM before it is deleted.\n      delete: async (config: ArkerConfig, volumeIdOrName: string): Promise<void> => {\n        const client = makeClient(config);\n        const fs = await findFilesystem(client, volumeIdOrName);\n        if (!fs) return;\n        try {\n          await client.deleteFilesystem(fs.filesystem_id);\n        } catch (err) {\n          if (!isNotFound(err)) throw err;\n        }\n      },\n    },\n  },\n});\n\nexport type { VM as ArkerSandbox } from '@arker-ai/sdk';\n"],"mappings":";AAOA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,kBAAsB;AACtC,SAAS,gBAAgB,gBAAgB,mBAAmB,uBAAuB,wBAAwB;AAgB3G,IAAM,mBAAmB;AAEzB,IAAM,iBAAiB;AAEvB,IAAM,iBAAiB;AAMvB,IAAM,gBAAkG;AAAA,EACtG,iBAAiB,EAAE,UAAU,GAAG,cAAc,MAAM,cAAc,MAAM;AAAA,EACxE,mBAAmB,EAAE,UAAU,GAAG,cAAc,MAAM,cAAc,MAAM;AAAA,EAC1E,oBAAoB,EAAE,UAAU,IAAI,cAAc,MAAM,cAAc,MAAM;AAAA,EAC5E,i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