Skip to content

dreamcli/runtime

Runtime adapter factory and platform detection.

ts
import { createAdapter, detectRuntime } from 'dreamcli/runtime';
import type { RuntimeAdapter } from 'dreamcli/runtime';

createAdapter(runtime?)

Create a runtime adapter for the specified platform.

ts
const adapter = createAdapter(); // auto-detect
const adapter = createAdapter('node'); // explicit
const adapter = createAdapter('bun');
const adapter = createAdapter('deno');

RuntimeAdapter Interface

MethodDescription
argv()Command-line arguments
env()Environment variables
cwd()Current working directory
exit(code)Exit the process
isTTY()Whether stdin/stdout is a TTY
readFile(path)Read a file (for config discovery)
homedir()User home directory
configDir()XDG config directory

detectRuntime()

Detect the current runtime environment.

ts
const runtime = detectRuntime();
// 'node' | 'bun' | 'deno'

Supported Runtimes

RuntimeAdapterNotes
Node.js >= 22NodeAdapterFull support
Bun >= 1.3BunAdapterDelegates to Node adapter
Deno >= 2.6DenoAdapterPermission-safe Deno namespace

Released under the MIT License.