mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 08:58:25 +01:00
First real cross-product call from FleetCrown into OrangeCat. Whenever a FleetCrown user adds a subscription on /money, the same record is mirrored into OrangeCat as a `service` owned by the FleetCrown group actor. Mao now sees FleetCrown's monthly burn inside the OrangeCat ledger — the bitbaum studio narrative gets its first real data point. - Adds @orangecat/sdk@0.1.0 as a file:vendor/ dep (vendor/orangecat-sdk-0.1.0.tgz committed; mirrors npm-install semantics for dev + Vercel until the SDK is published). - src/lib/integrations/orangecat.ts: singleton client, no-ops when ORANGECAT_API_KEY is unset. syncSubscriptionToOrangeCat() is fire-and-forget — never throws, never blocks the subscription POST. Stable Idempotency-Key (`fleetcrown_sub_<id>`) so retries dedupe cleanly when server-side dedup lands. - src/db/queries/money.ts: hook fires after the DB insert returns. Whether the OC sync succeeds or fails is irrelevant to the user response — the local subscription is already persisted. - .env.example: documents ORANGECAT_API_KEY + ORANGECAT_API_BASE. Reliability defaults baked in by the SDK: 20s timeout, 3 exp-backoff retries on network / 5xx / 429 honouring Retry-After, User-Agent identifying FleetCrown, AbortSignal-clean. Failure modes are non-fatal and logged with enough context for backfill: - ORANGECAT_API_KEY unset → silent no-op (most dev envs today) - OrangeCat returns OrangeCatError → console.warn with code+status, subscription still saved locally - Network error → SDK retries internally, then console.warn Follow-ups (each its own commit, all post-this-spike): - schema: add subscriptions.orangecat_service_id column so the link persists and the UI can render a "Synced ✓" badge - once /api/v1 exposes GET via integration-key auth, run a backfill job for existing subscriptions - when OrangeCat publishes the SDK to npm, replace the vendor/ tarball with a normal version range Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
88 lines
4.7 KiB
Bash
88 lines
4.7 KiB
Bash
# ── Required ────────────────────────────────────────────────────────────────
|
|
# PostgreSQL — see docs/infrastructure/postgres-portability.md
|
|
#
|
|
# Local dev (Docker): direct URL only
|
|
DATABASE_URL=postgresql://cockpit:changeme@localhost:5432/cockpit
|
|
#
|
|
# Production (Vercel): set BOTH on the host — not in .env.local
|
|
# DATABASE_URL — direct (:5432) for migrations + LISTEN/NOTIFY
|
|
# DATABASE_POOL_URL — pooled (:6432 / PgBouncer / Neon pooler) for app queries
|
|
#
|
|
# Legacy Neon names still work: NEON_DATABASE_URL (pool), NEON_DATABASE_URL_DIRECT (direct)
|
|
|
|
# Random secret for signing sessions — generate with: openssl rand -base64 32
|
|
AUTH_SECRET=
|
|
|
|
# ── Authentication ───────────────────────────────────────────────────────────
|
|
# Local password (quick dev) — leave empty to use the /setup wizard on first run.
|
|
# IMPORTANT: setting this alone does NOT enable the "Owner key" sign-in tab —
|
|
# you must also set ENABLE_OWNER_KEY=1 below. The cloud Vercel deployment
|
|
# keeps LOCAL_AUTH_PASSWORD set for legacy reasons, but the tab stays hidden
|
|
# there because ENABLE_OWNER_KEY is unset.
|
|
LOCAL_AUTH_PASSWORD=
|
|
|
|
# Set to 1 only on local installs (cockpit-app systemd, dev machines). When
|
|
# unset, the Owner-key sign-in tab is hidden AND the "local" credentials
|
|
# provider rejects every authorize() call — structural defense in depth so a
|
|
# stray LOCAL_AUTH_PASSWORD on a public deployment can't be brute-forced.
|
|
ENABLE_OWNER_KEY=
|
|
|
|
# GitHub OAuth (optional — get at github.com/settings/developers)
|
|
GITHUB_CLIENT_ID=
|
|
GITHUB_CLIENT_SECRET=
|
|
|
|
# ── Optional ─────────────────────────────────────────────────────────────────
|
|
# Timezone for cron jobs and schedule display (e.g. America/New_York).
|
|
# Reads APP_DEFAULT_TIMEZONE first, then COCKPIT_DEFAULT_TIMEZONE (legacy).
|
|
APP_DEFAULT_TIMEZONE=Europe/Zurich
|
|
|
|
# Locale for date/time formatting. APP_LOCALE preferred, COCKPIT_LOCALE accepted.
|
|
APP_LOCALE=de-CH
|
|
|
|
# Docker only — Postgres password (must match DATABASE_URL above)
|
|
POSTGRES_PASSWORD=changeme
|
|
|
|
# ── Brand alias scheme ───────────────────────────────────────────────────────
|
|
# Every env var below is read as APP_<KEY> first, then COCKPIT_<KEY> as a
|
|
# legacy fallback (mirror of scripts/_brand.sh:_brand_env). Set whichever
|
|
# prefix matches your environment — both work, APP_* takes precedence.
|
|
|
|
# ── Daemon ⇄ Cloud bridge ────────────────────────────────────────────────────
|
|
# When the local daemon talks to a remote app instance, it authenticates with
|
|
# a bearer token. Two paths exist:
|
|
#
|
|
# 1. Mint a per-user ck_* token from /settings (preferred, multi-tenant safe).
|
|
# 2. Use APP_DAEMON_TOKEN as a shared bearer — single-tenant only.
|
|
#
|
|
# To enable path (2), set BOTH of these on the *server*. The flag is required
|
|
# because the token maps to the "default" user and must not be on by accident
|
|
# in multi-tenant deployments.
|
|
APP_DAEMON_TOKEN=
|
|
APP_ALLOW_LEGACY_DAEMON_TOKEN=
|
|
|
|
# Set to 1 in the local daemon's environment when a local Next.js dev server
|
|
# is running alongside a different cloud deployment. Without this, the daemon
|
|
# prefers localhost:3000 (the local server's DB) and the cloud control
|
|
# panel's runtime state goes stale.
|
|
APP_DAEMON_FORCE_REMOTE=
|
|
|
|
# Override the daemon's remote base URL (defaults to APP_DOMAIN from brand.ts).
|
|
APP_BASE_URL=
|
|
|
|
# ── Web Push (optional — ambient agent-ready notifications) ─────────────────
|
|
# Generate keys: npx web-push generate-vapid-keys
|
|
# Server-side (Vercel): VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY, VAPID_SUBJECT (mailto: or https: URL)
|
|
# Client-side (browser subscribe): NEXT_PUBLIC_VAPID_PUBLIC_KEY must match VAPID_PUBLIC_KEY
|
|
VAPID_PUBLIC_KEY=
|
|
VAPID_PRIVATE_KEY=
|
|
VAPID_SUBJECT=mailto:you@example.com
|
|
NEXT_PUBLIC_VAPID_PUBLIC_KEY=
|
|
|
|
# ── OrangeCat integration (Loop A: mirror subscriptions to the economic layer)
|
|
# Mint at https://orangecat.ch/settings/integrations, choose the FleetCrown
|
|
# group actor at mint time. Format: ock_<48-hex>. Treat like a password — the
|
|
# plaintext is shown once and stored as a sha256 hash on OrangeCat's side.
|
|
# When unset, the integration no-ops (subscriptions are still saved locally).
|
|
ORANGECAT_API_KEY=
|
|
ORANGECAT_API_BASE=https://orangecat.ch
|