Commit Graph
9 Commits
Author SHA1 Message Date
Mao NakamotoandClaude Opus 4.7 1e969983c0 feat(orangecat): Loop A — mirror subscriptions to OrangeCat via @orangecat/sdk
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>
2026-06-03 15:27:51 +02:00
g-butandCursor 60f0cff749 feat(push): web push subscriptions and stop-hook notifications
Adds VAPID-backed subscribe/notify API, service worker, top-bar pill,
and Stop hook push_notify_stop for ambient agent-done signals on mobile.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 21:05:35 +02:00
g-but f44016dfd2 feat(auth): hide Owner-key tab on cloud — ENABLE_OWNER_KEY=1 opt-in required
The /sign-in page has an "Owner key" tab driven by LOCAL_AUTH_PASSWORD.
That tab signs in via the "local" Credentials provider, which auths
against getDefaultUser() — meant for single-tenant installs (the
founder's local cockpit-app, where they're the default user). But
LOCAL_AUTH_PASSWORD is also set in Vercel prod for legacy reasons, so
the tab renders to every visitor on cockpitapp.vercel.app. Harmless
today (no is_default=true user on Neon prod, auth always rejects with
"user-not-found") but confusing for new customers and a brute-force
surface if someone later mistakenly marks a prod user is_default.

Add a structural ENABLE_OWNER_KEY=1 gate (defense in depth):

  • src/app/sign-in/page.tsx — UI tab only renders when both
    LOCAL_AUTH_PASSWORD set AND ENABLE_OWNER_KEY === "1". Cloud has
    the password but not the flag, so tab stays hidden.

  • src/auth.ts — "local" Credentials authorize() returns null with
    user-not-found if ENABLE_OWNER_KEY !== "1". UI gate alone wouldn't
    stop a direct POST to /api/auth/callback/credentials/local;
    runtime gate closes that path too.

  • .env.example — documents the new variable and the rationale
    (LOCAL_AUTH_PASSWORD alone no longer enables Owner-key tab).

Local cockpit-app's .env.local has been updated separately (not
committed; gitignored) to add ENABLE_OWNER_KEY=1, so the founder's
existing Owner-key login keeps working after the next rebuild.

Cloud impact: Owner-key tab disappears from /sign-in for every cloud
visitor. New customers see only Email and OAuth providers — cleaner
onboarding signal, no "what's an Owner key?" confusion.
2026-05-25 20:54:14 +02:00
g-butandCursor ec6f423b0f feat(infra): Postgres portability, Oracle cutover scripts, and DB kill-switch essay
Vendor-neutral DATABASE_URL helpers, dump/restore/sync tooling, and one-command
Oracle migration after a single console VM step. Publishes the studio-stack
thoughts article and hardens build (dynamic layout, resilient sitemap).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 11:24:20 +02:00
g-butandClaude Opus 4.7 9ee1df41c3 refactor(brand): broker the brand through one TS + one shell SSOT
Audit before this commit: 642 case-insensitive 'cockpit' refs across 119
files; only 2 callers actually used src/config/brand.ts. A rename was an
hour of careful sed touching things like email templates, auth UI copy,
/tmp paths, env var names, log prefixes — easy to miss one.

After this commit: every UI string, every /tmp sentinel, every env var,
and every shell log prefix derives from one of two files:

  src/config/brand.ts    APP_NAME · APP_SLUG · APP_DOMAIN · APP_EMAIL_FROM
                         APP_KICKER · APP_DESCRIPTION · APP_TAGLINE
                         APP_URL · APP_PROFILE_URL(username)
  scripts/_brand.sh      $APP_NAME · $APP_SLUG · $APP_DOMAIN
                         _brand_env <KEY> <default>  → $APP_<KEY> || $COCKPIT_<KEY>
                         _brand_tmp <name>           → /tmp/$APP_SLUG-<name>

UI broker (TS): SignInForm, project-intent-panel, bootstrap-modal-steps,
AgentTokenSettings, setup/page, whitepaper/page, /u/[username]/page,
invite/layout, beacon/live/BeaconLiveClient, api/project/bootstrap, and
src/lib/email all import APP_NAME from brand.ts. /tmp paths in
agent-config:stateFile.run, control/sleep-mode/route, control/auto-continue/route,
beacon/route, beacon/sse/route derive from APP_SLUG.

Shell broker: cockpit-daemon.sh and agent-hook-bridge.sh source _brand.sh,
read env via _brand_env (so APP_DAEMON_TOKEN and APP_BASE_URL work alongside
the existing COCKPIT_* names), write /tmp paths via _brand_tmp, log under
[$APP_SLUG-daemon] / [$APP_SLUG-bridge].

Env aliases (TS): src/lib/brand-env.ts mirrors _brand_env. src/lib/constants,
src/lib/daemon-auth, src/lib/session, src/auth.config (Edge), and
api/beacon/transcribe all resolve env via the alias scheme. Existing
COCKPIT_*-prefixed env vars on machines in the wild keep working — APP_*
takes precedence when both are set.

To rebrand the entire product after this commit: edit APP_NAME / APP_SLUG /
APP_DOMAIN in src/config/brand.ts AND in scripts/_brand.sh, swap the
vercel.json alias, point DNS at the new registrar. That's it — no other
code touches the name.

Out of scope (deliberately): content/* essays and whitepaper.md (editorial
voice, not mechanical), README.md (would distract from this commit's
purpose), .env example DATABASE_URL (config value, not code), file names
themselves (CockpitMark.tsx, cockpit-daemon.sh — those become git mv after
a chosen new name).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 23:01:11 +02:00
g-butandClaude Opus 4.7 93e72d9f78 fix(daemon): COCKPIT_DAEMON_FORCE_REMOTE to pin daemon to cloud Cockpit
_base_url() prefers $_LOCAL_URL when /api/health responds, which is the
right default when the user runs everything locally. But when a local
Next.js dev server is up alongside a *different* cloud Cockpit (the
common case for cockpitapp.vercel.app users), the daemon ends up pushing
runtime state and claiming commands from the local DB while the user
watches the cloud — daemonLastPushedAt on cockpitapp.vercel.app stays
frozen for days even though the daemon is healthy.

Add a single env var that skips the local probe entirely. _init_base_url
logs the choice so it shows in the daemon log line at startup.

Verified locally: /api/health responds on localhost:3000 with
{"ok":true,"runtime":true}, but POST /api/control/runtime-state on
cockpitapp.vercel.app already returns {"ok":true,"count":0} with the
daemon bearer — so the moment the user restarts the daemon with the
flag set, state will land on the cloud control panel for the first
time since the schema-drift fixes landed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 22:11:32 +02:00
g-butandClaude Opus 4.7 c3ded1f2aa docs(env): document COCKPIT_ALLOW_LEGACY_DAEMON_TOKEN requirement
The local daemon authenticates writes to cockpitapp.vercel.app
(patch_project_state, /api/orchestration/runs/<id>/finish, etc.) via the
COCKPIT_DAEMON_TOKEN bearer. src/lib/session.ts:getApiUserId only honors
that token when COCKPIT_ALLOW_LEGACY_DAEMON_TOKEN=1 is also set on the
server — a safety gate to prevent accidental multi-tenant misuse.

Verified by curl: PATCH /api/project-states/<tab> returns 401 without
the flag, even with a valid token. With the flag, the daemon-side loop
(state push + outcome finish) closes against the cloud deployment.

Companion change: set COCKPIT_ALLOW_LEGACY_DAEMON_TOKEN=1 on Vercel
production (via vercel env add, no commit).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 20:59:41 +02:00
g-butandClaude Sonnet 4.6 70d1d6def4 feat(packaging): self-hosted distribution foundation
First-run flow:
- /setup page + /api/setup: creates first user with hashed password
  (Node crypto scrypt, no new deps). POST rejects if users already exist.
- Landing page redirects to /setup when DB has no users
- middleware.ts: protects app routes, passes public pages through

Auth:
- passwordHash column added to users schema (drizzle-kit push applied)
- src/lib/password.ts: hashPassword/verifyPassword via Node scrypt
- auth.ts Credentials: env var takes priority, falls back to DB hash
  so packaged installs work without LOCAL_AUTH_PASSWORD

Multi-tenancy groundwork:
- Replaced DEFAULT_USER_ID with getCurrentUserId() across all 12 API
  route files (people, subscriptions, events, goals, projects, commitments)

Docker:
- Dockerfile: multi-stage Node 22 alpine, standalone output
- docker-compose.yml: postgres + migrate + app services
- .dockerignore, .env.example with documented required vars
- next.config.ts: output: standalone
- package.json: added migrate script (drizzle-kit push)
- tsconfig.json: scope to src/ only, exclude .next generated files

Install: clone → cp .env.example .env.local → docker-compose up
First visit → /setup → create account → sign in → done.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 13:46:07 +02:00
g-butandClaude Sonnet 4.6 1a3374d48c chore: GitHub + Vercel/Neon deployment setup
- Created private GitHub repo g-but/cockpit and pushed all commits
- Added vercel.json for Next.js deployment config
- Added .env.example documenting required env vars
- Created Neon (cloud Postgres) project 'cockpit' in eu-central-1
- Ran drizzle-kit push to deploy schema to Neon
- Neon connection string stored in .env.local (gitignored)
- Next step: run 'vercel login' then 'vercel --prod' to complete Vercel deploy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 14:08:40 +02:00