better/compute

Installation

Requirements, installing better-compute and Better IAM from npm, the umbrella package's subpaths, packages outside it, optional peers, and building from a clone.

Better Compute is split into @better-compute/* packages. Most applications install the umbrella package, better-compute, which depends on all of them and re-exports each one as a subpath. A subpath loads only when you import it, and the server never imports the injected modules (provision, metal, vps): your application imports them and passes them in, so what you do not use costs nothing at run time.

Version 0.1.1

better-compute and every @better-compute/* package are published to npm at 0.1.1, on the latest dist-tag, and accept Better IAM >=0.2.0 <0.4.0 (better-iam and @better-iam/*; 0.3 is current), which is on npm too. The Go daemon bcd is not an npm package and has no released binary yet; see the daemon.

Requirements

RequirementNotes
Node.js 22.12 or newerThe engines field of every package. CI runs Node.js 22 and 24 on Ubuntu and Windows. A TypeScript configuration file (better-compute.config.ts) needs 22.18 or newer, which strips types by default.
ESMEvery package is an ES module with TypeScript declarations and { types, import } exports only. Use "type": "module" or a bundler.
PostgreSQL 16 or newerThe production store; CI runs PostgreSQL 17. The first migration creates the btree_gist extension, which the booking constraint needs. PgBouncer in transaction mode is supported.
PGlite, for developmentPostgreSQL in WebAssembly, through the optional peer @electric-sql/pglite. One connection, with transactions serialized. btree_gist works on it.
Native builds, for embedded Better IAMBetter IAM's SQLite adapter and password hashing use better-sqlite3 and argon2, so allow their install scripts (pnpm: allowBuilds).
TypeScript, optionalmoduleResolution of bundler, node16 or nodenext, so subpath exports resolve.

Compute's own store is PostgreSQL or PGlite only. It needs EXCLUDE constraints, SKIP LOCKED and range types, so there is no SQLite adapter for it. Embedded Better IAM can still use Better IAM's SQLite adapter in development.

Install from npm

Install Better Compute and Better IAM

npm install better-compute better-iam

better-compute is the umbrella package: it depends on every @better-compute/* package in it and gives you the better-compute command. better-iam is Better IAM's umbrella package; it brings @better-iam/server, @better-iam/core, @better-iam/adapter-sqlite and the rest of Better IAM, which Better Compute declares as optional peers (^0.2.0; see optional peers).

Add PGlite for development

PGlite is the development database, and better-compute dev uses it when there is no database URL. It is an optional peer, so npm does not install it for you:

npm install @electric-sql/pglite

A deployment that runs only against PostgreSQL does not need it.

Check it

npx better-compute --help
npx better-compute init   # writes better-compute.config.ts

With pnpm, list the Better IAM packages Better Compute imports as your own dependencies, so the optional peers resolve under pnpm's strict layout, and allow the native builds (allowBuilds for argon2 and better-sqlite3 in pnpm-workspace.yaml):

pnpm add better-compute better-iam @better-iam/server @better-iam/core @better-iam/adapter-sqlite @electric-sql/pglite

Then import the subpaths you need:

import { betterCompute } from 'better-compute';
import { metal } from 'better-compute/metal';
import { postgres } from 'better-compute/postgres';
import { createComputeClient } from 'better-compute/client';

Each package is also published on its own as @better-compute/<name>, for services that need only part of the platform, for example a browser bundle that needs only @better-compute/client.

Install from a clone

To work on Better Compute itself, or to try changes that are not released, build it from the repository. The workspace pins pnpm 11.19.0: install with that version once, then run the pinned copy from node_modules.

git clone https://github.com/better-compute/better-compute.git
cd better-compute
npx pnpm@11.19.0 install
node node_modules/pnpm/bin/pnpm.mjs build   # tsc -b: every package's dist/

Better IAM resolves from npm like any other dependency. The better-compute command is then packages/cli/dist/index.js; the quickstart shows how to put it on your path and run the repository's example configuration. To use the local build in another project, pack:all writes one tarball per package to artifacts/ (@better-compute/core@0.1.0 becomes artifacts/better-compute-core-0.1.0.tgz) without publishing anything; install those in place of the registry versions. The repository's packed smoke test (pnpm test:packed) does exactly that in a fresh consumer. Local development covers the workspace scripts.

Subpath imports

The umbrella's subpaths are generated from packages/better-compute/umbrella.json; each one is a one-line re-export of its package, and nested subpaths map to nested exports of the same package.

ImportPackageWhat it provides
better-compute@better-compute/server, @better-compute/corebetterCompute, defineConfig, configOptions, ComputeError, defineModule, definePlugin, defineDriver, defineSchedulerPlugin, defineAttestor, defineSink, manifest, field, and their types
better-compute/core@better-compute/coreBrowser-safe contracts: ids, errors, domain types, state tables, extension and port contracts, the IAM catalog, defineMethod
better-compute/protocol@better-compute/protocolGenerated daemon and control-plane wire types
better-compute/inventory@better-compute/inventorySection hashing, diffs, GPU model mapping, labels and health conditions
better-compute/capacity@better-compute/capacityAtoms, bookings, quotas, rollups and the placement pipeline
better-compute/provision@better-compute/provisionThe workflow engine, defineStep, defineProfile, provisionModule()
better-compute/metal@better-compute/metalBare-metal verbs and drivers, metal()
better-compute/vps@better-compute/vpsInstances, runtimes, flavors, defineProvider, vps()
better-compute/iam, /iam/plugin, /iam/testing@better-compute/iamThe Better IAM bridge, the plugin for IAM hosts, and an embedded Better IAM for tests and dev --sim
better-compute/events@better-compute/eventsSigned webhooks and the server-sent /watch stream
better-compute/fleet@better-compute/fleetFleetConfig export, plan and apply
better-compute/rollout@better-compute/rolloutSigned bcd releases and wave rollouts
better-compute/audit@better-compute/auditSigned per-tenant Merkle checkpoints over the audit log
better-compute/observability@better-compute/observabilityA bounded Prometheus registry and the standard metrics
better-compute/server@better-compute/serverEverything the server exports: betterCompute(), the envelope, the registry, JoinService, controllers
better-compute/gateway@better-compute/gatewayDaemon sessions over gRPC on HTTP/2 mTLS, liveness and dispatch
better-compute/pki@better-compute/pkiLocal CAs, SPIFFE node certificates, sealed join tokens, attestors
better-compute/postgres@better-compute/postgrespostgres({ url }), migrations, compute_now() and sim-clock helpers
better-compute/pglite@better-compute/postgres/pglitepglite(), the development and test store
better-compute/client@better-compute/clientcreateComputeClient, the typed, browser-safe client
better-compute/cli@better-compute/cliThe command line, also the umbrella's better-compute bin
better-compute/mcp@better-compute/mcpMCP tools for AI agents, gated by Better IAM
better-compute/testing@better-compute/testingcomputeFixture(), FakeDaemon, the fleet simulator, the dev stack

defineMethod comes from better-compute/core, defineStep and defineProfile from better-compute/provision, and defineProvider from better-compute/vps.

Built-in and injected modules

inventory and capacity are built in: betterCompute() always registers them (after the node controllers), and their groups (inventory, pools, capacity, reservations, quotas) exist in every deployment. Everything else is a module you pass in modules:

compute.ts
import { betterCompute } from 'better-compute';
import { eventsModule } from 'better-compute/events';
import { fleetModule } from 'better-compute/fleet';
import { metal } from 'better-compute/metal';
import { postgres } from 'better-compute/postgres';
import { provisionModule } from 'better-compute/provision';
import { vps } from 'better-compute/vps';

const secret = process.env.BETTER_COMPUTE_SECRET!; // at least 32 characters
const bareMetal = metal();

export const compute = betterCompute({
  database: postgres({ url: process.env.BETTER_COMPUTE_DATABASE_URL! }),
  secret,
  baseURL: 'https://compute.example.com',
  rootTenantId,
  iam,
  // provision runs metal's workflows; metal contributes its verbs, steps and profiles
  modules: [provisionModule({ modules: [bareMetal] }), bareMetal, vps(), eventsModule({ secret }), fleetModule()],
});

The API types follow the modules: client.instances exists only when vps() is in modules. The repository enforces the direction with scripts/check-deps.mjs: @better-compute/server never depends on provision, metal, vps, gateway, iam, postgres, a provider or a driver. See modules.

Packages outside the umbrella

These are installed directly, not through better-compute:

PackageWhat it is
@better-compute/provider-hetznerHetzner Cloud servers as VPS instances and offers, and Hetzner Robot bootstrap
@better-compute/provider-proxmoxProxmox VE QEMU VMs cloned from templates
@better-compute/provider-kubernetesNot a VPS provider: the manifests that run bcd as a DaemonSet on an existing cluster's nodes (bcdDaemonSetManifests, renderKubernetesManifests; 2c9f953). See bcd on Kubernetes
@better-compute/driver-sdkbcx, the out-of-process driver protocol (a v0.5 draft; the protocol is unstable until v0.5 ships)
@better-compute/console-kitFramework-free view models for consoles over the typed client

Nothing in packages/ imports a @better-compute/provider-* package; you pass providers to vps() yourself. See providers.

Optional peers

The umbrella declares these as optional peer dependencies. Install the ones you use; better-iam brings all of the @better-iam/* ones:

PeerNeeded for
@electric-sql/pglite ^0.5.8better-compute/pglite, the testing fixture, dev without a database URL. Without it, the CLI fails with MISSING_DEPENDENCY and an install hint.
@better-iam/server, @better-iam/core >=0.2.0 <0.4.0Embedded Better IAM through the bridge
@better-iam/adapter-sqlite >=0.2.0 <0.4.0Better IAM on SQLite in development, and the embedded IAM of dev --sim
@better-iam/client >=0.2.0 <0.4.0better-compute iam setup --meters, which creates the billing meters in Better IAM
@better-iam/cli >=0.2.0 <0.4.0Declared for Better IAM's CLI; today the better-compute CLI reads its credential from BETTER_COMPUTE_TOKEN only

@better-compute/cli also declares @better-compute/testing as an optional peer, for dev --sim and sim; the umbrella depends on it, so installing better-compute provides it. See Better IAM for how the two products fit together.

The daemon

bcd is not an npm package. It is designed as a Go binary for Linux on amd64 and arm64, released by goreleaser as bcd_<version>_linux_{amd64,arm64}.tar.gz with a .sha256, plus the bare binaries for machines, and listed in an offline-signed release manifest (better-compute release sign). better-compute daemon install-script already writes the POSIX installer: it downloads the pinned binary from {base-url}{base-path}/downloads/bcd/{version}/linux-{arch}, checks its SHA-256, writes /etc/bcd/config.toml and a hardened bcd.service, and runs bcd join. The control plane serves that download route when you configure downloads (see serving the binaries).

No binary is released yet. daemon/ is a Go module whose v0.1 node agent is built and tested: bcd join, bcd node and bcd status run end to end against a real gateway in tests/e2e/bcd.test.ts. What is missing is a release (goreleaser is configured but has not run), a run on a real GPU host (GPUs are read through nvidia-smi, cb987e5), and the later modes. You can build it yourself with Go 1.26 or later (go build ./cmd/bcd in daemon/). The TypeScript FakeDaemon in better-compute/testing speaks the real protocol for everything else. See installing the daemon.

All packages

@better-compute/audit0.1.1

Tamper-evident audit for better-compute: signed hourly per-tenant Merkle checkpoints over audit_events, inclusion proofs and verification.

better-compute0.1.1

Manage GPU and bare-metal capacity and provision nodes in many ways: one package with every better-compute subpath.

/core/protocol/inventory/capacity/provision/metal/vps/iam/iam/plugin/iam/testing/events/fleet/rollout/audit/observability/server/gateway/pki/postgres/pglite/client/cli/mcp/testing
@better-compute/capacity0.1.1

Capacity for better-compute: atoms, bookings, quotas, rollups and the placement pipeline.

@better-compute/cli0.1.1

The better-compute command line.

@better-compute/client0.1.1

Typed, browser-safe client for the better-compute API.

@better-compute/console-kit0.1.1

Framework-free view models for better-compute consoles: resource stores with pagination, live event refresh and permission-aware actions.

/react
@better-compute/core0.1.1

Browser-safe contracts for better-compute: domain types, errors, state tables, extension contracts and the IAM catalog.

/conformance
@better-compute/driver-sdk0.1.1

bcx, the better-compute out-of-process driver protocol: serveDriver runs a defineDriver object as a plugin, externalDriver hosts one over auto-mTLS gRPC.

@better-compute/events0.1.1

Event delivery for better-compute: per-tenant signed webhooks with retries and dead letters, and the SSE /watch stream, read from the outbox.

@better-compute/fleet0.1.1

FleetConfig as code for better-compute: export, plan and apply sites, pools, offers, quotas, flavors and provider accounts.

@better-compute/gateway0.1.1

The better-compute gateway: daemon sessions over gRPC/HTTP/2 mTLS, liveness, command dispatch and Join/Renew/Secret forwarding.

@better-compute/iam0.1.1

The better-iam bridge for better-compute: IAM plugin and catalog, event inbox, authz projection and resolver, the embedded IamPort, usage sink and flag cache.

/plugin/testing
@better-compute/inventory0.1.1

Hardware inventory for better-compute: section hashing, diffs, GPU model mapping, labels and health conditions.

@better-compute/mcp0.1.1

Model Context Protocol tools for better-compute: pools, capacity, GPU reservations and node status for AI agents, gated by better-iam.

@better-compute/metal0.1.1

Bare-metal lifecycle for better-compute: power, management, boot, deploy and inspect drivers.

@better-compute/observability0.1.1

Metrics for better-compute: a bounded Prometheus registry, the standard better_compute_* series, a metered IamPort and backlog gauges.

@better-compute/pki0.1.1

Machine PKI for better-compute: local CAs, SPIFFE node certificates, sealed join tokens, signed join responses and renew proofs.

@better-compute/postgres0.1.1

PostgreSQL and PGlite storage for better-compute: executor, migrations and store conformance.

/pglite/conformance
@better-compute/protocol0.1.1

Wire contracts between the bcd daemon and the better-compute control plane (protobuf-es generated).

@better-compute/provider-hetzner0.1.1

Hetzner providers for better-compute: Hetzner Cloud servers as VPS instances and offers.

@better-compute/provider-kubernetes0.1.1

Kubernetes as a capacity source for better-compute: bcd as a DaemonSet adopts a cluster's nodes and GPUs into a pool.

@better-compute/provider-proxmox0.1.1

Proxmox VE provider for better-compute: QEMU VMs cloned from templates as VPS instances.

@better-compute/provision0.1.1

Provisioning for better-compute: profiles, steps and the workflow engine.

@better-compute/rollout0.1.1

Signed bcd releases and wave rollouts (A/B self-update) for better-compute, within each pool's disruption budget.

@better-compute/server0.1.1

The better-compute control plane: betterCompute(), the operation envelope, router and runtimes.

@better-compute/testing0.1.1

Testing kit for better-compute: fixtures, simulated daemons, sim clock and conformance runners.

@better-compute/vps0.1.1

VPS instances for better-compute: runtimes, flavors and external providers.

Verify the installation

doctor loads your configuration and checks the database, the schema, the clock and the method registry without changing anything:

better-compute migrate
better-compute doctor --strict

It runs compute.selfCheck() (applied migrations, btree_gist, compute_now() against the database clock, every method's IAM action, each module's own checks) and adds the CLI's findings, such as iam.not-configured when no Better IAM is wired in. --strict exits non-zero with DOCTOR_FINDINGS on any warning, so you can run it in CI. See the CLI reference.

Next steps

Was this page helpful?

Better Compute is created by Sean Filimon

Last updated

On this page