The commented-out durable-Postgres block that SELF-HOSTING.md tells operators to uncomment shipped a default openjev/openjev/openjev user/password/db and published 5432:5432 to the host. An operator who followed the docs verbatim got Postgres (API key hashes, webhook secrets, session data) reachable by anyone on the host's network with a trivially guessable credential. Now requires POSTGRES_PASSWORD to be set (fails fast via compose's :? syntax if missing) and no longer publishes the Postgres port to the host — db stays reachable only on the internal compose network. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
261 lines
14 KiB
Plaintext
261 lines
14 KiB
Plaintext
###############################################################################
|
|
# openjev — environment configuration
|
|
#
|
|
# Copy to `.env` (`cp .env.example .env`) and fill in what you need. NOTHING in
|
|
# this file is required to boot: with no vars set the service runs the pure-TS
|
|
# decision engine on an in-memory PGLite database, with auth disabled.
|
|
#
|
|
# Every variable below is read somewhere in the code (grep `process.env.` /
|
|
# `env(` / `os.environ`). Grouped by concern.
|
|
###############################################################################
|
|
|
|
# =============================================================================
|
|
# Node service
|
|
# =============================================================================
|
|
# HTTP port the built Node server (Nitro node-server) listens on.
|
|
PORT=3000
|
|
# Bind host for the Node server.
|
|
HOST=0.0.0.0
|
|
|
|
# =============================================================================
|
|
# Decision backends — native engine & Laya neural sidecar
|
|
# =============================================================================
|
|
# URL of the in-tree native C++/Rust decision engine (engine/). Only needed if
|
|
# you run that engine; default assumes a local process on 8091.
|
|
OPENJEV_ENGINE_URL=http://127.0.0.1:8091
|
|
|
|
# Laya neural backend selector: "mlx" (Apple Silicon) | "onnx" (Linux/CPU).
|
|
# Unset = auto (mlx on macOS, onnx elsewhere). docker-compose uses onnx.
|
|
LAYA_BACKEND=onnx
|
|
# URL of the Laya sidecar (scripts/laya_sidecar.py). In docker-compose this is
|
|
# the sidecar service: http://laya-onnx:8092. Default for a local sidecar:
|
|
LAYA_ENGINE_URL=http://127.0.0.1:8092
|
|
|
|
# --- Laya sidecar / weight download (read by laya_sidecar.py + laya-download.sh)
|
|
# The onnx sidecar runs REAL onnxruntime inference from a LOCAL model directory
|
|
# (model.onnx + tokenizer/ + rl_agent_config.json + encoder/config.json). It
|
|
# cannot load a Hugging Face id directly and never fabricates decisions: without
|
|
# a real model it fails clean (/health ok:false, POST -> 503) and the Node
|
|
# service falls back to the deterministic local engine.
|
|
#
|
|
# There is NO public Laya ONNX checkpoint (laya-mlx exports MLX only, and
|
|
# aac6fef/laya-onnx does not exist on the Hub). So the default onnx path DISTILS
|
|
# a compact CPU model locally: scripts/laya_distill.py trains a MiniLM-L6
|
|
# (Apache-2.0, ~22.7M params) bidirectional encoder + typed Choice/Score/Noul
|
|
# heads on engine/gold.json + synthetic data, and exports ~91 MB model.onnx that
|
|
# scores 14/14 on the gold set. Needs python3 + torch>=2.5 + transformers + onnx.
|
|
# Set LAYA_ONNX_REPO to skip distillation and pull your own hosted ONNX export.
|
|
# LAYA_MODEL_PATH=/models/laya-onnx-base # REQUIRED for onnx: local weights dir
|
|
# LAYA_MODEL=base # base | multilingual | typed-decisions (variant)
|
|
# LAYA_ONNX_REPO=youracct/laya-onnx # hosted ONNX export repo (skips local distill)
|
|
# LAYA_FORCE_DISTILL=0 # 1 = re-distil even if models/.../model.onnx exists
|
|
# LAYA_HOST=0.0.0.0 # sidecar bind host (default 127.0.0.1)
|
|
# LAYA_PORT=8092 # sidecar bind port (matches LAYA_ENGINE_URL)
|
|
# LAYA_DEST=./models # download destination root (laya-download.sh)
|
|
# LAYA_SKIP_DOWNLOAD=0 # 1 = reuse an already-populated models volume
|
|
# LAYA_BATCH_SIZE=16 # onnx inference batch size
|
|
# LAYA_ORT_THREADS=0 # onnxruntime intra-op threads (0 = default)
|
|
|
|
# =============================================================================
|
|
# LLM escalation (optional) — hard decisions can escalate to a hosted provider
|
|
# =============================================================================
|
|
# Pin one provider: groq | ollama | openai | xai (aka grok) | anthropic (aka claude).
|
|
# Unset = every configured provider forms a chain, FREE first:
|
|
# groq -> ollama -> openai -> xai -> anthropic (a failing provider falls through).
|
|
# Used by the `openjev-grok` escalation model, the `auto` cascade, and shadow mode.
|
|
# With no usable provider the service answers locally and says so (`fallback`).
|
|
# LLM_PROVIDER=groq
|
|
|
|
# Groq (free API tier)
|
|
# GROQ_API_KEY=gsk_...
|
|
# GROQ_MODEL=llama-3.3-70b-versatile # optional override
|
|
|
|
# Ollama (local, keyless; any OpenAI-compatible server works)
|
|
# OLLAMA_BASE_URL=http://127.0.0.1:11434
|
|
# OLLAMA_MODEL=llama3.1:8b # optional override
|
|
|
|
# Global LLM calls per 5 minutes (default 8, a public-preview safety cap).
|
|
# LLM_RATE_LIMIT_PER_5MIN=600
|
|
|
|
# `auto` cascade: escalate questions whose local confidence is below this (0-1).
|
|
# Per request: `escalate_below`; per question: `questions.<id>.escalate_below`.
|
|
# OTS_AUTO_ESCALATE_BELOW=0.6
|
|
|
|
# OpenAI
|
|
# OPENAI_API_KEY=sk-...
|
|
# OPENAI_MODEL=gpt-4.1-mini # optional override (default gpt-4.1-mini)
|
|
# OPENAI_BASE_URL=https://openrouter.ai/api/v1 # optional: any OpenAI-compatible endpoint
|
|
|
|
# xAI (Grok)
|
|
# XAI_API_KEY=xai-...
|
|
# XAI_MODEL=grok-4.5 # optional override (default grok-4.5)
|
|
|
|
# Anthropic (Claude)
|
|
# ANTHROPIC_API_KEY=sk-ant-...
|
|
# ANTHROPIC_MODEL=claude-opus-5 # optional override (default claude-opus-5)
|
|
|
|
# =============================================================================
|
|
# OpenJev Cloud backend (optional) — proxy to a hosted System One endpoint
|
|
# =============================================================================
|
|
# When set, requests that select the "system-one-cloud" (aka "jev-cloud" /
|
|
# "typesafe-cloud") model are proxied to a hosted System One endpoint
|
|
# at <OPENJEV_BASE_URL>/v1/systemone (Authorization: Bearer <key>).
|
|
# This is NOT the default: the default chain stays local/native/laya/otsone, so
|
|
# a self-host needs no key. With no key set (or on any non-2xx / network error)
|
|
# the cloud model degrades cleanly to the local engine.
|
|
#
|
|
# PRIMARY env vars (OPENJEV_*):
|
|
# OPENJEV_API_KEY=ots_live_... # cloud API key
|
|
# OPENJEV_BASE_URL=https://your-host # hosted cloud API root (no trailing slash)
|
|
# OPENJEV_DEFAULT_MODEL=otsone-latest # cloud model name to send
|
|
#
|
|
# Back-compat aliases (TYPESAFE_* still accepted; OPENJEV_* takes priority):
|
|
# TYPESAFE_API_KEY=ts_live_...
|
|
# TYPESAFE_BASE_URL=https://your-host
|
|
# TYPESAFE_DEFAULT_MODEL=otsone-latest
|
|
|
|
# =============================================================================
|
|
# Railyard shared plane (optional) — usage metering + LLM cost control
|
|
# =============================================================================
|
|
# openjev can plug into the railyard shared services for usage metering and
|
|
# LLM spend caps. EVERYTHING here is OPT-IN and env-gated: with none of these set
|
|
# the service behaves exactly as today (self-host runs with zero railyard config,
|
|
# decisions still run, no metering). A metering failure never fails a request.
|
|
#
|
|
# --- RAGO (usage metering) — meters one `systemone_call` per decision ---------
|
|
# Set BOTH to enable. Seed catalog: railyard/apps/rago/seeds/opentypesafe.json
|
|
# (metric `systemone_call`, plan `opentypesafe_pro`). Money is in CENTS.
|
|
# RAGO_URL=http://127.0.0.1:3000
|
|
# RAGO_API_KEY=rago_...
|
|
# Optional identity overrides (default: derived from the caller's API key):
|
|
# RAGO_CUSTOMER_ID=cust_... # external customer id used for allowance/usage
|
|
# RAGO_SUBSCRIPTION_ID=sub_... # external subscription id events are billed to
|
|
#
|
|
# --- RELAY (LLM gateway) — routes this app's LLM escalation through TensorZero -
|
|
# Set RELAY_URL to route OpenAI-compatible escalation via ${RELAY_URL}/openai/v1
|
|
# (model is rewritten to its TensorZero name). RELAY_API_KEY is only needed if
|
|
# the gateway has auth turned on (off by default).
|
|
# RELAY_URL=http://127.0.0.1:3001
|
|
# RELAY_API_KEY=relay_...
|
|
#
|
|
# --- ABACUS (per-key LLM spend caps) — stacks in front of Relay ---------------
|
|
# Set ABACUS_URL + ABACUS_API_KEY to enforce a per-key spend cap before the LLM
|
|
# call (HTTP 402 => cap exceeded => this app degrades to its local engine, never
|
|
# spending past the cap). ABACUS_AGENT_ID is the per-key identity that is capped.
|
|
# ABACUS_URL=http://127.0.0.1:8100
|
|
# ABACUS_API_KEY=abacus_...
|
|
# ABACUS_AGENT_ID=openjev # sent as X-Abacus-Agent: agent_<id>
|
|
#
|
|
# --- MINT (settlement) — optional ledger; needs the @railyard/mint-sdk peer ----
|
|
# Set BOTH to enable settlement. Money is in MICRODOLLARS (1 cent = 10,000).
|
|
# MINT_BASE_URL=http://127.0.0.1:8080
|
|
# MINT_API_KEY=mint_...
|
|
|
|
# =============================================================================
|
|
# Database
|
|
# =============================================================================
|
|
# Postgres connection string. When set, real Postgres is used and migrations run
|
|
# at start; when UNSET, an in-memory PGLite fallback is used (data is lost on
|
|
# restart). For durable self-host, uncomment the `db` service in
|
|
# docker-compose.yml, set POSTGRES_PASSWORD below to a real secret (not the
|
|
# word "openjev" — that was only ever a placeholder), and point this at it
|
|
# using the SAME password, e.g.:
|
|
# POSTGRES_PASSWORD=<openssl rand -hex 24>
|
|
# DATABASE_URL=postgresql://openjev:<same POSTGRES_PASSWORD>@db:5432/openjev
|
|
|
|
# =============================================================================
|
|
# Auth & signing secret (optional — self-host sign-in)
|
|
# =============================================================================
|
|
# Master toggle for sign-in. Anything but "true" = keyless local mode: every
|
|
# console request acts as one local dev user (refused when DATABASE_URL is set).
|
|
# "true" = email/password accounts at /login, stored in the app database.
|
|
# NOTE: VITE_* values are baked into the client bundle at build time — set this
|
|
# before `npm run build` / `docker compose build`, not only at runtime.
|
|
VITE_AUTH_ENABLED=false
|
|
# Session signing secret (Better Auth). REQUIRED in production when auth is
|
|
# enabled — e.g. `openssl rand -hex 32`. Unset in dev = a process-stable random
|
|
# secret (sessions reset on restart).
|
|
# BETTER_AUTH_SECRET=change-me-openssl-rand-hex-32
|
|
# Public origin of this instance (required behind a proxy / on a real domain).
|
|
# BETTER_AUTH_URL=https://your-host.example.com
|
|
|
|
# =============================================================================
|
|
# Calibration audit reports (GET /v1/reports/:calibrationId)
|
|
# =============================================================================
|
|
# Reports are signed with HMAC-SHA256 so a reviewer can verify them at
|
|
# POST /v1/reports/verify. Set a dedicated secret (32+ characters, e.g.
|
|
# `openssl rand -hex 32`); when unset, a key is derived from BETTER_AUTH_SECRET.
|
|
# With neither set, the report endpoints answer 503 rather than sign with a
|
|
# throwaway key. Rotating the secret invalidates earlier reports' signatures.
|
|
# OPENJEV_REPORT_SIGNING_SECRET=
|
|
#
|
|
# Hosted service only: enforce plan gating (audit reports need the Team plan)
|
|
# and hold anonymous POST /api/v1/systemone + /api/v1/batch to the public demo
|
|
# limits below (a batch costs one unit per item). Leave unset when
|
|
# self-hosting; every feature is included and those endpoints stay unlimited.
|
|
# OPENJEV_HOSTED=1
|
|
#
|
|
# Build-time: show the hosted plans (Hosted Free / Calibrate / Team) and their
|
|
# checkout buttons on /pricing. Default off: a plain build advertises only
|
|
# self-hosting. Set only if you operate a hosted service with Creem configured.
|
|
# VITE_OPENJEV_HOSTED=1
|
|
|
|
# =============================================================================
|
|
# API client (docs page)
|
|
# =============================================================================
|
|
# API key the in-app docs example client authenticates with (optional).
|
|
# OPENJEV_API_KEY=ots_live_...
|
|
|
|
# =============================================================================
|
|
# Build tooling (rarely needed for self-host)
|
|
# =============================================================================
|
|
# NITRO_PRESET=node-server # build target; node-server for self-host (set by Dockerfile)
|
|
# SERVER_PRESET=node-server # alias honored by the build if NITRO_PRESET is unset
|
|
|
|
# =============================================================================
|
|
# Public site origin (SEO canonical, OG tags, sitemap.xml, robots.txt)
|
|
# =============================================================================
|
|
# The canonical origin of THIS deployment. There is deliberately no default
|
|
# brand domain. Unset: canonicals point at http://localhost:8080 and
|
|
# robots.txt / sitemap.xml tell crawlers not to index the deployment.
|
|
# OPENJEV_SITE_URL=https://decisions.example.com
|
|
# VITE_OPENJEV_SITE_URL=https://decisions.example.com # build-time (client bundle)
|
|
|
|
# =============================================================================
|
|
# Hosted plans (pricing page + /api/v1/checkout)
|
|
# =============================================================================
|
|
# Overage price per 1,000 decisions beyond a plan's allowance, in USD.
|
|
# Default 0.002 (Jev is ~0.01). 0 = never bill overage. Values > 1 are rejected.
|
|
# OTS_PRICE_PER_1K_DECISIONS_USD=0.002
|
|
# Creem checkout links for the paid plans. Unset = the pricing page shows a
|
|
# "checkout not configured" error instead of a broken button.
|
|
# CREEM_CHECKOUT_URL_CALIBRATE=https://www.creem.io/payment/prod_...
|
|
# CREEM_CHECKOUT_URL_TEAM=https://www.creem.io/payment/prod_...
|
|
# Plan upgrades: point a Creem webhook at https://<host>/api/v1/creem and set
|
|
# its signing secret here. A paid checkout for a product id below upgrades the
|
|
# buyer's account (matched by metadata.user_id / request_id, else by email);
|
|
# subscription.canceled / subscription.expired returns it to Hosted Free.
|
|
# Unsigned or mis-signed deliveries get 401; each event id applies once.
|
|
# CREEM_WEBHOOK_SECRET=
|
|
# CREEM_PRODUCT_ID_CALIBRATE=prod_...
|
|
# CREEM_PRODUCT_ID_TEAM=prod_...
|
|
# Optional: with an API key, signed-in users get a per-account checkout session
|
|
# (request_id = their user id) instead of the static link above.
|
|
# CREEM_API_KEY=
|
|
# CREEM_API_BASE=https://api.creem.io # https://test-api.creem.io for test mode
|
|
|
|
# =============================================================================
|
|
# Shadow mode savings projection
|
|
# =============================================================================
|
|
# Your incumbent LLM's price per million tokens (input / output), used by the
|
|
# /shadow dashboard to project savings. Defaults are labelled as assumptions.
|
|
# SHADOW_INCUMBENT_USD_PER_MTOK_IN=0.40
|
|
# SHADOW_INCUMBENT_USD_PER_MTOK_OUT=1.60
|
|
|
|
# Public demo route limits (/api/v1/cookbooks/*, /api/v1/loop, /api/v1/compact;
|
|
# plus anonymous /api/v1/systemone and /api/v1/batch when OPENJEV_HOSTED=1).
|
|
# Keyless callers only; a live ots_live_ key uses its plan quota. 0 disables a window.
|
|
# OPENJEV_PUBLIC_RPM_PER_IP=30
|
|
# OPENJEV_PUBLIC_RPM_GLOBAL=600
|
|
# OPENJEV_PUBLIC_MAX_BODY_BYTES=
|