Runtimes

Runtimes

The same package runs in Node, in a browser and on Cloudflare Workers. It works out which one it is in, and what it can do there, before the first call.

node · browser · workerdetected, not configured
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

You never tell the SDK where it is. It checks, and adapts: where the session is cached, whether an agent has a disk to work on, whether bash exists at all. What follows is what changes, and what you have to supply when something is missing.

Detection

Three checks, in this order. The order matters: a Worker has neither process nor window.document, so it has to be identified on its own terms.

ResultRecognised by
nodeprocess.versions.node is a string
workernavigator.userAgent is "Cloudflare-Workers"
browserwindow.document exists
unknownnone of the above — the SDK still works over HTTP
const api = new IaGenify({ apiKey });

api.env;           // "node" | "worker" | "browser" | "unknown"
api.framework;     // "node" | "next.js" | "gatsby" | "vite" | "browser"
api.capabilities;  // { runtime, shell, filesystem, persistentStorage, http }
api = IaGenify(api_key=api_key)

api.env           # "python"
api.framework     # "python"
api.capabilities  # {"runtime", "shell", "filesystem", "persistentStorage", "http"}

framework is a detail of where you are running, not a feature switch: it travels with the session so your own calls can be told apart later. capabilities is the one worth branching on.

What each one can do

NodeBrowserWorkers
capabilities.filesystemtruefalsefalse
capabilities.shelltruefalsefalse
capabilities.persistentStoragetruetruefalse
capabilities.httptruetruetrue
Session cachea filelocalStoragememory
Agent workspaceon disksupply filessupply files
bashyessupply shellsupply shell
Terminalsyesnono
A missing capability is refused, not worked around

An agent that cannot reach a workspace refuses at construction and names what is missing, so the failure arrives before the run rather than inside it.

Branching on it

// The same code path, wherever it runs
const machine = api.capabilities.filesystem
  ? await api.storage.get()                 // this computer
  : await api.storage.device({ deviceId }); // a browser device

const agent = api.agents.create({
  runtime: "local",
  machine,
  model: "gemini-3.5-flash",
  // Only needed where there is no disk; harmless to pass when there is one
  ...(api.capabilities.filesystem ? {} : { files: myFileBridge }),
});
# The same code path, wherever it runs
machine = (
    api.storage.get()                           # this computer
    if api.capabilities["filesystem"]
    else api.storage.device(device_id=device_id)  # a browser device
)

agent = api.agents.create(
    runtime="local",
    machine=machine,
    model="gemini-3.5-flash",
    # Only needed where there is no disk; harmless to pass when there is one
    **({} if api.capabilities["filesystem"] else {"files": my_file_bridge}),
)

The machine id

Every runtime computes one and caches it for the process. It is a hash of machine facts — hostname, platform, architecture, runtime string — and never of anything you typed. It travels on every request as X-IaGenify-Machine-Id, and it is what lets a machine appear as a storage on your account instead of being anonymous.

// What it is built from, per runtime
node     { os: "win32",      arch: "x64",     hostname: "DESKTOP-7F",  runtime: "node v22.4.0" }
browser  { os: navigator.platform, arch: "unknown", hostname: location.hostname, runtime: userAgent }
worker   { os: "cloudflare", arch: "unknown", hostname: "unknown",     runtime: "cloudflare-workers" }
# What it is built from in Python
import platform, socket

environment = {
    "os": platform.system().lower(),     # "windows", "linux", "darwin"
    "arch": platform.machine(),           # "AMD64", "x86_64", "arm64"
    "hostname": socket.gethostname(),
    "runtime": f"python {platform.python_version()}",
}

Reported resources

Each request carries an X-IaGenify-Resources header, recomputed at most every 30 seconds. Every probe is wrapped: when one is unavailable the field is left out rather than failing the call, so the header is a best effort and never a reason for an error.

// node
{ cpu:    { model, cores, speedMHz },
  memory: { totalBytes, freeBytes },
  gpu:    [{ model, vramBytes }],          // only when a GPU probe answers   
  disk:   [{ mount, totalBytes, freeBytes }] }

// browser
{ cpu:     { logicalCores },               // navigator.hardwareConcurrency
  memory:  { totalGb },                    // only where deviceMemory exists
  gpu:     [{ model }],                    // only if an adapter is granted
  storage: { quotaBytes, usageBytes } }

// worker
{ runtime: "cloudflare-workers" }
# What a Python process reports
{"cpu": {"model": ..., "cores": ...},
 "memory": {"totalBytes": ..., "freeBytes": ...},
 "disk": [{"mount": ..., "totalBytes": ..., "freeBytes": ...}]}

Choosing where to run

You wantRun it in
An agent that works on real files, or runs commandsNode
A low-latency endpoint close to the userWorkers
An agent working on a visitor's own deviceNode, with a files bridge to the browser
A key that never leaves your controlNode or Workers — never the browser