Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

1.3 KB
Raw Blame
import { mkdtemp } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'

export const FIXED_URL = 'https://example.invalid/fixed-artifact.bin'

export function responseFor(chunks, { ok = true, status = 200, contentLength, url = FIXED_URL } = {}) {
  let index = 0
  return {
    ok,
    status,
    statusText: ok ? 'OK' : 'ERR',
    url,
    redirected: false,
    headers: {
      get: (name) => (name.toLowerCase() === 'content-length' && contentLength !== undefined ? String(contentLength) : null)
    },
    body: {
      [Symbol.asyncIterator]() {
        return this
      },
      async next() {
        if (index >= chunks.length) return { done: true, value: undefined }
        return { done: false, value: Buffer.from(chunks[index++]) }
      },
      async return() {
        index = chunks.length
        return { done: true, value: undefined }
      }
    }
  }
}

export function redirectFor(location, status = 302) {
  return {
    ok: false,
    status,
    statusText: 'Found',
    url: undefined,
    redirected: false,
    headers: { get: (name) => (name.toLowerCase() === 'location' ? location : null) },
    body: { cancel: async () => {} }
  }
}

export async function scratch(name) {
  return mkdtemp(join(tmpdir(), `orca-download-${name}-`))
}